From 713255118301e4057971c3f2b8efb7ef223f61dc Mon Sep 17 00:00:00 2001 From: Rich-Harris Date: Mon, 17 Apr 2017 10:54:02 -0400 Subject: [PATCH] factor in attributes and bindings --- src/generators/dom/preprocess.js | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/generators/dom/preprocess.js b/src/generators/dom/preprocess.js index 62ee632a62..d6f1d08e42 100644 --- a/src/generators/dom/preprocess.js +++ b/src/generators/dom/preprocess.js @@ -82,7 +82,22 @@ const preprocessors = { }, Element: ( generator, block, node ) => { - // TODO attributes and bindings (and refs?)... + node.attributes.forEach( attribute => { + if ( attribute.type === 'Attribute' && attribute.value !== true ) { + attribute.value.forEach( chunk => { + if ( chunk.type !== 'Text' ) { + const { dependencies } = block.contextualise( chunk.expression ); + block.addDependencies( dependencies ); + } + }); + } + + else if ( attribute.type === 'Binding' ) { + const { dependencies } = block.contextualise( attribute.value ); + block.addDependencies( dependencies ); + } + }); + preprocessChildren( generator, block, node.children ); } };