Skip to content

fix(compiler): skip noscript children in client DOM output, matching babel-plugin - #5116

Merged
ryansolid merged 1 commit into
solidjs:mainfrom
Marve10s:fix-compiler-noscript-children
Nov 20, 2026
Merged

ryansolid merged 1 commit into
solidjs:mainfrom
Marve10s:fix-compiler-noscript-children

Conversation

@Marve10s

Copy link
Copy Markdown
Contributor

Summary

@solidjs/compiler renders <noscript> content on the client in cases where @solidjs/babel-plugin does not. With the usual Google Tag Manager fallback:

<noscript>
  <iframe src={"https://www.googletagmanager.com/ns.html?id=" + id()} height="0" width="0" />
</noscript>

the native compiler puts the iframe into the client template and binds its src, so in a browser with JavaScript on, the iframe is created and loads, and it loads again whenever id() changes. In jsdom (vitest), the template's noscript content parses as text, so the generated _el$.firstChild is a Text node and setAttribute throws node.setAttribute is not a function, which halts reactivity.

babel-plugin never lowers noscript children (if (tagName !== "noscript") transformChildren(...) in dom/element.ts), following #2178 ("we never want noscript content to render on the client"). The native compiler already skips them in static_template.rs for a fully static nested <noscript>, but its other two paths do not: a <noscript> that is the template root (dom/element.rs), and a nested <noscript> that has its own dynamic attribute, spread or ref and so is not static (dom/children.rs). Both now skip lower_dom_children for noscript, the same gate babel uses. Attributes and spreads on the <noscript> itself still bind, and SSR output is unchanged.

Public API changes

None.

How did you test this change?

  • Added two cases to the shared simpleElements fixtures (__dom_fixtures__ and __dom_hydratable_fixtures__): a root <noscript> with a dynamic iframe src, and a nested <noscript> with a dynamic data-id and a dynamic child. babel-plugin's source is unchanged, so its expected output comes from the current plugin; the native compiler's expected outputs were regenerated. With main's compiler binary, 43 compiler tests fail on these fixtures (babel-fixtures, dom-hydratable-fixtures, parity, cross-mode-parity and option-matrix), for example + var _tmpl$6 = _$template(<iframe height=0 width=0>) against babel's <noscript>. With the fix all compiler tests pass (6951) and babel-plugin passes (432).
  • cargo test and cargo clippy -- -D warnings pass. pnpm test from the repo root passes (39 of 39 turbo tasks).

Verification

Compiled output for <noscript><iframe src={"/ns.html?id=" + id()} /></noscript> with the published @solidjs/compiler 2.0.2:

var _tmpl$ = /* @__PURE__ */ _$template(`<noscript><iframe>`);
const App = () => (() => {
	var _el$ = _tmpl$();
	var _el$2 = _el$.firstChild;
	_$effect(() => "/ns.html?id=" + id(), (_v$) => {
		_$setAttribute(_el$2, "src", _v$);
	});
	return _el$;
})();

and with babel-plugin 2.0.2, and with this branch's native compiler (identical):

var _tmpl$ = /*#__PURE__*/_$template(`<noscript>`);
const App = () => _tmpl$();

Rendered in headless Chromium with 2.0.2, then setting the id from A to B:

babel {"html":"<noscript></noscript>","after":"<noscript></noscript>"} requests: []
oxc   {"html":"<noscript><iframe src=\"/ns.html?id=A\"></iframe></noscript>","after":"<noscript><iframe src=\"/ns.html?id=B\"></iframe></noscript>"} requests: ["http://x.test/ns.html?id=A","http://x.test/ns.html?id=B"]

In jsdom with 2.0.2 the native-compiled root and nested cases throw node.setAttribute is not a function; with this branch every case renders the same as babel (<noscript></noscript>, <div><noscript data-k="l"></noscript></div>).

@changeset-bot

changeset-bot Bot commented Nov 20, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 67d96b1

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@solidjs/compiler Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@codspeed

codspeed Bot commented Nov 20, 2026

Copy link
Copy Markdown

Merging this PR will degrade performance by 5.35%

3 warnings

⚠️ Upgrade your CodSpeed plugin for Node.js 24

@codspeed/* 5.4.0 is only tested on Node.js 18, 20, and 22, so your Node.js 24 measurements may be inaccurate. Upgrade your @codspeed/* packages to 6.0.0 or later.

See affected benchmarks

⚠️ 1 benchmark is dominated by system calls

System calls cannot be simulated consistently and are left out of the measure. The reported value understates the real cost. Switch to the Walltime instrument to measure them.

Learn more about system calls

See affected benchmarks

⚠️ 1 benchmark with a significant change ran in a different software environment

Its base and head results were measured with a different OS or toolchain, such as compiler, runtime or library versions, so the change might come from this difference rather than from the code. Open the benchmark to see what changed.

See affected benchmarks

❌ 1 regressed benchmark
✅ 200 untouched benchmarks
⏩ 5 skipped benchmarks1

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Benchmark BASE HEAD Efficiency
❌ mount-clear-cycle: 1000 rows 339 ms 358.1 ms -5.35%

Tip

Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.


Comparing Marve10s:fix-compiler-noscript-children (67d96b1) with main (99db9bc)

Open in CodSpeed

Footnotes

  1. 5 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

@ryansolid
ryansolid merged commit 841c506 into solidjs:main Nov 20, 2026
20 of 21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants