1
0
mirror of https://github.com/squidfunk/mkdocs-material.git synced 2024-11-28 09:20:52 +01:00

Fixed hero component not being mounted with instant loading

This commit is contained in:
squidfunk 2020-02-29 19:20:28 +01:00
parent a17c30c3ac
commit c201b3de5f

View File

@ -20,8 +20,7 @@
* IN THE SOFTWARE. * IN THE SOFTWARE.
*/ */
import { keys } from "ramda" import { EMPTY, Observable, of } from "rxjs"
import { NEVER, Observable, of } from "rxjs"
import { import {
distinctUntilChanged, distinctUntilChanged,
map, map,
@ -110,7 +109,7 @@ export function setupComponents(
/* Re-compute component map on document switch */ /* Re-compute component map on document switch */
scan((prev, next) => { scan((prev, next) => {
for (const name of keys(prev)) { for (const name of names) {
switch (name) { switch (name) {
/* Top-level components: update */ /* Top-level components: update */
@ -124,7 +123,10 @@ export function setupComponents(
/* All other components: rebind */ /* All other components: rebind */
default: default:
prev[name] = getElement(`[data-md-component=${name}]`) if (typeof next[name] !== "undefined")
prev[name] = getElement(`[data-md-component=${name}]`)
else
delete prev[name]
} }
} }
return prev return prev
@ -155,7 +157,7 @@ export function useComponent<T extends HTMLElement>(
switchMap(components => ( switchMap(components => (
typeof components[name] !== "undefined" typeof components[name] !== "undefined"
? of(components[name] as T) ? of(components[name] as T)
: NEVER : EMPTY
)), )),
distinctUntilChanged() distinctUntilChanged()
) )