@@ -13,12 +13,12 @@ import {from} from "rxjs/observable/from";
1313import { filter } from "rxjs/operators/filter" ;
1414import { map } from "rxjs/operators/map" ;
1515import { mergeMap } from "rxjs/operators/mergeMap" ;
16- import { take } from "rxjs/operators/take" ;
1716import { tap } from "rxjs/operators/tap" ;
1817import { mapTo } from "rxjs/operators/mapTo" ;
1918import { propSet } from "../lib/dom-effects/prop-set.dom-effect" ;
2019import { styleSet } from "../lib/dom-effects/style-set.dom-effect" ;
2120import { linkReplace } from "../lib/dom-effects/link-replace.dom-effect" ;
21+ import { mergeAll } from "rxjs/operators/mergeAll" ;
2222
2323var hiddenElem ;
2424
@@ -250,7 +250,7 @@ export function reload(document: Document, navigator: Navigator) {
250250 } ;
251251 }
252252
253- function reattachStylesheetLink ( link , document : Document , navigator : Navigator ) : Observable < any > {
253+ function reattachStylesheetLink ( link : HTMLLinkElement , document : Document , navigator : Navigator ) : Observable < any > {
254254 // ignore LINKs that will be removed by LR soon
255255 let clone ;
256256
@@ -291,10 +291,14 @@ export function reload(document: Document, navigator: Navigator) {
291291 additionalWaitingTime = 200 ;
292292 }
293293
294- return Observable . create ( obs => clone . onload = ( ) => obs . next ( true ) )
294+ return Observable . create ( obs => {
295+ clone . onload = ( ) => {
296+ obs . next ( true ) ;
297+ obs . complete ( )
298+ } ;
299+ } )
295300 . pipe (
296- take ( 1 )
297- , mergeMap ( ( ) => {
301+ mergeMap ( ( ) => {
298302 return timer ( additionalWaitingTime )
299303 . pipe (
300304 tap ( ( ) => {
@@ -387,7 +391,7 @@ export function reload(document: Document, navigator: Navigator) {
387391
388392 function reloadStylesheet ( path : string , document : Document , navigator ) : Observable < any > {
389393 // has to be a real array, because DOMNodeList will be modified
390- const links = array ( document . getElementsByTagName ( 'link' ) )
394+ const links : HTMLLinkElement [ ] = array ( document . getElementsByTagName ( 'link' ) )
391395 . filter ( link => {
392396 return link . rel . match ( / ^ s t y l e s h e e t $ / i)
393397 && ! link . __LiveReload_pendingRemoval ;
@@ -427,6 +431,15 @@ export function reload(document: Document, navigator: Navigator) {
427431 return reattachImportedRule ( match . object , document ) ;
428432 }
429433 return reattachStylesheetLink ( match . object , document , navigator ) ;
434+ } else {
435+ if ( links . length ) {
436+ // no <link> elements matched, so was the path including '*'?
437+ const [ first , ...rest ] = path . split ( '.' ) ;
438+ if ( first === '*' ) {
439+ return from ( links . map ( link => reattachStylesheetLink ( link , document , navigator ) ) )
440+ . pipe ( mergeAll ( ) )
441+ }
442+ }
430443 }
431444
432445 return empty ( ) ;
0 commit comments