use isTopLevel instead of elementDepth

pull/453/head
Rich-Harris 8 years ago
parent a9fb93eb32
commit 4b3bdcf946

@ -129,7 +129,8 @@ export default function dom ( parsed, source, options ) {
const state = { const state = {
namespace, namespace,
target: null target: null,
isTopLevel: true
}; };
parsed.html.children.forEach( node => { parsed.html.children.forEach( node => {

@ -76,7 +76,7 @@ export default function visitElement ( generator, fragment, state, node ) {
render = `var ${name} = ${generator.helper( 'createElement' )}( '${node.name}' );`; render = `var ${name} = ${generator.helper( 'createElement' )}( '${node.name}' );`;
} }
if ( generator.cssId && !state.elementDepth ) { if ( generator.cssId && state.isTopLevel ) {
render += `\n${generator.helper( 'setAttribute' )}( ${name}, '${generator.cssId}', '' );`; render += `\n${generator.helper( 'setAttribute' )}( ${name}, '${generator.cssId}', '' );`;
} }
@ -99,7 +99,7 @@ export default function visitElement ( generator, fragment, state, node ) {
fragment.createMountStatement( name, state.target ); fragment.createMountStatement( name, state.target );
const childState = Object.assign( {}, state, { const childState = Object.assign( {}, state, {
elementDepth: state.elementDepth + 1, isTopLevel: false,
target: name, target: name,
namespace: local.namespace namespace: local.namespace
}); });

Loading…
Cancel
Save