domql 1.3.2 → 1.4.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/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"description": "DOM rendering Javascript framework at early stage.",
|
|
4
4
|
"private": false,
|
|
5
5
|
"author": "rackai",
|
|
6
|
-
"version": "1.
|
|
6
|
+
"version": "1.4.0",
|
|
7
7
|
"repository": "https://github.com/rackai/domql",
|
|
8
8
|
"publishConfig": {
|
|
9
9
|
"registry": "https://registry.npmjs.org"
|
|
@@ -29,16 +29,16 @@
|
|
|
29
29
|
"@babel/core": "^7.10.4",
|
|
30
30
|
"@babel/preset-env": "^7.10.4",
|
|
31
31
|
"babel-eslint": "^10.0.3",
|
|
32
|
-
"babel-jest": "^
|
|
32
|
+
"babel-jest": "^28.1.0",
|
|
33
33
|
"babel-preset-env": "^1.7.0",
|
|
34
34
|
"coveralls": "^3.0.5",
|
|
35
35
|
"eslint": "^8.10.0",
|
|
36
36
|
"eslint-plugin-jest": "^26.1.0",
|
|
37
|
-
"jest": "^
|
|
37
|
+
"jest": "^28.1.0",
|
|
38
38
|
"nodemon": "^2.0.6",
|
|
39
39
|
"np": "^7.2.0",
|
|
40
40
|
"parcel-bundler": "^1.12.4",
|
|
41
|
-
"standard": "^
|
|
41
|
+
"standard": "^17.0.0"
|
|
42
42
|
},
|
|
43
43
|
"jest": {
|
|
44
44
|
"collectCoverageFrom": [
|
package/src/element/create.js
CHANGED
|
@@ -14,6 +14,7 @@ import { assignClass } from './mixins/classList'
|
|
|
14
14
|
import { isFunction, isNumber, isString, createID, isNode } from '../utils'
|
|
15
15
|
import { remove, lookup, log, keys, parse, parseDeep } from './methods'
|
|
16
16
|
import cacheNode from './cache'
|
|
17
|
+
import { registry } from './mixins'
|
|
17
18
|
// import { overwrite, clone, fillTheRest } from '../utils'
|
|
18
19
|
|
|
19
20
|
const ENV = process.env.NODE_ENV
|
|
@@ -26,6 +27,11 @@ const create = (element, parent, key, options = {}) => {
|
|
|
26
27
|
if (element === undefined) element = {}
|
|
27
28
|
if (element === null) return
|
|
28
29
|
|
|
30
|
+
if (Object.keys(options).length) {
|
|
31
|
+
registry.defaultOptions = options
|
|
32
|
+
if (options.ignoreChildProto) delete options.ignoreChildProto
|
|
33
|
+
}
|
|
34
|
+
|
|
29
35
|
// define KEY
|
|
30
36
|
const assignedKey = element.key || key || createID.next().value
|
|
31
37
|
|
|
@@ -71,14 +77,6 @@ const create = (element, parent, key, options = {}) => {
|
|
|
71
77
|
return assignNode(element, parent, assignedKey)
|
|
72
78
|
}
|
|
73
79
|
|
|
74
|
-
// run `on.init`
|
|
75
|
-
if (element.on && isFunction(element.on.init)) {
|
|
76
|
-
on.init(element.on.init, element, element.state)
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
// generate a CLASS name
|
|
80
|
-
assignClass(element)
|
|
81
|
-
|
|
82
80
|
// assign METHODS
|
|
83
81
|
element.set = set
|
|
84
82
|
element.update = update
|
|
@@ -110,6 +108,14 @@ const create = (element, parent, key, options = {}) => {
|
|
|
110
108
|
// apply props settings
|
|
111
109
|
createProps(element, parent)
|
|
112
110
|
|
|
111
|
+
// run `on.init`
|
|
112
|
+
if (element.on && isFunction(element.on.init)) {
|
|
113
|
+
on.init(element.on.init, element, element.state)
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// generate a CLASS name
|
|
117
|
+
assignClass(element)
|
|
118
|
+
|
|
113
119
|
// console.log('cache.props:')
|
|
114
120
|
// console.log(cache.props)
|
|
115
121
|
// console.log('applied props:')
|
|
@@ -128,7 +134,7 @@ const create = (element, parent, key, options = {}) => {
|
|
|
128
134
|
}
|
|
129
135
|
|
|
130
136
|
// CREATE a real NODE
|
|
131
|
-
createNode(element)
|
|
137
|
+
createNode(element, options)
|
|
132
138
|
|
|
133
139
|
// assign NODE
|
|
134
140
|
assignNode(element, parent, key)
|
|
@@ -28,7 +28,7 @@ const ENV = process.env.NODE_ENV
|
|
|
28
28
|
// }
|
|
29
29
|
// })
|
|
30
30
|
|
|
31
|
-
const createNode = (element) => {
|
|
31
|
+
const createNode = (element, options) => {
|
|
32
32
|
// create and assign a node
|
|
33
33
|
let { node, tag } = element
|
|
34
34
|
|
|
@@ -78,9 +78,9 @@ const createNode = (element) => {
|
|
|
78
78
|
const ourParam = registry[param]
|
|
79
79
|
|
|
80
80
|
if (ourParam) { // Check if param is in our method registry
|
|
81
|
-
if (isFunction(ourParam)) ourParam(prop, element, node)
|
|
81
|
+
if (isFunction(ourParam)) ourParam(prop, element, node, options)
|
|
82
82
|
} else if (element[param] && !hasDefined) {
|
|
83
|
-
create(prop, element, param) // Create element
|
|
83
|
+
create(prop, element, param, options) // Create element
|
|
84
84
|
}
|
|
85
85
|
}
|
|
86
86
|
}
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
import { deepClone, deepMerge, exec, isArray } from '../utils'
|
|
3
|
+
import { deepClone, deepMerge, exec, isArray, isObject } from '../utils'
|
|
4
4
|
|
|
5
5
|
const initProps = (element, parent) => {
|
|
6
6
|
const propsStack = []
|
|
7
7
|
|
|
8
|
-
if (element.props
|
|
8
|
+
if (isObject(element.props)) {
|
|
9
|
+
propsStack.push(element.props)
|
|
10
|
+
} else if (element.props === 'inherit') {
|
|
11
|
+
if (parent && parent.props) propsStack.push(parent.props)
|
|
12
|
+
} else if (element.props === 'match') {
|
|
9
13
|
if (parent && parent.props) propsStack.push(parent.props[element.key])
|
|
10
14
|
} else if (element.props) propsStack.push(element.props)
|
|
11
15
|
|
|
@@ -6,12 +6,12 @@ import set from '../set'
|
|
|
6
6
|
* Appends anything as content
|
|
7
7
|
* an original one as a child
|
|
8
8
|
*/
|
|
9
|
-
export default (param, element, node) => {
|
|
9
|
+
export default (param, element, node, options) => {
|
|
10
10
|
if (param && element) {
|
|
11
11
|
if (param.__hash === element.content.__hash && element.content.update) {
|
|
12
12
|
element.content.update(param)
|
|
13
13
|
} else {
|
|
14
|
-
set.call(element, param)
|
|
14
|
+
set.call(element, param, options)
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
17
|
}
|
package/src/element/proto.js
CHANGED
|
@@ -54,7 +54,12 @@ export const applyPrototype = (element, parent, options = {}) => {
|
|
|
54
54
|
stack = protoStack
|
|
55
55
|
} else if (childProtoLength) {
|
|
56
56
|
stack = childProtoStack
|
|
57
|
-
} else return element
|
|
57
|
+
} else if (!options.proto) return element
|
|
58
|
+
|
|
59
|
+
if (options.proto) {
|
|
60
|
+
const defaultOptionsProto = getProtoStack(options.proto)
|
|
61
|
+
stack = [].concat(stack, defaultOptionsProto)
|
|
62
|
+
}
|
|
58
63
|
|
|
59
64
|
element.__proto = stack
|
|
60
65
|
const mergedProto = cloneAndMergeArrayProto(stack)
|
package/src/element/set.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
3
|
import create from './create'
|
|
4
|
+
import { registry } from './mixins'
|
|
4
5
|
|
|
5
6
|
const removeContentElement = (params, element) => {
|
|
6
7
|
if (params && element.content) {
|
|
@@ -18,7 +19,7 @@ const removeContentElement = (params, element) => {
|
|
|
18
19
|
}
|
|
19
20
|
}
|
|
20
21
|
|
|
21
|
-
const set = function (params,
|
|
22
|
+
const set = function (params, options) {
|
|
22
23
|
const element = this
|
|
23
24
|
|
|
24
25
|
removeContentElement(params, element)
|
|
@@ -27,7 +28,8 @@ const set = function (params, enter, leave) {
|
|
|
27
28
|
const { childProto } = params
|
|
28
29
|
if (!childProto && element.childProto) params.childProto = element.childProto
|
|
29
30
|
create(params, element, 'content', {
|
|
30
|
-
ignoreChildProto: true
|
|
31
|
+
ignoreChildProto: true,
|
|
32
|
+
...registry.defaultOptions
|
|
31
33
|
})
|
|
32
34
|
}
|
|
33
35
|
|