Skip to content

Commit 2450dd1

Browse files
authored
update acorn@^7.3.1 for optional chaining support (#5013)
1 parent 55c8096 commit 2450dd1

File tree

18 files changed

+295
-65
lines changed

18 files changed

+295
-65
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
## Unreleased
44

5+
* Support nullish coalescing (`??`) and optional chaining (`?.`) operators ([#1972](https://github.com/sveltejs/svelte/issues/1972))
6+
* Support `import.meta` ([#4379](https://github.com/sveltejs/svelte/issues/4379))
57
* Fix placement of `{@html}` when used at the root of a slot or the root of a component ([#5012](https://github.com/sveltejs/svelte/issues/5012))
68
* Fix handling of `import`ed value that is used as a store and is also mutated ([#5019](https://github.com/sveltejs/svelte/issues/5019))
79
* Do not display `a11y-missing-content` warning on elements with `contenteditable` bindings ([#5020](https://github.com/sveltejs/svelte/issues/5020))

package-lock.json

Lines changed: 14 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,10 @@
6868
"@types/node": "^8.10.53",
6969
"@typescript-eslint/eslint-plugin": "^3.0.2",
7070
"@typescript-eslint/parser": "^3.0.2",
71-
"acorn": "^7.1.0",
71+
"acorn": "^7.3.1",
7272
"agadoo": "^1.1.0",
7373
"c8": "^5.0.1",
74-
"code-red": "0.1.2",
74+
"code-red": "^0.1.3",
7575
"codecov": "^3.5.0",
7676
"css-tree": "1.0.0-alpha22",
7777
"eslint": "^7.1.0",

src/compiler/compile/nodes/shared/Context.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { x } from 'code-red';
2-
import { Node, Identifier, RestElement, Property } from 'estree';
2+
import { Node, Identifier } from 'estree';
33

44
export interface Context {
55
key: Identifier;
@@ -34,12 +34,10 @@ export function unpack_destructuring(contexts: Context[], node: Node, modifier:
3434
const used_properties = [];
3535

3636
node.properties.forEach((property) => {
37-
const props: (RestElement | Property) = (property as any);
38-
39-
if (props.type === 'RestElement') {
37+
if (property.type === 'RestElement') {
4038
unpack_destructuring(
4139
contexts,
42-
props.argument,
40+
property.argument,
4341
node => x`@object_without_properties(${modifier(node)}, [${used_properties}])` as Node
4442
);
4543
} else {

src/compiler/compile/nodes/shared/Expression.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ export default class Expression {
198198
scope = map.get(node);
199199
}
200200

201-
if (is_reference(node, parent)) {
201+
if (node.type === 'Identifier' && is_reference(node, parent)) {
202202
const { name } = flatten_reference(node);
203203

204204
if (scope.has(name)) return;
Lines changed: 189 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,189 @@
1+
/* generated by Svelte vX.Y.Z */
2+
import {
3+
SvelteComponent,
4+
attr,
5+
create_component,
6+
destroy_component,
7+
detach,
8+
element,
9+
init,
10+
insert,
11+
mount_component,
12+
safe_not_equal,
13+
set_data,
14+
space,
15+
text,
16+
transition_in,
17+
transition_out
18+
} from "svelte/internal";
19+
20+
function create_fragment(ctx) {
21+
let t0_value = /*a*/ ctx[0].normal + "";
22+
let t0;
23+
let t1_value = /*b*/ ctx[1]?.optional + "";
24+
let t1;
25+
let t2;
26+
let t3_value = /*c*/ ctx[2]["computed"] + "";
27+
let t3;
28+
let t4_value = /*d*/ ctx[3]?.["computed_optional"] + "";
29+
let t4;
30+
let t5;
31+
let t6_value = /*e*/ ctx[4]() + "";
32+
let t6;
33+
let t7_value = /*f*/ ctx[5]?.() + "";
34+
let t7;
35+
let t8;
36+
let div;
37+
let div_a_value;
38+
let div_b_value;
39+
let div_c_value;
40+
let div_d_value;
41+
let div_e_value;
42+
let div_f_value;
43+
let t9;
44+
let component;
45+
let current;
46+
47+
component = new /*Component*/ ctx[6]({
48+
props: {
49+
a: /*a*/ ctx[0].normal,
50+
b: /*b*/ ctx[1]?.optional,
51+
c: /*c*/ ctx[2]["computed"],
52+
d: /*d*/ ctx[3]?.["computed_optional"],
53+
e: /*e*/ ctx[4](),
54+
f: /*f*/ ctx[5]?.()
55+
}
56+
});
57+
58+
return {
59+
c() {
60+
t0 = text(t0_value);
61+
t1 = text(t1_value);
62+
t2 = space();
63+
t3 = text(t3_value);
64+
t4 = text(t4_value);
65+
t5 = space();
66+
t6 = text(t6_value);
67+
t7 = text(t7_value);
68+
t8 = space();
69+
div = element("div");
70+
t9 = space();
71+
create_component(component.$$.fragment);
72+
attr(div, "a", div_a_value = /*a*/ ctx[0].normal);
73+
attr(div, "b", div_b_value = /*b*/ ctx[1]?.optional);
74+
attr(div, "c", div_c_value = /*c*/ ctx[2]["computed"]);
75+
attr(div, "d", div_d_value = /*d*/ ctx[3]?.["computed_optional"]);
76+
attr(div, "e", div_e_value = /*e*/ ctx[4]());
77+
attr(div, "f", div_f_value = /*f*/ ctx[5]?.());
78+
},
79+
m(target, anchor) {
80+
insert(target, t0, anchor);
81+
insert(target, t1, anchor);
82+
insert(target, t2, anchor);
83+
insert(target, t3, anchor);
84+
insert(target, t4, anchor);
85+
insert(target, t5, anchor);
86+
insert(target, t6, anchor);
87+
insert(target, t7, anchor);
88+
insert(target, t8, anchor);
89+
insert(target, div, anchor);
90+
insert(target, t9, anchor);
91+
mount_component(component, target, anchor);
92+
current = true;
93+
},
94+
p(ctx, [dirty]) {
95+
if ((!current || dirty & /*a*/ 1) && t0_value !== (t0_value = /*a*/ ctx[0].normal + "")) set_data(t0, t0_value);
96+
if ((!current || dirty & /*b*/ 2) && t1_value !== (t1_value = /*b*/ ctx[1]?.optional + "")) set_data(t1, t1_value);
97+
if ((!current || dirty & /*c*/ 4) && t3_value !== (t3_value = /*c*/ ctx[2]["computed"] + "")) set_data(t3, t3_value);
98+
if ((!current || dirty & /*d*/ 8) && t4_value !== (t4_value = /*d*/ ctx[3]?.["computed_optional"] + "")) set_data(t4, t4_value);
99+
if ((!current || dirty & /*e*/ 16) && t6_value !== (t6_value = /*e*/ ctx[4]() + "")) set_data(t6, t6_value);
100+
if ((!current || dirty & /*f*/ 32) && t7_value !== (t7_value = /*f*/ ctx[5]?.() + "")) set_data(t7, t7_value);
101+
102+
if (!current || dirty & /*a*/ 1 && div_a_value !== (div_a_value = /*a*/ ctx[0].normal)) {
103+
attr(div, "a", div_a_value);
104+
}
105+
106+
if (!current || dirty & /*b*/ 2 && div_b_value !== (div_b_value = /*b*/ ctx[1]?.optional)) {
107+
attr(div, "b", div_b_value);
108+
}
109+
110+
if (!current || dirty & /*c*/ 4 && div_c_value !== (div_c_value = /*c*/ ctx[2]["computed"])) {
111+
attr(div, "c", div_c_value);
112+
}
113+
114+
if (!current || dirty & /*d*/ 8 && div_d_value !== (div_d_value = /*d*/ ctx[3]?.["computed_optional"])) {
115+
attr(div, "d", div_d_value);
116+
}
117+
118+
if (!current || dirty & /*e*/ 16 && div_e_value !== (div_e_value = /*e*/ ctx[4]())) {
119+
attr(div, "e", div_e_value);
120+
}
121+
122+
if (!current || dirty & /*f*/ 32 && div_f_value !== (div_f_value = /*f*/ ctx[5]?.())) {
123+
attr(div, "f", div_f_value);
124+
}
125+
126+
const component_changes = {};
127+
if (dirty & /*a*/ 1) component_changes.a = /*a*/ ctx[0].normal;
128+
if (dirty & /*b*/ 2) component_changes.b = /*b*/ ctx[1]?.optional;
129+
if (dirty & /*c*/ 4) component_changes.c = /*c*/ ctx[2]["computed"];
130+
if (dirty & /*d*/ 8) component_changes.d = /*d*/ ctx[3]?.["computed_optional"];
131+
if (dirty & /*e*/ 16) component_changes.e = /*e*/ ctx[4]();
132+
if (dirty & /*f*/ 32) component_changes.f = /*f*/ ctx[5]?.();
133+
component.$set(component_changes);
134+
},
135+
i(local) {
136+
if (current) return;
137+
transition_in(component.$$.fragment, local);
138+
current = true;
139+
},
140+
o(local) {
141+
transition_out(component.$$.fragment, local);
142+
current = false;
143+
},
144+
d(detaching) {
145+
if (detaching) detach(t0);
146+
if (detaching) detach(t1);
147+
if (detaching) detach(t2);
148+
if (detaching) detach(t3);
149+
if (detaching) detach(t4);
150+
if (detaching) detach(t5);
151+
if (detaching) detach(t6);
152+
if (detaching) detach(t7);
153+
if (detaching) detach(t8);
154+
if (detaching) detach(div);
155+
if (detaching) detach(t9);
156+
destroy_component(component, detaching);
157+
}
158+
};
159+
}
160+
161+
function instance($$self, $$props, $$invalidate) {
162+
let { a } = $$props;
163+
let { b } = $$props;
164+
let { c } = $$props;
165+
let { d } = $$props;
166+
let { e } = $$props;
167+
let { f } = $$props;
168+
let Component;
169+
170+
$$self.$set = $$props => {
171+
if ("a" in $$props) $$invalidate(0, a = $$props.a);
172+
if ("b" in $$props) $$invalidate(1, b = $$props.b);
173+
if ("c" in $$props) $$invalidate(2, c = $$props.c);
174+
if ("d" in $$props) $$invalidate(3, d = $$props.d);
175+
if ("e" in $$props) $$invalidate(4, e = $$props.e);
176+
if ("f" in $$props) $$invalidate(5, f = $$props.f);
177+
};
178+
179+
return [a, b, c, d, e, f, Component];
180+
}
181+
182+
class Component_1 extends SvelteComponent {
183+
constructor(options) {
184+
super();
185+
init(this, options, instance, create_fragment, safe_not_equal, { a: 0, b: 1, c: 2, d: 3, e: 4, f: 5 });
186+
}
187+
}
188+
189+
export default Component_1;
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<script>
2+
export let a;
3+
export let b;
4+
export let c;
5+
export let d;
6+
export let e;
7+
export let f;
8+
let Component;
9+
</script>
10+
11+
{a.normal}{b?.optional}
12+
{c['computed']}{d?.['computed_optional']}
13+
{e()}{f?.()}
14+
15+
<div
16+
a={a.normal}
17+
b={b?.optional}
18+
c={c['computed']}
19+
d={d?.['computed_optional']}
20+
e={e()}
21+
f={f?.()}
22+
/>
23+
24+
<Component
25+
a={a.normal}
26+
b={b?.optional}
27+
c={c['computed']}
28+
d={d?.['computed_optional']}
29+
e={e()}
30+
f={f?.()}
31+
/>

test/parser/samples/action-with-call/output.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@
6464
"value": "tooltip msg",
6565
"raw": "'tooltip msg'"
6666
}
67-
]
67+
],
68+
"optional": false
6869
}
6970
}
7071
],

test/parser/samples/animation/output.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,10 @@
5252
}
5353
],
5454
"context": {
55-
"start": 17,
56-
"end": 22,
5755
"type": "Identifier",
58-
"name": "thing"
56+
"name": "thing",
57+
"start": 17,
58+
"end": 22
5959
},
6060
"key": {
6161
"type": "Identifier",

test/parser/samples/await-catch/output.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@
2626
},
2727
"value": null,
2828
"error": {
29-
"start": 47,
30-
"end": 55,
3129
"type": "Identifier",
32-
"name": "theError"
30+
"name": "theError",
31+
"start": 47,
32+
"end": 55
3333
},
3434
"pending": {
3535
"start": 19,
@@ -152,7 +152,8 @@
152152
},
153153
"name": "message"
154154
},
155-
"computed": false
155+
"computed": false,
156+
"optional": false
156157
}
157158
}
158159
]

0 commit comments

Comments
 (0)