zyc-real-dom
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

real-dom

Building DOM and style sheet

API documentation

appendStyle(selector: string, styleSheet: CSSSheet)

以添加style标签的方式添加或覆盖样式

deleteStyle(selector: string, list?: Array)

删除 appendStyle 方法添加的样式

createElementStr(tagName: HTMLElementTag | SVGElementTag, attr: Attribute, style: CSSSheet, child: string): string

创建HTML元素,以字符串的形式返回

createHTMLElement(tagName: HTMLElementTag, attr: Attribute, style?: CSSSheet): HTMLElement

创建HTML元素,返回DOM

createSVGElement(tagName: SVGElementTag, attr: Attribute): SVGElement

创建SVG元素,返回DOM

deleteElement(selector: string, matchAll = true)

删除选择器匹配到的第一个或者全部元素

Examples

import { createHTMLElement, appendStyle, deleteStyle } from 'real-dom'

appendStyle('.link', { fontSize: '20px', color: 'red' });

const element = createHTMLElement('a', { id: 'a', class: 'link' });
element.innerHTML = 'hello world!'
element.onclick = function() {
  deleteStyle('.link', ['color']);
}
document.body.appendChild(element);

Package Sidebar

Install

npm i zyc-real-dom

Weekly Downloads

3

Version

1.0.0

License

MIT

Unpacked Size

7.17 kB

Total Files

11

Last publish

Collaborators

  • zhou_yucheng