Selaa lähdekoodia

use strict in compile fns

Evan You 11 vuotta sitten
vanhempi
commit
b38daa0d17
1 muutettua tiedostoa jossa 5 lisäystä ja 5 poistoa
  1. 5 5
      src/parse/expression.js

+ 5 - 5
src/parse/expression.js

@@ -103,9 +103,9 @@ function compileExpFns (exp, needSet) {
   var getter = makeGetter(body)
   if (getter) {
     return {
-      get      : getter,
-      body     : body,
-      set      : needSet
+      get: getter,
+      body: body,
+      set: needSet
         ? makeSetter(body)
         : null
     }
@@ -153,7 +153,7 @@ function makeGetter (body) {
   try {
     return new Function(
       'scope',
-      'try{return ' + body + '}catch(e){};'
+      '"use strict";try{return ' + body + '}catch(e){};'
     )
   } catch (e) {
     _.warn(
@@ -182,7 +182,7 @@ function makeSetter (body) {
     return new Function(
       'scope',
       'value',
-      body + ' = value;'
+      '"use strict";' + body + ' = value;'
     )
   } catch (e) {
     _.warn('Invalid setter function body: ' + body)