Skip to content
This repository was archived by the owner on Jul 19, 2025. It is now read-only.

Commit 47f8b9a

Browse files
committed
test: undo
1 parent 61b572c commit 47f8b9a

File tree

4 files changed

+16
-15
lines changed

4 files changed

+16
-15
lines changed

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

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,6 @@ describe('component: props', () => {
222222
test('optimized props updates', async () => {
223223
const t0 = template('<div>')
224224
const { component: Child } = define({
225-
inheritAttrs: false,
226225
props: ['foo'],
227226
render() {
228227
const instance = getCurrentInstance()!
@@ -239,21 +238,26 @@ describe('component: props', () => {
239238
return { foo, id }
240239
},
241240
render(_ctx: Record<string, any>) {
242-
return createComponent(Child, {
243-
foo: () => _ctx.foo,
244-
id: () => _ctx.id,
245-
})
241+
return createComponent(
242+
Child,
243+
{
244+
foo: () => _ctx.foo,
245+
id: () => _ctx.id,
246+
},
247+
true,
248+
)
246249
},
247250
}).render()
248251
const reset = setCurrentInstance(instance)
249-
expect(host.innerHTML).toBe('<div>1</div>')
252+
expect(host.innerHTML).toBe('<div id="a">1</div>')
250253

251254
foo.value++
252255
await nextTick()
253-
expect(host.innerHTML).toBe('<div>2</div>')
256+
expect(host.innerHTML).toBe('<div id="a">2</div>')
254257

255258
id.value = 'b'
256259
await nextTick()
260+
expect(host.innerHTML).toBe('<div id="b">2</div>')
257261
reset()
258262
})
259263

packages/runtime-vapor/src/apiCreateComponent.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ import {
44
currentInstance,
55
} from './component'
66
import { setupComponent } from './apiRender'
7-
import type { NormalizedRawProps } from './componentProps'
7+
import type { RawProps } from './componentProps'
88
import { withAttrs } from './componentAttrs'
99

1010
export function createComponent(
1111
comp: Component,
12-
rawProps: NormalizedRawProps | null = null,
12+
rawProps: RawProps | null = null,
1313
singleRoot: boolean = false,
1414
) {
1515
const current = currentInstance!

packages/runtime-vapor/src/apiRender.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ export function setupComponent(
5757
block = []
5858
}
5959
instance.block = block
60-
fallThroughAttrs(instance, singleRoot)
60+
if (singleRoot) fallThroughAttrs(instance)
6161
return block
6262
})
6363
reset()

packages/runtime-vapor/src/componentAttrs.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,17 +57,14 @@ export function withAttrs(props: RawProps): RawProps {
5757
return [attrsGetter, props]
5858
}
5959

60-
export function fallThroughAttrs(
61-
instance: ComponentInternalInstance,
62-
singleRoot: boolean,
63-
) {
60+
export function fallThroughAttrs(instance: ComponentInternalInstance) {
6461
const {
6562
block,
6663
component: { inheritAttrs },
6764
} = instance
6865
if (inheritAttrs === false) return
6966

70-
if (singleRoot && block instanceof Element) {
67+
if (block instanceof Element) {
7168
renderEffect(() => setDynamicProps(block, instance.attrs))
7269
}
7370
}

0 commit comments

Comments
 (0)