diff --git a/compiler/generate/visitors/Element.js b/compiler/generate/visitors/Element.js index 1d4757f7f5..8cda9e7caa 100644 --- a/compiler/generate/visitors/Element.js +++ b/compiler/generate/visitors/Element.js @@ -20,11 +20,22 @@ export default { if ( isComponent ) { addComponentAttributes( generator, node, local ); - local.init.unshift( deindent` - var ${name} = new template.components.${node.name}({ - target: ${generator.current.target} - }); - ` ); + if ( local.data.length ) { + local.init.unshift( deindent` + var ${name} = new template.components.${node.name}({ + target: ${generator.current.target}, + data: { + ${local.data.join( ',\n' )} + } + }); + ` ); + } else { + local.init.unshift( deindent` + var ${name} = new template.components.${node.name}({ + target: ${generator.current.target} + }); + ` ); + } local.teardown.push( `${name}.teardown();` ); } diff --git a/compiler/generate/visitors/attributes/addComponentAttributes.js b/compiler/generate/visitors/attributes/addComponentAttributes.js index 55e37c4d9e..6e4e065dc3 100644 --- a/compiler/generate/visitors/attributes/addComponentAttributes.js +++ b/compiler/generate/visitors/attributes/addComponentAttributes.js @@ -1,41 +1,40 @@ import deindent from '../../utils/deindent.js'; export default function addComponentAttributes ( generator, node, local ) { + const variables = []; + local.data = []; + node.attributes.forEach( attribute => { if ( attribute.type === 'Attribute' ) { if ( attribute.value === true ) { // attributes without values, e.g.