11describe ( 'compiler' , function ( ) {
2- var compiler , markup , directives , widgets , compile , log ;
2+ var compiler , markup , directives , widgets , compile , log , scope ;
33
44 beforeEach ( function ( ) {
55 log = "" ;
@@ -32,6 +32,10 @@ describe('compiler', function(){
3232 return scope ;
3333 } ;
3434 } ) ;
35+
36+ afterEach ( function ( ) {
37+ dealoc ( scope ) ;
38+ } ) ;
3539
3640 it ( 'should recognize a directive' , function ( ) {
3741 var e = jqLite ( '<div directive="expr" ignore="me"></div>' ) ;
@@ -44,20 +48,21 @@ describe('compiler', function(){
4448 } ;
4549 } ;
4650 var template = compiler . compile ( e ) ;
47- var init = template ( e ) . $init ;
51+ scope = template ( e ) ;
52+ var init = scope . $init ;
4853 expect ( log ) . toEqual ( "found" ) ;
4954 init ( ) ;
5055 expect ( e . hasClass ( 'ng-directive' ) ) . toEqual ( true ) ;
5156 expect ( log ) . toEqual ( "found:init" ) ;
5257 } ) ;
5358
5459 it ( 'should recurse to children' , function ( ) {
55- var scope = compile ( '<div><span hello="misko"/></div>' ) ;
60+ scope = compile ( '<div><span hello="misko"/></div>' ) ;
5661 expect ( log ) . toEqual ( "hello misko" ) ;
5762 } ) ;
5863
5964 it ( 'should watch scope' , function ( ) {
60- var scope = compile ( '<span watch="name"/>' ) ;
65+ scope = compile ( '<span watch="name"/>' ) ;
6166 expect ( log ) . toEqual ( "" ) ;
6267 scope . $eval ( ) ;
6368 scope . $set ( 'name' , 'misko' ) ;
@@ -71,7 +76,7 @@ describe('compiler', function(){
7176
7277 it ( 'should prevent descend' , function ( ) {
7378 directives . stop = function ( ) { this . descend ( false ) ; } ;
74- var scope = compile ( '<span hello="misko" stop="true"><span hello="adam"/></span>' ) ;
79+ scope = compile ( '<span hello="misko" stop="true"><span hello="adam"/></span>' ) ;
7580 expect ( log ) . toEqual ( "hello misko" ) ;
7681 } ) ;
7782
@@ -87,7 +92,7 @@ describe('compiler', function(){
8792 } ) ;
8893 } ;
8994 } ;
90- var scope = compile ( 'before<span duplicate="expr">x</span>after' ) ;
95+ scope = compile ( 'before<span duplicate="expr">x</span>after' ) ;
9196 expect ( sortedHtml ( scope . $element ) ) . toEqual ( '<div>before<#comment></#comment><span>x</span>after</div>' ) ;
9297 scope . $eval ( ) ;
9398 expect ( sortedHtml ( scope . $element ) ) . toEqual ( '<div>before<#comment></#comment><span>x</span><span>x</span>after</div>' ) ;
@@ -103,7 +108,7 @@ describe('compiler', function(){
103108 textNode [ 0 ] . nodeValue = 'replaced' ;
104109 }
105110 } ) ;
106- var scope = compile ( 'before<span>middle</span>after' ) ;
111+ scope = compile ( 'before<span>middle</span>after' ) ;
107112 expect ( sortedHtml ( scope . $element [ 0 ] , true ) ) . toEqual ( '<div>before<span class="ng-directive" hello="middle">replaced</span>after</div>' ) ;
108113 expect ( log ) . toEqual ( "hello middle" ) ;
109114 } ) ;
@@ -116,7 +121,7 @@ describe('compiler', function(){
116121 log += 'init' ;
117122 } ;
118123 } ;
119- var scope = compile ( '<ng:button>push me</ng:button>' ) ;
124+ scope = compile ( '<ng:button>push me</ng:button>' ) ;
120125 expect ( lowercase ( scope . $element [ 0 ] . innerHTML ) ) . toEqual ( '<div>button</div>' ) ;
121126 expect ( log ) . toEqual ( 'init' ) ;
122127 } ) ;
@@ -135,7 +140,7 @@ describe('compiler', function(){
135140 if ( text == '{{1+2}}' )
136141 parent . text ( '3' ) ;
137142 } ) ;
138- var scope = compile ( '<div><h1>ignore me</h1></div>' ) ;
143+ scope = compile ( '<div><h1>ignore me</h1></div>' ) ;
139144 expect ( scope . $element . text ( ) ) . toEqual ( '3' ) ;
140145 } ) ;
141146
@@ -158,7 +163,7 @@ describe('compiler', function(){
158163 textNode . remove ( ) ;
159164 }
160165 } ) ;
161- var scope = compile ( 'A---B---C===D' ) ;
166+ scope = compile ( 'A---B---C===D' ) ;
162167 expect ( sortedHtml ( scope . $element ) ) . toEqual ( '<div>A<hr></hr>B<hr></hr>C<p></p>D</div>' ) ;
163168 } ) ;
164169
0 commit comments