@@ -174,11 +174,11 @@ export default function dom ( parsed, source, options, names ) {
174174 const builders = {
175175 main : new CodeBuilder ( ) ,
176176 init : new CodeBuilder ( ) ,
177- set : new CodeBuilder ( )
177+ _set : new CodeBuilder ( )
178178 } ;
179179
180- builders . set . addLine ( 'var oldState = this._state;' ) ;
181- builders . set . addLine ( 'this._state = Object.assign( {}, oldState, newState );' ) ;
180+ builders . _set . addLine ( 'var oldState = this._state;' ) ;
181+ builders . _set . addLine ( 'this._state = Object.assign( {}, oldState, newState );' ) ;
182182
183183 if ( computations . length ) {
184184 const builder = new CodeBuilder ( ) ;
@@ -197,11 +197,11 @@ export default function dom ( parsed, source, options, names ) {
197197 }
198198 ` ) ;
199199
200- builders . set . addLine ( `applyComputations( this._state, newState, oldState )` ) ;
200+ builders . _set . addLine ( `applyComputations( this._state, newState, oldState )` ) ;
201201 }
202202
203203 // TODO is the `if` necessary?
204- builders . set . addBlock ( deindent `
204+ builders . _set . addBlock ( deindent `
205205 dispatchObservers( this, this._observers.pre, newState, oldState );
206206 if ( this._fragment ) this._fragment.update( newState, this._state );
207207 dispatchObservers( this, this._observers.post, newState, oldState );
@@ -246,7 +246,7 @@ export default function dom ( parsed, source, options, names ) {
246246 while ( this._bindings.length ) this._bindings.pop()();
247247 ` ) ;
248248
249- builders . set . addLine ( `while ( this._bindings.length ) this._bindings.pop()();` ) ;
249+ builders . _set . addLine ( `while ( this._bindings.length ) this._bindings.pop()();` ) ;
250250 } else {
251251 builders . init . addBlock ( deindent `
252252 this._fragment = renderMainFragment( this._state, this );
@@ -255,15 +255,10 @@ export default function dom ( parsed, source, options, names ) {
255255 }
256256
257257 if ( generator . hasComponents ) {
258- const statement = deindent `
259- while ( this._renderHooks.length ) {
260- var hook = this._renderHooks.pop();
261- hook.fn.call( hook.context );
262- }
263- ` ;
258+ const statement = `this._flush();` ;
264259
265260 builders . init . addBlock ( statement ) ;
266- builders . set . addBlock ( statement ) ;
261+ builders . _set . addBlock ( statement ) ;
267262 }
268263
269264 if ( templateProperties . onrender ) {
@@ -310,6 +305,8 @@ export default function dom ( parsed, source, options, names ) {
310305 ${ name } .prototype.fire = fire;
311306 ${ name } .prototype.observe = observe;
312307 ${ name } .prototype.on = on;
308+ ${ name } .prototype.set = set;
309+ ${ name } .prototype._flush = _flush;
313310 ` :
314311 deindent `
315312 ${ name } .prototype.get = ${ shared . get } ;
@@ -319,11 +316,15 @@ export default function dom ( parsed, source, options, names ) {
319316 ${ name } .prototype.observe = ${ shared . observe } ;
320317
321318 ${ name } .prototype.on = ${ shared . on } ;
319+
320+ ${ name } .prototype.set = ${ shared . set } ;
321+
322+ ${ name } .prototype._flush = ${ shared . _flush } ;
322323 ` ) ;
323324
324325 builders . main . addBlock ( deindent `
325- ${ name } .prototype.set = function set ( newState ) {
326- ${ builders . set }
326+ ${ name } .prototype._set = function _set ( newState ) {
327+ ${ builders . _set }
327328 };
328329
329330 ${ name } .prototype.teardown = function teardown ( detach ) {
@@ -341,7 +342,7 @@ export default function dom ( parsed, source, options, names ) {
341342 throw new Error ( `Components with shared helpers must be compiled to ES2015 modules (format: 'es')` ) ;
342343 }
343344
344- const names = [ 'get' , 'fire' , 'observe' , 'on' , 'dispatchObservers' ] . concat ( Object . keys ( generator . uses ) ) ;
345+ const names = [ 'get' , 'fire' , 'observe' , 'on' , 'set' , '_flush' , ' dispatchObservers' ] . concat ( Object . keys ( generator . uses ) ) ;
345346 builders . main . addLineAtStart (
346347 `import { ${ names . join ( ', ' ) } } from ${ JSON . stringify ( sharedPath ) } `
347348 ) ;
0 commit comments