Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Proposal: update ng-src even when blank #10051

Open
@JasonGoemaat

Description

@JasonGoemaat

ngSrc does not update the src attribute if the value is blank:

    attr.$observe(normalized, function(value) {
      if (!value) { // do not update ngSrc or ngSrcSet if blank
        if (attrName === 'href') {
          attr.$set(name, null);
        }
        return;
      }

I noticed this when answering this question on stackoverflow to create a directive to display an alternate image if there is an error loading the bound image url.

This seems inappropriate to me. Imagine a SPA that loads a new product using $http. If the new product has a blank string for the image URL, the page would continue to display the image for the previous product when even an error placeholder for image not found would be more appropriate. Is there some special reason that the src attribute should not be set to blank when the bound url is empty? If not, I think it should be changed to appropriately reflect the intended binding.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions