From 2147d71a0b7cff494be0b8d9b10d9ec704f02129 Mon Sep 17 00:00:00 2001 From: Richard Harris Date: Sun, 27 Jan 2019 23:56:17 -0500 Subject: [PATCH] remove component.declarations --- src/compile/Component.ts | 26 +++----------------------- src/compile/nodes/shared/Expression.ts | 4 ++-- 2 files changed, 5 insertions(+), 25 deletions(-) diff --git a/src/compile/Component.ts b/src/compile/Component.ts index f42315dbba..613c038da5 100644 --- a/src/compile/Component.ts +++ b/src/compile/Component.ts @@ -62,7 +62,6 @@ export default class Component { module_javascript: string; javascript: string; - declarations: string[] = []; imported_declarations: Set = new Set(); hoistable_nodes: Set = new Set(); node_for_declaration: Map = new Map(); @@ -141,22 +140,6 @@ export default class Component { if (!options.customElement) this.stylesheet.reify(); this.stylesheet.warnOnUnusedSelectors(stats); - - if (!ast.instance && !ast.module) { - const props = [...this.template_references]; - this.declarations.push(...props); - - // props.forEach(name => { - // this.add_var({ - // name, - // kind: 'injected', - // export_name: name, - // mutated: true, // TODO kind of a misnomer... it's *mutable* but not necessarily *mutated*. is that a problem? - // referenced: true, - // writable: true - // }); - // }); - } } add_var(variable: Var) { @@ -573,8 +556,6 @@ export default class Component { kind, module: true }); - - this.declarations.push(name); } }); @@ -620,8 +601,6 @@ export default class Component { initialised: instance_scope.initialised_declarations.has(name), writable: kind === 'var' || kind === 'let' }); - - this.declarations.push(name); } this.node_for_declaration.set(name, node); @@ -995,7 +974,7 @@ export default class Component { const object = getObject(node); const { name } = object; - if (name[0] === '$' || component.declarations.indexOf(name) !== -1) { + if (name[0] === '$' || component.var_lookup.has(name)) { dependencies.add(name); } @@ -1079,8 +1058,9 @@ export default class Component { qualify(name) { const variable = this.var_lookup.get(name); + + if (!variable) return name; if (variable && variable.hoistable) return name; - if (this.declarations.indexOf(name) === -1) return name; this.add_reference(name); // TODO we can probably remove most other occurrences of this return `ctx.${name}`; diff --git a/src/compile/nodes/shared/Expression.ts b/src/compile/nodes/shared/Expression.ts index b5ed44b207..956106a84d 100644 --- a/src/compile/nodes/shared/Expression.ts +++ b/src/compile/nodes/shared/Expression.ts @@ -122,7 +122,7 @@ export default class Expression { const { name, nodes } = flattenReference(node); if (scope.has(name)) return; - if (globalWhitelist.has(name) && component.declarations.indexOf(name) === -1) return; + if (globalWhitelist.has(name) && !component.var_lookup.has(name)) return; if (template_scope.is_let(name)) { if (!function_expression) { @@ -242,7 +242,7 @@ export default class Expression { const { name, nodes } = flattenReference(node); if (scope.has(name)) return; - if (globalWhitelist.has(name) && component.declarations.indexOf(name) === -1) return; + if (globalWhitelist.has(name) && !component.var_lookup.has(name)) return; if (function_expression) { if (template_scope.names.has(name)) {