ripple 0.2.6 → 0.2.7
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 +1 -1
- package/package.json +1 -1
- package/src/compiler/errors.js +20 -22
- package/src/compiler/phases/1-parse/index.js +14 -10
- package/src/compiler/phases/1-parse/style.js +27 -27
- package/src/compiler/phases/2-analyze/index.js +25 -25
- package/src/compiler/phases/2-analyze/prune.js +64 -27
- package/src/compiler/phases/3-transform/index.js +144 -109
- package/src/compiler/phases/3-transform/segments.js +25 -20
- package/src/compiler/phases/3-transform/stylesheet.js +28 -28
- package/src/compiler/scope.js +3 -3
- package/src/compiler/utils.js +7 -9
- package/src/constants.js +1 -2
- package/src/jsx-runtime.d.ts +59 -59
- package/src/jsx-runtime.js +13 -13
- package/src/runtime/array.js +15 -15
- package/src/runtime/internal/client/blocks.js +1 -1
- package/src/runtime/internal/client/constants.js +1 -1
- package/src/runtime/internal/client/events.js +2 -2
- package/src/runtime/internal/client/for.js +5 -5
- package/src/runtime/internal/client/operations.js +1 -1
- package/src/runtime/internal/client/runtime.js +28 -20
- package/src/runtime/internal/client/template.js +1 -1
- package/src/runtime/internal/client/try.js +2 -2
- package/src/utils/ast.js +9 -9
- package/src/utils/builders.js +66 -28
- package/tests/basic.test.ripple +292 -263
- package/tests/composite.test.ripple +125 -0
- package/tests/use.test.ripple +24 -22
- package/types/index.d.ts +1 -1
package/tests/use.test.ripple
CHANGED
|
@@ -1,32 +1,34 @@
|
|
|
1
1
|
import { describe, it, expect, beforeEach, afterEach } from 'vitest';
|
|
2
|
+
|
|
2
3
|
import { mount, flushSync } from 'ripple';
|
|
3
4
|
|
|
4
5
|
describe('@use element decorators', () => {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
function render(component) {
|
|
8
|
-
mount(component, { target: container });
|
|
9
|
-
}
|
|
6
|
+
let container;
|
|
10
7
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
8
|
+
function render(component) {
|
|
9
|
+
mount(component, {
|
|
10
|
+
target: container
|
|
11
|
+
});
|
|
12
|
+
}
|
|
15
13
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
14
|
+
beforeEach(() => {
|
|
15
|
+
container = document.createElement('div');
|
|
16
|
+
document.body.appendChild(container);
|
|
17
|
+
});
|
|
20
18
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
<div {@use (node) => { div = node; }}>{"Hello World"}</div>
|
|
26
|
-
}
|
|
19
|
+
afterEach(() => {
|
|
20
|
+
document.body.removeChild(container);
|
|
21
|
+
container = null;
|
|
22
|
+
});
|
|
27
23
|
|
|
28
|
-
|
|
24
|
+
it('capture a <div>', () => {
|
|
25
|
+
let div;
|
|
29
26
|
|
|
30
|
-
|
|
31
|
-
|
|
27
|
+
component Component() {
|
|
28
|
+
<div {@use (node) => { div = node; }}>{'Hello World'}</div>
|
|
29
|
+
}
|
|
30
|
+
render(Component);
|
|
31
|
+
flushSync();
|
|
32
|
+
expect(div.textContent).toBe('Hello World');
|
|
33
|
+
});
|
|
32
34
|
});
|
package/types/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ export type Component<T = Record<string, any>> = (props: T) => void;
|
|
|
2
2
|
|
|
3
3
|
export declare function mount(
|
|
4
4
|
component: () => void,
|
|
5
|
-
options: { target: HTMLElement; props?: Record<string, any> }
|
|
5
|
+
options: { target: HTMLElement; props?: Record<string, any> },
|
|
6
6
|
): () => void;
|
|
7
7
|
|
|
8
8
|
export declare function untrack<T>(fn: () => T): T;
|