mirror of
https://github.com/squidfunk/mkdocs-material.git
synced 2024-06-14 11:52:32 +03:00
Fixed element typings
This commit is contained in:
parent
63c8544371
commit
6b1ff5ef1d
@ -83,7 +83,7 @@ function appendChild(el: Element, child: Child): void {
|
||||
export function h(
|
||||
tag: string, attributes: Attributes | null,
|
||||
...children: Array<Element | Text | string | number>
|
||||
) {
|
||||
): Element {
|
||||
const el = document.createElement(tag)
|
||||
|
||||
/* Set attributes, if any */
|
||||
@ -102,6 +102,17 @@ export function h(
|
||||
return el
|
||||
}
|
||||
|
||||
/**
|
||||
* JSX factory wrapper
|
||||
*
|
||||
* @param el - JSX element
|
||||
*
|
||||
* @return Element
|
||||
*/
|
||||
export function toElement(el: JSXInternal.Element): Element {
|
||||
return el as any // Hack: if you have a better idea, PR!
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
* Namespace
|
||||
* ------------------------------------------------------------------------- */
|
||||
|
@ -20,7 +20,7 @@
|
||||
* IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
import { h } from "extensions"
|
||||
import { h, toElement } from "extensions"
|
||||
import { SearchResult } from "modules"
|
||||
|
||||
import { renderArticleDocument } from "../article"
|
||||
@ -46,12 +46,12 @@ const css = {
|
||||
*
|
||||
* @param article - Search result
|
||||
*
|
||||
* @return JSX element
|
||||
* @return Element
|
||||
*/
|
||||
export function renderSearchResult(
|
||||
{ article, sections }: SearchResult
|
||||
) {
|
||||
return (
|
||||
): Element {
|
||||
return toElement(
|
||||
<li class={css.item}>
|
||||
{renderArticleDocument(article)}
|
||||
{...sections.map(renderSectionDocument)}
|
||||
|
@ -20,7 +20,7 @@
|
||||
* IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
import { h } from "extensions"
|
||||
import { h, toElement } from "extensions"
|
||||
import { ArticleDocument } from "modules"
|
||||
import { truncate } from "utilities"
|
||||
|
||||
@ -47,12 +47,12 @@ const css = {
|
||||
*
|
||||
* @param article - Article document
|
||||
*
|
||||
* @return JSX element
|
||||
* @return Element
|
||||
*/
|
||||
export function renderArticleDocument(
|
||||
{ location, title, text }: ArticleDocument
|
||||
) {
|
||||
return (
|
||||
): Element {
|
||||
return toElement(
|
||||
<a href={location} title={title} class={css.link} tabIndex={-1}>
|
||||
<article class={css.article}>
|
||||
<h1 class={css.title}>{title}</h1>
|
||||
|
@ -20,7 +20,7 @@
|
||||
* IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
import { h } from "extensions"
|
||||
import { h, toElement } from "extensions"
|
||||
import { SectionDocument } from "modules"
|
||||
import { truncate } from "utilities"
|
||||
|
||||
@ -47,12 +47,12 @@ const css = {
|
||||
*
|
||||
* @param section - Section document
|
||||
*
|
||||
* @return JSX element
|
||||
* @return Element
|
||||
*/
|
||||
export function renderSectionDocument(
|
||||
{ location, title, text }: SectionDocument
|
||||
) {
|
||||
return (
|
||||
): Element {
|
||||
return toElement(
|
||||
<a href={location} title={title} class={css.link} tabIndex={-1}>
|
||||
<article class={css.article}>
|
||||
<h1 class={css.title}>{title}</h1>
|
||||
|
Loading…
Reference in New Issue
Block a user