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

Commit

Permalink
fix($compile): correctly handle null/undefined href attrs.$set()
Browse files Browse the repository at this point in the history
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.

Closes #16520
  • Loading branch information
gkalpak authored and Narretz committed Apr 9, 2018
1 parent 4355dee commit f04e04e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/ng/compile.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
} else if (nodeName === 'img' && key === 'srcset' && isDefined(value)) {
// sanitize img[srcset] values
var result = '';
Expand Down Expand Up @@ -1761,7 +1761,7 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
}

if (writeAttr !== false) {
if (value === null || isUndefined(value)) {
if (value == null) {
this.$$element.removeAttr(attrName);
} else {
if (SIMPLE_ATTR_NAME.test(attrName)) {
Expand Down

0 comments on commit f04e04e

Please sign in to comment.