import { HostElement } from '../../declarations' ; import { setHmrAttr , hasShadowRoot } from './hmr-util' ; export const hmrComponents = ( elm , versionId , hmrTagNames ) => { const updatedTags = [ ] ; hmrTagNames . forEach ( ( hmrTagName ) => { hmrComponent ( updatedTags , elm , versionId , hmrTagName ) ; } ) ; return updatedTags . sort ( ) ; } ; const hmrComponent = ( updatedTags , elm , versionId , cmpTagName ) => { if ( elm . nodeName . toLowerCase ( ) === cmpTagName && typeof ( elm as HostElement ) [ 's-hmr' ] === 'function' ) { ( elm as HostElement ) [ 's-hmr' ] ( versionId ) ; setHmrAttr ( elm , versionId ) ; if ( updatedTags . indexOf ( cmpTagName ) === - 1 ) { updatedTags . push ( cmpTagName ) ; } } if ( hasShadowRoot ( elm ) ) { hmrComponent ( updatedTags , elm . shadowRoot as any , versionId , cmpTagName ) ; } if ( elm . children ) { for ( let i = 0 ; i < elm . children . length ; i ++ ) { hmrComponent ( updatedTags , elm . children [ i ] , versionId , cmpTagName ) ; } } } ;