deleight
Version:
A library with 9 modules for writing more expressive web applications with traditional HTML, CSS and JavaScript.
33 lines (32 loc) • 951 B
TypeScript
/**
* htmldom
* Functions for building DOM from HTML text or file.
*/
/**
* Shorthand for creating a DocumentFragment from HTML text.
*
* @example
* import { createFragment } from 'inherent';
* const frag1 = createFragment(`
* <p>Para 1</p>
* <p>Para 2</p>
*`)
* // <p>Para 1</p><p>Para 2</p>
*
* @param html The `outerHTML` of what to create
* @returns
*/
export declare function createFragment(html: string): DocumentFragment;
/**
* Fetches markup from a remote link and creates a document fragment out of it.
*
* @example
* import { loadFragment } from 'inherent';
* const frag1 = await loadFragment(`./my/fragment.html`)
* // <p>Para 1</p><p>Para 2</p>
*
* @param href The link to load the markup from
* @param init The request init used with `fetch`
* @returns A promise that resolves to the document fragment.
*/
export declare function loadFragment(href: string, init?: RequestInit): Promise<DocumentFragment>;