From 02fa10f93ce5a75dd925f13ec7456802a6e120e4 Mon Sep 17 00:00:00 2001 From: Misko Hevery Date: Mon, 26 Apr 2010 11:57:33 -0700 Subject: allow the widget to change structure of the DOM and have the compiler follow the replaced element. --- test/CompilerSpec.js | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'test') diff --git a/test/CompilerSpec.js b/test/CompilerSpec.js index a212634a..2e1ae4ae 100644 --- a/test/CompilerSpec.js +++ b/test/CompilerSpec.js @@ -108,7 +108,7 @@ describe('compiler', function(){ it('should replace widgets', function(){ widgets['NG:BUTTON'] = function(element) { - element.replaceWith('
button
', element); + element.replaceWith('
button
'); return function(element) { log += 'init'; }; @@ -118,4 +118,20 @@ describe('compiler', function(){ expect(log).toEqual('init'); }); + it('should use the replaced element after calling widget', function(){ + widgets['H1'] = function(element) { + var span = angular.element('{{1+2}}'); + element.replaceWith(span); + this.descend(true); + this.directives(true); + return noop; + }; + textMarkup.push(function(text, textNode, parent){ + if (text == '{{1+2}}') + textNode.text('3'); + }); + var scope = compile('

ignore me

'); + expect(scope.$element.text()).toEqual('3'); + }); + }); -- cgit v1.2.3