@@ -468,15 +468,15 @@ export class QuarkElement extends HTMLElement implements ReactiveControllerHost
468468
469469 // Reserve, may expand in the future
470470 requestUpdate ( ) {
471- // this._render();
472- // this._controllers?.forEach((c) => c.hostUpdated?.());
473- this . _renderWatcher ?. update ( ) ;
471+ console . log ( 'requestUpdate' )
472+ this . getOrInitRenderWatcher ( ) . update ( ) ;
474473 }
475474
476475 // Reserve, may expand in the future
477476 update ( ) {
477+ console . log ( 'update' )
478478 // this._render()
479- this . _renderWatcher ? .update ( ) ;
479+ this . getOrInitRenderWatcher ( ) . update ( )
480480 }
481481
482482 $on = ( eventName : string , eventHandler : EventHandler , el ?: Element ) => {
@@ -531,25 +531,39 @@ export class QuarkElement extends HTMLElement implements ReactiveControllerHost
531531 return "" as any ;
532532 }
533533
534+ private getOrInitRenderWatcher ( ) {
535+ if ( ! this . _renderWatcher ) {
536+ console . error ( 'getOrInitRenderWatcher if' , this ) ;
537+ let initRender = true ;
538+ this . _renderWatcher = new Watcher (
539+ this ,
540+ ( ) => {
541+ console . error ( 'render watcher callback' )
542+ this . _render ( ) ;
543+ const renderCbType = ! initRender ? 'hostUpdated' : 'hostMounted' ;
544+ this . _controllers ?. forEach ( ( c ) => c [ renderCbType ] ?.( ) ) ;
545+
546+ if ( initRender ) {
547+ initRender = false ;
548+
549+ if ( isFunction ( this . componentDidMount ) ) {
550+ this . componentDidMount ( ) ;
551+ }
552+ } else {
553+ this . flushUpdatedQueue ( ) ;
554+ }
555+ } ,
556+ { render : true } ,
557+ ) ;
558+ }
559+
560+ return this . _renderWatcher
561+ }
562+
534563 connectedCallback ( ) {
535564 this . _updateProps ( ) ;
536565 this . _controllers ?. forEach ( ( c ) => c . hostConnected ?.( ) ) ;
537- let initRender = true ;
538- this . _renderWatcher = new Watcher (
539- this ,
540- ( ) => {
541- this . _render ( ) ;
542- const renderCbType = ! initRender ? 'hostUpdated' : 'hostMounted' ;
543- this . _controllers ?. forEach ( ( c ) => c [ renderCbType ] ?.( ) ) ;
544- initRender = false ;
545- } ,
546- { render : true } ,
547- ) ;
548- this . flushUpdatedQueue ( ) ;
549-
550- if ( isFunction ( this . componentDidMount ) ) {
551- this . componentDidMount ( ) ;
552- }
566+ this . getOrInitRenderWatcher ( ) ;
553567 }
554568
555569 /** log old 'false' attribute value before resetting and removing it */
0 commit comments