@sigil-dev/compiler 0.10.1 → 0.10.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -907,38 +907,49 @@ test("compiler and runtime agree on the SVG attribute names", async () => {
907
907
  const { SVG_ATTR } = await import("../src/babel/util/svg-attrs.ts");
908
908
  expect(runtime.SVG_ATTR).toEqual(SVG_ATTR);
909
909
  });
910
-
911
- describe("textarea content", () => {
912
- // a textarea's content is raw text: markers would be typed into the box
913
- const valueOf = (host: HTMLElement) => (host.querySelector("textarea") as HTMLTextAreaElement).value;
914
-
915
- test("{expr} children become its value, with no markers anywhere", () => {
916
- const src = `const body = "a <b> & c"; export const App = () => <form><textarea name="b">{body}</textarea></form>;`;
917
- const r = render(src);
918
- const ssr = String(compile(src, "ssr")());
919
- expect(ssr).toBe('<form><textarea name="b">a &lt;b&gt; &amp; c</textarea></form>');
920
- expect(valueOf(r.hydrated)).toBe("a <b> & c");
921
- expect(valueOf(r.spa)).toBe("a <b> & c");
922
- });
923
-
924
- test("text and expressions join; null, undefined and booleans are empty", () => {
925
- const src = `const n = null; const u = undefined; const f = false; const x = 3; export const App = () => (
926
- <textarea>
927
- count: {x}{n}{u}{f}
928
- </textarea>
929
- );`;
930
- expect(String(compile(src, "ssr")())).toBe("<textarea>count: 3</textarea>");
931
- expect(valueOf(render(src).spa)).toBe("count: 3");
932
- });
933
-
934
- test("an explicit value wins over children", () => {
935
- const src = `export const App = () => <textarea value={"v"}>{"ignored"}</textarea>;`;
936
- expect(String(compile(src, "ssr")())).toBe("<textarea>v</textarea>");
937
- });
938
-
939
- test("a textarea nested in a condition is handled too", () => {
940
- const src = `const on = true; const t = "hi"; export const App = () => <div>{on ? <textarea>{t}</textarea> : null}</div>;`;
941
- expect(noMarkers(String(compile(src, "ssr")()))).toBe("<div><textarea>hi</textarea></div>");
942
- expect(String(compile(src, "ssr")())).toContain("<textarea>hi</textarea>");
943
- });
944
- });
910
+
911
+ describe("textarea content", () => {
912
+ // a textarea's content is raw text: markers would be typed into the box
913
+ const valueOf = (host: HTMLElement) => (host.querySelector("textarea") as HTMLTextAreaElement).value;
914
+
915
+ test("{expr} children become its value, with no markers anywhere", () => {
916
+ const src = `const body = "a <b> & c"; export const App = () => <form><textarea name="b">{body}</textarea></form>;`;
917
+ const r = render(src);
918
+ const ssr = String(compile(src, "ssr")());
919
+ expect(ssr).toBe('<form><textarea name="b">a &lt;b&gt; &amp; c</textarea></form>');
920
+ expect(valueOf(r.hydrated)).toBe("a <b> & c");
921
+ expect(valueOf(r.spa)).toBe("a <b> & c");
922
+ });
923
+
924
+ test("text and expressions join; null, undefined and booleans are empty", () => {
925
+ const src = `const n = null; const u = undefined; const f = false; const x = 3; export const App = () => (
926
+ <textarea>
927
+ count: {x}{n}{u}{f}
928
+ </textarea>
929
+ );`;
930
+ expect(String(compile(src, "ssr")())).toBe("<textarea>count: 3</textarea>");
931
+ expect(valueOf(render(src).spa)).toBe("count: 3");
932
+ });
933
+
934
+ test("an explicit value wins over children", () => {
935
+ const src = `export const App = () => <textarea value={"v"}>{"ignored"}</textarea>;`;
936
+ expect(String(compile(src, "ssr")())).toBe("<textarea>v</textarea>");
937
+ });
938
+
939
+ test("a textarea nested in a condition is handled too", () => {
940
+ const src = `const on = true; const t = "hi"; export const App = () => <div>{on ? <textarea>{t}</textarea> : null}</div>;`;
941
+ expect(noMarkers(String(compile(src, "ssr")()))).toBe("<div><textarea>hi</textarea></div>");
942
+ expect(String(compile(src, "ssr")())).toContain("<textarea>hi</textarea>");
943
+ });
944
+ });
945
+
946
+ describe("names the compiled code uses itself", () => {
947
+ // hydration checks `instanceof Text` / `instanceof Node`: a component with
948
+ // that name must not shadow the DOM's (it threw "non-object prototype")
949
+ test("components called Text and Node", () => {
950
+ expectAll(
951
+ `let name = $state("a"); let items = $state(["x"]); const Text = ({ l }) => <i>{l}</i>; const Node = () => <u />; export const App = () => <pre><span>{name}</span><b>{items.map((i) => <em>{i}</em>)}</b><Text l="t" /><Node /></pre>;`,
952
+ "<pre><span>a</span><b><em>x</em></b><i>t</i><u></u></pre>",
953
+ );
954
+ });
955
+ });