aboutsummaryrefslogtreecommitdiffstats
path: root/test/CompilerSpec.js
diff options
context:
space:
mode:
authorMisko Hevery2010-04-26 11:57:33 -0700
committerMisko Hevery2010-04-26 11:57:33 -0700
commit02fa10f93ce5a75dd925f13ec7456802a6e120e4 (patch)
treea7a90bbdd96a52c4183adbdc69ed92ea6dd95a1b /test/CompilerSpec.js
parent076f37a5ec26e88c5aeb2f37aa19ea7b2516d9f3 (diff)
downloadangular.js-02fa10f93ce5a75dd925f13ec7456802a6e120e4.tar.bz2
allow the widget to change structure of the DOM and have the compiler follow the replaced element.
Diffstat (limited to 'test/CompilerSpec.js')
-rw-r--r--test/CompilerSpec.js18
1 files changed, 17 insertions, 1 deletions
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('<div>button</div>', element);
+ element.replaceWith('<div>button</div>');
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('<span>{{1+2}}</span>');
+ 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('<div><h1>ignore me</h1></div>');
+ expect(scope.$element.text()).toEqual('3');
+ });
+
});