Skip to content

Commit ae0e07c

Browse files
committed
fix($compile): correctly handle null/undefined href attrs.$set()
Accidentally broken while backporting angular#14890.
1 parent da3d96c commit ae0e07c

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)