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

fix($compile): correctly handle null/undefined href attrs.$set() #16520

Merged
merged 1 commit into from
Apr 9, 2018

Conversation

gkalpak
Copy link
Member

@gkalpak gkalpak commented Apr 5, 2018

Accidentally broken while backporting #14890.

Since #14890, $$sanitizeUri() can no longer handle null/undefined values.
In 1.7.x, there are no such calls.
In 1.6.x, there is still one such calls inside Attributes.$set(), so it needs to be adjusted accordingly.

Copy link
Member

@mgol mgol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One remark but LGTM anyway.

@@ -1723,7 +1723,7 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
if ((nodeName === 'a' && (key === 'href' || key === 'xlinkHref')) ||
(nodeName === 'img' && key === 'src')) {
// sanitize a[href] and img[src] values
this[key] = value = $$sanitizeUri(value, key === 'src');
this[key] = value = (value == null) ? value : $$sanitizeUri(value, key === 'src');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are those parens around value == null necessary? ;)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, but look how much cleaner it looks with the parens 😛

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

De gustibus etc. but I'm not insisting. ;)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants