0
0
mirror of https://github.com/sveltejs/svelte.git synced 2024-12-01 01:11:24 +01:00

use isTopLevel instead of elementDepth

This commit is contained in:
Rich-Harris 2017-04-08 15:33:50 -04:00
parent a9fb93eb32
commit 4b3bdcf946
2 changed files with 4 additions and 3 deletions

View File

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

View File

@ -76,7 +76,7 @@ export default function visitElement ( generator, fragment, state, node ) {
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}', '' );`;
}
@ -99,7 +99,7 @@ export default function visitElement ( generator, fragment, state, node ) {
fragment.createMountStatement( name, state.target );
const childState = Object.assign( {}, state, {
elementDepth: state.elementDepth + 1,
isTopLevel: false,
target: name,
namespace: local.namespace
});