DOM
生成各种 DOM 节点.
start
npm i @punchly/dom
api
DOM
DOM.PROPERTIES
Symbol('PROPERTIES')
DOM.$(...args)
{
(str: string): HTMLCollection;
(node: ParentNode, ...children: (string | Node)[]): readonly Node[] & {
children: HTMLCollection;
}; // Return[0] = node;
}
DOM.$[tagName](attrs, children)
{
(attrs?: Attr, children?: ArrayLike<string | Node>) => HTMLElementTagNameMap[tagName];
}
type Attr = {
[qualifiedName: string]: string;
} & {
[PROPERTIES]: {...};
class: string[];
style: CSSStyleDeclaration;
};
Style
new Style(styleSheet, parentNode) / Style(...)
{
new (styleSheet: StyleSheets, parentNode?: Node = document.head): {
readonly node: HTMLStyleElement;
insert(selector: string): {
index: number;
rule: CSSStyleRule;
};
insertRule(styleSheet: StyleSheets): HTMLStyleElement;
}
(styleSheet: StyleSheets, parentNode?: Node): ...;
}
type StyleSheets = {
[selector: string]: CSSStyleDeclaration;
} & {
[AT]: {
[identifier: string]: string;
[identifier: string]: [rule: string];
[identifier: string]: [rule: string, cssBlock: {
[selector: string]: CSSStyleDeclaration;
}];
};
};