@domql/element 3.7.5 → 3.7.6

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/README.md CHANGED
@@ -55,6 +55,20 @@ variables, on, component, context
55
55
 
56
56
  Plus mixin handlers: `attr`, `style`, `text`, `html`, `data`, `classlist`, `state`, `scope`, `deps`.
57
57
 
58
+ ## Scope and globalScope
59
+
60
+ During `create()`, `createScope(element, parent)` establishes a prototype chain:
61
+
62
+ ```
63
+ el.scope → parent.scope → ... → root.scope → context.globalScope
64
+ ```
65
+
66
+ - Elements without a `scope` property inherit their parent's scope (same reference)
67
+ - Elements with `scope: { ... }` get their own scope with parent's scope as prototype
68
+ - `context.globalScope` is auto-initialized as `{}` and sits at the chain's root
69
+
70
+ This enables serialized functions to access module-scoped values (constants, helpers) via `el.scope.X` without closures or imports — the values are placed in `globalScope` by the serialization pipeline and are accessible through prototype lookup.
71
+
58
72
  > **v3 note:** `childExtend` (singular) is deprecated v2 syntax — use `childExtends` (plural) in new code. The singular forms remain in REGISTRY for backwards compatibility with older projects. If a key is missing from REGISTRY, it gets interpreted as a child element name, causing silent rendering failures.
59
73
 
60
74
  ## set.js — Content Setting
package/create.js CHANGED
@@ -91,7 +91,6 @@ export const create = (
91
91
  createScope(element, parent)
92
92
 
93
93
  createState(element, parent)
94
- if (element.scope === 'state') element.scope = element.state
95
94
 
96
95
  createIfConditionFlag(element, parent)
97
96
 
@@ -103,9 +102,6 @@ export const create = (
103
102
  if (!element.tag) element.tag = detectTag(element)
104
103
  // Populate element.attr from props matching the tag's HTML spec
105
104
  applyPropsAsAttrs(element)
106
- if (element.scope === 'props' || element.scope === true) {
107
- element.scope = element.props
108
- }
109
105
 
110
106
  // recatch if it passess props again
111
107
  createIfConditionFlag(element, parent)
@@ -240,7 +236,6 @@ const onlyResolveExtends = (element, parent, key, options) => {
240
236
  createScope(element, parent)
241
237
 
242
238
  createState(element, parent)
243
- if (element.scope === 'state') element.scope = element.state
244
239
 
245
240
  createIfConditionFlag(element, parent)
246
241
 
@@ -248,9 +243,6 @@ const onlyResolveExtends = (element, parent, key, options) => {
248
243
  initProps(element, parent, options)
249
244
  // Re-pickup component-named properties that entered props via childProps/inheritParentProps
250
245
  pickupElementFromProps.call(element, element, { cachedKeys: [] })
251
- if (element.scope === 'props' || element.scope === true) {
252
- element.scope = element.props
253
- }
254
246
 
255
247
  if (element.node && ref.__if) {
256
248
  parent[key || element.key] = element
@@ -72,15 +72,11 @@ const create = (props, parentEl, passedKey, options = import_utils.OPTIONS.creat
72
72
  (0, import_set.addMethods)(element, parent, options);
73
73
  (0, import_utils.createScope)(element, parent);
74
74
  (0, import_state.createState)(element, parent);
75
- if (element.scope === "state") element.scope = element.state;
76
75
  (0, import_utils.createIfConditionFlag)(element, parent);
77
76
  (0, import_utils.initProps)(element, parent, options);
78
77
  import_utils.pickupElementFromProps.call(element, element, { cachedKeys: [] });
79
78
  if (!element.tag) element.tag = (0, import_cache.detectTag)(element);
80
79
  applyPropsAsAttrs(element);
81
- if (element.scope === "props" || element.scope === true) {
82
- element.scope = element.props;
83
- }
84
80
  (0, import_utils.createIfConditionFlag)(element, parent);
85
81
  if (element.node) {
86
82
  if (ref.__if) return (0, import_render.assignNode)(element, parent, key, attachOptions);
@@ -176,13 +172,9 @@ const onlyResolveExtends = (element, parent, key, options) => {
176
172
  (0, import_set.addMethods)(element, parent, options);
177
173
  (0, import_utils.createScope)(element, parent);
178
174
  (0, import_state.createState)(element, parent);
179
- if (element.scope === "state") element.scope = element.state;
180
175
  (0, import_utils.createIfConditionFlag)(element, parent);
181
176
  (0, import_utils.initProps)(element, parent, options);
182
177
  import_utils.pickupElementFromProps.call(element, element, { cachedKeys: [] });
183
- if (element.scope === "props" || element.scope === true) {
184
- element.scope = element.props;
185
- }
186
178
  if (element.node && ref.__if) {
187
179
  parent[key || element.key] = element;
188
180
  }
@@ -63,15 +63,11 @@ const create = (props, parentEl, passedKey, options = OPTIONS.create || {}, atta
63
63
  addMethods(element, parent, options);
64
64
  createScope(element, parent);
65
65
  createState(element, parent);
66
- if (element.scope === "state") element.scope = element.state;
67
66
  createIfConditionFlag(element, parent);
68
67
  initProps(element, parent, options);
69
68
  pickupElementFromProps.call(element, element, { cachedKeys: [] });
70
69
  if (!element.tag) element.tag = detectTag(element);
71
70
  applyPropsAsAttrs(element);
72
- if (element.scope === "props" || element.scope === true) {
73
- element.scope = element.props;
74
- }
75
71
  createIfConditionFlag(element, parent);
76
72
  if (element.node) {
77
73
  if (ref.__if) return assignNode(element, parent, key, attachOptions);
@@ -167,13 +163,9 @@ const onlyResolveExtends = (element, parent, key, options) => {
167
163
  addMethods(element, parent, options);
168
164
  createScope(element, parent);
169
165
  createState(element, parent);
170
- if (element.scope === "state") element.scope = element.state;
171
166
  createIfConditionFlag(element, parent);
172
167
  initProps(element, parent, options);
173
168
  pickupElementFromProps.call(element, element, { cachedKeys: [] });
174
- if (element.scope === "props" || element.scope === true) {
175
- element.scope = element.props;
176
- }
177
169
  if (element.node && ref.__if) {
178
170
  parent[key || element.key] = element;
179
171
  }
@@ -1813,7 +1813,24 @@ var DomqlElement = (() => {
1813
1813
  "../utils/dist/esm/scope.js"() {
1814
1814
  createScope = (element, parent) => {
1815
1815
  const { __ref: ref } = element;
1816
- if (!element.scope) element.scope = parent.scope || ref.root?.scope || {};
1816
+ const context = element.context || parent.context || ref.root?.context;
1817
+ if (context && !context.globalScope) context.globalScope = {};
1818
+ const parentScope = parent.scope || ref.root?.scope;
1819
+ const globalScope = context?.globalScope;
1820
+ if (!element.scope) {
1821
+ if (parentScope) {
1822
+ element.scope = parentScope;
1823
+ } else if (globalScope) {
1824
+ element.scope = Object.create(globalScope);
1825
+ } else {
1826
+ element.scope = {};
1827
+ }
1828
+ } else if (typeof element.scope === "object" && element.scope !== null) {
1829
+ if (Object.getPrototypeOf(element.scope) === Object.prototype) {
1830
+ const proto = parentScope || globalScope;
1831
+ if (proto) Object.setPrototypeOf(element.scope, proto);
1832
+ }
1833
+ }
1817
1834
  };
1818
1835
  }
1819
1836
  });
@@ -6514,15 +6531,11 @@ ${element}` : "";
6514
6531
  addMethods(element, parent, options);
6515
6532
  createScope(element, parent);
6516
6533
  createState(element, parent);
6517
- if (element.scope === "state") element.scope = element.state;
6518
6534
  createIfConditionFlag(element, parent);
6519
6535
  initProps(element, parent, options);
6520
6536
  pickupElementFromProps.call(element, element, { cachedKeys: [] });
6521
6537
  if (!element.tag) element.tag = detectTag(element);
6522
6538
  applyPropsAsAttrs(element);
6523
- if (element.scope === "props" || element.scope === true) {
6524
- element.scope = element.props;
6525
- }
6526
6539
  createIfConditionFlag(element, parent);
6527
6540
  if (element.node) {
6528
6541
  if (ref.__if) return assignNode(element, parent, key, attachOptions);
@@ -6618,13 +6631,9 @@ ${element}` : "";
6618
6631
  addMethods(element, parent, options);
6619
6632
  createScope(element, parent);
6620
6633
  createState(element, parent);
6621
- if (element.scope === "state") element.scope = element.state;
6622
6634
  createIfConditionFlag(element, parent);
6623
6635
  initProps(element, parent, options);
6624
6636
  pickupElementFromProps.call(element, element, { cachedKeys: [] });
6625
- if (element.scope === "props" || element.scope === true) {
6626
- element.scope = element.props;
6627
- }
6628
6637
  if (element.node && ref.__if) {
6629
6638
  parent[key || element.key] = element;
6630
6639
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@domql/element",
3
- "version": "3.7.5",
3
+ "version": "3.7.6",
4
4
  "license": "CC-BY-NC-4.0",
5
5
  "type": "module",
6
6
  "module": "./dist/esm/index.js",
@@ -46,10 +46,10 @@
46
46
  "build:iife": "cross-env NODE_ENV=$NODE_ENV esbuild index.js --bundle --target=es2020 --format=iife --global-name=DomqlElement --outfile=dist/iife/index.js --define:process.env.NODE_ENV=process.env.NODE_ENV"
47
47
  },
48
48
  "dependencies": {
49
- "@domql/report": "^3.7.5",
50
- "@domql/state": "^3.7.5",
51
- "@domql/utils": "^3.7.5",
52
- "attrs-in-props": "^3.7.5"
49
+ "@domql/report": "^3.7.6",
50
+ "@domql/state": "^3.7.6",
51
+ "@domql/utils": "^3.7.6",
52
+ "attrs-in-props": "^3.7.6"
53
53
  },
54
54
  "gitHead": "9fc1b79b41cdc725ca6b24aec64920a599634681",
55
55
  "devDependencies": {