@lvce-editor/virtual-dom 2.18.0 → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +77 -2
- package/package.json +1 -1
- package/src/index.ts +0 -1
- package/src/parts/AddPatch/AddPatch.ts +0 -6
- package/src/parts/ApplyDragInfoMaybe/ApplyDragInfoMaybe.ts +0 -20
- package/src/parts/ApplyPatch/ApplyPatch.ts +0 -41
- package/src/parts/AttachEvent/AttachEvent.ts +0 -38
- package/src/parts/AttributePatch/AttributePatch.ts +0 -5
- package/src/parts/ClearNode/ClearNode.ts +0 -3
- package/src/parts/ComponentUid/ComponentUid.ts +0 -19
- package/src/parts/CreateEventListenerFunction/CreateEventListenerFunction.ts +0 -45
- package/src/parts/DomEventType/DomEventType.ts +0 -2
- package/src/parts/DragInfo/DragInfo.ts +0 -13
- package/src/parts/ElementTagMap/ElementTagMap.ts +0 -117
- package/src/parts/ElementTags/ElementTags.ts +0 -55
- package/src/parts/EventState/EventState.ts +0 -13
- package/src/parts/FileHandles/FileHandles.ts +0 -28
- package/src/parts/GetActiveElementInside/GetActiveElementInside.ts +0 -15
- package/src/parts/GetEventListenerArg/GetEventListenerArg.ts +0 -69
- package/src/parts/GetEventListenerArgs/GetEventListenerArgs.ts +0 -12
- package/src/parts/GetEventListenerOptions/GetEventListenerOptions.ts +0 -15
- package/src/parts/GetUidTarget/GetUidTarget.ts +0 -13
- package/src/parts/GetWrappedListener/GetWrappedListener.ts +0 -25
- package/src/parts/Id/Id.ts +0 -5
- package/src/parts/IpcState/IpcState.ts +0 -11
- package/src/parts/IsInputElement/IsInputElement.ts +0 -3
- package/src/parts/ListenerCache/ListenerCache.ts +0 -13
- package/src/parts/Main/Main.ts +0 -16
- package/src/parts/NameAnonymousFunction/NameAnonymousFunction.ts +0 -5
- package/src/parts/NavigateChildPatch/NavigateChildPatch.ts +0 -4
- package/src/parts/NavigateParentPatch/NavigateParentPatch.ts +0 -3
- package/src/parts/NavigateSiblingPatch/NavigateSiblingPatch.ts +0 -4
- package/src/parts/Patch/Patch.ts +0 -22
- package/src/parts/PatchFunctions/PatchFunctions.ts +0 -30
- package/src/parts/PatchType/PatchType.ts +0 -10
- package/src/parts/PreventEventsMaybe/PreventEventsMaybe.ts +0 -14
- package/src/parts/QueryInputs/QueryInputs.ts +0 -3
- package/src/parts/RegisterEventListeners/RegisterEventListeners.ts +0 -17
- package/src/parts/RememberFocus/RememberFocus.ts +0 -97
- package/src/parts/RemoveAttributePatch/RemoveAttributePatch.ts +0 -4
- package/src/parts/RemoveChildPatch/RemoveChildPatch.ts +0 -4
- package/src/parts/RemovePatch/RemovePatch.ts +0 -4
- package/src/parts/RenderInternal/RenderInternal.ts +0 -23
- package/src/parts/ReplacePatch/ReplacePatch.ts +0 -7
- package/src/parts/SetDragImage/SetDragImage.ts +0 -14
- package/src/parts/TextPatch/TextPatch.ts +0 -4
- package/src/parts/UidSymbol/UidSymbol.ts +0 -1
- package/src/parts/VirtualDom/VirtualDom.ts +0 -44
- package/src/parts/VirtualDomElement/VirtualDomElement.ts +0 -32
- package/src/parts/VirtualDomElementProp/VirtualDomElementProp.ts +0 -109
- package/src/parts/VirtualDomElementProps/VirtualDomElementProps.ts +0 -13
- package/src/parts/VirtualDomElements/VirtualDomElements.ts +0 -57
- package/src/parts/VirtualDomNode/VirtualDomNode.ts +0 -4
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import * as ComponentUid from '../ComponentUid/ComponentUid.ts'
|
|
2
|
-
import * as IpcState from '../IpcState/IpcState.ts'
|
|
3
|
-
import * as ListenerCache from '../ListenerCache/ListenerCache.ts'
|
|
4
|
-
import * as NameAnonymousFunction from '../NameAnonymousFunction/NameAnonymousFunction.ts'
|
|
5
|
-
|
|
6
|
-
export const getWrappedListener = (listener, returnValue): any => {
|
|
7
|
-
if (!returnValue) {
|
|
8
|
-
return listener
|
|
9
|
-
}
|
|
10
|
-
if (!ListenerCache.has(listener)) {
|
|
11
|
-
const wrapped = (event): void => {
|
|
12
|
-
const uid = ComponentUid.getComponentUidFromEvent(event)
|
|
13
|
-
const result = listener(event)
|
|
14
|
-
// TODO check for empty array by value
|
|
15
|
-
if (result.length === 0) {
|
|
16
|
-
return
|
|
17
|
-
}
|
|
18
|
-
const ipc = IpcState.getIpc()
|
|
19
|
-
ipc.send('Viewlet.executeViewletCommand', uid, ...result)
|
|
20
|
-
}
|
|
21
|
-
NameAnonymousFunction.nameAnonymousFunction(wrapped, listener.name)
|
|
22
|
-
ListenerCache.set(listener, wrapped)
|
|
23
|
-
}
|
|
24
|
-
return ListenerCache.get(listener)
|
|
25
|
-
}
|
package/src/parts/Id/Id.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
const cache = new Map()
|
|
2
|
-
|
|
3
|
-
export const has = (listener): boolean => {
|
|
4
|
-
return cache.has(listener)
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
export const set = (listener, value): void => {
|
|
8
|
-
cache.set(listener, value)
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export const get = (listener): any => {
|
|
12
|
-
return cache.get(listener)
|
|
13
|
-
}
|
package/src/parts/Main/Main.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
export { applyPatch } from '../ApplyPatch/ApplyPatch.ts'
|
|
2
|
-
export {
|
|
3
|
-
getComponentUid,
|
|
4
|
-
getComponentUidFromEvent,
|
|
5
|
-
setComponentUid,
|
|
6
|
-
} from '../ComponentUid/ComponentUid.ts'
|
|
7
|
-
export {
|
|
8
|
-
getDragInfo,
|
|
9
|
-
removeDragInfo,
|
|
10
|
-
setDragInfo,
|
|
11
|
-
} from '../DragInfo/DragInfo.ts'
|
|
12
|
-
export { addFileHandle, getFileHandles } from '../FileHandles/FileHandles.ts'
|
|
13
|
-
export { setIpc } from '../IpcState/IpcState.ts'
|
|
14
|
-
export { registerEventListeners } from '../RegisterEventListeners/RegisterEventListeners.ts'
|
|
15
|
-
export { rememberFocus } from '../RememberFocus/RememberFocus.ts'
|
|
16
|
-
export { render, renderInto } from '../VirtualDom/VirtualDom.ts'
|
package/src/parts/Patch/Patch.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import type { AddPatch } from '../AddPatch/AddPatch.ts'
|
|
2
|
-
import type { AttributePatch } from '../AttributePatch/AttributePatch.ts'
|
|
3
|
-
import type { NavigateChildPatch } from '../NavigateChildPatch/NavigateChildPatch.ts'
|
|
4
|
-
import type { NavigateParentPatch } from '../NavigateParentPatch/NavigateParentPatch.ts'
|
|
5
|
-
import type { NavigateSiblingPatch } from '../NavigateSiblingPatch/NavigateSiblingPatch.ts'
|
|
6
|
-
import type { RemoveAttributePatch } from '../RemoveAttributePatch/RemoveAttributePatch.ts'
|
|
7
|
-
import type { RemoveChildPatch } from '../RemoveChildPatch/RemoveChildPatch.ts'
|
|
8
|
-
import type { RemovePatch } from '../RemovePatch/RemovePatch.ts'
|
|
9
|
-
import type { ReplacePatch } from '../ReplacePatch/ReplacePatch.ts'
|
|
10
|
-
import type { TextPatch } from '../TextPatch/TextPatch.ts'
|
|
11
|
-
|
|
12
|
-
export type Patch =
|
|
13
|
-
| TextPatch
|
|
14
|
-
| AttributePatch
|
|
15
|
-
| ReplacePatch
|
|
16
|
-
| RemoveAttributePatch
|
|
17
|
-
| RemovePatch
|
|
18
|
-
| AddPatch
|
|
19
|
-
| NavigateChildPatch
|
|
20
|
-
| NavigateParentPatch
|
|
21
|
-
| RemoveChildPatch
|
|
22
|
-
| NavigateSiblingPatch
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import type { VirtualDomNode } from '../VirtualDomNode/VirtualDomNode.ts'
|
|
2
|
-
import * as RenderInternal from '../RenderInternal/RenderInternal.ts'
|
|
3
|
-
|
|
4
|
-
export const setAttribute = (
|
|
5
|
-
$Element: HTMLElement,
|
|
6
|
-
key: string,
|
|
7
|
-
value: any,
|
|
8
|
-
): void => {
|
|
9
|
-
$Element.setAttribute(key, value)
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export const removeAttribute = ($Element: HTMLElement, key: string): void => {
|
|
13
|
-
$Element.removeAttribute(key)
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export const setText = ($Element: Text, value: string): void => {
|
|
17
|
-
$Element.nodeValue = value
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export const removeChild = ($Element: HTMLElement, index: number): void => {
|
|
21
|
-
const $Child = $Element.children[index]
|
|
22
|
-
$Child.remove()
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export const add = (
|
|
26
|
-
$Element: HTMLElement,
|
|
27
|
-
nodes: readonly VirtualDomNode[],
|
|
28
|
-
): void => {
|
|
29
|
-
RenderInternal.renderInternal($Element, nodes, {}, {})
|
|
30
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export const SetText = 1
|
|
2
|
-
export const Replace = 2
|
|
3
|
-
export const SetAttribute = 3
|
|
4
|
-
export const RemoveAttribute = 4
|
|
5
|
-
export const Remove = 5
|
|
6
|
-
export const Add = 6
|
|
7
|
-
export const NavigateChild = 7
|
|
8
|
-
export const NavigateParent = 8
|
|
9
|
-
export const RemoveChild = 9
|
|
10
|
-
export const NavigateSibling = 10
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { isInputElement } from '../IsInputElement/IsInputElement.ts'
|
|
2
|
-
|
|
3
|
-
export const preventEventsMaybe = (info: any, event: any): void => {
|
|
4
|
-
if (info.preventDefault === 2) {
|
|
5
|
-
if (!isInputElement(event.target)) {
|
|
6
|
-
event.preventDefault()
|
|
7
|
-
}
|
|
8
|
-
} else if (info.preventDefault) {
|
|
9
|
-
event.preventDefault()
|
|
10
|
-
}
|
|
11
|
-
if (info.stopPropagation) {
|
|
12
|
-
event.stopPropagation()
|
|
13
|
-
}
|
|
14
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import * as CreateEventListenerFunction from '../CreateEventListenerFunction/CreateEventListenerFunction.ts'
|
|
2
|
-
|
|
3
|
-
const listeners = Object.create(null)
|
|
4
|
-
|
|
5
|
-
export const registerEventListeners = (id, eventListeners): void => {
|
|
6
|
-
const map = Object.create(null)
|
|
7
|
-
for (const info of eventListeners) {
|
|
8
|
-
const fn = CreateEventListenerFunction.createFn(info, map)
|
|
9
|
-
map[info.name] = fn
|
|
10
|
-
}
|
|
11
|
-
listeners[id] = map
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export const getEventListenerMap = (id): any => {
|
|
15
|
-
const map = listeners[id]
|
|
16
|
-
return map
|
|
17
|
-
}
|
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
import * as ComponentUid from '../ComponentUid/ComponentUid.ts'
|
|
2
|
-
import * as EventState from '../EventState/EventState.ts'
|
|
3
|
-
import { getActiveElementInside } from '../GetActiveElementInside/GetActiveElementInside.ts'
|
|
4
|
-
import * as QueryInputs from '../QueryInputs/QueryInputs.ts'
|
|
5
|
-
import * as RegisterEventListeners from '../RegisterEventListeners/RegisterEventListeners.ts'
|
|
6
|
-
import * as VirtualDom from '../VirtualDom/VirtualDom.ts'
|
|
7
|
-
|
|
8
|
-
const focusElement = ($Element: HTMLElement): void => {
|
|
9
|
-
$Element.focus({ preventScroll: true })
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export const rememberFocus = (
|
|
13
|
-
$Viewlet: HTMLElement,
|
|
14
|
-
dom: any[],
|
|
15
|
-
eventMap: any,
|
|
16
|
-
uid = 0,
|
|
17
|
-
): any => {
|
|
18
|
-
EventState.startIgnore()
|
|
19
|
-
const oldLeft = $Viewlet.style.left
|
|
20
|
-
const oldTop = $Viewlet.style.top
|
|
21
|
-
const oldWidth = $Viewlet.style.width
|
|
22
|
-
const oldHeight = $Viewlet.style.height
|
|
23
|
-
const activeElement = getActiveElementInside($Viewlet)
|
|
24
|
-
const isTreeFocused = activeElement?.getAttribute('role') === 'tree'
|
|
25
|
-
const isRootTree =
|
|
26
|
-
$Viewlet.getAttribute('role') === 'tree' && activeElement === $Viewlet
|
|
27
|
-
const focused = activeElement?.getAttribute('name')
|
|
28
|
-
const $Hidden = document.createElement('div')
|
|
29
|
-
$Hidden.style.display = 'none'
|
|
30
|
-
if (focused) {
|
|
31
|
-
if (document.body) {
|
|
32
|
-
document.body.append($Hidden)
|
|
33
|
-
}
|
|
34
|
-
// @ts-ignore
|
|
35
|
-
$Hidden.append(activeElement)
|
|
36
|
-
}
|
|
37
|
-
const $$Inputs = QueryInputs.queryInputs($Viewlet)
|
|
38
|
-
const inputMap = Object.create(null)
|
|
39
|
-
for (const $Input of $$Inputs) {
|
|
40
|
-
inputMap[$Input.name] = $Input.value
|
|
41
|
-
}
|
|
42
|
-
if (uid) {
|
|
43
|
-
const newEventMap = RegisterEventListeners.getEventListenerMap(uid)
|
|
44
|
-
const $New = VirtualDom.render(dom, eventMap, newEventMap)
|
|
45
|
-
.firstChild as HTMLElement
|
|
46
|
-
ComponentUid.setComponentUid($New, uid)
|
|
47
|
-
const $$NewInputs = QueryInputs.queryInputs($New)
|
|
48
|
-
for (const $Input of $$NewInputs) {
|
|
49
|
-
$Input.value = inputMap[$Input.name] || $Input.value || ''
|
|
50
|
-
}
|
|
51
|
-
$Viewlet.replaceWith($New)
|
|
52
|
-
if (focused) {
|
|
53
|
-
const $NewFocused = $New.querySelector(
|
|
54
|
-
`[name="${focused}"]`,
|
|
55
|
-
) as HTMLInputElement
|
|
56
|
-
if ($NewFocused) {
|
|
57
|
-
const $Previous = $Hidden.firstChild as HTMLInputElement
|
|
58
|
-
$Previous.className = $NewFocused.className
|
|
59
|
-
$Previous.placeholder = $NewFocused.placeholder
|
|
60
|
-
if ($NewFocused.childNodes) {
|
|
61
|
-
$Previous.replaceChildren(...$NewFocused.childNodes)
|
|
62
|
-
}
|
|
63
|
-
$NewFocused.replaceWith($Previous)
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
$Hidden.remove()
|
|
67
|
-
$Viewlet = $New
|
|
68
|
-
} else {
|
|
69
|
-
VirtualDom.renderInto($Viewlet, dom, eventMap)
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
if (isRootTree) {
|
|
73
|
-
focusElement($Viewlet)
|
|
74
|
-
} else if (isTreeFocused) {
|
|
75
|
-
const $Tree = $Viewlet.querySelector('[role="tree"]')
|
|
76
|
-
if ($Tree) {
|
|
77
|
-
// @ts-ignore
|
|
78
|
-
focusElement($Tree)
|
|
79
|
-
}
|
|
80
|
-
} else if (focused) {
|
|
81
|
-
const $Focused = $Viewlet.querySelector(`[name="${focused}"]`)
|
|
82
|
-
|
|
83
|
-
if ($Focused) {
|
|
84
|
-
// @ts-ignore
|
|
85
|
-
focusElement($Focused)
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
$Viewlet.style.top = oldTop
|
|
90
|
-
$Viewlet.style.left = oldLeft
|
|
91
|
-
$Viewlet.style.height = oldHeight
|
|
92
|
-
$Viewlet.style.width = oldWidth
|
|
93
|
-
|
|
94
|
-
EventState.stopIgnore()
|
|
95
|
-
|
|
96
|
-
return $Viewlet
|
|
97
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import type { VirtualDomNode } from '../VirtualDomNode/VirtualDomNode.ts'
|
|
2
|
-
import * as VirtualDomElement from '../VirtualDomElement/VirtualDomElement.ts'
|
|
3
|
-
|
|
4
|
-
export const renderInternal = (
|
|
5
|
-
$Parent: HTMLElement,
|
|
6
|
-
elements: readonly VirtualDomNode[],
|
|
7
|
-
eventMap: any,
|
|
8
|
-
newEventMap?: any,
|
|
9
|
-
): void => {
|
|
10
|
-
const max = elements.length - 1
|
|
11
|
-
let stack: Node[] = []
|
|
12
|
-
for (let i = max; i >= 0; i--) {
|
|
13
|
-
const element = elements[i]
|
|
14
|
-
const $Element = VirtualDomElement.render(element, eventMap, newEventMap)
|
|
15
|
-
if (element.childCount > 0) {
|
|
16
|
-
// @ts-expect-error
|
|
17
|
-
$Element.append(...stack.slice(0, element.childCount))
|
|
18
|
-
stack = stack.slice(element.childCount)
|
|
19
|
-
}
|
|
20
|
-
stack.unshift($Element)
|
|
21
|
-
}
|
|
22
|
-
$Parent.append(...stack)
|
|
23
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export const setDragImage = (
|
|
2
|
-
dataTransfer: DataTransfer,
|
|
3
|
-
label: string,
|
|
4
|
-
): void => {
|
|
5
|
-
const dragImage = document.createElement('div')
|
|
6
|
-
dragImage.className = 'DragImage'
|
|
7
|
-
dragImage.textContent = label
|
|
8
|
-
document.body.append(dragImage)
|
|
9
|
-
dataTransfer.setDragImage(dragImage, -10, -10)
|
|
10
|
-
const handleTimeOut = (): void => {
|
|
11
|
-
dragImage.remove()
|
|
12
|
-
}
|
|
13
|
-
setTimeout(handleTimeOut, 0)
|
|
14
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export const uidSymbol = Symbol('uid')
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import * as ClearNode from '../ClearNode/ClearNode.ts'
|
|
2
|
-
import * as RenderInternal from '../RenderInternal/RenderInternal.ts'
|
|
3
|
-
|
|
4
|
-
export const renderInto = ($Parent, dom, eventMap = {}): void => {
|
|
5
|
-
ClearNode.clearNode($Parent)
|
|
6
|
-
RenderInternal.renderInternal($Parent, dom, eventMap)
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export const renderIncremental = ($Parent, dom): void => {
|
|
10
|
-
if ($Parent.textContent === '') {
|
|
11
|
-
// @ts-expect-error
|
|
12
|
-
renderInternal($Parent, dom)
|
|
13
|
-
return
|
|
14
|
-
}
|
|
15
|
-
// TODO
|
|
16
|
-
const $Node = $Parent
|
|
17
|
-
for (let i = 0; i < dom.length; i++) {
|
|
18
|
-
const node = dom[i]
|
|
19
|
-
if ($Node.nodeValue !== node.props.text && node.props.text) {
|
|
20
|
-
$Node.nodeValue = node.props.text
|
|
21
|
-
}
|
|
22
|
-
if ($Node.title !== node.props.title && node.props.title) {
|
|
23
|
-
$Node.title = node.props.title
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
// const newCount = dom
|
|
27
|
-
// const $Root = render(dom)
|
|
28
|
-
// $Parent.replaceChildren(...$Root.children)
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
*
|
|
33
|
-
* @param {any[]} elements
|
|
34
|
-
* @returns
|
|
35
|
-
*/
|
|
36
|
-
export const render = (
|
|
37
|
-
elements,
|
|
38
|
-
eventMap = {},
|
|
39
|
-
newEventMap = {},
|
|
40
|
-
): HTMLElement => {
|
|
41
|
-
const $Root = document.createElement('div')
|
|
42
|
-
RenderInternal.renderInternal($Root, elements, eventMap, newEventMap)
|
|
43
|
-
return $Root
|
|
44
|
-
}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import type { VirtualDomNode } from '../VirtualDomNode/VirtualDomNode.ts'
|
|
2
|
-
import * as ElementTagMap from '../ElementTagMap/ElementTagMap.ts'
|
|
3
|
-
import * as VirtualDomElementProps from '../VirtualDomElementProps/VirtualDomElementProps.ts'
|
|
4
|
-
import * as VirtualDomElements from '../VirtualDomElements/VirtualDomElements.ts'
|
|
5
|
-
|
|
6
|
-
const renderDomTextNode = (element: any): Text => {
|
|
7
|
-
return document.createTextNode(element.text)
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
const renderDomElement = (
|
|
11
|
-
element: VirtualDomNode,
|
|
12
|
-
eventMap: any,
|
|
13
|
-
newEventMap: any,
|
|
14
|
-
): HTMLElement => {
|
|
15
|
-
const tag = ElementTagMap.getElementTag(element.type)
|
|
16
|
-
const $Element = document.createElement(tag)
|
|
17
|
-
VirtualDomElementProps.setProps($Element, element, eventMap, newEventMap)
|
|
18
|
-
return $Element
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export const render = (
|
|
22
|
-
element: VirtualDomNode,
|
|
23
|
-
eventMap: any,
|
|
24
|
-
newEventMap?: any,
|
|
25
|
-
): Node => {
|
|
26
|
-
switch (element.type) {
|
|
27
|
-
case VirtualDomElements.Text:
|
|
28
|
-
return renderDomTextNode(element)
|
|
29
|
-
default:
|
|
30
|
-
return renderDomElement(element, eventMap, newEventMap)
|
|
31
|
-
}
|
|
32
|
-
}
|
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
import * as AttachEvent from '../AttachEvent/AttachEvent.ts'
|
|
2
|
-
|
|
3
|
-
export const setProp = (
|
|
4
|
-
$Element: HTMLElement,
|
|
5
|
-
key: string,
|
|
6
|
-
value: any,
|
|
7
|
-
eventMap: any,
|
|
8
|
-
newEventMap?: any,
|
|
9
|
-
): void => {
|
|
10
|
-
switch (key) {
|
|
11
|
-
case 'maskImage':
|
|
12
|
-
$Element.style.maskImage = `url('${value}')`
|
|
13
|
-
$Element.style.webkitMaskImage = `url('${value}')`
|
|
14
|
-
break
|
|
15
|
-
case 'paddingLeft':
|
|
16
|
-
case 'paddingRight':
|
|
17
|
-
case 'top':
|
|
18
|
-
case 'left':
|
|
19
|
-
case 'marginTop':
|
|
20
|
-
$Element.style[key] = typeof value === 'number' ? `${value}px` : value
|
|
21
|
-
break
|
|
22
|
-
case 'translate':
|
|
23
|
-
$Element.style[key] = value
|
|
24
|
-
break
|
|
25
|
-
case 'width':
|
|
26
|
-
case 'height':
|
|
27
|
-
if ($Element instanceof HTMLImageElement) {
|
|
28
|
-
$Element[key] = value
|
|
29
|
-
} else if (typeof value === 'number') {
|
|
30
|
-
$Element.style[key] = `${value}px`
|
|
31
|
-
} else {
|
|
32
|
-
$Element.style[key] = value
|
|
33
|
-
}
|
|
34
|
-
break
|
|
35
|
-
case 'style':
|
|
36
|
-
throw new Error('style property is not supported')
|
|
37
|
-
case 'childCount':
|
|
38
|
-
case 'type':
|
|
39
|
-
break
|
|
40
|
-
case 'ariaOwns': // TODO remove this once idl is supported
|
|
41
|
-
if (value) {
|
|
42
|
-
$Element.setAttribute('aria-owns', value)
|
|
43
|
-
} else {
|
|
44
|
-
$Element.removeAttribute('aria-owns')
|
|
45
|
-
}
|
|
46
|
-
break
|
|
47
|
-
case 'ariaActivedescendant':
|
|
48
|
-
if (value) {
|
|
49
|
-
$Element.setAttribute('aria-activedescendant', value)
|
|
50
|
-
} else {
|
|
51
|
-
$Element.removeAttribute('aria-activedescendant')
|
|
52
|
-
}
|
|
53
|
-
break
|
|
54
|
-
case 'ariaControls':
|
|
55
|
-
$Element.setAttribute('aria-controls', value)
|
|
56
|
-
break
|
|
57
|
-
case 'inputType':
|
|
58
|
-
// @ts-ignore
|
|
59
|
-
$Element.type = value
|
|
60
|
-
break
|
|
61
|
-
case 'ariaLabelledBy':
|
|
62
|
-
$Element.setAttribute('aria-labelledby', value)
|
|
63
|
-
break
|
|
64
|
-
case 'onBlur':
|
|
65
|
-
case 'onChange':
|
|
66
|
-
case 'onClick':
|
|
67
|
-
case 'onContextMenu':
|
|
68
|
-
case 'onDblClick':
|
|
69
|
-
case 'onDragEnd':
|
|
70
|
-
case 'onDragEnter':
|
|
71
|
-
case 'onDragLeave':
|
|
72
|
-
case 'onDragOver':
|
|
73
|
-
case 'onDragStart':
|
|
74
|
-
case 'onDrop':
|
|
75
|
-
case 'onFocus':
|
|
76
|
-
case 'onFocusIn':
|
|
77
|
-
case 'onFocusOut':
|
|
78
|
-
case 'onInput':
|
|
79
|
-
case 'onKeyDown':
|
|
80
|
-
case 'onMouseDown':
|
|
81
|
-
case 'onMouseOut':
|
|
82
|
-
case 'onMouseOver':
|
|
83
|
-
case 'onPointerDown':
|
|
84
|
-
case 'onPointerMove':
|
|
85
|
-
case 'onPointerOut':
|
|
86
|
-
case 'onPointerOver':
|
|
87
|
-
case 'onScroll':
|
|
88
|
-
case 'onWheel':
|
|
89
|
-
const eventName = key.slice(2).toLowerCase()
|
|
90
|
-
if (!eventMap || !value) {
|
|
91
|
-
return
|
|
92
|
-
}
|
|
93
|
-
AttachEvent.attachEvent($Element, eventMap, eventName, value, newEventMap)
|
|
94
|
-
break
|
|
95
|
-
case 'id':
|
|
96
|
-
if (value) {
|
|
97
|
-
$Element[key] = value
|
|
98
|
-
} else {
|
|
99
|
-
$Element.removeAttribute(key)
|
|
100
|
-
}
|
|
101
|
-
break
|
|
102
|
-
default:
|
|
103
|
-
if (key.startsWith('data-')) {
|
|
104
|
-
$Element.dataset[key.slice('data-'.length)] = value
|
|
105
|
-
} else {
|
|
106
|
-
$Element[key] = value
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import * as VirtualDomElementProp from '../VirtualDomElementProp/VirtualDomElementProp.ts'
|
|
2
|
-
|
|
3
|
-
export const setProps = ($Element, props, eventMap, newEventMap): void => {
|
|
4
|
-
for (const key in props) {
|
|
5
|
-
VirtualDomElementProp.setProp(
|
|
6
|
-
$Element,
|
|
7
|
-
key,
|
|
8
|
-
props[key],
|
|
9
|
-
eventMap,
|
|
10
|
-
newEventMap,
|
|
11
|
-
)
|
|
12
|
-
}
|
|
13
|
-
}
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
export const Audio = 0
|
|
2
|
-
export const Button = 1
|
|
3
|
-
export const Col = 2
|
|
4
|
-
export const ColGroup = 3
|
|
5
|
-
export const Div = 4
|
|
6
|
-
export const H1 = 5
|
|
7
|
-
export const Input = 6
|
|
8
|
-
export const Kbd = 7
|
|
9
|
-
export const Span = 8
|
|
10
|
-
export const Table = 9
|
|
11
|
-
export const TBody = 10
|
|
12
|
-
export const Td = 11
|
|
13
|
-
export const Text = 12
|
|
14
|
-
export const Th = 13
|
|
15
|
-
export const THead = 14
|
|
16
|
-
export const Tr = 15
|
|
17
|
-
export const I = 16
|
|
18
|
-
export const Img = 17
|
|
19
|
-
export const Root = 0
|
|
20
|
-
export const Ins = 20
|
|
21
|
-
export const Del = 21
|
|
22
|
-
export const H2 = 22
|
|
23
|
-
export const H3 = 23
|
|
24
|
-
export const H4 = 24
|
|
25
|
-
export const H5 = 25
|
|
26
|
-
export const H6 = 26
|
|
27
|
-
export const Article = 27
|
|
28
|
-
export const Aside = 28
|
|
29
|
-
export const Footer = 29
|
|
30
|
-
export const Header = 30
|
|
31
|
-
export const Nav = 40
|
|
32
|
-
export const Section = 41
|
|
33
|
-
export const Search = 42
|
|
34
|
-
export const Dd = 43
|
|
35
|
-
export const Dl = 44
|
|
36
|
-
export const Figcaption = 45
|
|
37
|
-
export const Figure = 46
|
|
38
|
-
export const Hr = 47
|
|
39
|
-
export const Li = 48
|
|
40
|
-
export const Ol = 49
|
|
41
|
-
export const P = 50
|
|
42
|
-
export const Pre = 51
|
|
43
|
-
export const A = 53
|
|
44
|
-
export const Abbr = 54
|
|
45
|
-
export const Br = 55
|
|
46
|
-
export const Cite = 56
|
|
47
|
-
export const Data = 57
|
|
48
|
-
export const Time = 58
|
|
49
|
-
export const Tfoot = 59
|
|
50
|
-
export const Ul = 60
|
|
51
|
-
export const Video = 61
|
|
52
|
-
export const TextArea = 62
|
|
53
|
-
export const Select = 63
|
|
54
|
-
export const Option = 64
|
|
55
|
-
export const Code = 65
|
|
56
|
-
export const Label = 66
|
|
57
|
-
export const Dt = 67
|