Evan You 10 лет назад
Родитель
Сommit
5e7ebec193
1 измененных файлов с 10 добавлено и 7 удалено
  1. 10 7
      src/runtime/instance/proxy.js

+ 10 - 7
src/runtime/instance/proxy.js

@@ -1,9 +1,14 @@
-import { warn, inBrowser } from '../util/index'
+import { warn, inBrowser, makeMap } from '../util/index'
 
 
 let hasProxy, proxyHandlers, initProxy
 let hasProxy, proxyHandlers, initProxy
 
 
 if (process.env.NODE_ENV !== 'production') {
 if (process.env.NODE_ENV !== 'production') {
-  let context = inBrowser ? window : global
+  const context = inBrowser ? window : global
+  const allowedGlobals = makeMap(
+    'Infinity,undefined,NaN,isFinite,isNaN,' +
+    'parseFloat,parseInt,decodeURI,decodeURIComponent,encodeURI,encodeURIComponent,' +
+    'Math,Number,Date,Array,Object,Boolean,String,RegExp,Map,Set,JSON,Intl'
+  )
 
 
   hasProxy =
   hasProxy =
     typeof Proxy !== 'undefined' &&
     typeof Proxy !== 'undefined' &&
@@ -11,11 +16,9 @@ if (process.env.NODE_ENV !== 'production') {
 
 
   proxyHandlers = {
   proxyHandlers = {
     has (target, key) {
     has (target, key) {
-      if (key === 'undefined') {
-        return false
-      }
-      let has = key in target
-      if (!has && !(key in context)) {
+      const has = key in target
+      const allowed = allowedGlobals(key)
+      if (!has && !allowed) {
         warn(
         warn(
           `Trying to access non-existent property "${key}" while rendering.`,
           `Trying to access non-existent property "${key}" while rendering.`,
           target
           target