@lwc/synthetic-shadow 9.2.0 → 9.2.2

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
@@ -197,7 +197,7 @@ const KEY__LEGACY_SHADOW_TOKEN_PRIVATE = '$$LegacyShadowTokenKey$$';
197
197
  const KEY__SYNTHETIC_MODE = '$$lwc-synthetic-mode';
198
198
  const KEY__NATIVE_GET_ELEMENT_BY_ID = '$nativeGetElementById$';
199
199
  const KEY__NATIVE_QUERY_SELECTOR_ALL = '$nativeQuerySelectorAll$';
200
- /** version: 9.2.0 */
200
+ /** version: 9.2.2 */
201
201
 
202
202
  /**
203
203
  * Copyright (c) 2026 Salesforce, Inc.
@@ -205,7 +205,7 @@ const KEY__NATIVE_QUERY_SELECTOR_ALL = '$nativeQuerySelectorAll$';
205
205
  if (!globalThis.lwcRuntimeFlags) {
206
206
  Object.defineProperty(globalThis, 'lwcRuntimeFlags', { value: create(null) });
207
207
  }
208
- /** version: 9.2.0 */
208
+ /** version: 9.2.2 */
209
209
 
210
210
  /*
211
211
  * Copyright (c) 2018, salesforce.com, inc.
@@ -3327,11 +3327,31 @@ function innerHTMLGetterPatched() {
3327
3327
  function outerHTMLGetterPatched() {
3328
3328
  return getOuterHTML(this);
3329
3329
  }
3330
+ // Capture the browser's native error message for duplicate attachShadow calls
3331
+ // so the guard below throws an identical error regardless of browser.
3332
+ const nativeAttachShadowErrorMessage = (() => {
3333
+ const el = document.createElement('div');
3334
+ el.attachShadow({ mode: 'open' });
3335
+ try {
3336
+ el.attachShadow({ mode: 'open' });
3337
+ }
3338
+ catch ({ message }) {
3339
+ return message;
3340
+ }
3341
+ return '';
3342
+ })();
3330
3343
  function attachShadowPatched(options) {
3331
3344
  // To retain native behavior of the API, provide synthetic shadowRoot only when specified
3332
3345
  if (options[KEY__SYNTHETIC_MODE]) {
3333
3346
  return attachShadow(this, options);
3334
3347
  }
3348
+ // LWC hosts already use a synthetic shadow root. Without this guard, native
3349
+ // attachShadow would still succeed and attach a second (native) shadow tree,
3350
+ // which violates the one-shadow-per-element model this polyfill assumes and
3351
+ // leaves that subtree on a different patching path than synthetic shadow.
3352
+ if (!lwcRuntimeFlags.DISABLE_HOST_ATTACH_SHADOW_GUARD && hasInternalSlot(this)) {
3353
+ throw new Error(nativeAttachShadowErrorMessage);
3354
+ }
3335
3355
  return attachShadow$1.call(this, options);
3336
3356
  }
3337
3357
  function shadowRootGetterPatched() {
@@ -4362,6 +4382,6 @@ defineProperty(Element.prototype, '$domManual$', {
4362
4382
  },
4363
4383
  configurable: true,
4364
4384
  });
4365
- /** version: 9.2.0 */
4385
+ /** version: 9.2.2 */
4366
4386
  }
4367
4387
  //# sourceMappingURL=index.cjs.map
package/dist/index.js CHANGED
@@ -195,7 +195,7 @@ const KEY__LEGACY_SHADOW_TOKEN_PRIVATE = '$$LegacyShadowTokenKey$$';
195
195
  const KEY__SYNTHETIC_MODE = '$$lwc-synthetic-mode';
196
196
  const KEY__NATIVE_GET_ELEMENT_BY_ID = '$nativeGetElementById$';
197
197
  const KEY__NATIVE_QUERY_SELECTOR_ALL = '$nativeQuerySelectorAll$';
198
- /** version: 9.2.0 */
198
+ /** version: 9.2.2 */
199
199
 
200
200
  /**
201
201
  * Copyright (c) 2026 Salesforce, Inc.
@@ -203,7 +203,7 @@ const KEY__NATIVE_QUERY_SELECTOR_ALL = '$nativeQuerySelectorAll$';
203
203
  if (!globalThis.lwcRuntimeFlags) {
204
204
  Object.defineProperty(globalThis, 'lwcRuntimeFlags', { value: create(null) });
205
205
  }
206
- /** version: 9.2.0 */
206
+ /** version: 9.2.2 */
207
207
 
208
208
  /*
209
209
  * Copyright (c) 2018, salesforce.com, inc.
@@ -3325,11 +3325,31 @@ function innerHTMLGetterPatched() {
3325
3325
  function outerHTMLGetterPatched() {
3326
3326
  return getOuterHTML(this);
3327
3327
  }
3328
+ // Capture the browser's native error message for duplicate attachShadow calls
3329
+ // so the guard below throws an identical error regardless of browser.
3330
+ const nativeAttachShadowErrorMessage = (() => {
3331
+ const el = document.createElement('div');
3332
+ el.attachShadow({ mode: 'open' });
3333
+ try {
3334
+ el.attachShadow({ mode: 'open' });
3335
+ }
3336
+ catch ({ message }) {
3337
+ return message;
3338
+ }
3339
+ return '';
3340
+ })();
3328
3341
  function attachShadowPatched(options) {
3329
3342
  // To retain native behavior of the API, provide synthetic shadowRoot only when specified
3330
3343
  if (options[KEY__SYNTHETIC_MODE]) {
3331
3344
  return attachShadow(this, options);
3332
3345
  }
3346
+ // LWC hosts already use a synthetic shadow root. Without this guard, native
3347
+ // attachShadow would still succeed and attach a second (native) shadow tree,
3348
+ // which violates the one-shadow-per-element model this polyfill assumes and
3349
+ // leaves that subtree on a different patching path than synthetic shadow.
3350
+ if (!lwcRuntimeFlags.DISABLE_HOST_ATTACH_SHADOW_GUARD && hasInternalSlot(this)) {
3351
+ throw new Error(nativeAttachShadowErrorMessage);
3352
+ }
3333
3353
  return attachShadow$1.call(this, options);
3334
3354
  }
3335
3355
  function shadowRootGetterPatched() {
@@ -4360,6 +4380,6 @@ defineProperty(Element.prototype, '$domManual$', {
4360
4380
  },
4361
4381
  configurable: true,
4362
4382
  });
4363
- /** version: 9.2.0 */
4383
+ /** version: 9.2.2 */
4364
4384
  }
4365
4385
  //# 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.2.0",
7
+ "version": "9.2.2",
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.2.0",
55
- "@lwc/shared": "9.2.0"
54
+ "@lwc/features": "9.2.2",
55
+ "@lwc/shared": "9.2.2"
56
56
  },
57
57
  "lwc": {
58
58
  "modules": [