Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit cd9afd9

Browse files
committed
revert: fix(ngHref): remove attribute when empty value instead of ignoring
This reverts commit 948c86c. This commit caused tests to fail in IE8 due to a TypeError '0.childNodes is null or not an object. The issue should be investigated and fixed. Issue angular#8340 has been opened to investigate. See this job for failures: https://travis-ci.org/angular/angular.js/jobs/30792508
1 parent e25ed0d commit cd9afd9

File tree

2 files changed

+2
-23
lines changed

2 files changed

+2
-23
lines changed

src/ng/directive/booleanAttrs.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -380,12 +380,8 @@ forEach(['src', 'srcset', 'href'], function(attrName) {
380380
}
381381

382382
attr.$observe(normalized, function(value) {
383-
if (!value) {
384-
if (attrName === 'href') {
385-
attr.$set(name, null);
386-
}
387-
return;
388-
}
383+
if (!value)
384+
return;
389385

390386
attr.$set(name, value);
391387

test/ng/directive/booleanAttrsSpec.js

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -252,23 +252,6 @@ describe('ngHref', function() {
252252
expect(element.attr('href')).toEqual('http://server');
253253
}));
254254

255-
it('should not set the href if ng-href is empty', inject(function($rootScope, $compile) {
256-
$rootScope.url = null;
257-
element = $compile('<a ng-href="{{url}}">')($rootScope);
258-
$rootScope.$digest();
259-
expect(element.attr('href')).toEqual(undefined);
260-
}));
261-
262-
it('should remove the href if ng-href changes to empty', inject(function($rootScope, $compile) {
263-
$rootScope.url = 'http://www.google.com/';
264-
element = $compile('<a ng-href="{{url}}">')($rootScope);
265-
$rootScope.$digest();
266-
267-
$rootScope.url = null;
268-
$rootScope.$digest();
269-
expect(element.attr('href')).toEqual(undefined);
270-
}));
271-
272255
if (isDefined(window.SVGElement)) {
273256
describe('SVGAElement', function() {
274257
it('should interpolate the expression and bind to xlink:href', inject(function($compile, $rootScope) {

0 commit comments

Comments
 (0)