|
|
@ -393,18 +393,17 @@ export default function dom ( parsed, source, options ) {
|
|
|
|
|
|
|
|
|
|
|
|
const sharedPath = options.shared === true ? 'svelte/shared.js' : options.shared;
|
|
|
|
const sharedPath = options.shared === true ? 'svelte/shared.js' : options.shared;
|
|
|
|
|
|
|
|
|
|
|
|
if ( sharedPath ) {
|
|
|
|
const prototypeBase = `${name}.prototype` + ( templateProperties.methods ? `, ${generator.alias( 'template' )}.methods` : '' );
|
|
|
|
const base = templateProperties.methods ? `{}, ${generator.alias( 'template' )}.methods` : `{}`;
|
|
|
|
const proto = sharedPath ? generator.helper( 'proto ' ) : deindent`
|
|
|
|
builders.main.addBlock( `${name}.prototype = ${generator.helper( 'assign' )}( ${base}, ${generator.helper( 'proto' )} );` );
|
|
|
|
{
|
|
|
|
} else {
|
|
|
|
${
|
|
|
|
if ( templateProperties.methods ) {
|
|
|
|
[ 'get', 'fire', 'observe', 'on', 'set', '_flush' ]
|
|
|
|
builders.main.addBlock( `${name}.prototype = ${generator.alias( 'template' )}.methods;` );
|
|
|
|
.map( n => `${n}: ${generator.helper( n )}` )
|
|
|
|
}
|
|
|
|
.join( ',\n' )
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}`;
|
|
|
|
|
|
|
|
|
|
|
|
[ 'get', 'fire', 'observe', 'on', 'set', '_flush' ].forEach( methodName => {
|
|
|
|
builders.main.addBlock( `${generator.helper( 'assign' )}( ${prototypeBase}, ${proto});` );
|
|
|
|
builders.main.addLine( `${name}.prototype.${methodName} = ${generator.helper( methodName )};` );
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// TODO deprecate component.teardown()
|
|
|
|
// TODO deprecate component.teardown()
|
|
|
|
builders.main.addBlock( deindent`
|
|
|
|
builders.main.addBlock( deindent`
|
|
|
|