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

Commit 8b6d940

Browse files
committed
fix(ngSrcset): add test directly on <img> element
Closes #14470
1 parent 80ae614 commit 8b6d940

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

test/ng/compileSpec.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9394,6 +9394,21 @@ describe('$compile', function() {
93949394

93959395
describe('img[srcset] sanitization', function() {
93969396

9397+
it('should not error if undefined', function() {
9398+
module(function() {
9399+
directive({
9400+
setter: valueFn(function(scope, element, attr) {
9401+
attr.$set('srcset', undefined);
9402+
expect(attr.srcset).toBeUndefined();
9403+
})
9404+
});
9405+
});
9406+
inject(function($rootScope, $compile) {
9407+
element = $compile('<img setter></img>')($rootScope);
9408+
expect(element.attr('srcset')).toBeUndefined();
9409+
});
9410+
});
9411+
93979412
it('should NOT require trusted values for img srcset', inject(function($rootScope, $compile, $sce) {
93989413
element = $compile('<img srcset="{{testUrl}}"></img>')($rootScope);
93999414
$rootScope.testUrl = 'http://example.com/image.png';

test/ng/directive/ngSrcsetSpec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ describe('ngSrcset', function() {
3030
}));
3131

3232
it('should not throw an error if undefined', inject(function($rootScope, $compile) {
33-
element = $compile('<img data-ng-attr-srcset="{{undefined}}">')($rootScope);
33+
element = $compile('<img ng-attr-srcset="{{undefined}}">')($rootScope);
3434
$rootScope.$digest();
3535
}));
3636
});

0 commit comments

Comments
 (0)