@domql/element 2.3.154 → 2.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/update.js CHANGED
@@ -1,11 +1,9 @@
1
1
  'use strict'
2
2
 
3
- import { window } from '@domql/globals'
4
- import { exec, isArray, isFunction, isNumber, isObject, isString, isUndefined, merge, overwriteDeep } from '@domql/utils'
3
+ import { window, exec, isArray, isFunction, isNumber, isObject, isString, isUndefined, merge, overwriteDeep, createSnapshotId } from '@domql/utils'
5
4
  import { applyEvent, triggerEventOn, triggerEventOnUpdate } from '@domql/event'
6
- import { isMethod } from '@domql/methods'
7
- import { createSnapshotId } from '@domql/key'
8
- import { updateProps } from '@domql/props'
5
+ import { isMethod } from './methods'
6
+ import { updateProps } from './props'
9
7
  import { createState } from '@domql/state'
10
8
 
11
9
  import { METHODS_EXL, isVariant } from './utils'
@@ -13,7 +11,7 @@ import create from './create'
13
11
  import { throughUpdatedDefine, throughUpdatedExec } from './iterate'
14
12
  import { registry } from './mixins'
15
13
  import { applyParam } from './applyParam'
16
- import OPTIONS from './options'
14
+ import OPTIONS from './cache/options'
17
15
 
18
16
  const snapshot = {
19
17
  snapshotId: createSnapshotId
@@ -111,7 +109,7 @@ const update = function (params = {}, options = UPDATE_DEFAULT_OPTIONS) {
111
109
  const childUpdateCall = () => update.call(prop, params[prop], {
112
110
  ...options,
113
111
  currentSnapshot: snapshotOnCallee,
114
- calleeElement: calleeElement
112
+ calleeElement
115
113
  })
116
114
 
117
115
  if ((element.props && element.props.lazyLoad) || options.lazyLoad) {
package/methods.js DELETED
@@ -1,88 +0,0 @@
1
- 'use strict'
2
-
3
- import { isDefined, isFunction, isObjectLike } from '@domql/utils'
4
- import { parseFilters, registry } from './mixins'
5
-
6
- export const set = function () {
7
- }
8
-
9
- export const update = function () {
10
- }
11
-
12
- export const defineSetter = (element, key, get, set) =>
13
- Object.defineProperty(element, key, { get, set })
14
-
15
- export const keys = function () {
16
- const element = this
17
- const keys = []
18
- for (const param in element) {
19
- if (registry[param] && !parseFilters.elementKeys.includes(param)) { continue }
20
- keys.push(param)
21
- }
22
- return keys
23
- }
24
-
25
- export const parse = function (excl = []) {
26
- const element = this
27
- const obj = {}
28
- const keyList = keys.call(element)
29
- keyList.forEach(v => {
30
- if (excl.includes(v)) return
31
- let val = element[v]
32
- if (v === 'state') {
33
- if (element.__ref && element.__ref.__hasRootState) return
34
- if (isFunction(val && val.parse)) val = val.parse()
35
- } else if (v === 'props') {
36
- const { __element, update, ...props } = element[v]
37
- obj[v] = props
38
- } else if (isDefined(val)) obj[v] = val
39
- })
40
- return obj
41
- }
42
-
43
- export const parseDeep = function (excl = []) {
44
- const element = this
45
- const obj = parse.call(element, excl)
46
- for (const v in obj) {
47
- if (excl.includes(v)) return
48
- if (isObjectLike(obj[v])) { obj[v] = parseDeep.call(obj[v], excl) }
49
- }
50
- return obj
51
- }
52
-
53
- export const log = function (...args) {
54
- const element = this
55
- const { __ref } = element
56
- console.group(element.key)
57
- if (args.length) {
58
- args.forEach(v => console.log(`%c${v}:\n`, 'font-weight: bold', element[v]))
59
- } else {
60
- console.log(__ref.path)
61
- const keys = element.keys()
62
- keys.forEach(v => console.log(`%c${v}:\n`, 'font-weight: bold', element[v]))
63
- }
64
- console.groupEnd(element.key)
65
- return element
66
- }
67
-
68
- export const nextElement = function () {
69
- const element = this
70
- const { key, parent } = element
71
- const { __children } = parent.__ref
72
-
73
- const currentIndex = __children.indexOf(key)
74
- const nextChild = __children[currentIndex + 1]
75
-
76
- return parent[nextChild]
77
- }
78
-
79
- export const previousElement = function (el) {
80
- const element = el || this
81
- const { key, parent } = element
82
- const { __children } = parent.__ref
83
-
84
- if (!__children) return
85
-
86
- const currentIndex = __children.indexOf(key)
87
- return parent[__children[currentIndex - 1]]
88
- }
package/options.js DELETED
@@ -1,3 +0,0 @@
1
- 'use strict'
2
-
3
- export default {}
package/parse.js DELETED
@@ -1,17 +0,0 @@
1
- 'use strict'
2
-
3
- import { assignNode } from '@domql/render'
4
- import create from './create'
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/remove.js DELETED
@@ -1,30 +0,0 @@
1
- 'use strict'
2
-
3
- import { isFunction } from '@domql/utils'
4
-
5
- export const updateContentElement = function (params, options) {
6
- const element = this
7
-
8
- if (!element.content) return
9
- if (element.content.update) element.content.update(params, options)
10
- }
11
-
12
- export const removeContentElement = function (el) {
13
- const element = el || this
14
- const { __ref } = element
15
-
16
- if (element.content) {
17
- if (element.content.node) {
18
- if (element.content.tag === 'fragment') element.node.innerHTML = ''
19
- else element.node.removeChild(element.content.node)
20
- }
21
-
22
- const { __cached } = __ref
23
- if (__cached && __cached.content) {
24
- if (__cached.content.tag === 'fragment') __cached.content.parent.node.innerHTML = ''
25
- else if (__cached.content && isFunction(__cached.content.remove)) __cached.content.remove()
26
- }
27
-
28
- delete element.content
29
- }
30
- }