mirror of https://github.com/vuejs/core.git
Merge 5f70576c73
into bb4ae25793
This commit is contained in:
commit
37ce2d0b62
|
@ -445,4 +445,33 @@ describe('attribute fallthrough', () => {
|
||||||
// fn should be called once
|
// fn should be called once
|
||||||
expect(fn).toHaveBeenCalledTimes(1)
|
expect(fn).toHaveBeenCalledTimes(1)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('should fallthrough attrs to vdom child', () => {
|
||||||
|
const VDomChild = defineComponent({
|
||||||
|
setup() {
|
||||||
|
return () => h('div')
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
const VaporChild = defineVaporComponent({
|
||||||
|
setup() {
|
||||||
|
return createComponent(
|
||||||
|
VDomChild as any,
|
||||||
|
{ foo: () => 'vapor foo' },
|
||||||
|
null,
|
||||||
|
true,
|
||||||
|
)
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
const App = {
|
||||||
|
setup() {
|
||||||
|
return () => h(VaporChild as any, { foo: 'foo', bar: 'bar' })
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
const root = document.createElement('div')
|
||||||
|
createApp(App).use(vaporInteropPlugin).mount(root)
|
||||||
|
expect(root.innerHTML).toBe('<div foo="vapor foo" bar="bar"></div>')
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
|
@ -241,14 +241,11 @@ describe('component: slots', () => {
|
||||||
}),
|
}),
|
||||||
).render()
|
).render()
|
||||||
|
|
||||||
expect(props).toEqual({ foo: 100, baz: 'qux' })
|
// foo has higher priority than bindObj.foo
|
||||||
|
expect(props).toEqual({ foo: 0, baz: 'qux' })
|
||||||
|
|
||||||
foo.value = 2
|
foo.value = 2
|
||||||
await nextTick()
|
await nextTick()
|
||||||
expect(props).toEqual({ foo: 100, baz: 'qux' })
|
|
||||||
|
|
||||||
delete bindObj.value.foo
|
|
||||||
await nextTick()
|
|
||||||
expect(props).toEqual({ foo: 2, baz: 'qux' })
|
expect(props).toEqual({ foo: 2, baz: 'qux' })
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -150,19 +150,6 @@ export function createComponent(
|
||||||
resetInsertionState()
|
resetInsertionState()
|
||||||
}
|
}
|
||||||
|
|
||||||
// vdom interop enabled and component is not an explicit vapor component
|
|
||||||
if (appContext.vapor && !component.__vapor) {
|
|
||||||
const frag = appContext.vapor.vdomMount(
|
|
||||||
component as any,
|
|
||||||
rawProps,
|
|
||||||
rawSlots,
|
|
||||||
)
|
|
||||||
if (!isHydrating && _insertionParent) {
|
|
||||||
insert(frag, _insertionParent, _insertionAnchor)
|
|
||||||
}
|
|
||||||
return frag
|
|
||||||
}
|
|
||||||
|
|
||||||
if (
|
if (
|
||||||
isSingleRoot &&
|
isSingleRoot &&
|
||||||
component.inheritAttrs !== false &&
|
component.inheritAttrs !== false &&
|
||||||
|
@ -181,6 +168,19 @@ export function createComponent(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// vdom interop enabled and component is not an explicit vapor component
|
||||||
|
if (appContext.vapor && !component.__vapor) {
|
||||||
|
const frag = appContext.vapor.vdomMount(
|
||||||
|
component as any,
|
||||||
|
rawProps,
|
||||||
|
rawSlots,
|
||||||
|
)
|
||||||
|
if (!isHydrating && _insertionParent) {
|
||||||
|
insert(frag, _insertionParent, _insertionAnchor)
|
||||||
|
}
|
||||||
|
return frag
|
||||||
|
}
|
||||||
|
|
||||||
const instance = new VaporComponentInstance(
|
const instance = new VaporComponentInstance(
|
||||||
component,
|
component,
|
||||||
rawProps as RawProps,
|
rawProps as RawProps,
|
||||||
|
|
|
@ -178,6 +178,16 @@ export function getAttrFromRawProps(rawProps: RawProps, key: string): unknown {
|
||||||
if (key === '$') return
|
if (key === '$') return
|
||||||
// need special merging behavior for class & style
|
// need special merging behavior for class & style
|
||||||
const merged = key === 'class' || key === 'style' ? ([] as any[]) : undefined
|
const merged = key === 'class' || key === 'style' ? ([] as any[]) : undefined
|
||||||
|
|
||||||
|
// rawProps has high priority
|
||||||
|
if (hasOwn(rawProps, key)) {
|
||||||
|
if (merged) {
|
||||||
|
merged.push(rawProps[key]())
|
||||||
|
} else {
|
||||||
|
return rawProps[key]()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const dynamicSources = rawProps.$
|
const dynamicSources = rawProps.$
|
||||||
if (dynamicSources) {
|
if (dynamicSources) {
|
||||||
let i = dynamicSources.length
|
let i = dynamicSources.length
|
||||||
|
@ -196,13 +206,7 @@ export function getAttrFromRawProps(rawProps: RawProps, key: string): unknown {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (hasOwn(rawProps, key)) {
|
|
||||||
if (merged) {
|
|
||||||
merged.push(rawProps[key]())
|
|
||||||
} else {
|
|
||||||
return rawProps[key]()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (merged && merged.length) {
|
if (merged && merged.length) {
|
||||||
return merged
|
return merged
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue