Skip to content

Commit 645c553

Browse files
committed
fix(component): streamline applyFallthroughProps and getRootElement functions
1 parent 0ba9ef9 commit 645c553

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

packages/runtime-vapor/src/component.ts

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -381,10 +381,7 @@ export function setupComponent(
381381
component.inheritAttrs !== false &&
382382
Object.keys(instance.attrs).length
383383
) {
384-
const el = getRootElement(instance)
385-
if (el) {
386-
renderEffect(() => applyFallthroughProps(el, instance.attrs))
387-
}
384+
renderEffect(() => applyFallthroughProps(instance.block, instance.attrs))
388385
}
389386

390387
setActiveSub(prevSub)
@@ -402,9 +399,12 @@ export function applyFallthroughProps(
402399
block: Block,
403400
attrs: Record<string, any>,
404401
): void {
405-
isApplyingFallthroughProps = true
406-
setDynamicProps(block as Element, [attrs])
407-
isApplyingFallthroughProps = false
402+
const el = getRootElement(block)
403+
if (el) {
404+
isApplyingFallthroughProps = true
405+
setDynamicProps(el, [attrs])
406+
isApplyingFallthroughProps = false
407+
}
408408
}
409409

410410
/**
@@ -761,9 +761,7 @@ export function getExposed(
761761
}
762762
}
763763

764-
function getRootElement({
765-
block,
766-
}: VaporComponentInstance): Element | undefined {
764+
function getRootElement(block: Block): Element | undefined {
767765
if (block instanceof Element) {
768766
return block
769767
}

0 commit comments

Comments
 (0)