Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/fix-compiler-noscript-children.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@solidjs/compiler": patch
---

The DOM output no longer compiles a `<noscript>` element's JSX children when the `<noscript>` is a template root or has its own dynamic attribute or spread, matching `@solidjs/babel-plugin`.
16 changes: 16 additions & 0 deletions packages/babel-plugin/test/__dom_fixtures__/simpleElements/code.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,19 @@ const template5 = (
</noscript>
</div>
);

const template6 = (
<noscript>
<iframe src={trackingUrl()} height="0" width="0" />
</noscript>
);

const template7 = (
<div>
<noscript data-id={id()}>
<a href="/fallback" aria-label={label()}>
Fallback
</a>
</noscript>
</div>
);
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { template as _$template } from "r-dom";
import { setAttribute as _$setAttribute } from "r-dom";
import { effect as _$effect } from "r-dom";
var _tmpl$ = /*#__PURE__*/ _$template(
`<div id=main><style>div \{ color: red; }</style><h1>Welcome</h1><label for=entry>Edit:</label><input id=entry type=text>`
),
Expand All @@ -7,9 +9,20 @@ var _tmpl$ = /*#__PURE__*/ _$template(
_tmpl$4 = /*#__PURE__*/ _$template(
`<div><div><footer><div></div></footer></div><div><button><span>0`
),
_tmpl$5 = /*#__PURE__*/ _$template(`<div><noscript>`);
_tmpl$5 = /*#__PURE__*/ _$template(`<div><noscript>`),
_tmpl$6 = /*#__PURE__*/ _$template(`<noscript>`);
const template = _tmpl$();
const template2 = _tmpl$2();
const template3 = _tmpl$3();
const template4 = _tmpl$4();
const template5 = _tmpl$5();
const template6 = _tmpl$6();
var _el$7 = _tmpl$5(),
_el$8 = _el$7.firstChild;
_$effect(
() => id(),
_v$ => {
_$setAttribute(_el$8, "data-id", _v$);
}
);
const template7 = _el$7;
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,19 @@ const template5 = (
</noscript>
</div>
);

const template6 = (
<noscript>
<iframe src={trackingUrl()} height="0" width="0" />
</noscript>
);

const template7 = (
<div>
<noscript data-id={id()}>
<a href="/fallback" aria-label={label()}>
Fallback
</a>
</noscript>
</div>
);
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { template as _$template } from "r-dom";
import { setAttribute as _$setAttribute } from "r-dom";
import { effect as _$effect } from "r-dom";
import { getNextElement as _$getNextElement } from "r-dom";
var _tmpl$ = /*#__PURE__*/ _$template(
`<div id=main><style>div \{ color: red; }</style><h1>Welcome</h1><label for=entry>Edit:</label><input id=entry type=text>`
Expand All @@ -8,9 +10,20 @@ var _tmpl$ = /*#__PURE__*/ _$template(
_tmpl$4 = /*#__PURE__*/ _$template(
`<div><div><footer><div></div></footer></div><div><button><span>0`
),
_tmpl$5 = /*#__PURE__*/ _$template(`<div><noscript>`);
_tmpl$5 = /*#__PURE__*/ _$template(`<div><noscript>`),
_tmpl$6 = /*#__PURE__*/ _$template(`<noscript>`);
const template = _$getNextElement(_tmpl$);
const template2 = _$getNextElement(_tmpl$2);
const template3 = _$getNextElement(_tmpl$3);
const template4 = _$getNextElement(_tmpl$4);
const template5 = _$getNextElement(_tmpl$5);
const template6 = _$getNextElement(_tmpl$6);
var _el$7 = _$getNextElement(_tmpl$5),
_el$8 = _el$7.firstChild;
_$effect(
() => id(),
_v$ => {
_$setAttribute(_el$8, "data-id", _v$);
}
);
const template7 = _el$7;
Original file line number Diff line number Diff line change
@@ -1,12 +1,22 @@
import { template as _$template } from "r-dom";
import { getNextElement as _$getNextElement } from "r-dom";
import { effect as _$effect } from "r-dom";
import { setAttribute as _$setAttribute } from "r-dom";
var _tmpl$ = /* @__PURE__ */ _$template(`<div id=main><style>div { color: red; }</style><h1>Welcome</h1><label for=entry>Edit:</label><input id=entry type=text>`);
var _tmpl$2 = /* @__PURE__ */ _$template(`<div><span><a></a></span><span>`);
var _tmpl$3 = /* @__PURE__ */ _$template(`<div><div><table><tbody></tbody></table></div><div>`);
var _tmpl$4 = /* @__PURE__ */ _$template(`<div><div><footer><div></div></footer></div><div><button><span>0`);
var _tmpl$5 = /* @__PURE__ */ _$template(`<div><noscript>`);
var _tmpl$6 = /* @__PURE__ */ _$template(`<noscript>`);
const template = _$getNextElement(_tmpl$);
const template2 = _$getNextElement(_tmpl$2);
const template3 = _$getNextElement(_tmpl$3);
const template4 = _$getNextElement(_tmpl$4);
const template5 = _$getNextElement(_tmpl$5);
const template6 = _$getNextElement(_tmpl$6);
var _el$7 = _$getNextElement(_tmpl$5);
var _el$8 = _el$7.firstChild;
_$effect(() => id(), (_v$) => {
_$setAttribute(_el$8, "data-id", _v$);
});
const template7 = _el$7;
10 changes: 10 additions & 0 deletions packages/compiler/__tests__/fixtures/dom/simpleElements/output.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
import { template as _$template } from "r-dom";
import { effect as _$effect } from "r-dom";
import { setAttribute as _$setAttribute } from "r-dom";
var _tmpl$ = /* @__PURE__ */ _$template(`<div id=main><style>div { color: red; }</style><h1>Welcome</h1><label for=entry>Edit:</label><input id=entry type=text>`);
var _tmpl$2 = /* @__PURE__ */ _$template(`<div><span><a></a></span><span>`);
var _tmpl$3 = /* @__PURE__ */ _$template(`<div><div><table><tbody></tbody></table></div><div>`);
var _tmpl$4 = /* @__PURE__ */ _$template(`<div><div><footer><div></div></footer></div><div><button><span>0`);
var _tmpl$5 = /* @__PURE__ */ _$template(`<div><noscript>`);
var _tmpl$6 = /* @__PURE__ */ _$template(`<noscript>`);
const template = _tmpl$();
const template2 = _tmpl$2();
const template3 = _tmpl$3();
const template4 = _tmpl$4();
const template5 = _tmpl$5();
const template6 = _tmpl$6();
var _el$7 = _tmpl$5();
var _el$8 = _el$7.firstChild;
_$effect(() => id(), (_v$) => {
_$setAttribute(_el$8, "data-id", _v$);
});
const template7 = _el$7;
2 changes: 1 addition & 1 deletion packages/compiler/src/dom/children.rs
Original file line number Diff line number Diff line change
Expand Up @@ -949,7 +949,7 @@ impl<'a> AstDomTransform<'a, '_> {
child_template.push_both(">");
if attrs_lowering.needs_text_placeholder && child.children.is_empty() {
child_template.html.push(' ');
} else {
} else if tag_name != "noscript" {
self.lower_dom_children(
child,
&tag_name,
Expand Down
2 changes: 1 addition & 1 deletion packages/compiler/src/dom/element.rs
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ impl<'a, 'source> AstDomTransform<'a, 'source> {
// declaration still emits and the children compile normally).
// Attribute-driven, so like attributes it stays out of `closed`.
template.html.push(' ');
} else {
} else if tag_name != "noscript" {
self.lower_dom_children(
element,
&tag_name,
Expand Down
Loading