-import { EMPTY_ARR, NO, hasOwn, isFunction } from '@vue/shared'
+import { EMPTY_ARR, NO, YES, hasOwn, isFunction } from '@vue/shared'
import type { VaporComponent, VaporComponentInstance } from './component'
import {
type NormalizedPropsOptions,
const propsOptions = normalizePropsOptions(comp)[0]
const emitsOptions = normalizeEmitsOptions(comp)
const isProp = propsOptions ? (key: string) => hasOwn(propsOptions, key) : NO
+ const isAttr = propsOptions
+ ? (key: string) =>
+ key !== '$' && !isProp(key) && !isEmitListener(emitsOptions, key)
+ : YES
+
const castProp = propsOptions
? (value: any, key: string, isAbsent = false) =>
resolvePropValue(
} else if (isProp(key) || isEmitListener(emitsOptions, key)) {
return
}
-
- if (key in target) {
- return castProp(target[key as string](), key)
- }
const dynamicSources = target.$
if (dynamicSources) {
let i = dynamicSources.length
}
}
}
+ if (key in target) {
+ return castProp(target[key as string](), key)
+ }
return castProp(undefined, key, true)
}
: null
const hasAttr = (target: RawProps, key: string) => {
- if (key === '$' || isProp(key) || isEmitListener(emitsOptions, key)) {
- return false
- }
- const dynamicSources = target.$
- if (dynamicSources) {
- let i = dynamicSources.length
- while (i--) {
- if (hasOwn(resolveSource(dynamicSources[i]), key)) {
- return true
+ if (isAttr(key)) {
+ const dynamicSources = target.$
+ if (dynamicSources) {
+ let i = dynamicSources.length
+ while (i--) {
+ if (hasOwn(resolveSource(dynamicSources[i]), key)) {
+ return true
+ }
}
}
+ return hasOwn(target, key)
+ } else {
+ return false
}
- return hasOwn(target, key)
}
const attrsHandlers = {
}
},
ownKeys(target) {
- const keys = Object.keys(target)
+ const keys: string[] = []
+ for (const key in target) {
+ if (isAttr(key)) keys.push(key)
+ }
const dynamicSources = target.$
if (dynamicSources) {
let i = dynamicSources.length
+ let source
while (i--) {
- keys.push(...Object.keys(resolveSource(dynamicSources[i])))
+ source = resolveSource(dynamicSources[i])
+ for (const key in source) {
+ if (isAttr(key)) keys.push(key)
+ }
}
}
- return keys.filter(key => hasAttr(target, key))
+ return Array.from(new Set(keys))
},
set: NO,
deleteProperty: NO,