domql 2.0.7 → 2.1.1
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/allExports.js +21 -0
- package/index.js +15 -0
- package/package.json +17 -53
- package/README.md +0 -208
- package/packages/cookie/index.js +0 -22
- package/packages/emotion/index.js +0 -35
- package/packages/object/index.js +0 -29
- package/packages/object/package.json +0 -20
- package/packages/routeLink/index.js +0 -23
- package/packages/router/index.js +0 -18
- package/src/element/assign.js +0 -22
- package/src/element/cache.js +0 -52
- package/src/element/create.js +0 -144
- package/src/element/createNode.js +0 -92
- package/src/element/createProps.js +0 -64
- package/src/element/createState.js +0 -51
- package/src/element/define.js +0 -13
- package/src/element/id.js +0 -10
- package/src/element/index.js +0 -34
- package/src/element/iterate.js +0 -80
- package/src/element/methods.js +0 -96
- package/src/element/mixins/attr.js +0 -18
- package/src/element/mixins/classList.js +0 -37
- package/src/element/mixins/content.js +0 -17
- package/src/element/mixins/data.js +0 -21
- package/src/element/mixins/html.js +0 -17
- package/src/element/mixins/index.js +0 -23
- package/src/element/mixins/registry.js +0 -55
- package/src/element/mixins/state.js +0 -16
- package/src/element/mixins/style.js +0 -14
- package/src/element/mixins/text.js +0 -19
- package/src/element/nodes.js +0 -139
- package/src/element/parse.js +0 -17
- package/src/element/proto.js +0 -66
- package/src/element/root.js +0 -10
- package/src/element/set.js +0 -46
- package/src/element/tree.js +0 -5
- package/src/element/update.js +0 -100
- package/src/event/can.js +0 -10
- package/src/event/index.js +0 -11
- package/src/event/is.js +0 -13
- package/src/event/on.js +0 -33
- package/src/event/store.js +0 -6
- package/src/event/wrappers.js +0 -14
- package/src/index.js +0 -16
- package/src/utils/index.js +0 -6
- package/src/utils/node.js +0 -10
- package/src/utils/object.js +0 -193
- package/src/utils/protoUtils.js +0 -119
- package/src/utils/report.js +0 -62
package/src/element/nodes.js
DELETED
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
export default {
|
|
4
|
-
root: [
|
|
5
|
-
'body',
|
|
6
|
-
'html'
|
|
7
|
-
],
|
|
8
|
-
|
|
9
|
-
head: [
|
|
10
|
-
'title',
|
|
11
|
-
'base',
|
|
12
|
-
'meta',
|
|
13
|
-
'style'
|
|
14
|
-
],
|
|
15
|
-
|
|
16
|
-
body: [
|
|
17
|
-
'string',
|
|
18
|
-
'fragment',
|
|
19
|
-
'a',
|
|
20
|
-
'abbr',
|
|
21
|
-
'acronym',
|
|
22
|
-
'address',
|
|
23
|
-
'applet',
|
|
24
|
-
'area',
|
|
25
|
-
'article',
|
|
26
|
-
'aside',
|
|
27
|
-
'audio',
|
|
28
|
-
'b',
|
|
29
|
-
'basefont',
|
|
30
|
-
'bdi',
|
|
31
|
-
'bdo',
|
|
32
|
-
'big',
|
|
33
|
-
'blockquote',
|
|
34
|
-
'br',
|
|
35
|
-
'button',
|
|
36
|
-
'canvas',
|
|
37
|
-
'caption',
|
|
38
|
-
'center',
|
|
39
|
-
'cite',
|
|
40
|
-
'code',
|
|
41
|
-
'col',
|
|
42
|
-
'colgroup',
|
|
43
|
-
'data',
|
|
44
|
-
'datalist',
|
|
45
|
-
'dd',
|
|
46
|
-
'del',
|
|
47
|
-
'details',
|
|
48
|
-
'dfn',
|
|
49
|
-
'dialog',
|
|
50
|
-
'dir',
|
|
51
|
-
'div',
|
|
52
|
-
'dl',
|
|
53
|
-
'dt',
|
|
54
|
-
'em',
|
|
55
|
-
'embed',
|
|
56
|
-
'fieldset',
|
|
57
|
-
'figcaption',
|
|
58
|
-
'figure',
|
|
59
|
-
'font',
|
|
60
|
-
'footer',
|
|
61
|
-
'form',
|
|
62
|
-
'frame',
|
|
63
|
-
'frameset',
|
|
64
|
-
'h1',
|
|
65
|
-
'h2',
|
|
66
|
-
'h3',
|
|
67
|
-
'h4',
|
|
68
|
-
'h5',
|
|
69
|
-
'h6',
|
|
70
|
-
'head',
|
|
71
|
-
'header',
|
|
72
|
-
'hr',
|
|
73
|
-
'i',
|
|
74
|
-
'iframe',
|
|
75
|
-
'img',
|
|
76
|
-
'input',
|
|
77
|
-
'ins',
|
|
78
|
-
'kbd',
|
|
79
|
-
'label',
|
|
80
|
-
'legend',
|
|
81
|
-
'li',
|
|
82
|
-
'link',
|
|
83
|
-
'main',
|
|
84
|
-
'map',
|
|
85
|
-
'mark',
|
|
86
|
-
'meter',
|
|
87
|
-
'nav',
|
|
88
|
-
'noframes',
|
|
89
|
-
'noscript',
|
|
90
|
-
'object',
|
|
91
|
-
'ol',
|
|
92
|
-
'optgroup',
|
|
93
|
-
'option',
|
|
94
|
-
'output',
|
|
95
|
-
'p',
|
|
96
|
-
'param',
|
|
97
|
-
'picture',
|
|
98
|
-
'pre',
|
|
99
|
-
'progress',
|
|
100
|
-
'q',
|
|
101
|
-
'rp',
|
|
102
|
-
'rt',
|
|
103
|
-
'ruby',
|
|
104
|
-
's',
|
|
105
|
-
'samp',
|
|
106
|
-
'script',
|
|
107
|
-
'section',
|
|
108
|
-
'select',
|
|
109
|
-
'small',
|
|
110
|
-
'source',
|
|
111
|
-
'span',
|
|
112
|
-
'strike',
|
|
113
|
-
'strong',
|
|
114
|
-
'sub',
|
|
115
|
-
'summary',
|
|
116
|
-
'sup',
|
|
117
|
-
'table',
|
|
118
|
-
'tbody',
|
|
119
|
-
'td',
|
|
120
|
-
'template',
|
|
121
|
-
'textarea',
|
|
122
|
-
'tfoot',
|
|
123
|
-
'th',
|
|
124
|
-
'thead',
|
|
125
|
-
'time',
|
|
126
|
-
'tr',
|
|
127
|
-
'track',
|
|
128
|
-
'tt',
|
|
129
|
-
'u',
|
|
130
|
-
'ul',
|
|
131
|
-
'var',
|
|
132
|
-
'video',
|
|
133
|
-
'wbr',
|
|
134
|
-
|
|
135
|
-
// SVG
|
|
136
|
-
'svg',
|
|
137
|
-
'path'
|
|
138
|
-
]
|
|
139
|
-
}
|
package/src/element/parse.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
import create from './create'
|
|
4
|
-
import { assignNode } from './assign'
|
|
5
|
-
|
|
6
|
-
const parse = (element) => {
|
|
7
|
-
const virtualTree = {
|
|
8
|
-
node: document.createElement('div')
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
if (element && element.node) assignNode(element, virtualTree)
|
|
12
|
-
else create(element, virtualTree)
|
|
13
|
-
|
|
14
|
-
return virtualTree.node.innerHTML
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export default parse
|
package/src/element/proto.js
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
import { isFunction, exec, getProtoStack, jointStacks, cloneAndMergeArrayProto, deepMergeProto } from '../utils'
|
|
4
|
-
|
|
5
|
-
const ENV = process.env.NODE_ENV
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Checks whether element has `proto` or is a part
|
|
9
|
-
* of parent's `childProto` prototype
|
|
10
|
-
*/
|
|
11
|
-
export const applyPrototype = (element, parent, options = {}) => {
|
|
12
|
-
if (isFunction(element)) element = exec(element, parent)
|
|
13
|
-
|
|
14
|
-
const { proto } = element
|
|
15
|
-
|
|
16
|
-
// merge if proto is array
|
|
17
|
-
// const proto = mergeAndCloneIfArray(element.proto, v => {
|
|
18
|
-
// if (v.props) cache.props.push(v.props)
|
|
19
|
-
// console.log('v.propsIN_PROTO:')
|
|
20
|
-
// console.log(v.props)
|
|
21
|
-
// })
|
|
22
|
-
|
|
23
|
-
// console.log(proto)
|
|
24
|
-
const protoStack = getProtoStack(proto)
|
|
25
|
-
|
|
26
|
-
if (ENV !== 'test' || ENV !== 'development') delete element.proto
|
|
27
|
-
|
|
28
|
-
// console.log(parent.childProto)
|
|
29
|
-
|
|
30
|
-
// console.log(element)
|
|
31
|
-
// console.log(proto)
|
|
32
|
-
// console.log(protoStack)
|
|
33
|
-
// debugger
|
|
34
|
-
|
|
35
|
-
let childProtoStack = []
|
|
36
|
-
if (parent) {
|
|
37
|
-
// Assign parent attr to the element
|
|
38
|
-
element.parent = parent
|
|
39
|
-
if (!options.ignoreChildProto) {
|
|
40
|
-
childProtoStack = getProtoStack(parent.childProto)
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
// console.log(proto, parent && parent.childProto)
|
|
45
|
-
// console.log(protoStack, childProtoStack)
|
|
46
|
-
|
|
47
|
-
const protoLength = protoStack.length
|
|
48
|
-
const childProtoLength = childProtoStack.length
|
|
49
|
-
|
|
50
|
-
let stack = []
|
|
51
|
-
if (protoLength && childProtoLength) {
|
|
52
|
-
stack = jointStacks(protoStack, childProtoStack)
|
|
53
|
-
} else if (protoLength) {
|
|
54
|
-
stack = protoStack
|
|
55
|
-
} else if (childProtoLength) {
|
|
56
|
-
stack = childProtoStack
|
|
57
|
-
} else return element
|
|
58
|
-
|
|
59
|
-
element.__proto = stack
|
|
60
|
-
const mergedProto = cloneAndMergeArrayProto(stack)
|
|
61
|
-
|
|
62
|
-
// console.log(mergedProto)
|
|
63
|
-
return deepMergeProto(element, mergedProto)
|
|
64
|
-
|
|
65
|
-
// final merging with prototype
|
|
66
|
-
}
|
package/src/element/root.js
DELETED
package/src/element/set.js
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
import create from './create'
|
|
4
|
-
|
|
5
|
-
const removeContentElement = (params, element) => {
|
|
6
|
-
if (params && element.content) {
|
|
7
|
-
if (element.content.node) {
|
|
8
|
-
if (element.content.tag === 'fragment') element.node.innerHTML = ''
|
|
9
|
-
else element.node.removeChild(element.content.node)
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
if (element.__cached && element.__cached.content) {
|
|
13
|
-
if (element.__cached.content.tag === 'fragment') element.__cached.content.parent.node.innerHTML = ''
|
|
14
|
-
else element.__cached.content.remove()
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
delete element.content
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
const set = function (params, enter, leave) {
|
|
22
|
-
const element = this
|
|
23
|
-
|
|
24
|
-
removeContentElement(params, element)
|
|
25
|
-
|
|
26
|
-
if (params) {
|
|
27
|
-
const { childProto } = params
|
|
28
|
-
if (!childProto && element.childProto) params.childProto = element.childProto
|
|
29
|
-
create(params, element, 'content', {
|
|
30
|
-
ignoreChildProto: true
|
|
31
|
-
})
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
return element
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export default set
|
|
38
|
-
|
|
39
|
-
// if (element.content && (isFunction(element.content) || element.content.node)) {
|
|
40
|
-
// // leave(element, () => {
|
|
41
|
-
// // console.log('remove', element.content)
|
|
42
|
-
// // element.content.remove()
|
|
43
|
-
// // element.content.update(params)
|
|
44
|
-
// // element.node.removeChild(element.content.node)
|
|
45
|
-
// // delete element.content
|
|
46
|
-
// }
|
package/src/element/tree.js
DELETED
package/src/element/update.js
DELETED
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
import { overwrite, isFunction, isObject, isString, isNumber } from '../utils'
|
|
4
|
-
import { registry } from './mixins'
|
|
5
|
-
import * as on from '../event/on'
|
|
6
|
-
import { isMethod } from './methods'
|
|
7
|
-
import { throughUpdatedDefine, throughUpdatedExec } from './iterate'
|
|
8
|
-
import { merge } from '../utils/object'
|
|
9
|
-
import { appendNode } from './assign'
|
|
10
|
-
import { createNode } from '.'
|
|
11
|
-
import { updateProps } from './createProps'
|
|
12
|
-
|
|
13
|
-
const UPDATE_DEFAULT_OPTIONS = {
|
|
14
|
-
stackChanges: false,
|
|
15
|
-
cleanExec: true,
|
|
16
|
-
preventRecursive: false
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
const update = function (params = {}, options = UPDATE_DEFAULT_OPTIONS) {
|
|
20
|
-
const element = this
|
|
21
|
-
const { define, parent, node } = element
|
|
22
|
-
|
|
23
|
-
// console.groupCollapsed('Update:', element.path)
|
|
24
|
-
// console.log('params:')
|
|
25
|
-
// console.log(params)
|
|
26
|
-
// console.log('props:')
|
|
27
|
-
// console.log(element.props)
|
|
28
|
-
// console.log('element:')
|
|
29
|
-
// console.log(element)
|
|
30
|
-
// console.log('PARAMS.PROPS:')
|
|
31
|
-
// console.log(params.props)
|
|
32
|
-
// console.groupEnd('Update:')
|
|
33
|
-
// if params is string
|
|
34
|
-
if (isString(params) || isNumber(params)) {
|
|
35
|
-
params = { text: params }
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
if (element.on && isFunction(element.on.initUpdate)) {
|
|
39
|
-
on.initUpdate(element.on.initUpdate, element, element.state)
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
// console.log(element, parent)
|
|
43
|
-
updateProps(params.props, element, parent)
|
|
44
|
-
// // console.log(element.path)
|
|
45
|
-
// // console.log(element)
|
|
46
|
-
|
|
47
|
-
// console.groupCollapsed('UPDATE:')
|
|
48
|
-
// console.log(element)
|
|
49
|
-
// console.groupEnd('UPDATE:')
|
|
50
|
-
|
|
51
|
-
const overwriteChanges = overwrite(element, params, UPDATE_DEFAULT_OPTIONS)
|
|
52
|
-
const execChanges = throughUpdatedExec(element, UPDATE_DEFAULT_OPTIONS)
|
|
53
|
-
const definedChanges = throughUpdatedDefine(element)
|
|
54
|
-
|
|
55
|
-
if (UPDATE_DEFAULT_OPTIONS.stackChanges && element.__stackChanges) {
|
|
56
|
-
const stackChanges = merge(definedChanges, merge(execChanges, overwriteChanges))
|
|
57
|
-
element.__stackChanges.push(stackChanges)
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
if (isFunction(element.if)) {
|
|
61
|
-
// TODO: move as fragment
|
|
62
|
-
const ifPassed = element.if(element, element.state)
|
|
63
|
-
if (element.__ifFalsy && ifPassed) {
|
|
64
|
-
createNode(element)
|
|
65
|
-
appendNode(element.node, element.__ifFragment)
|
|
66
|
-
delete element.__ifFalsy
|
|
67
|
-
} else if (element.node && !ifPassed) {
|
|
68
|
-
element.node.remove()
|
|
69
|
-
element.__ifFalsy = true
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
// console.log(node)
|
|
74
|
-
// console.groupEnd('Update:')
|
|
75
|
-
|
|
76
|
-
if (!node || options.preventRecursive) return
|
|
77
|
-
|
|
78
|
-
for (const param in element) {
|
|
79
|
-
const prop = element[param]
|
|
80
|
-
|
|
81
|
-
if (isMethod(param) || isObject(registry[param]) || prop === undefined) continue
|
|
82
|
-
|
|
83
|
-
const hasDefined = define && define[param]
|
|
84
|
-
const ourParam = registry[param]
|
|
85
|
-
|
|
86
|
-
// // console.log(prop)
|
|
87
|
-
|
|
88
|
-
if (ourParam) {
|
|
89
|
-
if (isFunction(ourParam)) ourParam(prop, element, node)
|
|
90
|
-
} else if (prop && isObject(prop) && !hasDefined) {
|
|
91
|
-
update.call(prop, params[prop], UPDATE_DEFAULT_OPTIONS)
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
if (element.on && isFunction(element.on.update)) {
|
|
96
|
-
on.update(element.on.update, element, element.state)
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
export default update
|
package/src/event/can.js
DELETED
package/src/event/index.js
DELETED
package/src/event/is.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
export const node = (node) => {
|
|
4
|
-
const { Node } = window
|
|
5
|
-
return (
|
|
6
|
-
typeof Node === 'function'
|
|
7
|
-
? node instanceof Node
|
|
8
|
-
: node &&
|
|
9
|
-
typeof node === 'object' &&
|
|
10
|
-
typeof node.nodeType === 'number' &&
|
|
11
|
-
typeof node.tag === 'string'
|
|
12
|
-
)
|
|
13
|
-
}
|
package/src/event/on.js
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
export const init = (param, element, state) => {
|
|
4
|
-
param(element, state)
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
export const render = (param, element, state) => {
|
|
8
|
-
param(element, state)
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export const initUpdate = (param, element, state) => {
|
|
12
|
-
param(element, state)
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export const attachNode = (param, element, state) => {
|
|
16
|
-
param(element, state)
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export const stateCreated = (param, element, state) => {
|
|
20
|
-
param(element, state)
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export const initStateUpdated = (param, element, state) => {
|
|
24
|
-
param(element, state)
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export const stateUpdated = (param, element, state) => {
|
|
28
|
-
param(element, state)
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export const update = (param, element, state) => {
|
|
32
|
-
param(element, state)
|
|
33
|
-
}
|
package/src/event/store.js
DELETED
package/src/event/wrappers.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
export const getScrollPositions = () => {
|
|
4
|
-
if (window.pageYOffset !== undefined) {
|
|
5
|
-
return [window.pageXOffset, window.pageYOffset]
|
|
6
|
-
} else {
|
|
7
|
-
const d = document
|
|
8
|
-
const r = d.documentElement
|
|
9
|
-
const b = d.body
|
|
10
|
-
const sx = r.scrollLeft || b.scrollLeft || 0
|
|
11
|
-
const sy = r.scrollTop || b.scrollTop || 0
|
|
12
|
-
return [sx, sy]
|
|
13
|
-
}
|
|
14
|
-
}
|
package/src/index.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
import 'regenerator-runtime/runtime'
|
|
4
|
-
|
|
5
|
-
import { create, parse, set, define, tree } from './element'
|
|
6
|
-
|
|
7
|
-
const ENV = process.env.NODE_ENV
|
|
8
|
-
if (ENV === 'test' || ENV === 'development') window.tree = tree
|
|
9
|
-
|
|
10
|
-
export default {
|
|
11
|
-
create,
|
|
12
|
-
parse,
|
|
13
|
-
set,
|
|
14
|
-
define,
|
|
15
|
-
tree
|
|
16
|
-
}
|
package/src/utils/index.js
DELETED