@sigil-dev/compiler 0.9.33 → 0.10.1
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.
- package/package.json +1 -1
- package/src/babel/index.ts +801 -763
- package/src/babel/jsx/conditional-return.ts +71 -0
- package/src/babel/jsx/keyed-list.ts +5 -1
- package/src/babel/jsx/textarea.ts +58 -0
- package/src/babel/jsx/utils.ts +3 -1
- package/src/babel/util/compile-state.ts +5 -0
- package/src/bun-plugin.ts +16 -3
- package/test/bun-plugin.test.ts +14 -1
- package/test/conditional-return.test.ts +82 -0
- package/test/hydration.test.ts +380 -315
- package/test/render-parity.test.ts +35 -0
|
@@ -907,3 +907,38 @@ 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 <b> & 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
|
+
});
|