prevent component name from conflicting with globals

pull/2023/head
Richard Harris 6 years ago
parent 596cdb64a9
commit 21a07fcaf4

@ -93,8 +93,6 @@ export default class Component {
options: CompileOptions,
stats: Stats
) {
this.name = this.getUniqueName(name);
this.stats = stats;
this.ast = ast;
this.source = source;
@ -131,6 +129,7 @@ export default class Component {
this.walk_module_js();
this.walk_instance_js_pre_template();
this.name = this.getUniqueName(name);
this.fragment = new Fragment(this, ast.html);
this.walk_instance_js_post_template();

@ -34,7 +34,7 @@ describe("runtime", () => {
require.extensions[".html"] = function(module, filename) {
const options = Object.assign(
{ filename, name: getName(filename), format: 'cjs', sveltePath },
{ filename, name: compileOptions.name || getName(filename), format: 'cjs', sveltePath },
compileOptions
);

@ -0,0 +1,10 @@
export default {
show: 1,
compileOptions: {
name: 'Set'
},
preserveIdentifiers: true,
html: `<p>true</p>`
};

@ -0,0 +1,5 @@
<script>
let set = new Set(['x']);
</script>
<p>{set.has('x')}</p>
Loading…
Cancel
Save