ripple 0.2.21 → 0.2.23
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
|
@@ -410,7 +410,11 @@ function RipplePlugin(config) {
|
|
|
410
410
|
if (this.value === '<' && this.#path.findLast((n) => n.type === 'Component')) {
|
|
411
411
|
// Check if this looks like JSX by looking ahead
|
|
412
412
|
const ahead = this.lookahead();
|
|
413
|
-
|
|
413
|
+
const curContext = this.curContext();
|
|
414
|
+
if (
|
|
415
|
+
curContext.token !== '(' &&
|
|
416
|
+
(ahead.type.label === 'name' || ahead.value === '/' || ahead.value === '>')
|
|
417
|
+
) {
|
|
414
418
|
// This is JSX, rewind to the end of the object expression
|
|
415
419
|
// and let ASI handle the semicolon insertion naturally
|
|
416
420
|
this.pos = base.end;
|
|
@@ -787,8 +787,8 @@ const visitors = {
|
|
|
787
787
|
|
|
788
788
|
if (
|
|
789
789
|
left.type === 'MemberExpression' &&
|
|
790
|
-
|
|
791
|
-
|
|
790
|
+
left.property.type === 'Identifier' &&
|
|
791
|
+
is_tracked_name(left.property.name)
|
|
792
792
|
) {
|
|
793
793
|
return b.call(
|
|
794
794
|
'$.set_property',
|
package/tests/basic.test.ripple
CHANGED
|
@@ -275,25 +275,6 @@ describe('basic', () => {
|
|
|
275
275
|
expect(div.getAttribute('data-extra')).toBe('value');
|
|
276
276
|
});
|
|
277
277
|
|
|
278
|
-
it('renders without crashing', () => {
|
|
279
|
-
component App() {
|
|
280
|
-
let foo;
|
|
281
|
-
let bar;
|
|
282
|
-
let baz;
|
|
283
|
-
|
|
284
|
-
foo = {};
|
|
285
|
-
foo = {'test': 0};
|
|
286
|
-
foo['abc'] = 123;
|
|
287
|
-
|
|
288
|
-
bar = { 'def': 456 };
|
|
289
|
-
|
|
290
|
-
baz = { 'ghi': 789 };
|
|
291
|
-
baz['jkl'] = 987;
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
render(App);
|
|
295
|
-
});
|
|
296
|
-
|
|
297
278
|
it('renders multiple reactive lexical blocks', () => {
|
|
298
279
|
component Basic() {
|
|
299
280
|
<div>
|
|
@@ -510,6 +491,20 @@ describe('basic', () => {
|
|
|
510
491
|
expect(evenDiv.textContent).toBe('Even');
|
|
511
492
|
});
|
|
512
493
|
|
|
494
|
+
it('renders simple JS expression logic correctly', () => {
|
|
495
|
+
component Example() {
|
|
496
|
+
let test = {}
|
|
497
|
+
let counter = 0;
|
|
498
|
+
test[counter++] = 'Test';
|
|
499
|
+
|
|
500
|
+
<div>{JSON.stringify(test)}</div>
|
|
501
|
+
<div>{JSON.stringify(counter)}</div>
|
|
502
|
+
}
|
|
503
|
+
render(Example);
|
|
504
|
+
|
|
505
|
+
expect(container).toMatchSnapshot();
|
|
506
|
+
});
|
|
507
|
+
|
|
513
508
|
it('renders with simple reactive objects', () => {
|
|
514
509
|
component Basic() {
|
|
515
510
|
let $user = {
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { describe, it, expect, beforeEach, afterEach } from 'vitest';
|
|
2
|
+
|
|
3
|
+
import { mount } from 'ripple';
|
|
4
|
+
|
|
5
|
+
describe('compiler success tests', () => {
|
|
6
|
+
let container;
|
|
7
|
+
|
|
8
|
+
function render(component) {
|
|
9
|
+
mount(component, {
|
|
10
|
+
target: container
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
beforeEach(() => {
|
|
15
|
+
container = document.createElement('div');
|
|
16
|
+
document.body.appendChild(container);
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
afterEach(() => {
|
|
20
|
+
document.body.removeChild(container);
|
|
21
|
+
container = null;
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it('renders without crashing', () => {
|
|
25
|
+
component App() {
|
|
26
|
+
let foo;
|
|
27
|
+
let bar;
|
|
28
|
+
let baz;
|
|
29
|
+
|
|
30
|
+
foo = {};
|
|
31
|
+
foo = {'test': 0};
|
|
32
|
+
foo['abc'] = 123;
|
|
33
|
+
|
|
34
|
+
bar = { 'def': 456 };
|
|
35
|
+
|
|
36
|
+
baz = { 'ghi': 789 };
|
|
37
|
+
baz['jkl'] = 987;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
render(App);
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
it('renders without crashing using < character', () => {
|
|
45
|
+
component App() {
|
|
46
|
+
function bar() {
|
|
47
|
+
for (let i = 0; i < 10; i++) {
|
|
48
|
+
// do nothing
|
|
49
|
+
}
|
|
50
|
+
const x = 1 < 1;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
let x = 5 < 10
|
|
54
|
+
|
|
55
|
+
<div>{x}</div>
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
render(App);
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
});
|