@@ -121,6 +121,63 @@ describe('strict', function () {
121121 } ) ;
122122 } ) ;
123123
124+ describe ( 'strict and compat mode' , function ( ) {
125+ it ( 'GH-1741: should render a simple variable' , function ( ) {
126+ expectTemplate ( '{{v}}' )
127+ . withCompileOptions ( { strict : true , compat : true } )
128+ . withInput ( { v : 'a' } )
129+ . toCompileTo ( 'a' ) ;
130+ } ) ;
131+
132+ it ( 'should throw for a missing variable' , function ( ) {
133+ expectTemplate ( '{{v}}' )
134+ . withCompileOptions ( { strict : true , compat : true } )
135+ . toThrow ( Exception , / " v " n o t d e f i n e d i n / ) ;
136+ } ) ;
137+
138+ it ( 'GH-2149: should render correctly when block context is a boolean' , function ( ) {
139+ expectTemplate ( '{{#foo}}Hello {{bar}}{{/foo}}' )
140+ . withCompileOptions ( { strict : true , compat : true } )
141+ . withInput ( { foo : true , bar : 'World' } )
142+ . toCompileTo ( 'Hello World' ) ;
143+ } ) ;
144+
145+ it ( 'GH-2149: should render correctly when looking up a property on each item' , function ( ) {
146+ expectTemplate ( '{{#each items}}{{name}}{{/each}}' )
147+ . withCompileOptions ( { strict : true , compat : true } )
148+ . withInput ( { items : [ { name : 'Hello' } ] } )
149+ . toCompileTo ( 'Hello' ) ;
150+ } ) ;
151+
152+ it ( 'should still throw when a property is missing at all depths' , function ( ) {
153+ expectTemplate ( '{{#each items}}{{name}}{{/each}}' )
154+ . withCompileOptions ( { strict : true , compat : true } )
155+ . withInput ( { items : [ 1 , 2 ] } )
156+ . toThrow ( Exception , / " n a m e " n o t d e f i n e d i n / ) ;
157+ } ) ;
158+
159+ it ( 'should still perform recursive lookup when a property is not in the current context' , function ( ) {
160+ expectTemplate ( '{{#each items}}{{name}}{{/each}}' )
161+ . withCompileOptions ( { strict : true , compat : true } )
162+ . withInput ( { name : 'root' , items : [ { } ] } )
163+ . toCompileTo ( 'root' ) ;
164+ } ) ;
165+
166+ it ( 'should still perform recursive lookup with a multi-part path not in context' , function ( ) {
167+ expectTemplate ( '{{#with child}}{{name.first}}{{/with}}' )
168+ . withCompileOptions ( { strict : true , compat : true } )
169+ . withInput ( { name : { first : 'root' } , child : { name : null } } )
170+ . toCompileTo ( 'root' ) ;
171+ } ) ;
172+
173+ it ( 'should directly return an explicitly null property' , function ( ) {
174+ expectTemplate ( '{{#each items}}{{name}}{{/each}}' )
175+ . withCompileOptions ( { strict : true , compat : true } )
176+ . withInput ( { name : 'root' , items : [ { name : null } ] } )
177+ . toCompileTo ( '' ) ;
178+ } ) ;
179+ } ) ;
180+
124181 describe ( 'assume objects' , function ( ) {
125182 it ( 'should ignore missing property' , function ( ) {
126183 expectTemplate ( '{{hello}}' )
0 commit comments