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.

"TypeError: Cannot read property 'split' of undefined" when using ng-attr-srcset with potentially null value #14470

Closed
@ghost

Description

Do you want to request a feature or report a bug?
Bug report.

What is the current behavior?
We're seeing an internal Angular error:

TypeError: Cannot read property 'split' of undefined

when trying to use ng-attr-srcset, where the expression can be potentially undefined. To reproduce,:

    <img data-ng-attr-srcset="{{undefined}}">

What is the expected behavior?

Normally, ng-attr-defined attributes are supposed to be ignored if the associated value is undefined, but in this case, we're hitting an error:

    // split srcset into tuple of uri and descriptor except for the last item
    var rawUris = trimmedSrcset.split(pattern);

where trimmedSrcset is undefined under the above situation.

What is the motivation / use case for changing the behavior?

ng-attr is breaking with regards to "srcset". It should be consistent with ng-attr's behavior of undefined for other attribute names. What's happening is an internal error that should be fixed, since it's in the framework rather than application code.

Which versions of Angular, and which browser / OS are affected by this issue? Did this work in previous versions of Angular? Please also test with the latest stable and snapshot (https://code.angularjs.org/snapshot/) versions.

Angular 1.5.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions