mirror of https://github.com/vuejs/core.git
wip: fix value casting
This commit is contained in:
parent
33d1b8bcec
commit
caca46bb73
|
@ -212,13 +212,13 @@ export class VaporComponentInstance implements GenericComponentInstance {
|
||||||
// determine fallthrough
|
// determine fallthrough
|
||||||
this.hasFallthrough = false
|
this.hasFallthrough = false
|
||||||
if (rawProps) {
|
if (rawProps) {
|
||||||
if (rawProps.$) {
|
if (rawProps.$ || !comp.props) {
|
||||||
this.hasFallthrough = true
|
this.hasFallthrough = true
|
||||||
} else {
|
} else {
|
||||||
// check if rawProps contains any keys not declared
|
// check if rawProps contains any keys not declared
|
||||||
const propsOptions = normalizePropsOptions(comp)[0]!
|
const propsOptions = normalizePropsOptions(comp)[0]
|
||||||
for (const key in rawProps) {
|
for (const key in rawProps) {
|
||||||
if (!hasOwn(propsOptions, key)) {
|
if (!hasOwn(propsOptions!, key)) {
|
||||||
this.hasFallthrough = true
|
this.hasFallthrough = true
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,7 +36,7 @@ export function getPropsProxyHandlers(
|
||||||
const emitsOptions = normalizeEmitsOptions(comp)
|
const emitsOptions = normalizeEmitsOptions(comp)
|
||||||
const isProp = propsOptions ? (key: string) => hasOwn(propsOptions, key) : NO
|
const isProp = propsOptions ? (key: string) => hasOwn(propsOptions, key) : NO
|
||||||
const castProp = propsOptions
|
const castProp = propsOptions
|
||||||
? (key: string, value: any, isAbsent = false) =>
|
? (value: any, key: string, isAbsent = false) =>
|
||||||
resolvePropValue(
|
resolvePropValue(
|
||||||
propsOptions,
|
propsOptions,
|
||||||
key as string,
|
key as string,
|
||||||
|
@ -55,7 +55,7 @@ export function getPropsProxyHandlers(
|
||||||
}
|
}
|
||||||
|
|
||||||
if (key in target) {
|
if (key in target) {
|
||||||
return castProp(key, target[key as string]())
|
return castProp(target[key as string](), key)
|
||||||
}
|
}
|
||||||
const dynamicSources = target.$
|
const dynamicSources = target.$
|
||||||
if (dynamicSources) {
|
if (dynamicSources) {
|
||||||
|
@ -66,11 +66,11 @@ export function getPropsProxyHandlers(
|
||||||
isDynamic = isFunction(source)
|
isDynamic = isFunction(source)
|
||||||
source = isDynamic ? (source as Function)() : source
|
source = isDynamic ? (source as Function)() : source
|
||||||
if (hasOwn(source, key)) {
|
if (hasOwn(source, key)) {
|
||||||
return castProp(key, isDynamic ? source[key] : source[key]())
|
return castProp(isDynamic ? source[key] : source[key](), key)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return castProp(key, undefined, true)
|
return castProp(undefined, key, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
const propsHandlers = propsOptions
|
const propsHandlers = propsOptions
|
||||||
|
@ -109,7 +109,9 @@ export function getPropsProxyHandlers(
|
||||||
}
|
}
|
||||||
|
|
||||||
const attrsHandlers = {
|
const attrsHandlers = {
|
||||||
get: (target, key: string) => getProp(target, key, false),
|
get: (target, key: string) => {
|
||||||
|
return getProp(target, key, false)
|
||||||
|
},
|
||||||
has: hasAttr,
|
has: hasAttr,
|
||||||
getOwnPropertyDescriptor(target, key: string) {
|
getOwnPropertyDescriptor(target, key: string) {
|
||||||
if (hasAttr(target, key)) {
|
if (hasAttr(target, key)) {
|
||||||
|
|
Loading…
Reference in New Issue