Coder Social home page Coder Social logo

real-dom's Introduction

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);

real-dom's People

Contributors

aspurple avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.