ripple 0.2.58 → 0.2.59

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 CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "Ripple is an elegant TypeScript UI framework",
4
4
  "license": "MIT",
5
5
  "author": "Dominic Gannaway",
6
- "version": "0.2.58",
6
+ "version": "0.2.59",
7
7
  "type": "module",
8
8
  "module": "src/runtime/index.js",
9
9
  "main": "src/runtime/index.js",
@@ -432,7 +432,9 @@ function RipplePlugin(config) {
432
432
  // '}'
433
433
  if (
434
434
  ch === 125 &&
435
- (this.#path.length === 0 || this.#path.at(-1)?.type === 'Component')
435
+ (this.#path.length === 0 ||
436
+ this.#path.at(-1)?.type === 'Component' ||
437
+ this.#path.at(-1)?.type === 'Element')
436
438
  ) {
437
439
  return original.readToken.call(this, ch);
438
440
  }
@@ -1,5 +1,85 @@
1
1
  // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
2
2
 
3
+ exports[`for statements > correctly handles intermediate statements in for block 1`] = `
4
+ <div>
5
+ <div>
6
+ <div>
7
+ <div>
8
+ 1
9
+ </div>
10
+ <div>
11
+ 1
12
+ </div>
13
+ </div>
14
+ <div>
15
+ <div>
16
+ 2
17
+ </div>
18
+ <div>
19
+ 2
20
+ </div>
21
+ </div>
22
+ <div>
23
+ <div>
24
+ 3
25
+ </div>
26
+ <div>
27
+ 3
28
+ </div>
29
+ </div>
30
+
31
+ </div>
32
+ <button>
33
+ Add Item
34
+ </button>
35
+
36
+ </div>
37
+ `;
38
+
39
+ exports[`for statements > correctly handles intermediate statements in for block 2`] = `
40
+ <div>
41
+ <div>
42
+ <div>
43
+ <div>
44
+ 1
45
+ </div>
46
+ <div>
47
+ 1
48
+ </div>
49
+ </div>
50
+ <div>
51
+ <div>
52
+ 2
53
+ </div>
54
+ <div>
55
+ 2
56
+ </div>
57
+ </div>
58
+ <div>
59
+ <div>
60
+ 3
61
+ </div>
62
+ <div>
63
+ 3
64
+ </div>
65
+ </div>
66
+ <div>
67
+ <div>
68
+ 4
69
+ </div>
70
+ <div>
71
+ 4
72
+ </div>
73
+ </div>
74
+
75
+ </div>
76
+ <button>
77
+ Add Item
78
+ </button>
79
+
80
+ </div>
81
+ `;
82
+
3
83
  exports[`for statements > render a simple dynamic array 1`] = `
4
84
  <div>
5
85
  <!---->
@@ -56,4 +56,33 @@ describe('for statements', () => {
56
56
 
57
57
  expect(container).toMatchSnapshot();
58
58
  });
59
+
60
+ it('correctly handles intermediate statements in for block', () => {
61
+ component App() {
62
+ const items = new TrackedArray(1, 2, 3);
63
+
64
+ <div>
65
+ for (const item of items) {
66
+ <div>
67
+ <div>{item}</div>
68
+ const some_text = item;
69
+ <div>{some_text}</div>
70
+ </div>
71
+ }
72
+ </div>
73
+
74
+ <button onClick={() => items.push(items.length + 1)}>{"Add Item"}</button>
75
+ }
76
+
77
+ render(App);
78
+
79
+ expect(container).toMatchSnapshot();
80
+
81
+ const button = container.querySelector('button');
82
+
83
+ button.click();
84
+ flushSync();
85
+
86
+ expect(container).toMatchSnapshot();
87
+ })
59
88
  });