@lwc/synthetic-shadow 9.3.6 → 9.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/dist/index.cjs CHANGED
@@ -194,7 +194,7 @@ const KEY__SHADOW_TOKEN_PRIVATE = '$$ShadowTokenKey$$';
194
194
  const KEY__SYNTHETIC_MODE = '$$lwc-synthetic-mode';
195
195
  const KEY__NATIVE_GET_ELEMENT_BY_ID = '$nativeGetElementById$';
196
196
  const KEY__NATIVE_QUERY_SELECTOR_ALL = '$nativeQuerySelectorAll$';
197
- /** version: 9.3.6 */
197
+ /** version: 9.4.0 */
198
198
 
199
199
  /**
200
200
  * Copyright (c) 2026 Salesforce, Inc.
@@ -202,7 +202,7 @@ const KEY__NATIVE_QUERY_SELECTOR_ALL = '$nativeQuerySelectorAll$';
202
202
  if (!globalThis.lwcRuntimeFlags) {
203
203
  Object.defineProperty(globalThis, 'lwcRuntimeFlags', { value: create(null) });
204
204
  }
205
- /** version: 9.3.6 */
205
+ /** version: 9.4.0 */
206
206
 
207
207
  /*
208
208
  * Copyright (c) 2018, salesforce.com, inc.
@@ -852,6 +852,9 @@ StaticNodeList.prototype = create(NodeList.prototype, {
852
852
  enumerable: true,
853
853
  configurable: true,
854
854
  value(index) {
855
+ if (!Items$1.has(this) && !lwcRuntimeFlags.ENABLE_LEGACY_ITEM_POLYFILL) {
856
+ throw new TypeError('Cannot call "item" on object that is not a NodeList.');
857
+ }
855
858
  return this[index];
856
859
  },
857
860
  },
@@ -1032,6 +1035,9 @@ StaticHTMLCollection.prototype = create(HTMLCollection.prototype, {
1032
1035
  enumerable: true,
1033
1036
  configurable: true,
1034
1037
  value(index) {
1038
+ if (!Items.has(this) && !lwcRuntimeFlags.ENABLE_LEGACY_ITEM_POLYFILL) {
1039
+ throw new TypeError('Cannot call "item" on object that is not an HTMLCollection.');
1040
+ }
1035
1041
  return this[index];
1036
1042
  },
1037
1043
  },
@@ -1053,7 +1059,7 @@ StaticHTMLCollection.prototype = create(HTMLCollection.prototype, {
1053
1059
  }
1054
1060
  const items = Items.get(this);
1055
1061
  for (let i = 0, len = items.length; i < len; i++) {
1056
- const item = items[len];
1062
+ const item = items[lwcRuntimeFlags.ENABLE_BROKEN_HTML_COLLECTION_NAMED_ITEM ? len : i];
1057
1063
  if (name === getAttribute.call(item, 'id') ||
1058
1064
  name === getAttribute.call(item, 'name')) {
1059
1065
  return item;
@@ -1805,6 +1811,9 @@ function containsPatched(otherNode) {
1805
1811
  return ((compareDocumentPosition.call(host, otherNode) & DOCUMENT_POSITION_CONTAINED_BY) !== 0 &&
1806
1812
  isNodeOwnedBy(host, otherNode));
1807
1813
  }
1814
+ function disallowedGetElementById() {
1815
+ throw new Error(`Disallowed method "getElementById" on ShadowRoot.`);
1816
+ }
1808
1817
  const SyntheticShadowRootDescriptors = {
1809
1818
  constructor: {
1810
1819
  writable: true,
@@ -2196,12 +2205,24 @@ const ParentNodePatchDescriptors = {
2196
2205
  return children.item(children.length - 1) || null;
2197
2206
  },
2198
2207
  },
2208
+ // An accessor, unlike the other stubs, so the flag is read at call time (not at import) and the
2209
+ // setter preserves `root.getElementById = fn`. The flag exposes it as `undefined` so callers
2210
+ // that value-detect it fall back to `querySelector`; default OFF keeps the throwing stub.
2199
2211
  getElementById: {
2200
- writable: true,
2201
2212
  enumerable: true,
2202
2213
  configurable: true,
2203
- value() {
2204
- throw new Error('Disallowed method "getElementById" on ShadowRoot.');
2214
+ get() {
2215
+ return lwcRuntimeFlags.ENABLE_SHADOW_ROOT_UNDEFINED_GET_ELEMENT_BY_ID
2216
+ ? undefined
2217
+ : disallowedGetElementById;
2218
+ },
2219
+ set(value) {
2220
+ defineProperty(this, 'getElementById', {
2221
+ writable: true,
2222
+ enumerable: true,
2223
+ configurable: true,
2224
+ value,
2225
+ });
2205
2226
  },
2206
2227
  },
2207
2228
  querySelector: {
@@ -4338,6 +4359,6 @@ defineProperty(Element.prototype, '$domManual$', {
4338
4359
  },
4339
4360
  configurable: true,
4340
4361
  });
4341
- /** version: 9.3.6 */
4362
+ /** version: 9.4.0 */
4342
4363
  }
4343
4364
  //# sourceMappingURL=index.cjs.map
package/dist/index.js CHANGED
@@ -192,7 +192,7 @@ const KEY__SHADOW_TOKEN_PRIVATE = '$$ShadowTokenKey$$';
192
192
  const KEY__SYNTHETIC_MODE = '$$lwc-synthetic-mode';
193
193
  const KEY__NATIVE_GET_ELEMENT_BY_ID = '$nativeGetElementById$';
194
194
  const KEY__NATIVE_QUERY_SELECTOR_ALL = '$nativeQuerySelectorAll$';
195
- /** version: 9.3.6 */
195
+ /** version: 9.4.0 */
196
196
 
197
197
  /**
198
198
  * Copyright (c) 2026 Salesforce, Inc.
@@ -200,7 +200,7 @@ const KEY__NATIVE_QUERY_SELECTOR_ALL = '$nativeQuerySelectorAll$';
200
200
  if (!globalThis.lwcRuntimeFlags) {
201
201
  Object.defineProperty(globalThis, 'lwcRuntimeFlags', { value: create(null) });
202
202
  }
203
- /** version: 9.3.6 */
203
+ /** version: 9.4.0 */
204
204
 
205
205
  /*
206
206
  * Copyright (c) 2018, salesforce.com, inc.
@@ -850,6 +850,9 @@ StaticNodeList.prototype = create(NodeList.prototype, {
850
850
  enumerable: true,
851
851
  configurable: true,
852
852
  value(index) {
853
+ if (!Items$1.has(this) && !lwcRuntimeFlags.ENABLE_LEGACY_ITEM_POLYFILL) {
854
+ throw new TypeError('Cannot call "item" on object that is not a NodeList.');
855
+ }
853
856
  return this[index];
854
857
  },
855
858
  },
@@ -1030,6 +1033,9 @@ StaticHTMLCollection.prototype = create(HTMLCollection.prototype, {
1030
1033
  enumerable: true,
1031
1034
  configurable: true,
1032
1035
  value(index) {
1036
+ if (!Items.has(this) && !lwcRuntimeFlags.ENABLE_LEGACY_ITEM_POLYFILL) {
1037
+ throw new TypeError('Cannot call "item" on object that is not an HTMLCollection.');
1038
+ }
1033
1039
  return this[index];
1034
1040
  },
1035
1041
  },
@@ -1051,7 +1057,7 @@ StaticHTMLCollection.prototype = create(HTMLCollection.prototype, {
1051
1057
  }
1052
1058
  const items = Items.get(this);
1053
1059
  for (let i = 0, len = items.length; i < len; i++) {
1054
- const item = items[len];
1060
+ const item = items[lwcRuntimeFlags.ENABLE_BROKEN_HTML_COLLECTION_NAMED_ITEM ? len : i];
1055
1061
  if (name === getAttribute.call(item, 'id') ||
1056
1062
  name === getAttribute.call(item, 'name')) {
1057
1063
  return item;
@@ -1803,6 +1809,9 @@ function containsPatched(otherNode) {
1803
1809
  return ((compareDocumentPosition.call(host, otherNode) & DOCUMENT_POSITION_CONTAINED_BY) !== 0 &&
1804
1810
  isNodeOwnedBy(host, otherNode));
1805
1811
  }
1812
+ function disallowedGetElementById() {
1813
+ throw new Error(`Disallowed method "getElementById" on ShadowRoot.`);
1814
+ }
1806
1815
  const SyntheticShadowRootDescriptors = {
1807
1816
  constructor: {
1808
1817
  writable: true,
@@ -2194,12 +2203,24 @@ const ParentNodePatchDescriptors = {
2194
2203
  return children.item(children.length - 1) || null;
2195
2204
  },
2196
2205
  },
2206
+ // An accessor, unlike the other stubs, so the flag is read at call time (not at import) and the
2207
+ // setter preserves `root.getElementById = fn`. The flag exposes it as `undefined` so callers
2208
+ // that value-detect it fall back to `querySelector`; default OFF keeps the throwing stub.
2197
2209
  getElementById: {
2198
- writable: true,
2199
2210
  enumerable: true,
2200
2211
  configurable: true,
2201
- value() {
2202
- throw new Error('Disallowed method "getElementById" on ShadowRoot.');
2212
+ get() {
2213
+ return lwcRuntimeFlags.ENABLE_SHADOW_ROOT_UNDEFINED_GET_ELEMENT_BY_ID
2214
+ ? undefined
2215
+ : disallowedGetElementById;
2216
+ },
2217
+ set(value) {
2218
+ defineProperty(this, 'getElementById', {
2219
+ writable: true,
2220
+ enumerable: true,
2221
+ configurable: true,
2222
+ value,
2223
+ });
2203
2224
  },
2204
2225
  },
2205
2226
  querySelector: {
@@ -4336,6 +4357,6 @@ defineProperty(Element.prototype, '$domManual$', {
4336
4357
  },
4337
4358
  configurable: true,
4338
4359
  });
4339
- /** version: 9.3.6 */
4360
+ /** version: 9.4.0 */
4340
4361
  }
4341
4362
  //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "You can safely modify dependencies, devDependencies, keywords, etc., but other props will be overwritten."
5
5
  ],
6
6
  "name": "@lwc/synthetic-shadow",
7
- "version": "9.3.6",
7
+ "version": "9.4.0",
8
8
  "description": "Synthetic Shadow Root for LWC",
9
9
  "keywords": [
10
10
  "lwc"
@@ -51,8 +51,8 @@
51
51
  }
52
52
  },
53
53
  "devDependencies": {
54
- "@lwc/features": "9.3.6",
55
- "@lwc/shared": "9.3.6"
54
+ "@lwc/features": "9.4.0",
55
+ "@lwc/shared": "9.4.0"
56
56
  },
57
57
  "lwc": {
58
58
  "modules": [