@@ -62,8 +62,8 @@ export function createScope(parentScope, localVariables) {
6262 var scope ;
6363
6464 if ( parentScope ) {
65- scope = Object . create ( parentScope ) ;
66- scope . locals = Object . create ( parentScope . locals ) ;
65+ scope = createObject ( parentScope ) ;
66+ scope . locals = createObject ( parentScope . locals ) ;
6767 } else {
6868 scope = { self : null , locals : { } } ;
6969 }
@@ -81,7 +81,7 @@ export function block(env, morph, scope, path, params, hash, template, inverse)
8181 if ( morph . isDirty ) {
8282 var options = optionsFor ( morph , scope , env , template , inverse ) ;
8383
84- var helper = lookupHelper ( env , scope , path ) ;
84+ var helper = lookupHelper ( scope , env , path ) ;
8585 var result = helper ( params , hash , options , env ) ;
8686
8787 if ( result === undefined && state . lastResult ) {
@@ -99,7 +99,7 @@ export function block(env, morph, scope, path, params, hash, template, inverse)
9999export function inline ( env , morph , scope , path , params , hash ) {
100100 if ( morph . isDirty ) {
101101 var state = morph . state ;
102- var helper = lookupHelper ( env , scope , path ) ;
102+ var helper = lookupHelper ( scope , env , path ) ;
103103
104104 var value = helper ( params , hash , { renderNode : morph } , env ) ;
105105
@@ -115,7 +115,7 @@ export function inline(env, morph, scope, path, params, hash) {
115115export function content ( env , morph , scope , path ) {
116116 if ( morph . isDirty ) {
117117 var state = morph . state ;
118- var helper = lookupHelper ( env , scope , path ) ;
118+ var helper = lookupHelper ( scope , env , path ) ;
119119
120120 var value ;
121121 if ( helper ) {
@@ -135,7 +135,7 @@ export function content(env, morph, scope, path) {
135135
136136export function element ( env , morph , scope , path , params , hash ) {
137137 if ( morph . isDirty ) {
138- var helper = lookupHelper ( env , scope , path ) ;
138+ var helper = lookupHelper ( scope , env , path ) ;
139139 if ( helper ) {
140140 helper ( params , hash , { element : morph . element } , env ) ;
141141 }
@@ -160,7 +160,7 @@ export function attribute(env, morph, name, value) {
160160export function subexpr ( env , morph , scope , helperName , params , hash ) {
161161 if ( ! morph . isDirty ) { return ; }
162162
163- var helper = lookupHelper ( env , scope , helperName ) ;
163+ var helper = lookupHelper ( scope , env , helperName ) ;
164164 if ( helper ) {
165165 return helper ( params , hash , { } , env ) ;
166166 } else {
@@ -188,13 +188,13 @@ export function get(env, morph, scope, path) {
188188 return value ;
189189}
190190
191- export function bindLocal ( env , scope , name , value ) {
191+ export function bindLocal ( scope , env , name , value ) {
192192 scope . locals [ name ] = value ;
193193}
194194
195195export function component ( env , morph , scope , tagName , attrs , template ) {
196196 if ( morph . isDirty ) {
197- var helper = lookupHelper ( env , scope , tagName ) ;
197+ var helper = lookupHelper ( scope , env , tagName ) ;
198198 if ( helper ) {
199199 var options = optionsFor ( morph , scope , env , template , null ) ;
200200 helper ( [ ] , attrs , options , env ) ;
@@ -226,10 +226,22 @@ function componentFallback(env, morph, scope, tagName, attrs, template) {
226226 morph . setNode ( element ) ;
227227}
228228
229- function lookupHelper ( env , scope , helperName ) {
229+ function lookupHelper ( scope , env , helperName ) {
230230 return env . helpers [ helperName ] ;
231231}
232232
233+ // IE8 does not have Object.create, so use a polyfill if needed.
234+ // Polyfill based on Mozilla's (MDN)
235+ export function createObject ( obj ) {
236+ if ( typeof Object . create === 'function' ) {
237+ return Object . create ( obj ) ;
238+ } else {
239+ var Temp = function ( ) { } ;
240+ Temp . prototype = obj ;
241+ return new Temp ( ) ;
242+ }
243+ }
244+
233245export default {
234246 createScope : createScope ,
235247 content : content ,
0 commit comments