Skip to content

Commit fca35de

Browse files
tanhauhauConduitry
authored andcommitted
deconflict with builtins (#3724)
1 parent e3953b2 commit fca35de

File tree

8 files changed

+41
-30
lines changed

8 files changed

+41
-30
lines changed

src/compiler/compile/render_dom/Block.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,11 +146,13 @@ export default class Block {
146146

147147
if (!wrapper.var) continue;
148148

149+
let suffix = '';
149150
if (dupes.has(wrapper.var.name)) {
150151
const i = counts.get(wrapper.var.name) || 0;
151152
counts.set(wrapper.var.name, i + 1);
152-
wrapper.var.name = this.get_unique_name(wrapper.var.name + i).name;
153+
suffix = i;
153154
}
155+
wrapper.var.name = this.get_unique_name(wrapper.var.name + suffix).name;
154156
}
155157
}
156158

test/js/samples/debug-no-dependencies/expected.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ function create_each_block(ctx) {
6060
}
6161

6262
function create_fragment(ctx) {
63-
let each_anchor;
63+
let each_1_anchor;
6464
let each_value = things;
6565
let each_blocks = [];
6666

@@ -74,7 +74,7 @@ function create_fragment(ctx) {
7474
each_blocks[i].c();
7575
}
7676

77-
each_anchor = empty();
77+
each_1_anchor = empty();
7878
},
7979
l: function claim(nodes) {
8080
throw new Error("options.hydrate only works if the component was compiled with the `hydratable: true` option");
@@ -84,7 +84,7 @@ function create_fragment(ctx) {
8484
each_blocks[i].m(target, anchor);
8585
}
8686

87-
insert_dev(target, each_anchor, anchor);
87+
insert_dev(target, each_1_anchor, anchor);
8888
},
8989
p: function update(changed, ctx) {
9090
if (changed.things) {
@@ -99,7 +99,7 @@ function create_fragment(ctx) {
9999
} else {
100100
each_blocks[i] = create_each_block(child_ctx);
101101
each_blocks[i].c();
102-
each_blocks[i].m(each_anchor.parentNode, each_anchor);
102+
each_blocks[i].m(each_1_anchor.parentNode, each_1_anchor);
103103
}
104104
}
105105

@@ -114,7 +114,7 @@ function create_fragment(ctx) {
114114
o: noop,
115115
d: function destroy(detaching) {
116116
destroy_each(each_blocks, detaching);
117-
if (detaching) detach_dev(each_anchor);
117+
if (detaching) detach_dev(each_1_anchor);
118118
}
119119
};
120120

test/js/samples/deconflict-builtins/expected.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ function create_each_block(ctx) {
4343
}
4444

4545
function create_fragment(ctx) {
46-
let each_anchor;
46+
let each_1_anchor;
4747
let each_value = ctx.createElement;
4848
let each_blocks = [];
4949

@@ -57,14 +57,14 @@ function create_fragment(ctx) {
5757
each_blocks[i].c();
5858
}
5959

60-
each_anchor = empty();
60+
each_1_anchor = empty();
6161
},
6262
m(target, anchor) {
6363
for (let i = 0; i < each_blocks.length; i += 1) {
6464
each_blocks[i].m(target, anchor);
6565
}
6666

67-
insert(target, each_anchor, anchor);
67+
insert(target, each_1_anchor, anchor);
6868
},
6969
p(changed, ctx) {
7070
if (changed.createElement) {
@@ -79,7 +79,7 @@ function create_fragment(ctx) {
7979
} else {
8080
each_blocks[i] = create_each_block(child_ctx);
8181
each_blocks[i].c();
82-
each_blocks[i].m(each_anchor.parentNode, each_anchor);
82+
each_blocks[i].m(each_1_anchor.parentNode, each_1_anchor);
8383
}
8484
}
8585

@@ -94,7 +94,7 @@ function create_fragment(ctx) {
9494
o: noop,
9595
d(detaching) {
9696
destroy_each(each_blocks, detaching);
97-
if (detaching) detach(each_anchor);
97+
if (detaching) detach(each_1_anchor);
9898
}
9999
};
100100
}

test/js/samples/each-block-array-literal/expected.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ function create_each_block(ctx) {
4343
}
4444

4545
function create_fragment(ctx) {
46-
let each_anchor;
46+
let each_1_anchor;
4747
let each_value = [ctx.a, ctx.b, ctx.c, ctx.d, ctx.e];
4848
let each_blocks = [];
4949

@@ -57,14 +57,14 @@ function create_fragment(ctx) {
5757
each_blocks[i].c();
5858
}
5959

60-
each_anchor = empty();
60+
each_1_anchor = empty();
6161
},
6262
m(target, anchor) {
6363
for (let i = 0; i < 5; i += 1) {
6464
each_blocks[i].m(target, anchor);
6565
}
6666

67-
insert(target, each_anchor, anchor);
67+
insert(target, each_1_anchor, anchor);
6868
},
6969
p(changed, ctx) {
7070
if (changed.a || changed.b || changed.c || changed.d || changed.e) {
@@ -79,7 +79,7 @@ function create_fragment(ctx) {
7979
} else {
8080
each_blocks[i] = create_each_block(child_ctx);
8181
each_blocks[i].c();
82-
each_blocks[i].m(each_anchor.parentNode, each_anchor);
82+
each_blocks[i].m(each_1_anchor.parentNode, each_1_anchor);
8383
}
8484
}
8585

@@ -92,7 +92,7 @@ function create_fragment(ctx) {
9292
o: noop,
9393
d(detaching) {
9494
destroy_each(each_blocks, detaching);
95-
if (detaching) detach(each_anchor);
95+
if (detaching) detach(each_1_anchor);
9696
}
9797
};
9898
}

test/js/samples/each-block-keyed-animated/expected.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -63,15 +63,15 @@ function create_each_block(key_1, ctx) {
6363

6464
function create_fragment(ctx) {
6565
let each_blocks = [];
66-
let each_lookup = new Map();
67-
let each_anchor;
66+
let each_1_lookup = new Map();
67+
let each_1_anchor;
6868
let each_value = ctx.things;
6969
const get_key = ctx => ctx.thing.id;
7070

7171
for (let i = 0; i < each_value.length; i += 1) {
7272
let child_ctx = get_each_context(ctx, each_value, i);
7373
let key = get_key(child_ctx);
74-
each_lookup.set(key, each_blocks[i] = create_each_block(key, child_ctx));
74+
each_1_lookup.set(key, each_blocks[i] = create_each_block(key, child_ctx));
7575
}
7676

7777
return {
@@ -80,19 +80,19 @@ function create_fragment(ctx) {
8080
each_blocks[i].c();
8181
}
8282

83-
each_anchor = empty();
83+
each_1_anchor = empty();
8484
},
8585
m(target, anchor) {
8686
for (let i = 0; i < each_blocks.length; i += 1) {
8787
each_blocks[i].m(target, anchor);
8888
}
8989

90-
insert(target, each_anchor, anchor);
90+
insert(target, each_1_anchor, anchor);
9191
},
9292
p(changed, ctx) {
9393
const each_value = ctx.things;
9494
for (let i = 0; i < each_blocks.length; i += 1) each_blocks[i].r();
95-
each_blocks = update_keyed_each(each_blocks, changed, get_key, 1, ctx, each_value, each_lookup, each_anchor.parentNode, fix_and_destroy_block, create_each_block, each_anchor, get_each_context);
95+
each_blocks = update_keyed_each(each_blocks, changed, get_key, 1, ctx, each_value, each_1_lookup, each_1_anchor.parentNode, fix_and_destroy_block, create_each_block, each_1_anchor, get_each_context);
9696
for (let i = 0; i < each_blocks.length; i += 1) each_blocks[i].a();
9797
},
9898
i: noop,
@@ -102,7 +102,7 @@ function create_fragment(ctx) {
102102
each_blocks[i].d(detaching);
103103
}
104104

105-
if (detaching) detach(each_anchor);
105+
if (detaching) detach(each_1_anchor);
106106
}
107107
};
108108
}

test/js/samples/each-block-keyed/expected.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,15 @@ function create_each_block(key_1, ctx) {
4848

4949
function create_fragment(ctx) {
5050
let each_blocks = [];
51-
let each_lookup = new Map();
52-
let each_anchor;
51+
let each_1_lookup = new Map();
52+
let each_1_anchor;
5353
let each_value = ctx.things;
5454
const get_key = ctx => ctx.thing.id;
5555

5656
for (let i = 0; i < each_value.length; i += 1) {
5757
let child_ctx = get_each_context(ctx, each_value, i);
5858
let key = get_key(child_ctx);
59-
each_lookup.set(key, each_blocks[i] = create_each_block(key, child_ctx));
59+
each_1_lookup.set(key, each_blocks[i] = create_each_block(key, child_ctx));
6060
}
6161

6262
return {
@@ -65,18 +65,18 @@ function create_fragment(ctx) {
6565
each_blocks[i].c();
6666
}
6767

68-
each_anchor = empty();
68+
each_1_anchor = empty();
6969
},
7070
m(target, anchor) {
7171
for (let i = 0; i < each_blocks.length; i += 1) {
7272
each_blocks[i].m(target, anchor);
7373
}
7474

75-
insert(target, each_anchor, anchor);
75+
insert(target, each_1_anchor, anchor);
7676
},
7777
p(changed, ctx) {
7878
const each_value = ctx.things;
79-
each_blocks = update_keyed_each(each_blocks, changed, get_key, 1, ctx, each_value, each_lookup, each_anchor.parentNode, destroy_block, create_each_block, each_anchor, get_each_context);
79+
each_blocks = update_keyed_each(each_blocks, changed, get_key, 1, ctx, each_value, each_1_lookup, each_1_anchor.parentNode, destroy_block, create_each_block, each_1_anchor, get_each_context);
8080
},
8181
i: noop,
8282
o: noop,
@@ -85,7 +85,7 @@ function create_fragment(ctx) {
8585
each_blocks[i].d(detaching);
8686
}
8787

88-
if (detaching) detach(each_anchor);
88+
if (detaching) detach(each_1_anchor);
8989
}
9090
};
9191
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export default {
2+
html: `<text>hello world</text>`,
3+
preserveIdentifiers: true,
4+
};
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<script>
2+
let foo = 'hello world'
3+
</script>
4+
5+
<text>{foo}</text>

0 commit comments

Comments
 (0)