ripple 0.2.57 → 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.57",
6
+ "version": "0.2.59",
7
7
  "type": "module",
8
8
  "module": "src/runtime/index.js",
9
9
  "main": "src/runtime/index.js",
@@ -293,7 +293,7 @@ function RipplePlugin(config) {
293
293
  node.block = this.parseBlock();
294
294
  node.handler = null;
295
295
 
296
- if (this.value === 'pending') {
296
+ if (this.value === 'pending') {
297
297
  this.next();
298
298
  node.pending = this.parseBlock();
299
299
  } else {
@@ -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
  }
@@ -487,8 +489,10 @@ function RipplePlugin(config) {
487
489
  if (attr.name.type === 'JSXIdentifier') {
488
490
  attr.name.type = 'Identifier';
489
491
  }
490
- if (attr.value.type === 'JSXExpressionContainer') {
491
- attr.value = attr.value.expression;
492
+ if (attr.value !== null) {
493
+ if (attr.value.type === 'JSXExpressionContainer') {
494
+ attr.value = attr.value.expression;
495
+ }
492
496
  }
493
497
  }
494
498
  }
@@ -409,7 +409,7 @@ const visitors = {
409
409
 
410
410
  attr.metadata.delegated = delegated_event;
411
411
  }
412
- } else {
412
+ } else if (attr.value !== null) {
413
413
  visit(attr.value, state);
414
414
  }
415
415
  }
@@ -470,6 +470,11 @@ const visitors = {
470
470
  if (attr.name.type === 'Identifier') {
471
471
  const name = attr.name.name;
472
472
 
473
+ if (attr.value === null) {
474
+ handle_static_attr(name, true);
475
+ continue;
476
+ }
477
+
473
478
  if (attr.value.type === 'Literal' && name !== 'class') {
474
479
  handle_static_attr(name, attr.value.value);
475
480
  continue;
@@ -1,5 +1,24 @@
1
1
  // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
2
2
 
3
+ exports[`basic > handles boolean attributes with no prop value provides 1`] = `
4
+ <div>
5
+ <div
6
+ class="container"
7
+ >
8
+ <button
9
+ disabled=""
10
+ >
11
+ Button
12
+ </button>
13
+ <input
14
+ checked=""
15
+ type="checkbox"
16
+ />
17
+ </div>
18
+
19
+ </div>
20
+ `;
21
+
3
22
  exports[`basic > render semi-dynamic text 1`] = `
4
23
  <div>
5
24
  <div>
@@ -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
  <!---->
@@ -1246,4 +1246,16 @@ describe('basic', () => {
1246
1246
  flushSync();
1247
1247
  expect(countSpan.textContent).toBe('1');
1248
1248
  });
1249
+
1250
+ it('handles boolean attributes with no prop value provides', () => {
1251
+ component App() {
1252
+ <div class="container">
1253
+ <button onClick={() => console.log("clicked!")} disabled>{"Button"}</button>
1254
+ <input type="checkbox" checked />
1255
+ </div>
1256
+ }
1257
+
1258
+ render(App);
1259
+ expect(container).toMatchSnapshot();
1260
+ });
1249
1261
  });
@@ -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
  });