Evan You
9 years ago
27 changed files with 214 additions and 141 deletions
@ -1,6 +1,8 @@ |
|||
/* @flow */ |
|||
|
|||
import { addProp } from 'compiler/helpers' |
|||
|
|||
export default function html (el, dir) { |
|||
export default function html (el: ASTElement, dir: ASTDirective) { |
|||
if (!dir.value) return |
|||
addProp(el, 'innerHTML', `__toString__(${dir.value})`) |
|||
} |
|||
|
@ -1,6 +1,8 @@ |
|||
/* @flow */ |
|||
|
|||
import { addProp } from 'compiler/helpers' |
|||
|
|||
export default function text (el, dir) { |
|||
export default function text (el: ASTElement, dir: ASTDirective) { |
|||
if (!dir.value) return |
|||
addProp(el, 'textContent', `__toString__(${dir.value})`) |
|||
} |
|||
|
@ -1,41 +1,47 @@ |
|||
/* @flow */ |
|||
|
|||
import { namespaceMap } from 'web/util/index' |
|||
|
|||
export function createElement (tagName) { |
|||
export function createElement (tagName: string): Element { |
|||
return document.createElement(tagName) |
|||
} |
|||
|
|||
export function createElementNS (namespace, tagName) { |
|||
export function createElementNS (namespace: string, tagName: string): Element { |
|||
return document.createElementNS(namespaceMap[namespace], tagName) |
|||
} |
|||
|
|||
export function createTextNode (text) { |
|||
export function createTextNode (text: string): Text { |
|||
return document.createTextNode(text) |
|||
} |
|||
|
|||
export function insertBefore (parentNode, newNode, referenceNode) { |
|||
export function insertBefore (parentNode: Node, newNode: Node, referenceNode: Node) { |
|||
parentNode.insertBefore(newNode, referenceNode) |
|||
} |
|||
|
|||
export function removeChild (node, child) { |
|||
export function removeChild (node: Node, child: Node) { |
|||
node.removeChild(child) |
|||
} |
|||
|
|||
export function appendChild (node, child) { |
|||
export function appendChild (node: Node, child: Node) { |
|||
node.appendChild(child) |
|||
} |
|||
|
|||
export function parentNode (node) { |
|||
export function parentNode (node: Node): ?Element { |
|||
return node.parentElement |
|||
} |
|||
|
|||
export function nextSibling (node) { |
|||
export function nextSibling (node: Node): Node { |
|||
return node.nextSibling |
|||
} |
|||
|
|||
export function tagName (node) { |
|||
export function tagName (node: Element): string { |
|||
return node.tagName |
|||
} |
|||
|
|||
export function setTextContent (node, text) { |
|||
export function setTextContent (node: Node, text: string) { |
|||
node.textContent = text |
|||
} |
|||
|
|||
export function childNodes (node: Node): NodeList { |
|||
return node.childNodes |
|||
} |
|||
|
@ -1,5 +1,8 @@ |
|||
export default function show (node, dir) { |
|||
/* @flow */ |
|||
|
|||
export default function show (node: VNodeWithData, dir: VNodeDirective) { |
|||
if (!dir.value) { |
|||
(node.data.style || (node.data.style = {})).display = 'none' |
|||
const style: any = node.data.style || (node.data.style = {}) |
|||
style.display = 'none' |
|||
} |
|||
} |
|||
|
Loading…
Reference in new issue