wip: add types to refactored runtime-core

This commit is contained in:
Evan You
2019-05-26 15:19:44 +08:00
parent 3cded86b98
commit b3f8b5ae0a
9 changed files with 269 additions and 135 deletions

View File

@@ -1,37 +0,0 @@
import { NodeOps } from '@vue/runtime-core'
const svgNS = 'http://www.w3.org/2000/svg'
export const nodeOps: NodeOps = {
createElement: (tag: string, isSVG?: boolean): Element =>
isSVG ? document.createElementNS(svgNS, tag) : document.createElement(tag),
createText: (text: string): Text => document.createTextNode(text),
setText: (node: Text, text: string) => {
node.nodeValue = text
},
appendChild: (parent: Node, child: Node) => {
parent.appendChild(child)
},
insertBefore: (parent: Node, child: Node, ref: Node) => {
parent.insertBefore(child, ref)
},
removeChild: (parent: Node, child: Node) => {
parent.removeChild(child)
},
clearContent: (node: Node) => {
node.textContent = ''
},
parentNode: (node: Node): Node | null => node.parentNode,
nextSibling: (node: Node): Node | null => node.nextSibling,
querySelector: (selector: string): Node | null =>
document.querySelector(selector)
}