2020-01-31 13:23:47 +08:00
|
|
|
export function createElement(tagName, className) {
|
|
|
|
|
let node = document.createElement(tagName)
|
|
|
|
|
className && (node.className = className)
|
|
|
|
|
return node
|
2020-01-30 20:59:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function appendChild(node, child) {
|
2020-01-31 16:30:30 +08:00
|
|
|
return node.appendChild(child)
|
|
|
|
|
}
|
|
|
|
|
|
2020-02-06 16:43:18 +08:00
|
|
|
export function hasAttribute(node, attrName) {
|
|
|
|
|
return node.hasAttribute(attrName)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function setAttribute(node, attrName, attrValue) {
|
|
|
|
|
return node.setAttribute(attrName, attrValue || true)
|
|
|
|
|
}
|
|
|
|
|
|
2020-02-06 18:51:14 +08:00
|
|
|
export function getAttribute(node, attrName) {
|
|
|
|
|
return node.getAttribute(attrName)
|
|
|
|
|
}
|
|
|
|
|
|
2020-02-06 16:43:18 +08:00
|
|
|
export function removeAttribute(node, attrName) {
|
|
|
|
|
return node.removeAttribute(attrName)
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-31 16:30:30 +08:00
|
|
|
export function appendChildren(node, children) {
|
|
|
|
|
children.forEach(child => {
|
|
|
|
|
node.appendChild(child)
|
|
|
|
|
})
|
|
|
|
|
return node
|
2020-01-30 20:59:37 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function insertBefore(parentNode, newNode, referenceNode) {
|
|
|
|
|
parentNode.insertBefore(newNode, referenceNode)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function nextSibling(node) {
|
|
|
|
|
return node.nextSibling
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function removeChild(node, child) {
|
|
|
|
|
node.removeChild(child)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function cloneNode(node, deep) {
|
|
|
|
|
return node.cloneNode(deep)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function querySelector(node, query) {
|
|
|
|
|
return node.querySelector(query)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function querySelectorAll(node, query) {
|
|
|
|
|
return node.querySelectorAll(query)
|
|
|
|
|
}
|