From 295019f9e4956f7b870bfa7e2500b917e41328c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iv=C3=A1n=20S=C3=A1nchez=20Ortega?= Date: Fri, 22 Feb 2019 17:46:25 +0100 Subject: [PATCH 01/69] Check if slotted component has an update function during runtime --- src/compile/render-dom/wrappers/Slot.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/compile/render-dom/wrappers/Slot.ts b/src/compile/render-dom/wrappers/Slot.ts index 440590239d..de866ed882 100644 --- a/src/compile/render-dom/wrappers/Slot.ts +++ b/src/compile/render-dom/wrappers/Slot.ts @@ -141,7 +141,7 @@ export default class SlotWrapper extends Wrapper { if (this.dependencies.size > 1) update_conditions = `(${update_conditions})`; block.builders.update.addBlock(deindent` - if (${slot} && ${update_conditions}) { + if (${slot} && ${slot}.p && ${update_conditions}) { ${slot}.p(@assign(@assign({}, ${get_slot_changes}(changed)), ctx.$$scope.changed), @get_slot_context(${slot_definition}, ctx, ${get_slot_context})); } `); @@ -150,4 +150,4 @@ export default class SlotWrapper extends Wrapper { `if (${slot}) ${slot}.d(detach);` ); } -} \ No newline at end of file +} From 1e1784adaf4b8c41acf0ef80853fe0429ff459fe Mon Sep 17 00:00:00 2001 From: Conduitry Date: Sun, 10 Mar 2019 05:38:28 -0400 Subject: [PATCH 02/69] update options.customElement/ handling (#2025) --- src/compile/Component.ts | 15 +++++++-------- src/compile/index.ts | 34 +++++++++++++++++++++++++++++++++- src/interfaces.ts | 3 +-- src/parse/index.ts | 4 ++-- 4 files changed, 43 insertions(+), 13 deletions(-) diff --git a/src/compile/Component.ts b/src/compile/Component.ts index 1b843e9ca2..8589ef6af7 100644 --- a/src/compile/Component.ts +++ b/src/compile/Component.ts @@ -119,16 +119,15 @@ export default class Component { this.componentOptions = process_component_options(this, this.ast.html.children); this.namespace = namespaces[this.componentOptions.namespace] || this.componentOptions.namespace; - if (compileOptions.customElement === true && !this.componentOptions.tag) { - throw new Error(`No tag name specified`); // TODO better error + if (compileOptions.customElement) { + this.tag = compileOptions.customElement.tag || this.componentOptions.tag; + if (!this.tag) { + throw new Error(`Cannot compile to a custom element without specifying a tag name via options.customElement or `); + } + } else { + this.tag = this.name; } - this.tag = compileOptions.customElement - ? compileOptions.customElement === true - ? this.componentOptions.tag - : compileOptions.customElement as string - : this.name; - this.walk_module_js(); this.walk_instance_js_pre_template(); diff --git a/src/compile/index.ts b/src/compile/index.ts index 704d5bd706..ae9d554035 100644 --- a/src/compile/index.ts +++ b/src/compile/index.ts @@ -3,7 +3,7 @@ import Stats from '../Stats'; import parse from '../parse/index'; import renderDOM from './render-dom/index'; import renderSSR from './render-ssr/index'; -import { CompileOptions, Ast, Warning } from '../interfaces'; +import { CompileOptions, Ast, Warning, CustomElementOptions } from '../interfaces'; import Component from './Component'; import fuzzymatch from '../utils/fuzzymatch'; @@ -41,6 +41,10 @@ function validate_options(options: CompileOptions, warnings: Warning[]) { throw new Error(`options.name must be a valid identifier (got '${name}')`); } + if ('customElement' in options) { + options.customElement = normalize_customElement_option(options.customElement); + } + if (name && /^[a-z]/.test(name)) { const message = `options.name should be capitalised`; warnings.push({ @@ -52,6 +56,34 @@ function validate_options(options: CompileOptions, warnings: Warning[]) { } } +const valid_customElement_options = ['tag']; + +function normalize_customElement_option(customElement: boolean | string | CustomElementOptions) { + if (typeof customElement === 'boolean') { + return customElement ? {} : null; + } else if (typeof customElement === 'string') { + customElement = { tag: customElement }; + } else if (typeof customElement === 'object') { + Object.keys(customElement).forEach(key => { + if (valid_customElement_options.indexOf(key) === -1) { + const match = fuzzymatch(key, valid_customElement_options); + let message = `Unrecognized option 'customElement.${key}'`; + if (match) message += ` (did you mean 'customElement.${match}'?)`; + + throw new Error(message); + } + }); + } else { + throw new Error(`options.customElement must be a boolean, a string or an object`); + } + + if ('tag' in customElement && !/^[a-zA-Z][a-zA-Z0-9]*-[a-zA-Z0-9-]+$/.test(customElement.tag)) { + throw new Error(`options.customElement tag name must be two or more words joined by the '-' character`); + } + + return customElement; +} + function get_name(filename) { if (!filename) return null; const parts = filename.split(/[\/\\]/); diff --git a/src/interfaces.ts b/src/interfaces.ts index 4ec258c94a..fc2e6b260e 100644 --- a/src/interfaces.ts +++ b/src/interfaces.ts @@ -52,7 +52,7 @@ export interface CompileOptions { immutable?: boolean; hydratable?: boolean; legacy?: boolean; - customElement?: CustomElementOptions | true; + customElement?: CustomElementOptions; css?: boolean; preserveComments?: boolean | false; @@ -65,7 +65,6 @@ export interface Visitor { export interface CustomElementOptions { tag?: string; - props?: string[]; } export interface AppendTarget { diff --git a/src/parse/index.ts b/src/parse/index.ts index 4b1e0a225c..1618ee5e6e 100644 --- a/src/parse/index.ts +++ b/src/parse/index.ts @@ -9,7 +9,7 @@ import error from '../utils/error'; interface ParserOptions { filename?: string; bind?: boolean; - customElement?: CustomElementOptions | true; + customElement?: CustomElementOptions; } type ParserState = (parser: Parser) => (ParserState | void); @@ -17,7 +17,7 @@ type ParserState = (parser: Parser) => (ParserState | void); export class Parser { readonly template: string; readonly filename?: string; - readonly customElement: CustomElementOptions | true; + readonly customElement: CustomElementOptions; index = 0; stack: Array = []; From 328db0920f1d543702f907d7b89d71a25e8b2039 Mon Sep 17 00:00:00 2001 From: Conduitry Date: Mon, 11 Mar 2019 14:13:03 -0400 Subject: [PATCH 03/69] repl: better bundling error when unable to resolve module (#2208) --- site/static/workers/bundler.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/site/static/workers/bundler.js b/site/static/workers/bundler.js index 2874820529..678612c350 100644 --- a/site/static/workers/bundler.js +++ b/site/static/workers/bundler.js @@ -89,6 +89,8 @@ async function getBundle(mode, cache, lookup) { if (importee.endsWith('.html')) importee = importee.replace(/\.html$/, '.svelte'); if (importee in lookup) return importee; + + throw new Error(`Could not resolve "${importee}" from "${importer}"`); }, load(id) { if (id.startsWith(`https://`)) return fetch_if_uncached(id); From 78cb0183fb044e7820821d69a1b9fa70dd8f9921 Mon Sep 17 00:00:00 2001 From: Conduitry Date: Mon, 11 Mar 2019 14:39:08 -0400 Subject: [PATCH 04/69] repl: use Rollup 1.x --- site/static/workers/bundler.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/site/static/workers/bundler.js b/site/static/workers/bundler.js index 678612c350..c724cc7da0 100644 --- a/site/static/workers/bundler.js +++ b/site/static/workers/bundler.js @@ -14,7 +14,7 @@ self.addEventListener('message', async event => { version === 'local' ? '/repl/local?file=compiler.js' : `https://unpkg.com/svelte@${version}/compiler.js`, - `https://unpkg.com/rollup@0.68/dist/rollup.browser.js` + `https://unpkg.com/rollup@1/dist/rollup.browser.js` ); fulfil(); @@ -62,7 +62,6 @@ function fetch_if_uncached(url) { async function getBundle(mode, cache, lookup) { let bundle; - let error; const all_warnings = []; const new_cache = {}; @@ -106,7 +105,7 @@ async function getBundle(mode, cache, lookup) { : svelte.compile(code, Object.assign({ generate: mode, format: 'esm', - name: name, + name, filename: name + '.svelte' }, commonCompilerOptions)); @@ -124,6 +123,7 @@ async function getBundle(mode, cache, lookup) { return result.js; } }], + inlineDynamicImports: true, onwarn(warning) { all_warnings.push({ message: warning.message @@ -131,7 +131,7 @@ async function getBundle(mode, cache, lookup) { } }); } catch (error) { - return { error, bundle: null, cache: new_cache, warnings: all_warnings } + return { error, bundle: null, cache: new_cache, warnings: all_warnings }; } return { bundle, cache: new_cache, error: null, warnings: all_warnings }; @@ -168,7 +168,7 @@ async function bundle(components) { let uid = 1; - const dom_result = await dom.bundle.generate({ + const dom_result = (await dom.bundle.generate({ format: 'iife', name: 'SvelteComponent', globals: id => { @@ -177,7 +177,7 @@ async function bundle(components) { return name; }, sourcemap: true - }); + })).output[0]; if (token !== currentToken) return; @@ -195,16 +195,16 @@ async function bundle(components) { if (token !== currentToken) return; const ssr_result = ssr - ? await ssr.bundle.generate({ + ? (await ssr.bundle.generate({ format: 'iife', name: 'SvelteComponent', globals: id => import_map.get(id), sourcemap: true - }) + })).output[0] : null; return { - imports: dom.bundle.imports, + imports: dom_result.imports, import_map, dom: dom_result, ssr: ssr_result, From 52146fed7e08a6c2a442fc9c6b83768d7f4fc354 Mon Sep 17 00:00:00 2001 From: Conduitry Date: Tue, 12 Mar 2019 08:46:36 -0400 Subject: [PATCH 05/69] deconflict fragment method aliases with other identifiers (#2212) --- src/compile/render-dom/Block.ts | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/src/compile/render-dom/Block.ts b/src/compile/render-dom/Block.ts index 1d5c3c99a2..8051b9407c 100644 --- a/src/compile/render-dom/Block.ts +++ b/src/compile/render-dom/Block.ts @@ -239,6 +239,8 @@ export default class Block { const properties = new CodeBuilder(); + const methodName = (short: string, long: string) => dev ? `${short}: function ${this.getUniqueName(long)}` : short; + if (localKey) { properties.addBlock(`key: ${localKey},`); } @@ -258,7 +260,7 @@ export default class Block { ); properties.addBlock(deindent` - ${dev ? 'c: function create' : 'c'}() { + ${methodName('c', 'create')}() { ${this.builders.create} ${hydrate} }, @@ -270,7 +272,7 @@ export default class Block { properties.addLine(`l: @noop,`); } else { properties.addBlock(deindent` - ${dev ? 'l: function claim' : 'l'}(nodes) { + ${methodName('l', 'claim')}(nodes) { ${this.builders.claim} ${this.renderer.options.hydratable && !this.builders.hydrate.isEmpty() && `this.h();`} }, @@ -280,7 +282,7 @@ export default class Block { if (this.renderer.options.hydratable && !this.builders.hydrate.isEmpty()) { properties.addBlock(deindent` - ${dev ? 'h: function hydrate' : 'h'}() { + ${methodName('h', 'hydrate')}() { ${this.builders.hydrate} }, `); @@ -290,7 +292,7 @@ export default class Block { properties.addLine(`m: @noop,`); } else { properties.addBlock(deindent` - ${dev ? 'm: function mount' : 'm'}(#target, anchor) { + ${methodName('m', 'mount')}(#target, anchor) { ${this.builders.mount} }, `); @@ -301,7 +303,7 @@ export default class Block { properties.addLine(`p: @noop,`); } else { properties.addBlock(deindent` - ${dev ? 'p: function update' : 'p'}(changed, ${this.maintainContext ? 'new_ctx' : 'ctx'}) { + ${methodName('p', 'update')}(changed, ${this.maintainContext ? 'new_ctx' : 'ctx'}) { ${this.maintainContext && `ctx = new_ctx;`} ${this.builders.update} }, @@ -311,15 +313,15 @@ export default class Block { if (this.hasAnimation) { properties.addBlock(deindent` - ${dev ? `r: function measure` : `r`}() { + ${methodName('r', 'measure')}() { ${this.builders.measure} }, - ${dev ? `f: function fix` : `f`}() { + ${methodName('f', 'fix')}() { ${this.builders.fix} }, - ${dev ? `a: function animate` : `a`}() { + ${methodName('a', 'animate')}() { ${this.builders.animate} }, `); @@ -330,7 +332,7 @@ export default class Block { properties.addLine(`i: @noop,`); } else { properties.addBlock(deindent` - ${dev ? 'i: function intro' : 'i'}(#local) { + ${methodName('i', 'intro')}(#local) { ${this.hasOutros && `if (#current) return;`} ${this.builders.intro} }, @@ -341,7 +343,7 @@ export default class Block { properties.addLine(`o: @noop,`); } else { properties.addBlock(deindent` - ${dev ? 'o: function outro' : 'o'}(#local) { + ${methodName('o', 'outro')}(#local) { ${this.builders.outro} }, `); @@ -352,7 +354,7 @@ export default class Block { properties.addLine(`d: @noop`); } else { properties.addBlock(deindent` - ${dev ? 'd: function destroy' : 'd'}(detach) { + ${methodName('d', 'destroy')}(detach) { ${this.builders.destroy} } `); From e619de7e089eb37f3e266e80b2ec17cf536862fa Mon Sep 17 00:00:00 2001 From: Thomas Ghysels Date: Sun, 3 Mar 2019 21:58:48 +0100 Subject: [PATCH 06/69] Throw descriptive error when 'subscribable' of undefined Fix #2139 --- src/compile/nodes/shared/Expression.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/compile/nodes/shared/Expression.ts b/src/compile/nodes/shared/Expression.ts index 0d33988fb3..d52a0d80de 100644 --- a/src/compile/nodes/shared/Expression.ts +++ b/src/compile/nodes/shared/Expression.ts @@ -149,6 +149,13 @@ export default class Expression { dependencies.add(name); } + if (name[0] === '$' && !component.var_lookup.get(name.slice(1)) && name !== '$$props') { + component.error(node, { + code: `missing-store`, + message: `Stores must be declared` + }); + } + component.add_reference(name); component.warn_if_undefined(nodes[0], template_scope, true); } From fc1761538b8a74b00beb9d5287f89ca1e6dd1589 Mon Sep 17 00:00:00 2001 From: Conduitry Date: Fri, 15 Mar 2019 15:19:08 -0400 Subject: [PATCH 07/69] update Acorn --- package-lock.json | 6 +++--- package.json | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/package-lock.json b/package-lock.json index 9771d83536..f655a13c30 100644 --- a/package-lock.json +++ b/package-lock.json @@ -61,9 +61,9 @@ "dev": true }, "acorn": { - "version": "6.0.5", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-6.0.5.tgz", - "integrity": "sha512-i33Zgp3XWtmZBMNvCr4azvOFeWVw1Rk6p3hfi3LUDvIFraOMywb1kAtrbi+med14m4Xfpqm3zRZMT+c0FNE7kg==", + "version": "6.1.1", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-6.1.1.tgz", + "integrity": "sha512-jPTiwtOxaHNaAPg/dmrJ/beuzLRnXtB0kQPQ8JpotKJgTB6rX6c8mlf315941pyjBSaPg8NHXS9fhP4u17DpGA==", "dev": true }, "acorn-dynamic-import": { diff --git a/package.json b/package.json index 4b85fdfdb9..a56268da60 100644 --- a/package.json +++ b/package.json @@ -51,7 +51,7 @@ "devDependencies": { "@types/mocha": "^5.2.0", "@types/node": "^10.5.5", - "acorn": "^6.0.5", + "acorn": "^6.1.1", "acorn-dynamic-import": "^4.0.0", "agadoo": "^1.0.1", "c8": "^3.4.0", From b328cecc04fb0ca6439516044cf760d0f9d8ebcd Mon Sep 17 00:00:00 2001 From: Conduitry Date: Fri, 15 Mar 2019 15:23:41 -0400 Subject: [PATCH 08/69] temporarily disallow `export ... from` statements (#2214) --- src/compile/Component.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/compile/Component.ts b/src/compile/Component.ts index 9dbfb3b41c..4f4a6b1e84 100644 --- a/src/compile/Component.ts +++ b/src/compile/Component.ts @@ -438,6 +438,12 @@ export default class Component { } if (node.type === 'ExportNamedDeclaration') { + if (node.source) { + this.error(node, { + code: `not-implemented`, + message: `A component currently cannot have an export ... from` + }); + } if (node.declaration) { if (node.declaration.type === 'VariableDeclaration') { node.declaration.declarations.forEach(declarator => { From d91cf4b2efc9df0937c21c1297372a435909bcf8 Mon Sep 17 00:00:00 2001 From: Conduitry Date: Fri, 15 Mar 2019 18:30:08 -0400 Subject: [PATCH 09/69] skip non-writable vars in reactive declaration deps (#2173) --- src/compile/Component.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/compile/Component.ts b/src/compile/Component.ts index 9dbfb3b41c..0a8fee5cf0 100644 --- a/src/compile/Component.ts +++ b/src/compile/Component.ts @@ -1034,7 +1034,10 @@ export default class Component { if (!assignee_nodes.has(identifier)) { const { name } = identifier; const owner = scope.findOwner(name); - if ((!owner || owner === component.instance_scope) && (name[0] === '$' || component.var_lookup.has(name))) { + if ( + (!owner || owner === component.instance_scope) && + (name[0] === '$' || component.var_lookup.has(name) && component.var_lookup.get(name).writable) + ) { dependencies.add(name); } } From a26b276c5eeda35e5c1828cbd0973a61a43a01c0 Mon Sep 17 00:00:00 2001 From: Conduitry Date: Fri, 15 Mar 2019 18:39:02 -0400 Subject: [PATCH 10/69] update tests --- .../reactive-values-non-writable-dependencies/expected.js | 4 ++-- .../samples/reactive-declaration-no-deps/errors.json | 7 +++++++ .../samples/reactive-declaration-no-deps/input.svelte | 3 +++ 3 files changed, 12 insertions(+), 2 deletions(-) create mode 100644 test/validator/samples/reactive-declaration-no-deps/errors.json create mode 100644 test/validator/samples/reactive-declaration-no-deps/input.svelte diff --git a/test/js/samples/reactive-values-non-writable-dependencies/expected.js b/test/js/samples/reactive-values-non-writable-dependencies/expected.js index 42f57a0037..deded0d4e9 100644 --- a/test/js/samples/reactive-values-non-writable-dependencies/expected.js +++ b/test/js/samples/reactive-values-non-writable-dependencies/expected.js @@ -17,11 +17,11 @@ let a = 1; let b = 2; function instance($$self, $$props, $$invalidate) { - + let max; - $$self.$$.update = ($$dirty = { Math: 1, a: 1, b: 1 }) => { + $$self.$$.update = ($$dirty = { a: 1, b: 1 }) => { if ($$dirty.a || $$dirty.b) { max = Math.max(a, b); $$invalidate('max', max); } diff --git a/test/validator/samples/reactive-declaration-no-deps/errors.json b/test/validator/samples/reactive-declaration-no-deps/errors.json new file mode 100644 index 0000000000..0063d4005e --- /dev/null +++ b/test/validator/samples/reactive-declaration-no-deps/errors.json @@ -0,0 +1,7 @@ +[{ + "message": "Invalid reactive declaration — must depend on local state", + "code": "invalid-reactive-declaration", + "start": { "line": 2, "column": 1, "character": 10 }, + "end": { "line": 2, "column": 23, "character": 32 }, + "pos": 10 +}] diff --git a/test/validator/samples/reactive-declaration-no-deps/input.svelte b/test/validator/samples/reactive-declaration-no-deps/input.svelte new file mode 100644 index 0000000000..c334f92ab5 --- /dev/null +++ b/test/validator/samples/reactive-declaration-no-deps/input.svelte @@ -0,0 +1,3 @@ + From 66e29050669667e96e77fe961c6e3caceb7c988d Mon Sep 17 00:00:00 2001 From: Conduitry Date: Fri, 15 Mar 2019 19:16:59 -0400 Subject: [PATCH 11/69] repl: deal with named module exports from main App --- site/src/components/Repl/Output/Viewer.svelte | 2 +- site/static/workers/bundler.js | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/site/src/components/Repl/Output/Viewer.svelte b/site/src/components/Repl/Output/Viewer.svelte index f5fcb0295e..d2f7b87001 100644 --- a/site/src/components/Repl/Output/Viewer.svelte +++ b/site/src/components/Repl/Output/Viewer.svelte @@ -76,7 +76,7 @@ window.location.hash = ''; window._svelteTransitionManager = null; - window.component = new SvelteComponent({ + window.component = new SvelteComponent.default({ target: document.body }); `); diff --git a/site/static/workers/bundler.js b/site/static/workers/bundler.js index 2874820529..34b5c906a3 100644 --- a/site/static/workers/bundler.js +++ b/site/static/workers/bundler.js @@ -174,6 +174,7 @@ async function bundle(components) { import_map.set(id, name); return name; }, + exports: 'named', sourcemap: true }); @@ -197,6 +198,7 @@ async function bundle(components) { format: 'iife', name: 'SvelteComponent', globals: id => import_map.get(id), + exports: 'named', sourcemap: true }) : null; From bc049470464ab2f93c04be2f397b1fc52022c427 Mon Sep 17 00:00:00 2001 From: Richard Harris Date: Fri, 15 Mar 2019 19:42:07 -0400 Subject: [PATCH 12/69] bump beta version --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index f655a13c30..51ee2c94a1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "svelte", - "version": "3.0.0-beta.15", + "version": "3.0.0-beta.16", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index a56268da60..2f272a882d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "svelte", - "version": "3.0.0-beta.15", + "version": "3.0.0-beta.16", "description": "The magical disappearing UI framework", "module": "index.mjs", "main": "index", From 8c61edf2d5fe8eb72478f9becd4818067485847e Mon Sep 17 00:00:00 2001 From: Richard Harris Date: Fri, 15 Mar 2019 21:34:14 -0400 Subject: [PATCH 13/69] 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 0f0f9478652db2cdc42c80c54fd22e920659d352 Mon Sep 17 00:00:00 2001 From: Richard Harris Date: Fri, 15 Mar 2019 21:34:22 -0400 Subject: [PATCH 14/69] 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 73e45ab483296d4282295342a8314baddf78650f Mon Sep 17 00:00:00 2001 From: Richard Harris Date: Fri, 15 Mar 2019 22:44:30 -0400 Subject: [PATCH 15/69] 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: