dx: warn private fields usage
This commit is contained in:
parent
93744d5889
commit
fa2240143c
@ -6,6 +6,7 @@ import { warn } from './warning'
|
|||||||
|
|
||||||
const bindCache = new WeakMap()
|
const bindCache = new WeakMap()
|
||||||
|
|
||||||
|
// TODO: bound methods should also capture/handle errors
|
||||||
function getBoundMethod(fn: Function, target: any, receiver: any): Function {
|
function getBoundMethod(fn: Function, target: any, receiver: any): Function {
|
||||||
let boundMethodsForTarget = bindCache.get(target)
|
let boundMethodsForTarget = bindCache.get(target)
|
||||||
if (boundMethodsForTarget === void 0) {
|
if (boundMethodsForTarget === void 0) {
|
||||||
|
@ -10,17 +10,20 @@ export let isRendering = false
|
|||||||
export function renderInstanceRoot(instance: ComponentInstance): VNode {
|
export function renderInstanceRoot(instance: ComponentInstance): VNode {
|
||||||
let vnode
|
let vnode
|
||||||
const { render, $proxy, $props, $slots, $attrs, $parentVNode } = instance
|
const { render, $proxy, $props, $slots, $attrs, $parentVNode } = instance
|
||||||
|
if (__DEV__) {
|
||||||
|
isRendering = true
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
if (__DEV__) {
|
|
||||||
isRendering = true
|
|
||||||
}
|
|
||||||
vnode = render.call($proxy, $props, $slots, $attrs, $parentVNode)
|
vnode = render.call($proxy, $props, $slots, $attrs, $parentVNode)
|
||||||
|
} catch (err) {
|
||||||
if (__DEV__) {
|
if (__DEV__) {
|
||||||
isRendering = false
|
isRendering = false
|
||||||
}
|
}
|
||||||
} catch (err) {
|
|
||||||
handleError(err, instance, ErrorTypes.RENDER)
|
handleError(err, instance, ErrorTypes.RENDER)
|
||||||
}
|
}
|
||||||
|
if (__DEV__) {
|
||||||
|
isRendering = false
|
||||||
|
}
|
||||||
return normalizeComponentRoot(vnode, $parentVNode)
|
return normalizeComponentRoot(vnode, $parentVNode)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,7 +54,7 @@ export function callLifecycleHookWithHandler(
|
|||||||
) {
|
) {
|
||||||
try {
|
try {
|
||||||
const res = hook.call(instanceProxy, arg)
|
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 => {
|
;(res as Promise<any>).catch(err => {
|
||||||
handleError(err, instanceProxy._self, type)
|
handleError(err, instanceProxy._self, type)
|
||||||
})
|
})
|
||||||
@ -114,11 +114,18 @@ function logError(err: Error, type: ErrorTypes, contextVNode: VNode | null) {
|
|||||||
if (contextVNode) {
|
if (contextVNode) {
|
||||||
pushWarningContext(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) {
|
if (contextVNode) {
|
||||||
popWarningContext()
|
popWarningContext()
|
||||||
}
|
}
|
||||||
console.error(err)
|
|
||||||
} else {
|
} else {
|
||||||
throw err
|
throw err
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user