Skip to content

Commit 119f9c9

Browse files
committed
fix(compiler): skip JSXStyleElement in strong-dom rendersChild check
Sibling-scoped <style> blocks are extracted by the CSS pipeline and never become rendered host children. The rendersChild helper fell through to `return true` for JSXStyleElement, making element.children true for containers that only hold a scoped style block. This caused false OCTANE_STRONG_MANAGED_DOM_WRITE errors on valid widget mounts (e.g. appendChild) into those hosts. Add the same JSXStyleElement exclusion that isRenderableChild, hasOnlyDefinitelyNullishJsxChildren, and the renderer-boundaries equivalent already apply. Add a regression test for mounting into a container whose only children are scoped style blocks.
1 parent f001359 commit 119f9c9

2 files changed

Lines changed: 14 additions & 0 deletions

File tree

‎packages/octane/src/compiler/strong-dom.js‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ function rendersChild(child) {
162162
}
163163
if (child.type === 'JSXExpressionContainer')
164164
return child.expression?.type !== 'JSXEmptyExpression';
165+
if (child.type === 'JSXStyleElement') return false;
165166
return true;
166167
}
167168

‎packages/octane/tests/compiler/strong-dom.test.ts‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,19 @@ function measure(ref) { return ref; }`;
399399
expectStrongValid(source, '/src/App.tsx');
400400
});
401401

402+
it('allows mounting into a container whose only children are scoped style blocks', () => {
403+
expectStrongValid(
404+
`${IMPORTS}export function Chart({ data }) @{
405+
const container = useRef(null);
406+
useEffect(() => { container.current.appendChild(document.createElement('canvas')); });
407+
<div ref={container} class="chart">
408+
<style>.chart { display: block; }</style>
409+
</div>
410+
}`,
411+
'/src/Chart.tsrx',
412+
);
413+
});
414+
402415
it('does not prove a ref declared outside the @for row that attaches it', () => {
403416
expectStrongValid(
404417
`${IMPORTS}export function List({ items }) @{

0 commit comments

Comments
 (0)