From e59d40f885ed61c826c997b4f0d48d0b878b731c Mon Sep 17 00:00:00 2001 From: Richard Harris Date: Fri, 15 Mar 2019 21:34:14 -0400 Subject: [PATCH 01/12] remove support for logic-less components with vars --- src/compile/Component.ts | 12 +----------- src/interfaces.ts | 1 - 2 files changed, 1 insertion(+), 12 deletions(-) diff --git a/src/compile/Component.ts b/src/compile/Component.ts index 004ecb32ca..f2b6d25121 100644 --- a/src/compile/Component.ts +++ b/src/compile/Component.ts @@ -169,15 +169,6 @@ export default class Component { const variable = this.var_lookup.get(subscribable_name); variable.subscribable = true; - } else if (!this.ast.instance) { - this.add_var({ - name, - export_name: name, - implicit: true, - mutated: false, - referenced: true, - writable: true - }); } else { this.usedNames.add(name); } @@ -1140,7 +1131,7 @@ export default class Component { return `ctx.${name}`; } - warn_if_undefined(node, template_scope: TemplateScope, allow_implicit?: boolean) { + warn_if_undefined(node, template_scope: TemplateScope) { let { name } = node; if (name[0] === '$') { @@ -1148,7 +1139,6 @@ export default class Component { this.has_reactive_assignments = true; } - if (allow_implicit && !this.ast.instance && !this.ast.module) return; if (this.var_lookup.has(name)) return; if (template_scope && template_scope.names.has(name)) return; if (globalWhitelist.has(name)) return; diff --git a/src/interfaces.ts b/src/interfaces.ts index 4ec258c94a..b3e778a48b 100644 --- a/src/interfaces.ts +++ b/src/interfaces.ts @@ -85,7 +85,6 @@ export interface Var { // used internally, but not exposed global?: boolean; - implicit?: boolean; // logic-less template references internal?: boolean; // event handlers, bindings initialised?: boolean; hoistable?: boolean; From ed9016b68924e9997bb48ec84965cb4b86d749cc Mon Sep 17 00:00:00 2001 From: Richard Harris Date: Fri, 15 Mar 2019 21:34:22 -0400 Subject: [PATCH 02/12] update vars tests --- test/vars/index.js | 2 +- test/vars/samples/implicit-action/_config.js | 5 ----- test/vars/samples/implicit-action/input.svelte | 1 - test/vars/samples/implicit/_config.js | 13 +------------ test/vars/samples/template-references/_config.js | 12 ++++++------ test/vars/samples/template-references/input.svelte | 7 +++++++ 6 files changed, 15 insertions(+), 25 deletions(-) delete mode 100644 test/vars/samples/implicit-action/_config.js delete mode 100644 test/vars/samples/implicit-action/input.svelte diff --git a/test/vars/index.js b/test/vars/index.js index 66ffd94c70..71617b8bf9 100644 --- a/test/vars/index.js +++ b/test/vars/index.js @@ -2,7 +2,7 @@ import * as fs from 'fs'; import * as assert from 'assert'; import { svelte, loadConfig, tryToLoadJson } from '../helpers.js'; -describe('vars', () => { +describe.only('vars', () => { fs.readdirSync('test/vars/samples').forEach(dir => { if (dir[0] === '.') return; diff --git a/test/vars/samples/implicit-action/_config.js b/test/vars/samples/implicit-action/_config.js deleted file mode 100644 index 2b84e83f12..0000000000 --- a/test/vars/samples/implicit-action/_config.js +++ /dev/null @@ -1,5 +0,0 @@ -export default { - test(assert, vars) { - assert.deepEqual(vars, []); - }, -}; diff --git a/test/vars/samples/implicit-action/input.svelte b/test/vars/samples/implicit-action/input.svelte deleted file mode 100644 index 466495d255..0000000000 --- a/test/vars/samples/implicit-action/input.svelte +++ /dev/null @@ -1 +0,0 @@ -
\ No newline at end of file diff --git a/test/vars/samples/implicit/_config.js b/test/vars/samples/implicit/_config.js index 0c685e7f18..2b84e83f12 100644 --- a/test/vars/samples/implicit/_config.js +++ b/test/vars/samples/implicit/_config.js @@ -1,16 +1,5 @@ export default { test(assert, vars) { - assert.deepEqual(vars, [ - { - export_name: 'foo', - injected: false, - module: false, - mutated: false, - name: 'foo', - reassigned: false, - referenced: true, - writable: true, - }, - ]); + assert.deepEqual(vars, []); }, }; diff --git a/test/vars/samples/template-references/_config.js b/test/vars/samples/template-references/_config.js index 1d78fbdf46..adacc0d2ef 100644 --- a/test/vars/samples/template-references/_config.js +++ b/test/vars/samples/template-references/_config.js @@ -2,27 +2,27 @@ export default { test(assert, vars) { assert.deepEqual(vars, [ { - export_name: 'foo', + export_name: null, injected: false, module: false, mutated: false, - name: 'foo', + name: 'Bar', reassigned: false, referenced: true, - writable: true, + writable: false, }, { - export_name: 'Bar', + export_name: null, injected: false, module: false, mutated: false, - name: 'Bar', + name: 'foo', reassigned: false, referenced: true, writable: true, }, { - export_name: 'baz', + export_name: null, injected: false, module: false, mutated: false, diff --git a/test/vars/samples/template-references/input.svelte b/test/vars/samples/template-references/input.svelte index 938e61b7bd..4e2edad7e6 100644 --- a/test/vars/samples/template-references/input.svelte +++ b/test/vars/samples/template-references/input.svelte @@ -1,2 +1,9 @@ + + {foo} From 5f053325c0a2d07a7346dbb27aa20911896893c8 Mon Sep 17 00:00:00 2001 From: Richard Harris Date: Fri, 15 Mar 2019 22:44:30 -0400 Subject: [PATCH 03/12] update validate tests --- .../samples/a11y-html-has-lang/input.svelte | 4 ++++ .../samples/a11y-html-has-lang/warnings.json | 10 +++++----- .../a11y-iframe-has-title/input.svelte | 6 +++++- .../a11y-iframe-has-title/warnings.json | 12 +++++------ .../a11y-tabindex-no-positive/input.svelte | 4 ++++ .../a11y-tabindex-no-positive/warnings.json | 10 +++++----- .../samples/animation-missing/input.svelte | 4 ++++ .../samples/animation-missing/warnings.json | 10 +++++----- .../binding-dimensions-svg-child/errors.json | 10 +++++----- .../binding-dimensions-svg-child/input.svelte | 4 ++++ .../binding-dimensions-svg/errors.json | 10 +++++----- .../binding-dimensions-svg/input.svelte | 4 ++++ .../binding-dimensions-void/errors.json | 10 +++++----- .../binding-dimensions-void/input.svelte | 4 ++++ .../samples/binding-input-checked/errors.json | 10 +++++----- .../binding-input-checked/input.svelte | 4 ++++ .../binding-input-type-boolean/errors.json | 10 +++++----- .../binding-input-type-boolean/input.svelte | 4 ++++ .../binding-input-type-dynamic/errors.json | 12 +++++------ .../binding-input-type-dynamic/input.svelte | 7 ++++++- .../binding-invalid-on-element/errors.json | 10 +++++----- .../binding-invalid-on-element/input.svelte | 4 ++++ .../samples/binding-invalid/errors.json | 10 +++++----- .../samples/binding-invalid/input.svelte | 4 ++++ .../errors.json | 10 +++++----- .../input.svelte | 5 +++++ .../each-block-multiple-children/input.svelte | 5 +++++ .../samples/empty-block/input.svelte | 4 ++++ .../samples/empty-block/warnings.json | 20 +++++++++---------- .../samples/non-empty-block-dev/input.svelte | 4 ++++ .../samples/select-multiple/input.svelte | 4 ++++ .../input.svelte | 2 +- .../input.svelte | 9 ++++++++- .../warnings.json | 12 +++++------ .../window-binding-online/input.svelte | 4 ++++ test/vars/index.js | 2 +- 36 files changed, 170 insertions(+), 88 deletions(-) diff --git a/test/validator/samples/a11y-html-has-lang/input.svelte b/test/validator/samples/a11y-html-has-lang/input.svelte index 0fa84d90a6..ccc238e5d4 100644 --- a/test/validator/samples/a11y-html-has-lang/input.svelte +++ b/test/validator/samples/a11y-html-has-lang/input.svelte @@ -1,3 +1,7 @@ + + diff --git a/test/validator/samples/a11y-html-has-lang/warnings.json b/test/validator/samples/a11y-html-has-lang/warnings.json index 963a2570db..2ac8a2e5e0 100644 --- a/test/validator/samples/a11y-html-has-lang/warnings.json +++ b/test/validator/samples/a11y-html-has-lang/warnings.json @@ -4,14 +4,14 @@ "message": "A11y: element should have a lang attribute", "start": { "column": 0, - "line": 5, - "character": 82 + "line": 9, + "character": 124 }, "end": { - "line": 5, + "line": 9, "column": 13, - "character": 95 + "character": 137 }, - "pos": 82 + "pos": 124 } ] diff --git a/test/validator/samples/a11y-iframe-has-title/input.svelte b/test/validator/samples/a11y-iframe-has-title/input.svelte index 5e07ca5a08..4689a2dcf7 100644 --- a/test/validator/samples/a11y-iframe-has-title/input.svelte +++ b/test/validator/samples/a11y-iframe-has-title/input.svelte @@ -1 +1,5 @@ - \ No newline at end of file + + + \ No newline at end of file diff --git a/test/validator/samples/a11y-iframe-has-title/warnings.json b/test/validator/samples/a11y-iframe-has-title/warnings.json index d71bae1dae..cc80cceaa2 100644 --- a/test/validator/samples/a11y-iframe-has-title/warnings.json +++ b/test/validator/samples/a11y-iframe-has-title/warnings.json @@ -3,15 +3,15 @@ "code": "a11y-missing-attribute", "message": "A11y: