This repository has been archived by the owner on Apr 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 27.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ngSrcset): add new ngSrcset directive
In line with ngSrc and ngHref, this new directive ensures that the `srcset` HTML5 attribute does not include a pre-interpolated string. Without it the browser will fetch from the URL with the literal text `{{hash}}` until AngularJS replaces the expression inside `{{hash}}`. Closes #2601
- Loading branch information
1 parent
629fb37
commit d551d72
Showing
3 changed files
with
60 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
'use strict'; | ||
|
||
describe('ngSrcset', function() { | ||
var element; | ||
|
||
afterEach(function() { | ||
dealoc(element); | ||
}); | ||
|
||
it('should not result empty string in img srcset', inject(function($rootScope, $compile) { | ||
$rootScope.image = {}; | ||
element = $compile('<img ng-srcset="{{image.url}} 2x">')($rootScope); | ||
$rootScope.$digest(); | ||
expect(element.attr('srcset')).toEqual(' 2x'); | ||
})); | ||
}); |