@domql/element 2.5.143 → 2.5.144

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/create.js CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  import createNode from './node'
4
4
  import { ROOT } from './tree'
5
+
5
6
  import {
6
7
  HTML_TAGS,
7
8
  isObject,
@@ -20,6 +21,7 @@ import {
20
21
  detectInfiniteLoop,
21
22
  addChildrenIfNotInOriginal
22
23
  } from '@domql/utils'
24
+
23
25
  import { triggerEventOn } from '@domql/event'
24
26
  import { assignNode } from '@domql/render'
25
27
  import { createState } from '@domql/state'
@@ -306,6 +308,7 @@ const addCaching = (element, parent) => {
306
308
 
307
309
  // enable EXEC
308
310
  if (!ref.__exec) ref.__exec = {}
311
+ if (!ref.__execProps) ref.__execProps = {}
309
312
 
310
313
  // enable CLASS CACHING
311
314
  if (!ref.__class) ref.__class = {}
@@ -246,6 +246,8 @@ const addCaching = (element, parent) => {
246
246
  ref.__defineCache = {};
247
247
  if (!ref.__exec)
248
248
  ref.__exec = {};
249
+ if (!ref.__execProps)
250
+ ref.__execProps = {};
249
251
  if (!ref.__class)
250
252
  ref.__class = {};
251
253
  if (!ref.__classNames)
@@ -18,6 +18,7 @@ var __copyProps = (to, from, except, desc) => {
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
19
  var iterate_exports = {};
20
20
  __export(iterate_exports, {
21
+ throughExecProps: () => throughExecProps,
21
22
  throughInitialDefine: () => throughInitialDefine,
22
23
  throughInitialExec: () => throughInitialExec,
23
24
  throughUpdatedDefine: () => throughUpdatedDefine,
@@ -63,6 +64,20 @@ const throughUpdatedExec = (element, options = { excludes: import_utils2.METHODS
63
64
  }
64
65
  return changes;
65
66
  };
67
+ const throughExecProps = (element) => {
68
+ const { __ref: ref } = element;
69
+ const { props } = element;
70
+ for (const k in props) {
71
+ const isDefine = k.startsWith("is") || k.startsWith("has") || k.startsWith("use");
72
+ const cachedExecProp = ref.__execProps[k];
73
+ if ((0, import_utils.isFunction)(cachedExecProp)) {
74
+ props[k] = (0, import_utils.exec)(cachedExecProp, element);
75
+ } else if (isDefine && (0, import_utils.isFunction)(props[k])) {
76
+ ref.__execProps[k] = props[k];
77
+ props[k] = (0, import_utils.exec)(props[k], element);
78
+ }
79
+ }
80
+ };
66
81
  const throughInitialDefine = (element) => {
67
82
  const { define, context, __ref: ref } = element;
68
83
  let defineObj = {};
package/dist/cjs/node.js CHANGED
@@ -60,6 +60,7 @@ const createNode = (element, options) => {
60
60
  if ((0, import_utils.isFunction)(node.setAttribute))
61
61
  node.setAttribute("key", element.key);
62
62
  }
63
+ (0, import_iterate.throughExecProps)(element);
63
64
  (0, import_iterate.throughInitialDefine)(element);
64
65
  (0, import_iterate.throughInitialExec)(element);
65
66
  if (element.tag !== "string" && element.tag !== "fragment") {
@@ -93,16 +93,13 @@ const update = function(params = {}, opts) {
93
93
  if (beforeUpdateReturns === false)
94
94
  return element;
95
95
  }
96
- const overwriteChanges = (0, import_utils.overwriteDeep)(element, params, import_utils2.METHODS_EXL);
97
- const execChanges = (0, import_iterate.throughUpdatedExec)(element, { ignore: UPDATE_DEFAULT_OPTIONS });
98
- const definedChanges = (0, import_iterate.throughUpdatedDefine)(element);
96
+ (0, import_utils.overwriteDeep)(element, params, import_utils2.METHODS_EXL);
97
+ (0, import_iterate.throughExecProps)(element);
98
+ (0, import_iterate.throughUpdatedExec)(element, { ignore: UPDATE_DEFAULT_OPTIONS });
99
+ (0, import_iterate.throughUpdatedDefine)(element);
99
100
  if (!options.isForced && !options.preventListeners) {
100
101
  (0, import_event.triggerEventOn)("beforeClassAssign", element, options);
101
102
  }
102
- if (options.stackChanges && element.__stackChanges) {
103
- const stackChanges = (0, import_utils.merge)(definedChanges, (0, import_utils.merge)(execChanges, overwriteChanges));
104
- element.__stackChanges.push(stackChanges);
105
- }
106
103
  if (!ref.__if)
107
104
  return false;
108
105
  if (!node) {
@@ -42,6 +42,8 @@ const onlyResolveExtends = (element, parent, key, options) => {
42
42
  ref2.__defineCache = {};
43
43
  if (!ref2.__exec)
44
44
  ref2.__exec = {};
45
+ if (!ref2.__execProps)
46
+ ref2.__execProps = {};
45
47
  if (!ref2.__class)
46
48
  ref2.__class = {};
47
49
  if (!ref2.__classNames)
package/iterate.js CHANGED
@@ -58,6 +58,21 @@ export const throughUpdatedExec = (element, options = { excludes: METHODS_EXL })
58
58
  return changes
59
59
  }
60
60
 
61
+ export const throughExecProps = (element) => {
62
+ const { __ref: ref } = element
63
+ const { props } = element
64
+ for (const k in props) {
65
+ const isDefine = k.startsWith('is') || k.startsWith('has') || k.startsWith('use')
66
+ const cachedExecProp = ref.__execProps[k]
67
+ if (isFunction(cachedExecProp)) {
68
+ props[k] = exec(cachedExecProp, element)
69
+ } else if (isDefine && isFunction(props[k])) {
70
+ ref.__execProps[k] = props[k]
71
+ props[k] = exec(props[k], element)
72
+ }
73
+ }
74
+ }
75
+
61
76
  export const throughInitialDefine = (element) => {
62
77
  const { define, context, __ref: ref } = element
63
78
 
package/node.js CHANGED
@@ -8,6 +8,7 @@ import { isMethod } from './methods'
8
8
  import create from './create'
9
9
 
10
10
  import {
11
+ throughExecProps,
11
12
  throughInitialDefine,
12
13
  throughInitialExec
13
14
  } from './iterate'
@@ -44,6 +45,9 @@ export const createNode = (element, options) => {
44
45
  if (isFunction(node.setAttribute)) node.setAttribute('key', element.key)
45
46
  }
46
47
 
48
+ // iterate through exec props
49
+ throughExecProps(element)
50
+
47
51
  // iterate through define
48
52
  throughInitialDefine(element)
49
53
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@domql/element",
3
- "version": "2.5.143",
3
+ "version": "2.5.144",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "module": "index.js",
@@ -26,12 +26,12 @@
26
26
  "prepublish": "rimraf -I dist && yarn build && yarn copy:package:cjs"
27
27
  },
28
28
  "dependencies": {
29
- "@domql/event": "^2.5.143",
30
- "@domql/render": "^2.5.143",
31
- "@domql/state": "^2.5.143",
32
- "@domql/utils": "^2.5.143"
29
+ "@domql/event": "^2.5.144",
30
+ "@domql/render": "^2.5.144",
31
+ "@domql/state": "^2.5.144",
32
+ "@domql/utils": "^2.5.144"
33
33
  },
34
- "gitHead": "46440d5034244c18657bf272df1bdc3e8ff666c5",
34
+ "gitHead": "9026efab1932521ec5eec3e88261eadb81f2e3cb",
35
35
  "devDependencies": {
36
36
  "@babel/core": "^7.12.0"
37
37
  }
package/update.js CHANGED
@@ -21,7 +21,7 @@ import { updateProps } from './props'
21
21
  import { createState, findInheritedState } from '@domql/state'
22
22
 
23
23
  import create from './create'
24
- import { throughUpdatedDefine, throughUpdatedExec } from './iterate'
24
+ import { throughExecProps, throughUpdatedDefine, throughUpdatedExec } from './iterate'
25
25
  import { registry } from './mixins'
26
26
  import { applyParam } from './utils/applyParam'
27
27
  import OPTIONS from './cache/options'
@@ -80,20 +80,15 @@ const update = function (params = {}, opts) {
80
80
  if (beforeUpdateReturns === false) return element
81
81
  }
82
82
 
83
- const overwriteChanges = overwriteDeep(element, params, METHODS_EXL)
84
- // const overwriteChanges = overwriteDeep(element, params)
85
- const execChanges = throughUpdatedExec(element, { ignore: UPDATE_DEFAULT_OPTIONS })
86
- const definedChanges = throughUpdatedDefine(element)
83
+ overwriteDeep(element, params, METHODS_EXL)
84
+ throughExecProps(element)
85
+ throughUpdatedExec(element, { ignore: UPDATE_DEFAULT_OPTIONS })
86
+ throughUpdatedDefine(element)
87
87
 
88
88
  if (!options.isForced && !options.preventListeners) {
89
89
  triggerEventOn('beforeClassAssign', element, options)
90
90
  }
91
91
 
92
- if (options.stackChanges && element.__stackChanges) {
93
- const stackChanges = merge(definedChanges, merge(execChanges, overwriteChanges))
94
- element.__stackChanges.push(stackChanges)
95
- }
96
-
97
92
  if (!ref.__if) return false
98
93
  if (!node) {
99
94
  // return createNode(element, options)
@@ -315,3 +310,14 @@ const createStateUpdate = (element, parent, options) => {
315
310
  }
316
311
 
317
312
  export default update
313
+
314
+ // save updates history
315
+ // const overwriteChanges = overwriteDeep(element, params, METHODS_EXL)
316
+ // // const overwriteChanges = overwriteDeep(element, params)
317
+ // const propsChanges = throughExecProps(element)
318
+ // const execChanges = throughUpdatedExec(element, { ignore: UPDATE_DEFAULT_OPTIONS })
319
+ // const definedChanges = throughUpdatedDefine(element)
320
+ // if (options.stackChanges && ref.__stackChanges) {
321
+ // const stackChanges = merge(definedChanges, merge(execChanges, overwriteChanges))
322
+ // ref.__stackChanges.push(stackChanges)
323
+ // }
@@ -32,6 +32,7 @@ export const onlyResolveExtends = (element, parent, key, options) => {
32
32
 
33
33
  // enable EXEC
34
34
  if (!ref.__exec) ref.__exec = {}
35
+ if (!ref.__execProps) ref.__execProps = {}
35
36
 
36
37
  // enable CLASS CACHING
37
38
  if (!ref.__class) ref.__class = {}