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

Commit f04e04e

Browse files
gkalpakNarretz
authored andcommitted
fix($compile): correctly handle null/undefined href attrs.$set()
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
1 parent 4355dee commit f04e04e

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/ng/compile.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1723,7 +1723,7 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
17231723
if ((nodeName === 'a' && (key === 'href' || key === 'xlinkHref')) ||
17241724
(nodeName === 'img' && key === 'src')) {
17251725
// sanitize a[href] and img[src] values
1726-
this[key] = value = $$sanitizeUri(value, key === 'src');
1726+
this[key] = value = (value == null) ? value : $$sanitizeUri(value, key === 'src');
17271727
} else if (nodeName === 'img' && key === 'srcset' && isDefined(value)) {
17281728
// sanitize img[srcset] values
17291729
var result = '';
@@ -1761,7 +1761,7 @@ function $CompileProvider($provide, $$sanitizeUriProvider) {
17611761
}
17621762

17631763
if (writeAttr !== false) {
1764-
if (value === null || isUndefined(value)) {
1764+
if (value == null) {
17651765
this.$$element.removeAttr(attrName);
17661766
} else {
17671767
if (SIMPLE_ATTR_NAME.test(attrName)) {

0 commit comments

Comments
 (0)