use builders in place of local.detach and local.teardown

pull/183/head
Rich-Harris 8 years ago
parent 83fe123a5c
commit 7c00ea47bc

@ -110,13 +110,11 @@ export default {
` );
}
local.teardown.push( `${name}.teardown( ${isToplevel ? 'detach' : 'false'} );` );
generator.current.builders.teardown.addLine( `${name}.teardown( ${isToplevel ? 'detach' : 'false'} );` );
generator.current.builders.init.addBlock( local.init.join( '\n' ) );
if ( local.update.length ) generator.current.builders.update.addBlock( local.update.join( '\n' ) );
if ( local.mount.length ) generator.current.builders.mount.addBlock( local.mount.join( '\n' ) );
if ( local.detach.length ) generator.current.builders.detach.addBlock( local.detach.join( '\n' ) );
generator.current.builders.teardown.addBlock( local.teardown.join( '\n' ) );
generator.push({
namespace: local.namespace,

@ -69,7 +69,7 @@ export default {
local.init.unshift( render );
if ( isToplevel ) {
local.detach.push( `${name}.parentNode.removeChild( ${name} );` );
generator.current.builders.detach.addLine( `${name}.parentNode.removeChild( ${name} );` );
}
// special case bound <option> without a value attribute
@ -82,8 +82,6 @@ export default {
generator.current.builders.init.addBlock( local.init.join( '\n' ) );
if ( local.update.length ) generator.current.builders.update.addBlock( local.update.join( '\n' ) );
if ( local.mount.length ) generator.current.builders.mount.addBlock( local.mount.join( '\n' ) );
if ( local.detach.length ) generator.current.builders.detach.addBlock( local.detach.join( '\n' ) );
generator.current.builders.teardown.addBlock( local.teardown.join( '\n' ) );
generator.createMountStatement( name );

@ -122,7 +122,7 @@ export default function addComponentAttributes ( generator, node, local ) {
component.refs.${attribute.name} = ${local.name};
` );
local.teardown.push( deindent`
generator.current.builders.teardown.addLine( deindent`
if ( component.refs.${attribute.name} === ${local.name} ) component.refs.${attribute.name} = null;
` );
}

@ -152,7 +152,7 @@ export default function addElementAttributes ( generator, node, local ) {
});
` );
local.teardown.push( deindent`
generator.current.builders.teardown.addLine( deindent`
${handlerName}.teardown();
` );
} else {
@ -164,7 +164,7 @@ export default function addElementAttributes ( generator, node, local ) {
${local.name}.addEventListener( '${attribute.name}', ${handlerName}, false );
` );
local.teardown.push( deindent`
generator.current.builders.teardown.addLine( deindent`
${local.name}.removeEventListener( '${attribute.name}', ${handlerName}, false );
` );
}
@ -181,7 +181,7 @@ export default function addElementAttributes ( generator, node, local ) {
component.refs.${attribute.name} = ${local.name};
` );
local.teardown.push( deindent`
generator.current.builders.teardown.addLine( deindent`
if ( component.refs.${attribute.name} === ${local.name} ) component.refs.${attribute.name} = null;
` );
}

@ -121,7 +121,7 @@ export default function createBinding ( generator, node, attribute, current, loc
if ( !${local.name}_updating ) ${updateElement};
` );
local.teardown.push( deindent`
generator.current.builders.teardown.addLine( deindent`
${local.name}.removeEventListener( '${eventName}', ${handler}, false );
` );
}

Loading…
Cancel
Save