From b7a40879a77315ef2b29e934444683d4c9318abd Mon Sep 17 00:00:00 2001 From: Rich-Harris Date: Mon, 17 Apr 2017 14:55:42 -0400 Subject: [PATCH] remove some unused code --- src/generators/Generator.js | 10 +++------- src/generators/dom/Block.js | 4 ++-- src/generators/dom/preprocess.js | 9 +-------- 3 files changed, 6 insertions(+), 17 deletions(-) diff --git a/src/generators/Generator.js b/src/generators/Generator.js index 1bf2b7c111..8d43de8bf8 100644 --- a/src/generators/Generator.js +++ b/src/generators/Generator.js @@ -151,13 +151,11 @@ export default class Generator { }; } - findDependencies ( block, expression, isEventHandler ) { + findDependencies ( contextDependencies, expression ) { if ( expression._dependencies ) return expression._dependencies; - const dependencies = []; - const { contextDependencies, contexts } = block; - let scope = annotateWithScopes( expression ); + const dependencies = []; walk( expression, { enter ( node, parent ) { @@ -170,9 +168,7 @@ export default class Generator { const { name } = flattenReference( node ); if ( scope.has( name ) ) return; - if ( name === 'event' && isEventHandler ) { - // noop - } else if ( contexts.has( name ) ) { + if ( contextDependencies.has( name ) ) { dependencies.push( ...contextDependencies.get( name ) ); } else { dependencies.push( name ); diff --git a/src/generators/dom/Block.js b/src/generators/dom/Block.js index 45df24c63c..11889070fa 100644 --- a/src/generators/dom/Block.js +++ b/src/generators/dom/Block.js @@ -74,8 +74,8 @@ export default class Block { this.addElement( name, renderStatement, parentNode, true ); } - findDependencies ( expression, isEventHandler ) { - return this.generator.findDependencies( this, expression, isEventHandler ); + findDependencies ( expression ) { + return this.generator.findDependencies( this.contextDependencies, expression ); } mount ( name, parentNode ) { diff --git a/src/generators/dom/preprocess.js b/src/generators/dom/preprocess.js index 6c739ed3b8..bc23543b3f 100644 --- a/src/generators/dom/preprocess.js +++ b/src/generators/dom/preprocess.js @@ -127,14 +127,6 @@ const preprocessors = { const dependencies = block.findDependencies( attribute.value ); block.addDependencies( dependencies ); } - - // else if ( attribute.type === 'EventHandler' ) { - // // TODO is this necessary? - // attribute.expression.arguments.forEach( arg => { - // const dependencies = block.findDependencies( arg ); - // block.addDependencies( dependencies ); - // }); - // } }); const isComponent = generator.components.has( node.name ) || node.name === ':Self'; @@ -175,6 +167,7 @@ export default function preprocess ( generator, children ) { contexts: new Map(), indexes: new Map(), + contextDependencies: new Map(), params: [ 'root' ], indexNames: new Map(),