Skip to content

Commit 000d4d0

Browse files
committed
chore: tweaks
1 parent 5f70576 commit 000d4d0

File tree

3 files changed

+13
-14
lines changed

3 files changed

+13
-14
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: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,11 +241,14 @@ 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' })
246245

247246
foo.value = 2
248247
await nextTick()
248+
expect(props).toEqual({ foo: 100, baz: 'qux' })
249+
250+
delete bindObj.value.foo
251+
await nextTick()
249252
expect(props).toEqual({ foo: 2, baz: 'qux' })
250253
})
251254

packages/runtime-vapor/src/componentProps.ts

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -178,16 +178,6 @@ export function getAttrFromRawProps(rawProps: RawProps, key: string): unknown {
178178
if (key === '$') return
179179
// need special merging behavior for class & style
180180
const merged = key === 'class' || key === 'style' ? ([] as any[]) : undefined
181-
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-
191181
const dynamicSources = rawProps.$
192182
if (dynamicSources) {
193183
let i = dynamicSources.length
@@ -206,7 +196,13 @@ export function getAttrFromRawProps(rawProps: RawProps, key: string): unknown {
206196
}
207197
}
208198
}
209-
199+
if (hasOwn(rawProps, key)) {
200+
if (merged) {
201+
merged.push(rawProps[key]())
202+
} else {
203+
return rawProps[key]()
204+
}
205+
}
210206
if (merged && merged.length) {
211207
return merged
212208
}

0 commit comments

Comments
 (0)