wip: portal

This commit is contained in:
Evan You
2019-05-29 16:10:25 +08:00
parent 178c7c827e
commit 453cdcd600
4 changed files with 85 additions and 13 deletions

View File

@@ -1,6 +1,7 @@
import { RendererOptions } from '@vue/runtime-core'
import { patchProp } from './patchProp'
const doc = document
const svgNS = 'http://www.w3.org/2000/svg'
export const DOMRendererOptions: RendererOptions = {
@@ -23,11 +24,11 @@ export const DOMRendererOptions: RendererOptions = {
},
createElement: (tag: string, isSVG?: boolean): Element =>
isSVG ? document.createElementNS(svgNS, tag) : document.createElement(tag),
isSVG ? doc.createElementNS(svgNS, tag) : doc.createElement(tag),
createText: (text: string): Text => document.createTextNode(text),
createText: (text: string): Text => doc.createTextNode(text),
createComment: (text: string): Comment => document.createComment(text),
createComment: (text: string): Comment => doc.createComment(text),
setText: (node: Text, text: string) => {
node.nodeValue = text
@@ -39,5 +40,7 @@ export const DOMRendererOptions: RendererOptions = {
parentNode: (node: Node): Node | null => node.parentNode,
nextSibling: (node: Node): Node | null => node.nextSibling
nextSibling: (node: Node): Node | null => node.nextSibling,
querySelector: (selector: string): Node | null => doc.querySelector(selector)
}