angular.js/test/ng/directive/ngSrcsetSpec.js
Samuel Santos d551d72924 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
2013-05-14 21:29:21 +01:00

16 lines
400 B
JavaScript

'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');
}));
});