]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
dx: warn private fields usage
authorEvan You <yyx990803@gmail.com>
Fri, 1 Mar 2019 15:28:29 +0000 (10:28 -0500)
committerEvan You <yyx990803@gmail.com>
Fri, 1 Mar 2019 15:28:29 +0000 (10:28 -0500)
packages/runtime-core/src/componentProxy.ts
packages/runtime-core/src/componentRenderUtils.ts
packages/runtime-core/src/errorHandling.ts

index 1747631d0f46bb151b4c86eea2dfa6f5a2b641c6..4ebbbf791541a3c4ac1bfd3e4fcbd841d113be2c 100644 (file)
@@ -6,6 +6,7 @@ import { warn } from './warning'
 
 const bindCache = new WeakMap()
 
+// TODO: bound methods should also capture/handle errors
 function getBoundMethod(fn: Function, target: any, receiver: any): Function {
   let boundMethodsForTarget = bindCache.get(target)
   if (boundMethodsForTarget === void 0) {
index 07588600b1159a59b174be814c859c801180f039..d327d0fe1934de84927926927d7d8efc4bbdd758 100644 (file)
@@ -10,17 +10,20 @@ export let isRendering = false
 export function renderInstanceRoot(instance: ComponentInstance): VNode {
   let vnode
   const { render, $proxy, $props, $slots, $attrs, $parentVNode } = instance
+  if (__DEV__) {
+    isRendering = true
+  }
   try {
-    if (__DEV__) {
-      isRendering = true
-    }
     vnode = render.call($proxy, $props, $slots, $attrs, $parentVNode)
+  } catch (err) {
     if (__DEV__) {
       isRendering = false
     }
-  } catch (err) {
     handleError(err, instance, ErrorTypes.RENDER)
   }
+  if (__DEV__) {
+    isRendering = false
+  }
   return normalizeComponentRoot(vnode, $parentVNode)
 }
 
index 301fa66bd3192f413f138218c05cb57988276fe1..2d427684816a5a053343e195fbe0167037d627b1 100644 (file)
@@ -54,7 +54,7 @@ export function callLifecycleHookWithHandler(
 ) {
   try {
     const res = hook.call(instanceProxy, arg)
-    if (res && typeof res.then === 'function') {
+    if (res && !res._isVue && typeof res.then === 'function') {
       ;(res as Promise<any>).catch(err => {
         handleError(err, instanceProxy._self, type)
       })
@@ -114,11 +114,18 @@ function logError(err: Error, type: ErrorTypes, contextVNode: VNode | null) {
     if (contextVNode) {
       pushWarningContext(contextVNode)
     }
-    warn(`Unhandled error${info ? ` ${info}` : ``}`)
+    if (/private field/.test(err.message)) {
+      warn(
+        `Private fields are not supported in component classes because they ` +
+          `cannot be tunneled through Proxies.`
+      )
+    } else {
+      warn(`Unhandled error${info ? ` ${info}` : ``}`)
+    }
+    console.error(err)
     if (contextVNode) {
       popWarningContext()
     }
-    console.error(err)
   } else {
     throw err
   }