Skip to content

Commit 05be5cf

Browse files
committed
chore: tweaks
1 parent 5f70576 commit 05be5cf

File tree

3 files changed

+18
-12
lines changed

3 files changed

+18
-12
lines changed

packages/runtime-vapor/__tests__/componentAttrs.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -472,6 +472,6 @@ describe('attribute fallthrough', () => {
472472

473473
const root = document.createElement('div')
474474
createApp(App).use(vaporInteropPlugin).mount(root)
475-
expect(root.innerHTML).toBe('<div foo="vapor foo" bar="bar"></div>')
475+
expect(root.innerHTML).toBe('<div foo="foo" bar="bar"></div>')
476476
})
477477
})

packages/runtime-vapor/__tests__/componentSlots.spec.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,8 +241,15 @@ describe('component: slots', () => {
241241
}),
242242
).render()
243243

244-
// foo has higher priority than bindObj.foo
245-
expect(props).toEqual({ foo: 0, baz: 'qux' })
244+
expect(props).toEqual({ foo: 100, baz: 'qux' })
245+
246+
foo.value = 2
247+
await nextTick()
248+
expect(props).toEqual({ foo: 100, baz: 'qux' })
249+
250+
delete bindObj.value.foo
251+
await nextTick()
252+
expect(props).toEqual({ foo: 2, baz: 'qux' })
246253

247254
foo.value = 2
248255
await nextTick()

packages/runtime-vapor/src/componentProps.ts

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -179,15 +179,6 @@ export function getAttrFromRawProps(rawProps: RawProps, key: string): unknown {
179179
// need special merging behavior for class & style
180180
const merged = key === 'class' || key === 'style' ? ([] as any[]) : undefined
181181

182-
// rawProps has high priority
183-
if (hasOwn(rawProps, key)) {
184-
if (merged) {
185-
merged.push(rawProps[key]())
186-
} else {
187-
return rawProps[key]()
188-
}
189-
}
190-
191182
const dynamicSources = rawProps.$
192183
if (dynamicSources) {
193184
let i = dynamicSources.length
@@ -207,6 +198,14 @@ export function getAttrFromRawProps(rawProps: RawProps, key: string): unknown {
207198
}
208199
}
209200

201+
if (hasOwn(rawProps, key)) {
202+
if (merged) {
203+
merged.push(rawProps[key]())
204+
} else {
205+
return rawProps[key]()
206+
}
207+
}
208+
210209
if (merged && merged.length) {
211210
return merged
212211
}

0 commit comments

Comments
 (0)