本文整理匯總了TypeScript中nerv-utils.doc類的典型用法代碼示例。如果您正苦於以下問題:TypeScript doc類的具體用法?TypeScript doc怎麽用?TypeScript doc使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了doc類的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: mountVNode
export function mountVNode (vnode: VNode, isSvg?: boolean, parentContext?, parentComponent?) {
if (vnode.isSvg) {
isSvg = true
} else if (vnode.type === 'svg') {
isSvg = true
/* istanbul ignore next */
} else if (!isSupportSVG) {
isSvg = false
}
if (isSvg) {
vnode.namespace = SVG_NAMESPACE
vnode.isSvg = isSvg
}
const domNode = !isSvg
? doc.createElement(vnode.type)
: doc.createElementNS(vnode.namespace, vnode.type)
setProps(domNode, vnode, isSvg as boolean)
if (vnode.type === 'foreignObject') {
isSvg = false
}
const children = vnode.children
if (isArray(children)) {
for (let i = 0, len = children.length; i < len; i++) {
mountChild(children[i] as VNode, domNode, parentContext, parentComponent, isSvg)
}
} else {
mountChild(children as VNode, domNode, parentContext, parentComponent, isSvg)
}
vnode.dom = domNode
if (vnode.ref !== null) {
Ref.attach(vnode, vnode.ref, domNode)
}
return domNode
}
示例2: processOnPropertyChangeEvent
/* istanbul ignore next */
function processOnPropertyChangeEvent (node, handler) {
propertyChangeActiveHandler = handler
if (!bindFocus) {
bindFocus = true
doc.addEventListener(
'focusin',
() => {
unbindOnPropertyChange()
bindOnPropertyChange(node)
},
false
)
doc.addEventListener('focusout', unbindOnPropertyChange, false)
}
}
示例3: detachEvent
export function detachEvent (
domNode: Element,
eventName: string,
handler: Function
) {
eventName = fixEvent(domNode, eventName)
if (eventName === ONPROPERTYCHANGE) {
return
}
const delegatedRoots = delegatedEvents.get(eventName)
if (unbubbleEvents[eventName] === 1 && delegatedRoots) {
const event = delegatedRoots.get(domNode)
if (event) {
domNode.removeEventListener(parseEventName(eventName), event.event, false)
/* istanbul ignore next */
const delegatedRootsSize = delegatedRoots.size
if (delegatedRoots.delete(domNode) && delegatedRootsSize === 0) {
delegatedEvents.delete(eventName)
}
}
} else if (delegatedRoots && delegatedRoots.items) {
const items = delegatedRoots.items
if (items.delete(domNode) && items.size === 0) {
doc.removeEventListener(
parseEventName(eventName),
delegatedRoots.event,
false
)
delegatedEvents.delete(eventName)
}
}
}
示例4: createVoid
export function createVoid () {
const dom = doc.createTextNode('')
return {
dom,
vtype: VType.Void
}
}
示例5:
doc.addEventListener('selectionchange', () => {
const el = doc.activeElement
if (detectCanUseOnInputNode(el)) {
const ev = doc.createEvent('CustomEvent')
ev.initCustomEvent('input', true, true, {})
el.dispatchEvent(ev)
}
})
示例6: createElement
function createElement (
vnode: VirtualNode | VirtualNode[],
isSvg?: boolean,
parentContext?,
parentComponent?
): Element | Text | Comment | DocumentFragment | null {
let domNode
if (isValidElement(vnode)) {
const vtype = vnode.vtype
if (vtype & (VType.Composite | VType.Stateless)) {
domNode = (vnode as CompositeComponent).init(parentContext, parentComponent)
options.afterMount(vnode as CompositeComponent)
} else if (vtype & VType.Text) {
domNode = doc.createTextNode((vnode as any).text);
(vnode as any).dom = domNode
} else if (vtype & VType.Node) {
domNode = mountVNode(vnode as any, isSvg, parentContext, parentComponent)
} else if (vtype & VType.Void) {
domNode = (vnode as any).dom
}
} else if (isString(vnode) || isNumber(vnode)) {
domNode = doc.createTextNode(vnode as string)
} else if (isNullOrUndef(vnode) || (vnode as any) === false) {
domNode = doc.createTextNode('')
} else if (isArray(vnode)) {
domNode = doc.createDocumentFragment()
vnode.forEach((child) => {
if (!isInvalid(child)) {
const childNode = createElement(child, isSvg, parentContext, parentComponent)
if (childNode) {
domNode.appendChild(childNode)
}
}
})
} else {
throw new Error('Unsupported VNode.')
}
return domNode
}