lwc 2.35.0 → 2.35.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.
Files changed (39) hide show
  1. package/dist/engine-dom/esm/es2017/engine-dom.js +61 -134
  2. package/dist/engine-dom/iife/es2017/engine-dom.js +61 -134
  3. package/dist/engine-dom/iife/es2017/engine-dom.min.js +1 -1
  4. package/dist/engine-dom/iife/es2017/engine-dom_debug.js +100 -74
  5. package/dist/engine-dom/iife/es5/engine-dom.js +249 -327
  6. package/dist/engine-dom/iife/es5/engine-dom.min.js +1 -1
  7. package/dist/engine-dom/iife/es5/engine-dom_debug.js +266 -244
  8. package/dist/engine-dom/umd/es2017/engine-dom.js +61 -134
  9. package/dist/engine-dom/umd/es2017/engine-dom.min.js +1 -1
  10. package/dist/engine-dom/umd/es2017/engine-dom_debug.js +100 -74
  11. package/dist/engine-dom/umd/es5/engine-dom.js +249 -327
  12. package/dist/engine-dom/umd/es5/engine-dom.min.js +1 -1
  13. package/dist/engine-dom/umd/es5/engine-dom_debug.js +266 -244
  14. package/dist/engine-server/commonjs/es2017/engine-server.js +47 -136
  15. package/dist/engine-server/commonjs/es2017/engine-server.min.js +1 -1
  16. package/dist/engine-server/esm/es2017/engine-server.js +47 -136
  17. package/dist/synthetic-shadow/esm/es2017/synthetic-shadow.js +11 -42
  18. package/dist/synthetic-shadow/iife/es2017/synthetic-shadow.js +11 -42
  19. package/dist/synthetic-shadow/iife/es2017/synthetic-shadow.min.js +2 -2
  20. package/dist/synthetic-shadow/iife/es2017/synthetic-shadow_debug.js +8 -38
  21. package/dist/synthetic-shadow/iife/es5/synthetic-shadow.js +15 -44
  22. package/dist/synthetic-shadow/iife/es5/synthetic-shadow.min.js +2 -2
  23. package/dist/synthetic-shadow/iife/es5/synthetic-shadow_debug.js +12 -40
  24. package/dist/synthetic-shadow/umd/es2017/synthetic-shadow.js +11 -42
  25. package/dist/synthetic-shadow/umd/es2017/synthetic-shadow.min.js +2 -2
  26. package/dist/synthetic-shadow/umd/es2017/synthetic-shadow_debug.js +8 -38
  27. package/dist/synthetic-shadow/umd/es5/synthetic-shadow.js +15 -44
  28. package/dist/synthetic-shadow/umd/es5/synthetic-shadow.min.js +2 -2
  29. package/dist/synthetic-shadow/umd/es5/synthetic-shadow_debug.js +12 -40
  30. package/dist/wire-service/esm/es2017/wire-service.js +2 -2
  31. package/dist/wire-service/iife/es2017/wire-service.js +2 -2
  32. package/dist/wire-service/iife/es2017/wire-service_debug.js +2 -2
  33. package/dist/wire-service/iife/es5/wire-service.js +2 -2
  34. package/dist/wire-service/iife/es5/wire-service_debug.js +2 -2
  35. package/dist/wire-service/umd/es2017/wire-service.js +2 -2
  36. package/dist/wire-service/umd/es2017/wire-service_debug.js +2 -2
  37. package/dist/wire-service/umd/es5/wire-service.js +2 -2
  38. package/dist/wire-service/umd/es5/wire-service_debug.js +2 -2
  39. package/package.json +7 -7
@@ -31,10 +31,10 @@ function fail(msg) {
31
31
 
32
32
  var assert = /*#__PURE__*/Object.freeze({
33
33
  __proto__: null,
34
+ fail: fail,
34
35
  invariant: invariant,
35
- isTrue: isTrue$1,
36
36
  isFalse: isFalse$1,
37
- fail: fail
37
+ isTrue: isTrue$1
38
38
  });
39
39
 
40
40
  /*
@@ -194,47 +194,15 @@ function isAriaAttribute(attrName) {
194
194
  * SPDX-License-Identifier: MIT
195
195
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
196
196
  */
197
- // Inspired from: https://mathiasbynens.be/notes/globalthis
198
- const _globalThis = /*@__PURE__*/ (function () {
199
- // On recent browsers, `globalThis` is already defined. In this case return it directly.
200
- if (typeof globalThis === 'object') {
201
- return globalThis;
202
- }
203
- let _globalThis;
204
- try {
205
- // eslint-disable-next-line no-extend-native
206
- Object.defineProperty(Object.prototype, '__magic__', {
207
- get: function () {
208
- return this;
209
- },
210
- configurable: true,
211
- });
212
- // __magic__ is undefined in Safari 10 and IE10 and older.
213
- // @ts-ignore
214
- // eslint-disable-next-line no-undef
215
- _globalThis = __magic__;
216
- // @ts-ignore
217
- delete Object.prototype.__magic__;
218
- }
219
- catch (ex) {
220
- // In IE8, Object.defineProperty only works on DOM objects.
221
- }
222
- finally {
223
- // If the magic above fails for some reason we assume that we are in a legacy browser.
224
- // Assume `window` exists in this case.
225
- if (typeof _globalThis === 'undefined') {
226
- // @ts-ignore
227
- _globalThis = window;
228
- }
229
- }
230
- return _globalThis;
231
- })();
197
+ // See browser support for globalThis:
198
+ // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/globalThis#browser_compatibility
199
+ /* istanbul ignore next */
200
+ // @ts-ignore
201
+ const _globalThis = typeof globalThis === 'object' ? globalThis : window;
232
202
  const KEY__SHADOW_RESOLVER = '$shadowResolver$';
233
203
  const KEY__SHADOW_STATIC = '$shadowStaticNode$';
234
204
  const KEY__SYNTHETIC_MODE = '$$lwc-synthetic-mode';
235
205
  const KEY__SCOPED_CSS = '$scoped$';
236
- const KEY__NATIVE_GET_ELEMENT_BY_ID = '$nativeGetElementById$';
237
- const KEY__NATIVE_QUERY_SELECTOR_ALL = '$nativeQuerySelectorAll$';
238
206
 
239
207
  /*
240
208
  * Copyright (c) 2022, salesforce.com, inc.
@@ -474,9 +442,9 @@ function htmlEscape(str, attrMode = false) {
474
442
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
475
443
  */
476
444
  // Increment whenever the LWC template compiler changes
477
- const LWC_VERSION = "2.35.0";
445
+ const LWC_VERSION = "2.35.2";
478
446
  const LWC_VERSION_COMMENT_REGEX = /\/\*LWC compiler v([\d.]+)\*\/\s*}/;
479
- /** version: 2.35.0 */
447
+ /** version: 2.35.2 */
480
448
 
481
449
  /*
482
450
  * Copyright (c) 2020, salesforce.com, inc.
@@ -561,7 +529,8 @@ function setFeatureFlag(name, value) {
561
529
  console.warn(`Failed to set the value "${value}" for the runtime feature flag "${name}" because it is undefined. Available flags: ${availableFlags}.`);
562
530
  return;
563
531
  }
564
- if (process.env.NODE_ENV !== 'production') {
532
+ // This may seem redundant, but `process.env.NODE_ENV === 'test-karma-lwc'` is replaced by Karma tests
533
+ if (process.env.NODE_ENV === 'test-karma-lwc' || process.env.NODE_ENV !== 'production') {
565
534
  // Allow the same flag to be set more than once outside of production to enable testing
566
535
  lwcRuntimeFlags[name] = value;
567
536
  }
@@ -581,11 +550,12 @@ function setFeatureFlag(name, value) {
581
550
  * purposes. It is a no-op when invoked in production mode.
582
551
  */
583
552
  function setFeatureFlagForTest(name, value) {
584
- if (process.env.NODE_ENV !== 'production') {
553
+ // This may seem redundant, but `process.env.NODE_ENV === 'test-karma-lwc'` is replaced by Karma tests
554
+ if (process.env.NODE_ENV === 'test-karma-lwc' || process.env.NODE_ENV !== 'production') {
585
555
  setFeatureFlag(name, value);
586
556
  }
587
557
  }
588
- /** version: 2.35.0 */
558
+ /** version: 2.35.2 */
589
559
 
590
560
  /**
591
561
  * Copyright (C) 2018 salesforce.com, inc.
@@ -649,7 +619,7 @@ function applyAriaReflection(prototype = Element.prototype) {
649
619
  }
650
620
  }
651
621
  }
652
- /** version: 2.35.0 */
622
+ /** version: 2.35.2 */
653
623
 
654
624
  /* proxy-compat-disable */
655
625
 
@@ -660,8 +630,7 @@ function applyAriaReflection(prototype = Element.prototype) {
660
630
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
661
631
  */
662
632
  // Only used in LWC's Karma tests
663
- // @ts-ignore
664
- if (process.env.NODE_ENV !== 'production' && typeof __karma__ !== 'undefined') {
633
+ if (process.env.NODE_ENV === 'test-karma-lwc') {
665
634
  window.addEventListener('test-dummy-flag', () => {
666
635
  let hasFlag = false;
667
636
  if (lwcRuntimeFlags.DUMMY_TEST_FLAG) {
@@ -730,8 +699,8 @@ function addErrorComponentStack(vm, error) {
730
699
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
731
700
  */
732
701
  const alreadyLoggedMessages = new Set();
733
- // @ts-ignore
734
- if (process.env.NODE_ENV !== 'production' && typeof __karma__ !== 'undefined') {
702
+ // Only used in LWC's Karma tests
703
+ if (process.env.NODE_ENV === 'test-karma-lwc') {
735
704
  // @ts-ignore
736
705
  window.__lwcResetAlreadyLoggedMessages = () => {
737
706
  alreadyLoggedMessages.clear();
@@ -846,6 +815,14 @@ function setRefVNode(vm, ref, vnode) {
846
815
  refVNodes[ref] = vnode;
847
816
  }
848
817
  }
818
+ // Throw an error if we're running in prod mode. Ensures code is truly removed from prod mode.
819
+ function assertNotProd() {
820
+ /* istanbul ignore if */
821
+ if (process.env.NODE_ENV === 'production') {
822
+ // this method should never leak to prod
823
+ throw new ReferenceError();
824
+ }
825
+ }
849
826
 
850
827
  /*
851
828
  * Copyright (c) 2020, salesforce.com, inc.
@@ -1051,27 +1028,18 @@ function generateAccessorDescriptor(options) {
1051
1028
  }
1052
1029
  let isDomMutationAllowed = false;
1053
1030
  function unlockDomMutation() {
1054
- if (process.env.NODE_ENV === 'production') {
1055
- // this method should never leak to prod
1056
- throw new ReferenceError();
1057
- }
1031
+ assertNotProd(); // this method should never leak to prod
1058
1032
  isDomMutationAllowed = true;
1059
1033
  }
1060
1034
  function lockDomMutation() {
1061
- if (process.env.NODE_ENV === 'production') {
1062
- // this method should never leak to prod
1063
- throw new ReferenceError();
1064
- }
1035
+ assertNotProd(); // this method should never leak to prod
1065
1036
  isDomMutationAllowed = false;
1066
1037
  }
1067
1038
  function logMissingPortalError(name, type) {
1068
1039
  return logError(`The \`${name}\` ${type} is available only on elements that use the \`lwc:dom="manual"\` directive.`);
1069
1040
  }
1070
1041
  function patchElementWithRestrictions(elm, options) {
1071
- if (process.env.NODE_ENV === 'production') {
1072
- // this method should never leak to prod
1073
- throw new ReferenceError();
1074
- }
1042
+ assertNotProd(); // this method should never leak to prod
1075
1043
  const originalOuterHTMLDescriptor = getPropertyDescriptor(elm, 'outerHTML');
1076
1044
  const descriptors = {
1077
1045
  outerHTML: generateAccessorDescriptor({
@@ -1152,10 +1120,7 @@ function patchElementWithRestrictions(elm, options) {
1152
1120
  defineProperties(elm, descriptors);
1153
1121
  }
1154
1122
  function getShadowRootRestrictionsDescriptors(sr) {
1155
- if (process.env.NODE_ENV === 'production') {
1156
- // this method should never leak to prod
1157
- throw new ReferenceError();
1158
- }
1123
+ assertNotProd(); // this method should never leak to prod
1159
1124
  // Disallowing properties in dev mode only to avoid people doing the wrong
1160
1125
  // thing when using the real shadow root, because if that's the case,
1161
1126
  // the component will not work when running with synthetic shadow.
@@ -1196,10 +1161,7 @@ function getShadowRootRestrictionsDescriptors(sr) {
1196
1161
  // Custom Elements Restrictions:
1197
1162
  // -----------------------------
1198
1163
  function getCustomElementRestrictionsDescriptors(elm) {
1199
- if (process.env.NODE_ENV === 'production') {
1200
- // this method should never leak to prod
1201
- throw new ReferenceError();
1202
- }
1164
+ assertNotProd(); // this method should never leak to prod
1203
1165
  const originalAddEventListener = elm.addEventListener;
1204
1166
  const originalInnerHTMLDescriptor = getPropertyDescriptor(elm, 'innerHTML');
1205
1167
  const originalOuterHTMLDescriptor = getPropertyDescriptor(elm, 'outerHTML');
@@ -1244,10 +1206,7 @@ function getCustomElementRestrictionsDescriptors(elm) {
1244
1206
  };
1245
1207
  }
1246
1208
  function getComponentRestrictionsDescriptors() {
1247
- if (process.env.NODE_ENV === 'production') {
1248
- // this method should never leak to prod
1249
- throw new ReferenceError();
1250
- }
1209
+ assertNotProd(); // this method should never leak to prod
1251
1210
  return {
1252
1211
  tagName: generateAccessorDescriptor({
1253
1212
  get() {
@@ -1261,10 +1220,7 @@ function getComponentRestrictionsDescriptors() {
1261
1220
  };
1262
1221
  }
1263
1222
  function getLightningElementPrototypeRestrictionsDescriptors(proto) {
1264
- if (process.env.NODE_ENV === 'production') {
1265
- // this method should never leak to prod
1266
- throw new ReferenceError();
1267
- }
1223
+ assertNotProd(); // this method should never leak to prod
1268
1224
  const originalDispatchEvent = proto.dispatchEvent;
1269
1225
  const descriptors = {
1270
1226
  dispatchEvent: generateDataDescriptor({
@@ -1969,7 +1925,6 @@ function createBridgeToElementDescriptor(propName, descriptor) {
1969
1925
  }
1970
1926
  };
1971
1927
  }
1972
- const EMPTY_REFS = freeze(create(null));
1973
1928
  const refsCache = new WeakMap();
1974
1929
  /**
1975
1930
  * This class is the base class for any LWC element.
@@ -2256,7 +2211,6 @@ LightningElement.prototype = {
2256
2211
  }
2257
2212
  const {
2258
2213
  refVNodes,
2259
- hasRefVNodes,
2260
2214
  cmpTemplate
2261
2215
  } = vm;
2262
2216
  // If the `cmpTemplate` is null, that means that the template has not been rendered yet. Most likely this occurs
@@ -2270,15 +2224,9 @@ LightningElement.prototype = {
2270
2224
  // were introduced, we return undefined if the template has no refs defined
2271
2225
  // anywhere. This fixes components that may want to add an expando called `refs`
2272
2226
  // and are checking if it exists with `if (this.refs)` before adding it.
2273
- // Note it is not sufficient to just check if `refVNodes` is null or empty,
2274
- // because a template may have `lwc:ref` defined within a falsy `if:true` block.
2275
- if (!hasRefVNodes) {
2276
- return;
2277
- }
2278
- // For templates that are using `lwc:ref`, if there are no refs currently available
2279
- // (e.g. refs inside of a falsy `if:true` block), we return an empty object.
2227
+ // Note we use a null refVNodes to indicate that the template has no refs defined.
2280
2228
  if (isNull(refVNodes)) {
2281
- return EMPTY_REFS;
2229
+ return;
2282
2230
  }
2283
2231
  // The refNodes can be cached based on the refVNodes, since the refVNodes
2284
2232
  // are recreated from scratch every time the template is rendered.
@@ -3077,8 +3025,8 @@ function getDecoratorsMeta(Ctor) {
3077
3025
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
3078
3026
  */
3079
3027
  let warned = false;
3080
- // @ts-ignore
3081
- if (process.env.NODE_ENV !== 'production' && typeof __karma__ !== 'undefined') {
3028
+ // Only used in LWC's Karma tests
3029
+ if (process.env.NODE_ENV === 'test-karma-lwc') {
3082
3030
  // @ts-ignore
3083
3031
  window.__lwcResetWarnedOnVersionMismatch = () => {
3084
3032
  warned = false;
@@ -3300,10 +3248,7 @@ const activeTemplates = new WeakMap();
3300
3248
  const activeComponents = new WeakMap();
3301
3249
  const activeStyles = new WeakMap();
3302
3250
  function getTemplateOrSwappedTemplate(tpl) {
3303
- if (process.env.NODE_ENV === 'production') {
3304
- // this method should never leak to prod
3305
- throw new ReferenceError();
3306
- }
3251
+ assertNotProd(); // this method should never leak to prod
3307
3252
  const visited = new Set();
3308
3253
  while (swappedTemplateMap.has(tpl) && !visited.has(tpl)) {
3309
3254
  visited.add(tpl);
@@ -3312,10 +3257,7 @@ function getTemplateOrSwappedTemplate(tpl) {
3312
3257
  return tpl;
3313
3258
  }
3314
3259
  function getComponentOrSwappedComponent(Ctor) {
3315
- if (process.env.NODE_ENV === 'production') {
3316
- // this method should never leak to prod
3317
- throw new ReferenceError();
3318
- }
3260
+ assertNotProd(); // this method should never leak to prod
3319
3261
  const visited = new Set();
3320
3262
  while (swappedComponentMap.has(Ctor) && !visited.has(Ctor)) {
3321
3263
  visited.add(Ctor);
@@ -3324,10 +3266,7 @@ function getComponentOrSwappedComponent(Ctor) {
3324
3266
  return Ctor;
3325
3267
  }
3326
3268
  function getStyleOrSwappedStyle(style) {
3327
- if (process.env.NODE_ENV === 'production') {
3328
- // this method should never leak to prod
3329
- throw new ReferenceError();
3330
- }
3269
+ assertNotProd(); // this method should never leak to prod
3331
3270
  const visited = new Set();
3332
3271
  while (swappedStyleMap.has(style) && !visited.has(style)) {
3333
3272
  visited.add(style);
@@ -3336,10 +3275,7 @@ function getStyleOrSwappedStyle(style) {
3336
3275
  return style;
3337
3276
  }
3338
3277
  function setActiveVM(vm) {
3339
- if (process.env.NODE_ENV === 'production') {
3340
- // this method should never leak to prod
3341
- throw new ReferenceError();
3342
- }
3278
+ assertNotProd(); // this method should never leak to prod
3343
3279
  // tracking active component
3344
3280
  const Ctor = vm.def.ctor;
3345
3281
  let componentVMs = activeComponents.get(Ctor);
@@ -3382,10 +3318,7 @@ function setActiveVM(vm) {
3382
3318
  }
3383
3319
  }
3384
3320
  function removeActiveVM(vm) {
3385
- if (process.env.NODE_ENV === 'production') {
3386
- // this method should never leak to prod
3387
- throw new ReferenceError();
3388
- }
3321
+ assertNotProd(); // this method should never leak to prod
3389
3322
  // tracking inactive component
3390
3323
  const Ctor = vm.def.ctor;
3391
3324
  let list = activeComponents.get(Ctor);
@@ -5436,10 +5369,7 @@ function setVMBeingRendered(vm) {
5436
5369
  vmBeingRendered = vm;
5437
5370
  }
5438
5371
  function validateSlots(vm, html) {
5439
- if (process.env.NODE_ENV === 'production') {
5440
- // this method should never leak to prod
5441
- throw new ReferenceError();
5442
- }
5372
+ assertNotProd(); // this method should never leak to prod
5443
5373
  const { cmpSlots } = vm;
5444
5374
  const { slots = EmptyArray } = html;
5445
5375
  for (const slotName in cmpSlots.slotAssignments) {
@@ -5568,9 +5498,7 @@ function evaluateTemplate(vm, html) {
5568
5498
  setActiveVM(vm);
5569
5499
  }
5570
5500
  // reset the refs; they will be set during the tmpl() instantiation
5571
- const hasRefVNodes = Boolean(html.hasRefs);
5572
- vm.hasRefVNodes = hasRefVNodes;
5573
- vm.refVNodes = hasRefVNodes ? create(null) : null;
5501
+ vm.refVNodes = html.hasRefs ? create(null) : null;
5574
5502
  // right before producing the vnodes, we clear up all internal references
5575
5503
  // to custom elements from the template.
5576
5504
  vm.velements = [];
@@ -5751,7 +5679,7 @@ function markComponentAsDirty(vm) {
5751
5679
  const cmpEventListenerMap = new WeakMap();
5752
5680
  function getWrappedComponentsListener(vm, listener) {
5753
5681
  if (!isFunction$1(listener)) {
5754
- throw new TypeError(); // avoiding problems with non-valid listeners
5682
+ throw new TypeError('Expected an EventListener but received ' + typeof listener); // avoiding problems with non-valid listeners
5755
5683
  }
5756
5684
  let wrappedListener = cmpEventListenerMap.get(listener);
5757
5685
  if (isUndefined$1(wrappedListener)) {
@@ -5896,7 +5824,6 @@ function createVM(elm, ctor, renderer, options) {
5896
5824
  mode,
5897
5825
  owner,
5898
5826
  refVNodes: null,
5899
- hasRefVNodes: false,
5900
5827
  children: EmptyArray,
5901
5828
  aChildren: EmptyArray,
5902
5829
  velements: EmptyArray,
@@ -6270,22 +6197,6 @@ function runWithBoundaryProtection(vm, owner, pre, job, post) {
6270
6197
  }
6271
6198
  }
6272
6199
 
6273
- /*
6274
- * Copyright (c) 2018, salesforce.com, inc.
6275
- * All rights reserved.
6276
- * SPDX-License-Identifier: MIT
6277
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6278
- */
6279
- //
6280
- // The goal of this code is to detect invalid cross-root ARIA references in synthetic shadow DOM.
6281
- // These invalid references should be fixed before the offending components can be migrated to native shadow DOM.
6282
- // When invalid usage is detected, we warn in dev mode and call the reporting API if enabled.
6283
- // See: https://lwc.dev/guide/accessibility#link-ids-and-aria-attributes-from-different-templates
6284
- //
6285
- // Use the unpatched native getElementById/querySelectorAll rather than the synthetic one
6286
- _globalThis[KEY__NATIVE_GET_ELEMENT_BY_ID];
6287
- _globalThis[KEY__NATIVE_QUERY_SELECTOR_ALL];
6288
-
6289
6200
  /*
6290
6201
  * Copyright (c) 2018, salesforce.com, inc.
6291
6202
  * All rights reserved.
@@ -6530,7 +6441,7 @@ function freezeTemplate(tmpl) {
6530
6441
  }
6531
6442
  }
6532
6443
  }
6533
- /* version: 2.35.0 */
6444
+ /* version: 2.35.2 */
6534
6445
 
6535
6446
  /*
6536
6447
  * Copyright (c) 2020, salesforce.com, inc.
@@ -7001,7 +6912,7 @@ function renderComponent(tagName, Ctor, props = {}) {
7001
6912
  */
7002
6913
  freeze(LightningElement);
7003
6914
  seal(LightningElement.prototype);
7004
- /* version: 2.35.0 */
6915
+ /* version: 2.35.2 */
7005
6916
 
7006
6917
  exports.LightningElement = LightningElement;
7007
6918
  exports.api = api$1;