@domql/element 2.5.63 → 2.5.66

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
@@ -263,7 +263,7 @@ const applyContext = (element, parent, options) => {
263
263
  const createScope = (element, parent) => {
264
264
  const { __ref: ref } = element
265
265
  // If the element doesn't have a scope, initialize it using the parent's scope or the root's scope.
266
- if (!element.scope) element.scope = parent.scope || ref.__root.scope || {}
266
+ if (!element.scope) element.scope = parent.scope || ref.root.scope || {}
267
267
  }
268
268
 
269
269
  const createIfConditionFlag = (element, parent) => {
@@ -303,7 +303,7 @@ const addCaching = (element, parent) => {
303
303
 
304
304
  // Add _root element property
305
305
  const hasRoot = parent && parent.key === ':root'
306
- if (!ref.__root) ref.__root = hasRoot ? element : parentRef.__root
306
+ if (!ref.root) ref.root = hasRoot ? element : parentRef.root
307
307
 
308
308
  // set the PATH array
309
309
  if (ENV === 'test' || ENV === 'development') {
@@ -341,9 +341,9 @@ const onlyResolveExtends = (element, parent, key, options) => {
341
341
  // enable CHANGES storing
342
342
  if (!ref.__children) ref.__children = []
343
343
 
344
- // Add __root element property
344
+ // Add root element property
345
345
  // const hasRoot = parent && parent.key === ':root'
346
- // if (!ref.__root) ref.__root = hasRoot ? element : parentRef.__root
346
+ // if (!ref.root) ref.root = hasRoot ? element : parentRef.root
347
347
 
348
348
  addMethods(element, parent)
349
349
 
@@ -201,7 +201,7 @@ const applyContext = (element, parent, options) => {
201
201
  const createScope = (element, parent) => {
202
202
  const { __ref: ref } = element;
203
203
  if (!element.scope)
204
- element.scope = parent.scope || ref.__root.scope || {};
204
+ element.scope = parent.scope || ref.root.scope || {};
205
205
  };
206
206
  const createIfConditionFlag = (element, parent) => {
207
207
  const { __ref: ref } = element;
@@ -232,8 +232,8 @@ const addCaching = (element, parent) => {
232
232
  if (!ref.__children)
233
233
  ref.__children = [];
234
234
  const hasRoot = parent && parent.key === ":root";
235
- if (!ref.__root)
236
- ref.__root = hasRoot ? element : parentRef.__root;
235
+ if (!ref.root)
236
+ ref.root = hasRoot ? element : parentRef.root;
237
237
  if (ENV === "test" || ENV === "development") {
238
238
  if (!parentRef)
239
239
  parentRef = parent.ref = {};
@@ -105,20 +105,39 @@ const update = function(params = {}, options = UPDATE_DEFAULT_OPTIONS) {
105
105
  if (!node) {
106
106
  return;
107
107
  }
108
+ const {
109
+ onlyUpdate,
110
+ preventUpdate,
111
+ preventDefineUpdate,
112
+ preventContentUpdate,
113
+ preventStateUpdate,
114
+ preventRecursive,
115
+ preventUpdateListener,
116
+ preventUpdateAfter,
117
+ preventUpdateAfterCount
118
+ } = options;
119
+ if (preventUpdateAfter) {
120
+ if ((0, import_utils.isNumber)(preventUpdateAfterCount) && preventUpdateAfter <= preventUpdateAfterCount)
121
+ return;
122
+ else if (options.preventUpdateAfterCount === void 0)
123
+ options.preventUpdateAfterCount = 1;
124
+ else
125
+ options.preventUpdateAfterCount++;
126
+ }
108
127
  for (const param in element) {
109
128
  const prop = element[param];
110
- const hasOnlyUpdateFalsy = options.onlyUpdate && (options.onlyUpdate !== param || !element.lookup(options.onlyUpdate));
111
- const isInPreventUpdate = (0, import_utils.isArray)(options.preventUpdate) && options.preventUpdate.includes(param);
112
- const isInPreventDefineUpdate = (0, import_utils.isArray)(options.preventDefineUpdate) && options.preventDefineUpdate.includes(param);
129
+ const hasOnlyUpdateFalsy = onlyUpdate && (onlyUpdate !== param || !element.lookup(onlyUpdate));
130
+ const isInPreventUpdate = (0, import_utils.isArray)(preventUpdate) && preventUpdate.includes(param);
131
+ const isInPreventDefineUpdate = (0, import_utils.isArray)(preventDefineUpdate) && preventDefineUpdate.includes(param);
113
132
  const hasCollection = element.$collection || element.$stateCollection || element.$propsCollection;
114
- if ((0, import_utils.isUndefined)(prop) || hasOnlyUpdateFalsy || isInPreventUpdate || isInPreventDefineUpdate || options.preventDefineUpdate === true || options.preventDefineUpdate === param || options.preventContentUpdate && param === "content" && !hasCollection || (options.preventStateUpdate && param) === "state" || (0, import_methods.isMethod)(param) || (0, import_utils.isObject)(import_mixins.registry[param]) || (0, import_utils2.isVariant)(param))
133
+ if ((0, import_utils.isUndefined)(prop) || hasOnlyUpdateFalsy || isInPreventUpdate || isInPreventDefineUpdate || preventDefineUpdate === true || preventDefineUpdate === param || preventContentUpdate && param === "content" && !hasCollection || (preventStateUpdate && param) === "state" || (0, import_methods.isMethod)(param) || (0, import_utils.isObject)(import_mixins.registry[param]) || (0, import_utils2.isVariant)(param))
115
134
  continue;
116
- if (options.preventStateUpdate === "once")
135
+ if (preventStateUpdate === "once")
117
136
  options.preventStateUpdate = false;
118
137
  const isElement = (0, import_applyParam.applyParam)(param, element, options);
119
138
  if (isElement) {
120
139
  const { hasDefine, hasContextDefine } = isElement;
121
- const canUpdate = (0, import_utils.isObject)(prop) && !hasDefine && !hasContextDefine && !options.preventRecursive;
140
+ const canUpdate = (0, import_utils.isObject)(prop) && !hasDefine && !hasContextDefine && !preventRecursive;
122
141
  if (!canUpdate)
123
142
  continue;
124
143
  const lazyLoad = element.props.lazyLoad || options.lazyLoad;
@@ -130,7 +149,7 @@ const update = function(params = {}, options = UPDATE_DEFAULT_OPTIONS) {
130
149
  lazyLoad ? import_utils.window.requestAnimationFrame(() => childUpdateCall()) : childUpdateCall();
131
150
  }
132
151
  }
133
- if (!options.preventUpdateListener)
152
+ if (!preventUpdateListener)
134
153
  (0, import_event.triggerEventOn)("update", element, options);
135
154
  };
136
155
  const captureSnapshot = (element, options) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@domql/element",
3
- "version": "2.5.63",
3
+ "version": "2.5.66",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "module": "index.js",
@@ -31,7 +31,7 @@
31
31
  "@domql/state": "latest",
32
32
  "@domql/utils": "latest"
33
33
  },
34
- "gitHead": "318bb5d6c6b3989cc97b2a2f12c0169599786ffa",
34
+ "gitHead": "5cb5b9bd779042cc3cfe3d912bdc48fb8293ea0b",
35
35
  "devDependencies": {
36
36
  "@babel/core": "^7.12.0"
37
37
  }
package/update.js CHANGED
@@ -97,11 +97,23 @@ const update = function (params = {}, options = UPDATE_DEFAULT_OPTIONS) {
97
97
  return
98
98
  }
99
99
 
100
+ const {
101
+ onlyUpdate, preventUpdate, preventDefineUpdate, preventContentUpdate, preventStateUpdate,
102
+ preventRecursive, preventUpdateListener, preventUpdateAfter, preventUpdateAfterCount
103
+ } = options
104
+
105
+ if (preventUpdateAfter) {
106
+ if (isNumber(preventUpdateAfterCount) && preventUpdateAfter <= preventUpdateAfterCount) return
107
+ else if (options.preventUpdateAfterCount === undefined) options.preventUpdateAfterCount = 1
108
+ else options.preventUpdateAfterCount++
109
+ }
110
+
100
111
  for (const param in element) {
101
112
  const prop = element[param]
102
- const hasOnlyUpdateFalsy = options.onlyUpdate && (options.onlyUpdate !== param || !element.lookup(options.onlyUpdate))
103
- const isInPreventUpdate = isArray(options.preventUpdate) && options.preventUpdate.includes(param)
104
- const isInPreventDefineUpdate = isArray(options.preventDefineUpdate) && options.preventDefineUpdate.includes(param)
113
+
114
+ const hasOnlyUpdateFalsy = onlyUpdate && (onlyUpdate !== param || !element.lookup(onlyUpdate))
115
+ const isInPreventUpdate = isArray(preventUpdate) && preventUpdate.includes(param)
116
+ const isInPreventDefineUpdate = isArray(preventDefineUpdate) && preventDefineUpdate.includes(param)
105
117
 
106
118
  const hasCollection = element.$collection || element.$stateCollection || element.$propsCollection
107
119
 
@@ -110,18 +122,18 @@ const update = function (params = {}, options = UPDATE_DEFAULT_OPTIONS) {
110
122
  hasOnlyUpdateFalsy ||
111
123
  isInPreventUpdate ||
112
124
  isInPreventDefineUpdate ||
113
- options.preventDefineUpdate === true ||
114
- options.preventDefineUpdate === param ||
115
- (options.preventContentUpdate && param === 'content' && !hasCollection) ||
116
- (options.preventStateUpdate && param) === 'state' ||
125
+ preventDefineUpdate === true ||
126
+ preventDefineUpdate === param ||
127
+ (preventContentUpdate && param === 'content' && !hasCollection) ||
128
+ (preventStateUpdate && param) === 'state' ||
117
129
  isMethod(param) || isObject(registry[param]) || isVariant(param)
118
130
  ) continue
119
- if (options.preventStateUpdate === 'once') options.preventStateUpdate = false
131
+ if (preventStateUpdate === 'once') options.preventStateUpdate = false
120
132
 
121
133
  const isElement = applyParam(param, element, options)
122
134
  if (isElement) {
123
135
  const { hasDefine, hasContextDefine } = isElement
124
- const canUpdate = isObject(prop) && !hasDefine && !hasContextDefine && !options.preventRecursive
136
+ const canUpdate = isObject(prop) && !hasDefine && !hasContextDefine && !preventRecursive
125
137
  if (!canUpdate) continue
126
138
 
127
139
  const lazyLoad = element.props.lazyLoad || options.lazyLoad
@@ -136,7 +148,7 @@ const update = function (params = {}, options = UPDATE_DEFAULT_OPTIONS) {
136
148
  }
137
149
  }
138
150
 
139
- if (!options.preventUpdateListener) triggerEventOn('update', element, options)
151
+ if (!preventUpdateListener) triggerEventOn('update', element, options)
140
152
  }
141
153
 
142
154
  const captureSnapshot = (element, options) => {
@@ -46,9 +46,9 @@ export const onlyResolveExtends = (element, parent, key, options) => {
46
46
  // enable CHANGES storing
47
47
  if (!ref.__children) ref.__children = []
48
48
 
49
- // Add __root element property
49
+ // Add root element property
50
50
  // const hasRoot = parent && parent.key === ':root'
51
- // if (!ref.__root) ref.__root = hasRoot ? element : parentRef.__root
51
+ // if (!ref.root) ref.root = hasRoot ? element : parentRef.root
52
52
  }
53
53
 
54
54
  addMethods(element, parent)