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()
|
||||
|
||||
// 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) {
|
||||
|
@ -10,17 +10,20 @@ export let isRendering = false
|
||||
export function renderInstanceRoot(instance: ComponentInstance): VNode {
|
||||
let vnode
|
||||
const { render, $proxy, $props, $slots, $attrs, $parentVNode } = instance
|
||||
try {
|
||||
if (__DEV__) {
|
||||
isRendering = true
|
||||
}
|
||||
try {
|
||||
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)
|
||||
}
|
||||
|
||||
|
@ -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)
|
||||
}
|
||||
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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user