diff --git a/src/generators/dom/index.js b/src/generators/dom/index.js index 1c1017f022..2cc549f362 100644 --- a/src/generators/dom/index.js +++ b/src/generators/dom/index.js @@ -291,42 +291,40 @@ export default function dom ( parsed, source, options, names ) { this._handlers = Object.create( null ); - this.get = get; - this.fire = fire; - this.observe = observe; - this.on = on; - this.set = set; - this.teardown = teardown; - this._root = options._root; this._yield = options._yield; ${builders.init} } + ` ); + + if ( templateProperties.methods ) { + builders.main.addBlock( `${name}.prototype = template.methods;` ); + } + + builders.main.addBlock( deindent` + ${name}.prototype.get = ${shared.get}; + + ${name}.prototype.fire = ${shared.fire}; - function set ( newState ) { + ${name}.prototype.observe = ${shared.observe}; + + ${name}.prototype.on = ${shared.on}; + + ${name}.prototype.set = function set ( newState ) { ${builders.set} - } + }; - function teardown ( detach ) { + ${name}.prototype.teardown = function teardown ( detach ) { this.fire( 'teardown' );${templateProperties.onteardown ? `\ntemplate.onteardown.call( this );` : ``} this._fragment.teardown( detach !== false ); this._fragment = null; this._state = {}; - } + }; ` ); - if ( templateProperties.methods ) { - builders.main.addBlock( `${name}.prototype = template.methods;` ); - } - - builders.main.addBlock( shared.fire.toString() ); - builders.main.addBlock( shared.get.toString() ); - builders.main.addBlock( shared.observe.toString() ); - builders.main.addBlock( shared.on.toString() ); - builders.main.addBlock( shared.dispatchObservers.toString() ); Object.keys( generator.uses ).forEach( key => {