diff options
| author | Igor Minar | 2013-02-23 22:54:35 -0800 |
|---|---|---|
| committer | Igor Minar | 2013-02-23 23:40:03 -0800 |
| commit | 4759aacba96f2503b1c3d67ce4c5c915f109337b (patch) | |
| tree | 34611d482ba564fe7ebb06309c37e1b801f42d38 /test | |
| parent | 802bfc259c95838aa3edcdfe33d02a1085910f14 (diff) | |
| download | angular.js-4759aacba96f2503b1c3d67ce4c5c915f109337b.tar.bz2 | |
fix($compile): handle elements with no childNodes property
see the test for more details
Diffstat (limited to 'test')
| -rw-r--r-- | test/ng/compileSpec.js | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/test/ng/compileSpec.js b/test/ng/compileSpec.js index 78d37082..0b77be30 100644 --- a/test/ng/compileSpec.js +++ b/test/ng/compileSpec.js @@ -178,6 +178,28 @@ describe('$compile', function() { expect(calcCacheSize()).toEqual(0); }); + + it('should not blow up when elements with no childNodes property are compiled', inject( + function($compile, $rootScope) { + // it turns out that when a browser plugin is bound to an DOM element (typically <object>), + // the plugin's context rather than the usual DOM apis are exposed on this element, so + // childNodes might not exist. + if (msie < 9) return; + + element = jqLite('<div>{{1+2}}</div>'); + element[0].childNodes[1] = {nodeType: 3, nodeName: 'OBJECT', textContent: 'fake node'}; + + if (!element[0].childNodes[1]) return; //browser doesn't support this kind of mocking + expect(element[0].childNodes[1].textContent).toBe('fake node'); + + $compile(element)($rootScope); + $rootScope.$apply(); + + // object's children can't be compiled in this case, so we expect them to be raw + expect(element.html()).toBe("3"); + })); + + describe('multiple directives per element', function() { it('should allow multiple directives per element', inject(function($compile, $rootScope, log){ element = $compile( |
