@sigil-dev/compiler 0.9.21 → 0.9.22
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/README.md +162 -162
- package/package.json +3 -2
- package/src/analysis/hydration.ts +899 -0
- package/src/babel/handlers/dom/state.ts +106 -106
- package/src/babel/index.ts +685 -667
- package/src/babel/jsx/anchor-mount.ts +426 -426
- package/src/babel/jsx/children.ts +116 -116
- package/src/babel/jsx/element.ts +1027 -960
- package/src/babel/jsx/fragment.ts +271 -271
- package/src/babel/jsx/keyed-list.ts +317 -317
- package/src/babel/jsx/ssr.ts +307 -297
- package/src/babel/jsx/utils.ts +355 -333
- package/src/babel/util/bind.ts +143 -143
- package/src/babel/util/compile-state.ts +5 -0
- package/src/babel/util/css.ts +208 -208
- package/src/babel/util/props.ts +256 -256
- package/src/babel/util/reactive-fns.ts +110 -0
- package/src/babel/util/static-assertion.ts +51 -0
- package/src/bun-plugin.ts +103 -103
- package/src/vite/index.ts +61 -61
- package/test/bun-plugin.test.ts +45 -45
- package/test/hydration-analysis.test.ts +133 -0
- package/test/hydration.test.ts +277 -277
- package/test/jsx.test.ts +254 -254
- package/test/reactive-helpers.test.ts +135 -0
- package/test/render-parity.test.ts +827 -827
- package/test/scoped-css.test.ts +166 -166
- package/test/ssr-boolean-attrs.test.ts +56 -56
- package/test/ssr-raw-text.test.ts +68 -68
- package/test/ssr.test.ts +130 -130
- package/test/static-assertion.test.ts +123 -0
- package/test/static-skip.test.ts +292 -0
- package/test/style-object.test.ts +36 -36
|
@@ -1,36 +1,36 @@
|
|
|
1
|
-
import { describe, expect, test } from "bun:test";
|
|
2
|
-
import { transformSSR } from "./helpers/transform.ts";
|
|
3
|
-
|
|
4
|
-
function render(src: string): string {
|
|
5
|
-
const body = transformSSR(src).replace(/^export\s+/gm, "");
|
|
6
|
-
return String(new Function(`${body};\nreturn Card();`)());
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
describe("SSR style objects", () => {
|
|
10
|
-
test("style={{...}} serializes to CSS text, numbers in px", () => {
|
|
11
|
-
expect(
|
|
12
|
-
render(
|
|
13
|
-
`export function Card() { return <div style={{ display: "grid", marginTop: 12 }}>x</div>; }`,
|
|
14
|
-
),
|
|
15
|
-
).toBe(`<div style="display:grid;margin-top:12px">x</div>`);
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
test("unitless properties, custom properties and empty values", () => {
|
|
19
|
-
expect(
|
|
20
|
-
render(
|
|
21
|
-
`const s = { opacity: 0.5, zIndex: 3, "--gap": 4, color: null, lineHeight: 1.2, padding: 0 };
|
|
22
|
-
export function Card() { return <div style={s} />; }`,
|
|
23
|
-
),
|
|
24
|
-
).toBe(
|
|
25
|
-
`<div style="opacity:0.5;z-index:3;--gap:4;line-height:1.2;padding:0"></div>`,
|
|
26
|
-
);
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
test("values are attribute-escaped", () => {
|
|
30
|
-
expect(
|
|
31
|
-
render(
|
|
32
|
-
`const bg = 'url("a.png")'; export function Card() { return <div style={{ background: bg }} />; }`,
|
|
33
|
-
),
|
|
34
|
-
).toBe(`<div style="background:url("a.png")"></div>`);
|
|
35
|
-
});
|
|
36
|
-
});
|
|
1
|
+
import { describe, expect, test } from "bun:test";
|
|
2
|
+
import { transformSSR } from "./helpers/transform.ts";
|
|
3
|
+
|
|
4
|
+
function render(src: string): string {
|
|
5
|
+
const body = transformSSR(src).replace(/^export\s+/gm, "");
|
|
6
|
+
return String(new Function(`${body};\nreturn Card();`)());
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
describe("SSR style objects", () => {
|
|
10
|
+
test("style={{...}} serializes to CSS text, numbers in px", () => {
|
|
11
|
+
expect(
|
|
12
|
+
render(
|
|
13
|
+
`export function Card() { return <div style={{ display: "grid", marginTop: 12 }}>x</div>; }`,
|
|
14
|
+
),
|
|
15
|
+
).toBe(`<div style="display:grid;margin-top:12px">x</div>`);
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
test("unitless properties, custom properties and empty values", () => {
|
|
19
|
+
expect(
|
|
20
|
+
render(
|
|
21
|
+
`const s = { opacity: 0.5, zIndex: 3, "--gap": 4, color: null, lineHeight: 1.2, padding: 0 };
|
|
22
|
+
export function Card() { return <div style={s} />; }`,
|
|
23
|
+
),
|
|
24
|
+
).toBe(
|
|
25
|
+
`<div style="opacity:0.5;z-index:3;--gap:4;line-height:1.2;padding:0"></div>`,
|
|
26
|
+
);
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
test("values are attribute-escaped", () => {
|
|
30
|
+
expect(
|
|
31
|
+
render(
|
|
32
|
+
`const bg = 'url("a.png")'; export function Card() { return <div style={{ background: bg }} />; }`,
|
|
33
|
+
),
|
|
34
|
+
).toBe(`<div style="background:url("a.png")"></div>`);
|
|
35
|
+
});
|
|
36
|
+
});
|