domql 1.5.27 → 1.5.29
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 +1 -1
- package/src/element/create.js +15 -13
- package/src/element/extend.js +8 -1
- package/src/element/mixins/registry.js +1 -0
- package/src/element/options.js +3 -0
- package/src/element/set.js +3 -1
- package/src/element/state.js +5 -0
- package/src/event/is.js +3 -0
- package/src/event/on.js +4 -0
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.5.
|
|
6
|
+
"version": "1.5.29",
|
|
7
7
|
"repository": "https://github.com/rackai/domql",
|
|
8
8
|
"publishConfig": {
|
|
9
9
|
"registry": "https://registry.npmjs.org"
|
package/src/element/create.js
CHANGED
|
@@ -9,29 +9,23 @@ import set, { removeContentElement } from './set'
|
|
|
9
9
|
import createState from './state'
|
|
10
10
|
import createProps from './props'
|
|
11
11
|
import update from './update'
|
|
12
|
-
import
|
|
12
|
+
import { on, is } from '../event'
|
|
13
13
|
import { assignClass } from './mixins/classList'
|
|
14
14
|
import { isFunction, isNumber, isString, createID, isNode, exec, isArray } from '../utils'
|
|
15
15
|
import { remove, lookup, setProps, log, keys, parse, parseDeep, spotByPath } from './methods'
|
|
16
16
|
import cacheNode from './cache'
|
|
17
17
|
import { registry } from './mixins'
|
|
18
|
+
import OPTIONS from './options'
|
|
18
19
|
// import { overwrite, clone, fillTheRest } from '../utils'
|
|
19
20
|
|
|
20
21
|
const ENV = process.env.NODE_ENV
|
|
21
22
|
|
|
22
|
-
const isComponent = (key) => {
|
|
23
|
-
const isFirstKeyString = isString(key)
|
|
24
|
-
if(!isFirstKeyString) return
|
|
25
|
-
|
|
26
|
-
const firstCharKey = key.slice(0, 1)
|
|
27
|
-
|
|
28
|
-
return /^[A-Z]*$/.test(firstCharKey)
|
|
29
|
-
}
|
|
30
|
-
|
|
31
23
|
/**
|
|
32
24
|
* Creating a domQL element using passed parameters
|
|
33
25
|
*/
|
|
34
|
-
const create = (element, parent, key, options = {}) => {
|
|
26
|
+
const create = (element, parent, key, options = OPTIONS.create || {}) => {
|
|
27
|
+
if (options && !OPTIONS.create) OPTIONS.create = options
|
|
28
|
+
|
|
35
29
|
// if ELEMENT is not given
|
|
36
30
|
if (element === undefined) {
|
|
37
31
|
if (ENV === 'test' || ENV === 'development')
|
|
@@ -63,7 +57,7 @@ const create = (element, parent, key, options = {}) => {
|
|
|
63
57
|
|
|
64
58
|
const { extend, props, state, childExtend, childProps } = element
|
|
65
59
|
|
|
66
|
-
if (
|
|
60
|
+
if (isKeyComponent(assignedKey)) {
|
|
67
61
|
if (!extend && !childExtend && !props && !state || childProps) {
|
|
68
62
|
element = {
|
|
69
63
|
extend: assignedKey.split('_')[0],
|
|
@@ -154,7 +148,6 @@ const create = (element, parent, key, options = {}) => {
|
|
|
154
148
|
element.log = log
|
|
155
149
|
}
|
|
156
150
|
|
|
157
|
-
|
|
158
151
|
// enable STATE
|
|
159
152
|
element.state = createState(element, parent)
|
|
160
153
|
|
|
@@ -208,4 +201,13 @@ const create = (element, parent, key, options = {}) => {
|
|
|
208
201
|
return element
|
|
209
202
|
}
|
|
210
203
|
|
|
204
|
+
const isKeyComponent = (key) => {
|
|
205
|
+
const isFirstKeyString = isString(key)
|
|
206
|
+
if(!isFirstKeyString) return
|
|
207
|
+
|
|
208
|
+
const firstCharKey = key.slice(0, 1)
|
|
209
|
+
|
|
210
|
+
return /^[A-Z]*$/.test(firstCharKey)
|
|
211
|
+
}
|
|
212
|
+
|
|
211
213
|
export default create
|
package/src/element/extend.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
import { isFunction, exec, getExtendStack, jointStacks, cloneAndMergeArrayExtend, deepMergeExtend } from '../utils'
|
|
3
|
+
import { isFunction, exec, getExtendStack, jointStacks, cloneAndMergeArrayExtend, deepMergeExtend, isString } from '../utils'
|
|
4
4
|
|
|
5
5
|
const ENV = process.env.NODE_ENV
|
|
6
6
|
|
|
@@ -12,6 +12,7 @@ export const applyExtend = (element, parent, options = {}) => {
|
|
|
12
12
|
if (isFunction(element)) element = exec(element, parent)
|
|
13
13
|
|
|
14
14
|
const { extend } = element
|
|
15
|
+
if (isString(extend)) extend = options.components[extend]
|
|
15
16
|
const extendStack = getExtendStack(extend)
|
|
16
17
|
|
|
17
18
|
if (ENV !== 'test' || ENV !== 'development') delete element.extend
|
|
@@ -22,6 +23,12 @@ export const applyExtend = (element, parent, options = {}) => {
|
|
|
22
23
|
element.parent = parent
|
|
23
24
|
if (!options.ignoreChildExtend) {
|
|
24
25
|
childExtendStack = getExtendStack(parent.childExtend)
|
|
26
|
+
|
|
27
|
+
if (parent.childExtendRecursive) {
|
|
28
|
+
const childExtendRecursiveStack = getExtendStack(parent.childExtendRecursive)
|
|
29
|
+
childExtendStack = childExtendStack.concat(childExtendRecursiveStack)
|
|
30
|
+
element.childExtendRecursive = parent.childExtendRecursive
|
|
31
|
+
}
|
|
25
32
|
}
|
|
26
33
|
}
|
|
27
34
|
|
package/src/element/set.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import create from './create'
|
|
4
4
|
import { isEqualDeep, isFunction } from '../utils'
|
|
5
5
|
import { registry } from './mixins'
|
|
6
|
+
import OPTIONS from './options'
|
|
6
7
|
|
|
7
8
|
export const removeContentElement = function (el) {
|
|
8
9
|
const element = el || this
|
|
@@ -35,7 +36,8 @@ const set = function (params, options, el) {
|
|
|
35
36
|
if (!childExtend && element.childExtend) params.childExtend = element.childExtend
|
|
36
37
|
create(params, element, 'content', {
|
|
37
38
|
ignoreChildExtend: true,
|
|
38
|
-
...registry.defaultOptions
|
|
39
|
+
...registry.defaultOptions,
|
|
40
|
+
...OPTIONS.create
|
|
39
41
|
})
|
|
40
42
|
}
|
|
41
43
|
|
package/src/element/state.js
CHANGED
|
@@ -73,6 +73,11 @@ export default function (element, parent) {
|
|
|
73
73
|
return {}
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
+
// run `on.init`
|
|
77
|
+
if (element.on && isFunction(element.on.stateInit)) {
|
|
78
|
+
on.stateInit(element.on.stateInit, element, element.state)
|
|
79
|
+
}
|
|
80
|
+
|
|
76
81
|
if (isFunction(state)) state = exec(state, element)
|
|
77
82
|
|
|
78
83
|
const { __ref } = state
|
package/src/event/is.js
CHANGED
package/src/event/on.js
CHANGED
|
@@ -20,6 +20,10 @@ export const attachNode = (param, element, state) => {
|
|
|
20
20
|
param(element, state)
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
+
export const stateInit = (param, element, state) => {
|
|
24
|
+
param(element, state)
|
|
25
|
+
}
|
|
26
|
+
|
|
23
27
|
export const stateCreated = (param, element, state) => {
|
|
24
28
|
param(element, state)
|
|
25
29
|
}
|