From 931bf0e1e07ad997cd6a97be303810c6dfc27f51 Mon Sep 17 00:00:00 2001 From: Richard Harris Date: Tue, 29 Jan 2019 21:59:13 -0500 Subject: [PATCH 1/4] bump alpha version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 6cc7dc89c9..6f9b2a8f71 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "svelte", - "version": "3.0.0-alpha20", + "version": "3.0.0-alpha21", "description": "The magical disappearing UI framework", "module": "index.mjs", "main": "index.js", From 58489d36db31377f188e501f00e1072bb912b7ee Mon Sep 17 00:00:00 2001 From: Richard Harris Date: Tue, 29 Jan 2019 22:08:00 -0500 Subject: [PATCH 2/4] prevent component name from conflicting with globals --- src/compile/Component.ts | 3 +-- test/runtime/index.js | 2 +- .../deconflict-component-name-with-global/_config.js | 10 ++++++++++ .../deconflict-component-name-with-global/main.html | 5 +++++ 4 files changed, 17 insertions(+), 3 deletions(-) create mode 100644 test/runtime/samples/deconflict-component-name-with-global/_config.js create mode 100644 test/runtime/samples/deconflict-component-name-with-global/main.html diff --git a/src/compile/Component.ts b/src/compile/Component.ts index 42d3f7a449..e09f5ed0c6 100644 --- a/src/compile/Component.ts +++ b/src/compile/Component.ts @@ -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(); diff --git a/test/runtime/index.js b/test/runtime/index.js index 98daf51c2a..f320e37d6e 100644 --- a/test/runtime/index.js +++ b/test/runtime/index.js @@ -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 ); diff --git a/test/runtime/samples/deconflict-component-name-with-global/_config.js b/test/runtime/samples/deconflict-component-name-with-global/_config.js new file mode 100644 index 0000000000..2b1efdcba6 --- /dev/null +++ b/test/runtime/samples/deconflict-component-name-with-global/_config.js @@ -0,0 +1,10 @@ +export default { + show: 1, + compileOptions: { + name: 'Set' + }, + + preserveIdentifiers: true, + + html: `

true

` +}; \ No newline at end of file diff --git a/test/runtime/samples/deconflict-component-name-with-global/main.html b/test/runtime/samples/deconflict-component-name-with-global/main.html new file mode 100644 index 0000000000..e5cc140b7a --- /dev/null +++ b/test/runtime/samples/deconflict-component-name-with-global/main.html @@ -0,0 +1,5 @@ + + +

{set.has('x')}

\ No newline at end of file From a1267d3e09119256394dc3aa3a2f099cc45e3bd3 Mon Sep 17 00:00:00 2001 From: Richard Harris Date: Tue, 29 Jan 2019 22:08:52 -0500 Subject: [PATCH 3/4] remove debugging output --- .../samples/deconflict-component-name-with-global/_config.js | 1 - 1 file changed, 1 deletion(-) diff --git a/test/runtime/samples/deconflict-component-name-with-global/_config.js b/test/runtime/samples/deconflict-component-name-with-global/_config.js index 2b1efdcba6..4b8255868e 100644 --- a/test/runtime/samples/deconflict-component-name-with-global/_config.js +++ b/test/runtime/samples/deconflict-component-name-with-global/_config.js @@ -1,5 +1,4 @@ export default { - show: 1, compileOptions: { name: 'Set' }, From 6676b11f1375b076d885e4224e20c3ff2747e2db Mon Sep 17 00:00:00 2001 From: Richard Harris Date: Tue, 29 Jan 2019 22:23:49 -0500 Subject: [PATCH 4/4] fix tests --- src/compile/Component.ts | 2 ++ .../samples/dev-warning-missing-data-binding/_config.js | 2 +- .../samples/dev-warning-missing-data-component/_config.js | 2 +- test/runtime/samples/dev-warning-missing-data/_config.js | 4 ++-- test/runtime/samples/dev-warning-readonly-computed/_config.js | 2 +- .../samples/dev-warning-readonly-window-binding/_config.js | 2 +- 6 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/compile/Component.ts b/src/compile/Component.ts index e09f5ed0c6..a09955d86d 100644 --- a/src/compile/Component.ts +++ b/src/compile/Component.ts @@ -93,6 +93,8 @@ export default class Component { options: CompileOptions, stats: Stats ) { + this.name = name; + this.stats = stats; this.ast = ast; this.source = source; diff --git a/test/runtime/samples/dev-warning-missing-data-binding/_config.js b/test/runtime/samples/dev-warning-missing-data-binding/_config.js index ffe62384a1..f23c5d5ec5 100644 --- a/test/runtime/samples/dev-warning-missing-data-binding/_config.js +++ b/test/runtime/samples/dev-warning-missing-data-binding/_config.js @@ -4,6 +4,6 @@ export default { }, warnings: [ - ` was created without expected prop 'value'` + `
was created without expected prop 'value'` ] }; diff --git a/test/runtime/samples/dev-warning-missing-data-component/_config.js b/test/runtime/samples/dev-warning-missing-data-component/_config.js index f3fc130528..a95e570988 100644 --- a/test/runtime/samples/dev-warning-missing-data-component/_config.js +++ b/test/runtime/samples/dev-warning-missing-data-component/_config.js @@ -4,6 +4,6 @@ export default { }, warnings: [ - ` was created without expected prop 'y'` + ` was created without expected prop 'y'` ] }; diff --git a/test/runtime/samples/dev-warning-missing-data/_config.js b/test/runtime/samples/dev-warning-missing-data/_config.js index 5bc6c8be1f..b929ff4741 100644 --- a/test/runtime/samples/dev-warning-missing-data/_config.js +++ b/test/runtime/samples/dev-warning-missing-data/_config.js @@ -4,7 +4,7 @@ export default { }, warnings: [ - ` was created without expected prop 'foo'`, - ` was created without expected prop 'bar'` + `
was created without expected prop 'foo'`, + `
was created without expected prop 'bar'` ] }; diff --git a/test/runtime/samples/dev-warning-readonly-computed/_config.js b/test/runtime/samples/dev-warning-readonly-computed/_config.js index e8ffbaba3c..33339071f4 100644 --- a/test/runtime/samples/dev-warning-readonly-computed/_config.js +++ b/test/runtime/samples/dev-warning-readonly-computed/_config.js @@ -12,7 +12,7 @@ export default { component.foo = 1; throw new Error( 'Expected an error' ); } catch ( err ) { - assert.equal( err.message, `: Cannot set read-only property 'foo'` ); + assert.equal( err.message, `
: Cannot set read-only property 'foo'` ); } } }; \ No newline at end of file diff --git a/test/runtime/samples/dev-warning-readonly-window-binding/_config.js b/test/runtime/samples/dev-warning-readonly-window-binding/_config.js index 751cffde79..e0b46584e4 100644 --- a/test/runtime/samples/dev-warning-readonly-window-binding/_config.js +++ b/test/runtime/samples/dev-warning-readonly-window-binding/_config.js @@ -8,7 +8,7 @@ export default { component.width = 99; throw new Error('Expected an error'); } catch (err) { - assert.equal(err.message, `: Cannot set read-only property 'width'`); + assert.equal(err.message, `
: Cannot set read-only property 'width'`); } } }; \ No newline at end of file