aboutsummaryrefslogtreecommitdiffstats
path: root/test/ng/directive/ngSrcSpec.js
diff options
context:
space:
mode:
authorXiangru Chen2012-07-14 17:40:24 +0800
committerMisko Hevery2012-09-06 15:49:49 -0700
commitfd3071843ca53a34a084f5d495f9f0aea82f2ef5 (patch)
tree182ba2c009bb078a7a11f345d6ef7d5f0076fd12 /test/ng/directive/ngSrcSpec.js
parenta631ceb223392244d6241c5bb44712ef802f0c98 (diff)
downloadangular.js-fd3071843ca53a34a084f5d495f9f0aea82f2ef5.tar.bz2
fix(ngSrc): don't set src if value is empty string
Current implementation of ngSrc may lead to empty src attribute when page is loading. For example: <img ng-src="{{image.url}}"> can be temporarily rendered as <img src=""> before the image resource is loaded. Some browser emits a request to the current page when seeing <img src=""> (Firefox13 and IE8 will, Chromium20 won't), which leads to performance problems.
Diffstat (limited to 'test/ng/directive/ngSrcSpec.js')
-rw-r--r--test/ng/directive/ngSrcSpec.js17
1 files changed, 17 insertions, 0 deletions
diff --git a/test/ng/directive/ngSrcSpec.js b/test/ng/directive/ngSrcSpec.js
new file mode 100644
index 00000000..a917c511
--- /dev/null
+++ b/test/ng/directive/ngSrcSpec.js
@@ -0,0 +1,17 @@
+'use strict';
+
+describe('ngSrc', function() {
+ var element;
+
+ afterEach(function() {
+ dealoc(element);
+ });
+
+ it('should not result empty string in img src', inject(function($rootScope, $compile) {
+ $rootScope.image = {};
+ element = $compile('<img ng-src="{{image.url}}">')($rootScope);
+ $rootScope.$digest();
+ expect(element.attr('src')).not.toBe('');
+ expect(element.attr('src')).toBe(undefined);
+ }));
+});