Added more inline comments and simplified component mounting

This commit is contained in:
squidfunk
2021-02-13 17:03:15 +01:00
parent 96797b471f
commit aacb5ca5a7
45 changed files with 155 additions and 84 deletions

View File

@@ -27,7 +27,6 @@ import { configuration } from "~/_"
import {
Keyboard,
getActiveElement,
getElementOrThrow,
getElements,
requestJSON,
setElementFocus,
@@ -41,7 +40,7 @@ import {
setupSearchWorker
} from "~/integrations"
import { Component } from "../../_"
import { Component, getComponentElement } from "../../_"
import { SearchQuery, mountSearchQuery } from "../query"
import { SearchResult, mountSearchResult } from "../result"
@@ -89,6 +88,9 @@ function fetchSearchIndex(url: string) {
/**
* Mount search
*
* This function sets up the search functionality, including the underlying
* web worker and all keyboard bindings.
*
* @param el - Search element
* @param options - Options
*
@@ -103,8 +105,8 @@ export function mountSearch(
))
/* Retrieve elements */
const query = getElementOrThrow("[data-md-component=search-query]", el)
const result = getElementOrThrow("[data-md-component=search-result]", el)
const query = getComponentElement("search-query", el)
const result = getComponentElement("search-result", el)
/* Re-emit query when search is ready */
const { tx$, rx$ } = worker