lwc 2.35.0 → 2.35.1

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 +48 -121
  2. package/dist/engine-dom/iife/es2017/engine-dom.js +48 -121
  3. package/dist/engine-dom/iife/es2017/engine-dom.min.js +1 -1
  4. package/dist/engine-dom/iife/es2017/engine-dom_debug.js +87 -61
  5. package/dist/engine-dom/iife/es5/engine-dom.js +48 -119
  6. package/dist/engine-dom/iife/es5/engine-dom.min.js +1 -1
  7. package/dist/engine-dom/iife/es5/engine-dom_debug.js +89 -60
  8. package/dist/engine-dom/umd/es2017/engine-dom.js +48 -121
  9. package/dist/engine-dom/umd/es2017/engine-dom.min.js +1 -1
  10. package/dist/engine-dom/umd/es2017/engine-dom_debug.js +87 -61
  11. package/dist/engine-dom/umd/es5/engine-dom.js +48 -119
  12. package/dist/engine-dom/umd/es5/engine-dom.min.js +1 -1
  13. package/dist/engine-dom/umd/es5/engine-dom_debug.js +89 -60
  14. package/dist/engine-server/commonjs/es2017/engine-server.js +45 -134
  15. package/dist/engine-server/commonjs/es2017/engine-server.min.js +1 -1
  16. package/dist/engine-server/esm/es2017/engine-server.js +45 -134
  17. package/dist/synthetic-shadow/esm/es2017/synthetic-shadow.js +9 -40
  18. package/dist/synthetic-shadow/iife/es2017/synthetic-shadow.js +9 -40
  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 +9 -38
  22. package/dist/synthetic-shadow/iife/es5/synthetic-shadow.min.js +2 -2
  23. package/dist/synthetic-shadow/iife/es5/synthetic-shadow_debug.js +8 -36
  24. package/dist/synthetic-shadow/umd/es2017/synthetic-shadow.js +9 -40
  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 +9 -38
  28. package/dist/synthetic-shadow/umd/es5/synthetic-shadow.min.js +2 -2
  29. package/dist/synthetic-shadow/umd/es5/synthetic-shadow_debug.js +8 -36
  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
@@ -202,41 +202,11 @@ const ID_REFERENCING_ATTRIBUTES_SET = new Set([
202
202
  * SPDX-License-Identifier: MIT
203
203
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
204
204
  */
205
- // Inspired from: https://mathiasbynens.be/notes/globalthis
206
- const _globalThis = /*@__PURE__*/ (function () {
207
- // On recent browsers, `globalThis` is already defined. In this case return it directly.
208
- if (typeof globalThis === 'object') {
209
- return globalThis;
210
- }
211
- let _globalThis;
212
- try {
213
- // eslint-disable-next-line no-extend-native
214
- Object.defineProperty(Object.prototype, '__magic__', {
215
- get: function () {
216
- return this;
217
- },
218
- configurable: true,
219
- });
220
- // __magic__ is undefined in Safari 10 and IE10 and older.
221
- // @ts-ignore
222
- // eslint-disable-next-line no-undef
223
- _globalThis = __magic__;
224
- // @ts-ignore
225
- delete Object.prototype.__magic__;
226
- }
227
- catch (ex) {
228
- // In IE8, Object.defineProperty only works on DOM objects.
229
- }
230
- finally {
231
- // If the magic above fails for some reason we assume that we are in a legacy browser.
232
- // Assume `window` exists in this case.
233
- if (typeof _globalThis === 'undefined') {
234
- // @ts-ignore
235
- _globalThis = window;
236
- }
237
- }
238
- return _globalThis;
239
- })();
205
+ // See browser support for globalThis:
206
+ // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/globalThis#browser_compatibility
207
+ /* istanbul ignore next */
208
+ // @ts-ignore
209
+ const _globalThis = typeof globalThis === 'object' ? globalThis : window;
240
210
 
241
211
  /*
242
212
  * Copyright (c) 2018, salesforce.com, inc.
@@ -359,9 +329,9 @@ function htmlAttributeToProperty(attrName) {
359
329
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
360
330
  */
361
331
  // Increment whenever the LWC template compiler changes
362
- const LWC_VERSION = "2.35.0";
332
+ const LWC_VERSION = "2.35.1";
363
333
  const LWC_VERSION_COMMENT_REGEX = /\/\*LWC compiler v([\d.]+)\*\/\s*}/;
364
- /** version: 2.35.0 */
334
+ /** version: 2.35.1 */
365
335
 
366
336
  /**
367
337
  * Copyright (C) 2018 salesforce.com, inc.
@@ -414,7 +384,8 @@ function setFeatureFlag(name, value) {
414
384
  console.warn(`Failed to set the value "${value}" for the runtime feature flag "${name}" because it is undefined. Available flags: ${availableFlags}.`);
415
385
  return;
416
386
  }
417
- if (process.env.NODE_ENV !== 'production') {
387
+ // This may seem redundant, but `process.env.NODE_ENV === 'test-karma-lwc'` is replaced by Karma tests
388
+ if (process.env.NODE_ENV === 'test-karma-lwc' || process.env.NODE_ENV !== 'production') {
418
389
  // Allow the same flag to be set more than once outside of production to enable testing
419
390
  lwcRuntimeFlags[name] = value;
420
391
  }
@@ -434,11 +405,12 @@ function setFeatureFlag(name, value) {
434
405
  * purposes. It is a no-op when invoked in production mode.
435
406
  */
436
407
  function setFeatureFlagForTest(name, value) {
437
- if (process.env.NODE_ENV !== 'production') {
408
+ // This may seem redundant, but `process.env.NODE_ENV === 'test-karma-lwc'` is replaced by Karma tests
409
+ if (process.env.NODE_ENV === 'test-karma-lwc' || process.env.NODE_ENV !== 'production') {
438
410
  setFeatureFlag(name, value);
439
411
  }
440
412
  }
441
- /** version: 2.35.0 */
413
+ /** version: 2.35.1 */
442
414
 
443
415
  /**
444
416
  * Copyright (C) 2018 salesforce.com, inc.
@@ -502,7 +474,7 @@ function applyAriaReflection(prototype = Element.prototype) {
502
474
  }
503
475
  }
504
476
  }
505
- /** version: 2.35.0 */
477
+ /** version: 2.35.1 */
506
478
 
507
479
  /*
508
480
  * Copyright (c) 2018, salesforce.com, inc.
@@ -523,8 +495,7 @@ if (!lwcRuntimeFlags.DISABLE_ARIA_REFLECTION_POLYFILL) {
523
495
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
524
496
  */
525
497
  // Only used in LWC's Karma tests
526
- // @ts-ignore
527
- if (process.env.NODE_ENV !== 'production' && typeof __karma__ !== 'undefined') {
498
+ if (process.env.NODE_ENV === 'test-karma-lwc') {
528
499
  window.addEventListener('test-dummy-flag', () => {
529
500
  let hasFlag = false;
530
501
  if (lwcRuntimeFlags.DUMMY_TEST_FLAG) {
@@ -548,8 +519,7 @@ if (process.env.NODE_ENV !== 'production' && typeof __karma__ !== 'undefined') {
548
519
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
549
520
  */
550
521
  // Only used in LWC's Karma tests
551
- // @ts-ignore
552
- if (process.env.NODE_ENV !== 'production' && typeof __karma__ !== 'undefined') {
522
+ if (process.env.NODE_ENV === 'test-karma-lwc') {
553
523
  window.addEventListener('test-dummy-flag', () => {
554
524
  let hasFlag = false;
555
525
  if (lwcRuntimeFlags.DUMMY_TEST_FLAG) {
@@ -690,8 +660,8 @@ function addErrorComponentStack(vm, error) {
690
660
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
691
661
  */
692
662
  const alreadyLoggedMessages = new Set();
693
- // @ts-ignore
694
- if (process.env.NODE_ENV !== 'production' && typeof __karma__ !== 'undefined') {
663
+ // Only used in LWC's Karma tests
664
+ if (process.env.NODE_ENV === 'test-karma-lwc') {
695
665
  // @ts-ignore
696
666
  window.__lwcResetAlreadyLoggedMessages = () => {
697
667
  alreadyLoggedMessages.clear();
@@ -940,6 +910,14 @@ function setRefVNode(vm, ref, vnode) {
940
910
  refVNodes[ref] = vnode;
941
911
  }
942
912
  }
913
+ // Throw an error if we're running in prod mode. Ensures code is truly removed from prod mode.
914
+ function assertNotProd() {
915
+ /* istanbul ignore if */
916
+ if (process.env.NODE_ENV === 'production') {
917
+ // this method should never leak to prod
918
+ throw new ReferenceError();
919
+ }
920
+ }
943
921
 
944
922
  /*
945
923
  * Copyright (c) 2020, salesforce.com, inc.
@@ -1145,27 +1123,18 @@ function generateAccessorDescriptor(options) {
1145
1123
  }
1146
1124
  let isDomMutationAllowed = false;
1147
1125
  function unlockDomMutation() {
1148
- if (process.env.NODE_ENV === 'production') {
1149
- // this method should never leak to prod
1150
- throw new ReferenceError();
1151
- }
1126
+ assertNotProd(); // this method should never leak to prod
1152
1127
  isDomMutationAllowed = true;
1153
1128
  }
1154
1129
  function lockDomMutation() {
1155
- if (process.env.NODE_ENV === 'production') {
1156
- // this method should never leak to prod
1157
- throw new ReferenceError();
1158
- }
1130
+ assertNotProd(); // this method should never leak to prod
1159
1131
  isDomMutationAllowed = false;
1160
1132
  }
1161
1133
  function logMissingPortalError(name, type) {
1162
1134
  return logError(`The \`${name}\` ${type} is available only on elements that use the \`lwc:dom="manual"\` directive.`);
1163
1135
  }
1164
1136
  function patchElementWithRestrictions(elm, options) {
1165
- if (process.env.NODE_ENV === 'production') {
1166
- // this method should never leak to prod
1167
- throw new ReferenceError();
1168
- }
1137
+ assertNotProd(); // this method should never leak to prod
1169
1138
  const originalOuterHTMLDescriptor = getPropertyDescriptor(elm, 'outerHTML');
1170
1139
  const descriptors = {
1171
1140
  outerHTML: generateAccessorDescriptor({
@@ -1246,10 +1215,7 @@ function patchElementWithRestrictions(elm, options) {
1246
1215
  defineProperties(elm, descriptors);
1247
1216
  }
1248
1217
  function getShadowRootRestrictionsDescriptors(sr) {
1249
- if (process.env.NODE_ENV === 'production') {
1250
- // this method should never leak to prod
1251
- throw new ReferenceError();
1252
- }
1218
+ assertNotProd(); // this method should never leak to prod
1253
1219
  // Disallowing properties in dev mode only to avoid people doing the wrong
1254
1220
  // thing when using the real shadow root, because if that's the case,
1255
1221
  // the component will not work when running with synthetic shadow.
@@ -1290,10 +1256,7 @@ function getShadowRootRestrictionsDescriptors(sr) {
1290
1256
  // Custom Elements Restrictions:
1291
1257
  // -----------------------------
1292
1258
  function getCustomElementRestrictionsDescriptors(elm) {
1293
- if (process.env.NODE_ENV === 'production') {
1294
- // this method should never leak to prod
1295
- throw new ReferenceError();
1296
- }
1259
+ assertNotProd(); // this method should never leak to prod
1297
1260
  const originalAddEventListener = elm.addEventListener;
1298
1261
  const originalInnerHTMLDescriptor = getPropertyDescriptor(elm, 'innerHTML');
1299
1262
  const originalOuterHTMLDescriptor = getPropertyDescriptor(elm, 'outerHTML');
@@ -1338,10 +1301,7 @@ function getCustomElementRestrictionsDescriptors(elm) {
1338
1301
  };
1339
1302
  }
1340
1303
  function getComponentRestrictionsDescriptors() {
1341
- if (process.env.NODE_ENV === 'production') {
1342
- // this method should never leak to prod
1343
- throw new ReferenceError();
1344
- }
1304
+ assertNotProd(); // this method should never leak to prod
1345
1305
  return {
1346
1306
  tagName: generateAccessorDescriptor({
1347
1307
  get() {
@@ -1355,10 +1315,7 @@ function getComponentRestrictionsDescriptors() {
1355
1315
  };
1356
1316
  }
1357
1317
  function getLightningElementPrototypeRestrictionsDescriptors(proto) {
1358
- if (process.env.NODE_ENV === 'production') {
1359
- // this method should never leak to prod
1360
- throw new ReferenceError();
1361
- }
1318
+ assertNotProd(); // this method should never leak to prod
1362
1319
  const originalDispatchEvent = proto.dispatchEvent;
1363
1320
  const descriptors = {
1364
1321
  dispatchEvent: generateDataDescriptor({
@@ -2072,7 +2029,6 @@ function createBridgeToElementDescriptor(propName, descriptor) {
2072
2029
  }
2073
2030
  };
2074
2031
  }
2075
- const EMPTY_REFS = freeze(create(null));
2076
2032
  const refsCache = new WeakMap();
2077
2033
  /**
2078
2034
  * This class is the base class for any LWC element.
@@ -2360,7 +2316,6 @@ LightningElement.prototype = {
2360
2316
  }
2361
2317
  const {
2362
2318
  refVNodes,
2363
- hasRefVNodes,
2364
2319
  cmpTemplate
2365
2320
  } = vm;
2366
2321
  // If the `cmpTemplate` is null, that means that the template has not been rendered yet. Most likely this occurs
@@ -2374,15 +2329,9 @@ LightningElement.prototype = {
2374
2329
  // were introduced, we return undefined if the template has no refs defined
2375
2330
  // anywhere. This fixes components that may want to add an expando called `refs`
2376
2331
  // and are checking if it exists with `if (this.refs)` before adding it.
2377
- // Note it is not sufficient to just check if `refVNodes` is null or empty,
2378
- // because a template may have `lwc:ref` defined within a falsy `if:true` block.
2379
- if (!hasRefVNodes) {
2380
- return;
2381
- }
2382
- // For templates that are using `lwc:ref`, if there are no refs currently available
2383
- // (e.g. refs inside of a falsy `if:true` block), we return an empty object.
2332
+ // Note we use a null refVNodes to indicate that the template has no refs defined.
2384
2333
  if (isNull(refVNodes)) {
2385
- return EMPTY_REFS;
2334
+ return;
2386
2335
  }
2387
2336
  // The refNodes can be cached based on the refVNodes, since the refVNodes
2388
2337
  // are recreated from scratch every time the template is rendered.
@@ -3197,8 +3146,8 @@ function getDecoratorsMeta(Ctor) {
3197
3146
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
3198
3147
  */
3199
3148
  let warned = false;
3200
- // @ts-ignore
3201
- if (process.env.NODE_ENV !== 'production' && typeof __karma__ !== 'undefined') {
3149
+ // Only used in LWC's Karma tests
3150
+ if (process.env.NODE_ENV === 'test-karma-lwc') {
3202
3151
  // @ts-ignore
3203
3152
  window.__lwcResetWarnedOnVersionMismatch = () => {
3204
3153
  warned = false;
@@ -3494,10 +3443,7 @@ function rehydrateHotComponent(Ctor) {
3494
3443
  return canRefreshAllInstances;
3495
3444
  }
3496
3445
  function getTemplateOrSwappedTemplate(tpl) {
3497
- if (process.env.NODE_ENV === 'production') {
3498
- // this method should never leak to prod
3499
- throw new ReferenceError();
3500
- }
3446
+ assertNotProd(); // this method should never leak to prod
3501
3447
  const visited = new Set();
3502
3448
  while (swappedTemplateMap.has(tpl) && !visited.has(tpl)) {
3503
3449
  visited.add(tpl);
@@ -3506,10 +3452,7 @@ function getTemplateOrSwappedTemplate(tpl) {
3506
3452
  return tpl;
3507
3453
  }
3508
3454
  function getComponentOrSwappedComponent(Ctor) {
3509
- if (process.env.NODE_ENV === 'production') {
3510
- // this method should never leak to prod
3511
- throw new ReferenceError();
3512
- }
3455
+ assertNotProd(); // this method should never leak to prod
3513
3456
  const visited = new Set();
3514
3457
  while (swappedComponentMap.has(Ctor) && !visited.has(Ctor)) {
3515
3458
  visited.add(Ctor);
@@ -3518,10 +3461,7 @@ function getComponentOrSwappedComponent(Ctor) {
3518
3461
  return Ctor;
3519
3462
  }
3520
3463
  function getStyleOrSwappedStyle(style) {
3521
- if (process.env.NODE_ENV === 'production') {
3522
- // this method should never leak to prod
3523
- throw new ReferenceError();
3524
- }
3464
+ assertNotProd(); // this method should never leak to prod
3525
3465
  const visited = new Set();
3526
3466
  while (swappedStyleMap.has(style) && !visited.has(style)) {
3527
3467
  visited.add(style);
@@ -3530,10 +3470,7 @@ function getStyleOrSwappedStyle(style) {
3530
3470
  return style;
3531
3471
  }
3532
3472
  function setActiveVM(vm) {
3533
- if (process.env.NODE_ENV === 'production') {
3534
- // this method should never leak to prod
3535
- throw new ReferenceError();
3536
- }
3473
+ assertNotProd(); // this method should never leak to prod
3537
3474
  // tracking active component
3538
3475
  const Ctor = vm.def.ctor;
3539
3476
  let componentVMs = activeComponents.get(Ctor);
@@ -3576,10 +3513,7 @@ function setActiveVM(vm) {
3576
3513
  }
3577
3514
  }
3578
3515
  function removeActiveVM(vm) {
3579
- if (process.env.NODE_ENV === 'production') {
3580
- // this method should never leak to prod
3581
- throw new ReferenceError();
3582
- }
3516
+ assertNotProd(); // this method should never leak to prod
3583
3517
  // tracking inactive component
3584
3518
  const Ctor = vm.def.ctor;
3585
3519
  let list = activeComponents.get(Ctor);
@@ -5752,10 +5686,7 @@ function setVMBeingRendered(vm) {
5752
5686
  vmBeingRendered = vm;
5753
5687
  }
5754
5688
  function validateSlots(vm, html) {
5755
- if (process.env.NODE_ENV === 'production') {
5756
- // this method should never leak to prod
5757
- throw new ReferenceError();
5758
- }
5689
+ assertNotProd(); // this method should never leak to prod
5759
5690
  const { cmpSlots } = vm;
5760
5691
  const { slots = EmptyArray } = html;
5761
5692
  for (const slotName in cmpSlots.slotAssignments) {
@@ -5889,9 +5820,7 @@ function evaluateTemplate(vm, html) {
5889
5820
  setActiveVM(vm);
5890
5821
  }
5891
5822
  // reset the refs; they will be set during the tmpl() instantiation
5892
- const hasRefVNodes = Boolean(html.hasRefs);
5893
- vm.hasRefVNodes = hasRefVNodes;
5894
- vm.refVNodes = hasRefVNodes ? create(null) : null;
5823
+ vm.refVNodes = html.hasRefs ? create(null) : null;
5895
5824
  // right before producing the vnodes, we clear up all internal references
5896
5825
  // to custom elements from the template.
5897
5826
  vm.velements = [];
@@ -6078,7 +6007,7 @@ function markComponentAsDirty(vm) {
6078
6007
  const cmpEventListenerMap = new WeakMap();
6079
6008
  function getWrappedComponentsListener(vm, listener) {
6080
6009
  if (!isFunction$1(listener)) {
6081
- throw new TypeError(); // avoiding problems with non-valid listeners
6010
+ throw new TypeError('Expected an EventListener but received ' + typeof listener); // avoiding problems with non-valid listeners
6082
6011
  }
6083
6012
  let wrappedListener = cmpEventListenerMap.get(listener);
6084
6013
  if (isUndefined$1(wrappedListener)) {
@@ -6223,7 +6152,6 @@ function createVM(elm, ctor, renderer, options) {
6223
6152
  mode,
6224
6153
  owner,
6225
6154
  refVNodes: null,
6226
- hasRefVNodes: false,
6227
6155
  children: EmptyArray,
6228
6156
  aChildren: EmptyArray,
6229
6157
  velements: EmptyArray,
@@ -7491,7 +7419,7 @@ function getComponentConstructor(elm) {
7491
7419
  }
7492
7420
  return ctor;
7493
7421
  }
7494
- /* version: 2.35.0 */
7422
+ /* version: 2.35.1 */
7495
7423
 
7496
7424
  /*
7497
7425
  * Copyright (c) 2018, salesforce.com, inc.
@@ -7599,8 +7527,7 @@ const stylesheetCache = new Map();
7599
7527
  // Test utilities
7600
7528
  //
7601
7529
  // Only used in LWC's Karma tests
7602
- // @ts-ignore
7603
- if (process.env.NODE_ENV !== 'production' && typeof __karma__ !== 'undefined') {
7530
+ if (process.env.NODE_ENV === 'test-karma-lwc') {
7604
7531
  // @ts-ignore
7605
7532
  window.__lwcResetGlobalStylesheets = () => {
7606
7533
  stylesheetCache.clear();
@@ -8466,7 +8393,7 @@ function rendererFactory(baseRenderer) {
8466
8393
  function isNull(obj) {
8467
8394
  return obj === null;
8468
8395
  }
8469
- /** version: 2.35.0 */
8396
+ /** version: 2.35.1 */
8470
8397
 
8471
8398
  /*
8472
8399
  * Copyright (c) 2018, salesforce.com, inc.
@@ -9027,6 +8954,6 @@ defineProperty(LightningElement, 'CustomElementConstructor', {
9027
8954
  });
9028
8955
  freeze(LightningElement);
9029
8956
  seal(LightningElement.prototype);
9030
- /* version: 2.35.0 */
8957
+ /* version: 2.35.1 */
9031
8958
 
9032
8959
  export { LightningElement, profilerControl as __unstable__ProfilerControl, reportingControl as __unstable__ReportingControl, api$1 as api, deprecatedBuildCustomElementConstructor as buildCustomElementConstructor, createContextProvider, createElement, freezeTemplate, getComponentConstructor, getComponentDef, hydrateComponent, isComponentConstructor, isNodeShadowed as isNodeFromTemplate, parseFragment, parseSVGFragment, readonly, register, registerComponent, registerDecorators, registerTemplate, renderer, rendererFactory, sanitizeAttribute, setFeatureFlag, setFeatureFlagForTest, setHooks, swapComponent, swapStyle, swapTemplate, track, unwrap, wire };