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(
|
export function h(
|
||||||
tag: string, attributes: Attributes | null,
|
tag: string, attributes: Attributes | null,
|
||||||
...children: Array<Element | Text | string | number>
|
...children: Array<Element | Text | string | number>
|
||||||
) {
|
): Element {
|
||||||
const el = document.createElement(tag)
|
const el = document.createElement(tag)
|
||||||
|
|
||||||
/* Set attributes, if any */
|
/* Set attributes, if any */
|
||||||
@ -102,6 +102,17 @@ export function h(
|
|||||||
return el
|
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
|
* Namespace
|
||||||
* ------------------------------------------------------------------------- */
|
* ------------------------------------------------------------------------- */
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
* IN THE SOFTWARE.
|
* IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { h } from "extensions"
|
import { h, toElement } from "extensions"
|
||||||
import { SearchResult } from "modules"
|
import { SearchResult } from "modules"
|
||||||
|
|
||||||
import { renderArticleDocument } from "../article"
|
import { renderArticleDocument } from "../article"
|
||||||
@ -46,12 +46,12 @@ const css = {
|
|||||||
*
|
*
|
||||||
* @param article - Search result
|
* @param article - Search result
|
||||||
*
|
*
|
||||||
* @return JSX element
|
* @return Element
|
||||||
*/
|
*/
|
||||||
export function renderSearchResult(
|
export function renderSearchResult(
|
||||||
{ article, sections }: SearchResult
|
{ article, sections }: SearchResult
|
||||||
) {
|
): Element {
|
||||||
return (
|
return toElement(
|
||||||
<li class={css.item}>
|
<li class={css.item}>
|
||||||
{renderArticleDocument(article)}
|
{renderArticleDocument(article)}
|
||||||
{...sections.map(renderSectionDocument)}
|
{...sections.map(renderSectionDocument)}
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
* IN THE SOFTWARE.
|
* IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { h } from "extensions"
|
import { h, toElement } from "extensions"
|
||||||
import { ArticleDocument } from "modules"
|
import { ArticleDocument } from "modules"
|
||||||
import { truncate } from "utilities"
|
import { truncate } from "utilities"
|
||||||
|
|
||||||
@ -47,12 +47,12 @@ const css = {
|
|||||||
*
|
*
|
||||||
* @param article - Article document
|
* @param article - Article document
|
||||||
*
|
*
|
||||||
* @return JSX element
|
* @return Element
|
||||||
*/
|
*/
|
||||||
export function renderArticleDocument(
|
export function renderArticleDocument(
|
||||||
{ location, title, text }: ArticleDocument
|
{ location, title, text }: ArticleDocument
|
||||||
) {
|
): Element {
|
||||||
return (
|
return toElement(
|
||||||
<a href={location} title={title} class={css.link} tabIndex={-1}>
|
<a href={location} title={title} class={css.link} tabIndex={-1}>
|
||||||
<article class={css.article}>
|
<article class={css.article}>
|
||||||
<h1 class={css.title}>{title}</h1>
|
<h1 class={css.title}>{title}</h1>
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
* IN THE SOFTWARE.
|
* IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { h } from "extensions"
|
import { h, toElement } from "extensions"
|
||||||
import { SectionDocument } from "modules"
|
import { SectionDocument } from "modules"
|
||||||
import { truncate } from "utilities"
|
import { truncate } from "utilities"
|
||||||
|
|
||||||
@ -47,12 +47,12 @@ const css = {
|
|||||||
*
|
*
|
||||||
* @param section - Section document
|
* @param section - Section document
|
||||||
*
|
*
|
||||||
* @return JSX element
|
* @return Element
|
||||||
*/
|
*/
|
||||||
export function renderSectionDocument(
|
export function renderSectionDocument(
|
||||||
{ location, title, text }: SectionDocument
|
{ location, title, text }: SectionDocument
|
||||||
) {
|
): Element {
|
||||||
return (
|
return toElement(
|
||||||
<a href={location} title={title} class={css.link} tabIndex={-1}>
|
<a href={location} title={title} class={css.link} tabIndex={-1}>
|
||||||
<article class={css.article}>
|
<article class={css.article}>
|
||||||
<h1 class={css.title}>{title}</h1>
|
<h1 class={css.title}>{title}</h1>
|
||||||
|
Loading…
Reference in New Issue
Block a user