lwc 2.5.2 → 2.5.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.
Files changed (41) hide show
  1. package/dist/engine-dom/esm/es2017/engine-dom.js +181 -101
  2. package/dist/engine-dom/iife/es2017/engine-dom.js +183 -101
  3. package/dist/engine-dom/iife/es2017/engine-dom.min.js +2 -2
  4. package/dist/engine-dom/iife/es2017/engine-dom_debug.js +163 -82
  5. package/dist/engine-dom/iife/es5/engine-dom.js +211 -108
  6. package/dist/engine-dom/iife/es5/engine-dom.min.js +2 -2
  7. package/dist/engine-dom/iife/es5/engine-dom_debug.js +189 -87
  8. package/dist/engine-dom/umd/es2017/engine-dom.js +184 -102
  9. package/dist/engine-dom/umd/es2017/engine-dom.min.js +2 -2
  10. package/dist/engine-dom/umd/es2017/engine-dom_debug.js +164 -83
  11. package/dist/engine-dom/umd/es5/engine-dom.js +212 -109
  12. package/dist/engine-dom/umd/es5/engine-dom.min.js +2 -2
  13. package/dist/engine-dom/umd/es5/engine-dom_debug.js +190 -88
  14. package/dist/engine-server/commonjs/es2017/engine-server.js +174 -99
  15. package/dist/engine-server/commonjs/es2017/engine-server.min.js +2 -2
  16. package/dist/engine-server/esm/es2017/engine-server.js +173 -100
  17. package/dist/synthetic-shadow/esm/es2017/synthetic-shadow.js +46 -40
  18. package/dist/synthetic-shadow/iife/es2017/synthetic-shadow.js +47 -41
  19. package/dist/synthetic-shadow/iife/es2017/synthetic-shadow.min.js +2 -2
  20. package/dist/synthetic-shadow/iife/es2017/synthetic-shadow_debug.js +46 -40
  21. package/dist/synthetic-shadow/iife/es5/synthetic-shadow.js +47 -41
  22. package/dist/synthetic-shadow/iife/es5/synthetic-shadow.min.js +2 -2
  23. package/dist/synthetic-shadow/iife/es5/synthetic-shadow_debug.js +46 -40
  24. package/dist/synthetic-shadow/umd/es2017/synthetic-shadow.js +48 -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 +47 -41
  27. package/dist/synthetic-shadow/umd/es5/synthetic-shadow.js +48 -42
  28. package/dist/synthetic-shadow/umd/es5/synthetic-shadow.min.js +2 -2
  29. package/dist/synthetic-shadow/umd/es5/synthetic-shadow_debug.js +47 -41
  30. package/dist/wire-service/esm/es2017/wire-service.js +2 -2
  31. package/dist/wire-service/iife/es2017/wire-service.js +3 -3
  32. package/dist/wire-service/iife/es2017/wire-service_debug.js +3 -3
  33. package/dist/wire-service/iife/es5/wire-service.js +3 -3
  34. package/dist/wire-service/iife/es5/wire-service.min.js +1 -1
  35. package/dist/wire-service/iife/es5/wire-service_debug.js +3 -3
  36. package/dist/wire-service/umd/es2017/wire-service.js +4 -4
  37. package/dist/wire-service/umd/es2017/wire-service_debug.js +4 -4
  38. package/dist/wire-service/umd/es5/wire-service.js +4 -4
  39. package/dist/wire-service/umd/es5/wire-service.min.js +1 -1
  40. package/dist/wire-service/umd/es5/wire-service_debug.js +4 -4
  41. package/package.json +8 -8
@@ -2,7 +2,7 @@
2
2
  typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
3
3
  typeof define === 'function' && define.amd ? define(['exports'], factory) :
4
4
  (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.LWC = {}));
5
- }(this, (function (exports) { 'use strict';
5
+ })(this, (function (exports) { 'use strict';
6
6
 
7
7
  /* proxy-compat-disable */
8
8
 
@@ -305,7 +305,7 @@
305
305
  CACHED_PROPERTY_ATTRIBUTE_MAPPING.set(propName, attributeName);
306
306
  return attributeName;
307
307
  }
308
- /** version: 2.5.2 */
308
+ /** version: 2.5.6 */
309
309
 
310
310
  /*
311
311
  * Copyright (c) 2018, salesforce.com, inc.
@@ -415,6 +415,7 @@
415
415
  ENABLE_HMR: null,
416
416
  ENABLE_INNER_OUTER_TEXT_PATCH: null,
417
417
  ENABLE_ELEMENT_PATCH: null,
418
+ ENABLE_FORCE_NATIVE_SHADOW_MODE_FOR_TEST: null,
418
419
  ENABLE_NODE_LIST_PATCH: null,
419
420
  ENABLE_HTML_COLLECTIONS_PATCH: null,
420
421
  ENABLE_NODE_PATCH: null,
@@ -484,7 +485,7 @@
484
485
  setFeatureFlag(name, value);
485
486
  }
486
487
  }
487
- /** version: 2.5.2 */
488
+ /** version: 2.5.6 */
488
489
 
489
490
  /* proxy-compat-disable */
490
491
 
@@ -2856,9 +2857,9 @@
2856
2857
  }
2857
2858
  }
2858
2859
 
2859
- function warnIfInvokedDuringConstruction(vm, methodName) {
2860
+ function warnIfInvokedDuringConstruction(vm, methodOrPropName) {
2860
2861
  if (isBeingConstructed(vm)) {
2861
- logError(`this.${methodName}() should not be called during the construction of the custom element for ${getComponentTag(vm)} because the element is not yet in the DOM or has no children yet.`);
2862
+ logError(`this.${methodOrPropName} should not be called during the construction of the custom element for ${getComponentTag(vm)} because the element is not yet in the DOM or has no children yet.`);
2862
2863
  }
2863
2864
  } // @ts-ignore
2864
2865
 
@@ -3018,76 +3019,12 @@
3018
3019
  } = vm;
3019
3020
 
3020
3021
  if (process.env.NODE_ENV !== 'production') {
3021
- warnIfInvokedDuringConstruction(vm, 'getBoundingClientRect');
3022
+ warnIfInvokedDuringConstruction(vm, 'getBoundingClientRect()');
3022
3023
  }
3023
3024
 
3024
3025
  return getBoundingClientRect(elm);
3025
3026
  },
3026
3027
 
3027
- querySelector(selectors) {
3028
- const vm = getAssociatedVM(this);
3029
- const {
3030
- elm,
3031
- renderer: {
3032
- querySelector
3033
- }
3034
- } = vm;
3035
-
3036
- if (process.env.NODE_ENV !== 'production') {
3037
- warnIfInvokedDuringConstruction(vm, 'querySelector');
3038
- }
3039
-
3040
- return querySelector(elm, selectors);
3041
- },
3042
-
3043
- querySelectorAll(selectors) {
3044
- const vm = getAssociatedVM(this);
3045
- const {
3046
- elm,
3047
- renderer: {
3048
- querySelectorAll
3049
- }
3050
- } = vm;
3051
-
3052
- if (process.env.NODE_ENV !== 'production') {
3053
- warnIfInvokedDuringConstruction(vm, 'querySelectorAll');
3054
- }
3055
-
3056
- return querySelectorAll(elm, selectors);
3057
- },
3058
-
3059
- getElementsByTagName(tagNameOrWildCard) {
3060
- const vm = getAssociatedVM(this);
3061
- const {
3062
- elm,
3063
- renderer: {
3064
- getElementsByTagName
3065
- }
3066
- } = vm;
3067
-
3068
- if (process.env.NODE_ENV !== 'production') {
3069
- warnIfInvokedDuringConstruction(vm, 'getElementsByTagName');
3070
- }
3071
-
3072
- return getElementsByTagName(elm, tagNameOrWildCard);
3073
- },
3074
-
3075
- getElementsByClassName(names) {
3076
- const vm = getAssociatedVM(this);
3077
- const {
3078
- elm,
3079
- renderer: {
3080
- getElementsByClassName
3081
- }
3082
- } = vm;
3083
-
3084
- if (process.env.NODE_ENV !== 'production') {
3085
- warnIfInvokedDuringConstruction(vm, 'getElementsByClassName');
3086
- }
3087
-
3088
- return getElementsByClassName(elm, names);
3089
- },
3090
-
3091
3028
  get isConnected() {
3092
3029
  const {
3093
3030
  elm,
@@ -3147,6 +3084,50 @@
3147
3084
  }
3148
3085
 
3149
3086
  };
3087
+ const queryAndChildGetterDescriptors = create(null);
3088
+ const childGetters = [['children', 'getChildren'], ['childNodes', 'getChildNodes'], ['firstChild', 'getFirstChild'], ['firstElementChild', 'getFirstElementChild'], ['lastChild', 'getLastChild'], ['lastElementChild', 'getLastElementChild']]; // Generic passthrough for child getters on HTMLElement to the relevant Renderer APIs
3089
+
3090
+ for (const [elementProp, rendererMethod] of childGetters) {
3091
+ queryAndChildGetterDescriptors[elementProp] = {
3092
+ get() {
3093
+ const vm = getAssociatedVM(this);
3094
+ const {
3095
+ elm,
3096
+ renderer
3097
+ } = vm;
3098
+
3099
+ if (process.env.NODE_ENV !== 'production') {
3100
+ warnIfInvokedDuringConstruction(vm, elementProp);
3101
+ }
3102
+
3103
+ return renderer[rendererMethod](elm);
3104
+ }
3105
+
3106
+ };
3107
+ }
3108
+
3109
+ const queryMethods = ['getElementsByClassName', 'getElementsByTagName', 'querySelector', 'querySelectorAll']; // Generic passthrough for query APIs on HTMLElement to the relevant Renderer APIs
3110
+
3111
+ for (const queryMethod of queryMethods) {
3112
+ queryAndChildGetterDescriptors[queryMethod] = {
3113
+ value(arg) {
3114
+ const vm = getAssociatedVM(this);
3115
+ const {
3116
+ elm,
3117
+ renderer
3118
+ } = vm;
3119
+
3120
+ if (process.env.NODE_ENV !== 'production') {
3121
+ warnIfInvokedDuringConstruction(vm, `${queryMethod}()`);
3122
+ }
3123
+
3124
+ return renderer[queryMethod](elm, arg);
3125
+ }
3126
+
3127
+ };
3128
+ }
3129
+
3130
+ defineProperties(LightningElement.prototype, queryAndChildGetterDescriptors);
3150
3131
  const lightningBasedDescriptors = create(null);
3151
3132
 
3152
3133
  for (const propName in HTMLElementOriginalDescriptors) {
@@ -3737,15 +3718,14 @@
3737
3718
  return tpl;
3738
3719
  }
3739
3720
  /**
3740
- * EXPERIMENTAL: This function acts like a hook for Lightning Locker
3741
- * Service and other similar libraries to sanitize vulnerable attributes.
3742
- * This API is subject to change or being removed.
3721
+ * EXPERIMENTAL: This function acts like a hook for Lightning Locker Service and other similar
3722
+ * libraries to sanitize vulnerable attributes.
3743
3723
  */
3744
3724
 
3745
3725
 
3746
3726
  function sanitizeAttribute(tagName, namespaceUri, attrName, attrValue) {
3747
- // locker-service patches this function during runtime to sanitize vulnerable attributes.
3748
- // when ran off-core this function becomes a noop and returns the user authored value.
3727
+ // locker-service patches this function during runtime to sanitize vulnerable attributes. When
3728
+ // ran off-core this function becomes a noop and returns the user authored value.
3749
3729
  return attrValue;
3750
3730
  }
3751
3731
  /*
@@ -4866,6 +4846,38 @@
4866
4846
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
4867
4847
  */
4868
4848
 
4849
+ /**
4850
+ * EXPERIMENTAL: This function acts like a hook for Lightning Locker Service and other similar
4851
+ * libraries to sanitize HTML content. This hook process the content passed via the template to
4852
+ * lwc:inner-html directive.
4853
+ * It is meant to be overridden with setSanitizeHtmlContentHook
4854
+ */
4855
+
4856
+
4857
+ let sanitizeHtmlContentHook = () => {
4858
+ // locker-service patches this function during runtime to sanitize HTML content.
4859
+ throw new Error('sanitizeHtmlContent hook must be implemented.');
4860
+ };
4861
+ /**
4862
+ * Sets the sanitizeHtmlContentHook.
4863
+ *
4864
+ * @param newHookImpl
4865
+ * @returns oldHookImplementation.
4866
+ */
4867
+
4868
+
4869
+ function setSanitizeHtmlContentHook(newHookImpl) {
4870
+ const currentHook = sanitizeHtmlContentHook;
4871
+ sanitizeHtmlContentHook = newHookImpl;
4872
+ return currentHook;
4873
+ }
4874
+ /*
4875
+ * Copyright (c) 2018, salesforce.com, inc.
4876
+ * All rights reserved.
4877
+ * SPDX-License-Identifier: MIT
4878
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
4879
+ */
4880
+
4869
4881
 
4870
4882
  const SVG_NAMESPACE = 'http://www.w3.org/2000/svg';
4871
4883
  const SymbolIterator = Symbol.iterator;
@@ -5241,7 +5253,7 @@
5241
5253
  next = iterator.next();
5242
5254
  last = next.done; // template factory logic based on the previous collected value
5243
5255
 
5244
- const vnode = factory(value, j, j === 0, last);
5256
+ const vnode = factory(value, j, j === 0, last === true);
5245
5257
 
5246
5258
  if (isArray$1(vnode)) {
5247
5259
  ArrayPush$1.apply(list, vnode);
@@ -5507,25 +5519,29 @@
5507
5519
 
5508
5520
  markAsDynamicChildren(vnodes);
5509
5521
  return vnodes;
5510
- }
5511
-
5512
- var api = /*#__PURE__*/Object.freeze({
5513
- __proto__: null,
5514
- h: h,
5515
- ti: ti,
5516
- s: s,
5517
- c: c,
5518
- i: i,
5519
- f: f,
5520
- t: t,
5521
- co: co,
5522
- d: d,
5523
- b: b,
5524
- k: k,
5525
- gid: gid,
5526
- fid: fid,
5527
- dc: dc,
5528
- sc: sc
5522
+ } // [s]anitize [h]tml [c]ontent
5523
+
5524
+
5525
+ function shc(content) {
5526
+ return sanitizeHtmlContentHook(content);
5527
+ }
5528
+
5529
+ const api = freeze({
5530
+ s,
5531
+ h,
5532
+ c,
5533
+ i,
5534
+ f,
5535
+ t,
5536
+ d,
5537
+ b,
5538
+ k,
5539
+ co,
5540
+ dc,
5541
+ ti,
5542
+ gid,
5543
+ fid,
5544
+ shc
5529
5545
  });
5530
5546
  /*
5531
5547
  * Copyright (c) 2018, salesforce.com, inc.
@@ -5539,12 +5555,12 @@
5539
5555
  }
5540
5556
 
5541
5557
  function createInlineStyleVNode(content) {
5542
- return h('style', {
5558
+ return api.h('style', {
5543
5559
  key: 'style',
5544
5560
  attrs: {
5545
5561
  type: 'text/css'
5546
5562
  }
5547
- }, [t(content)]);
5563
+ }, [api.t(content)]);
5548
5564
  }
5549
5565
 
5550
5566
  function updateStylesheetToken(vm, template) {
@@ -6443,6 +6459,12 @@
6443
6459
  vm.toString = () => {
6444
6460
  return `[object:vm ${def.name} (${vm.idx})]`;
6445
6461
  };
6462
+
6463
+ if (runtimeFlags.ENABLE_FORCE_NATIVE_SHADOW_MODE_FOR_TEST) {
6464
+ vm.shadowMode = 0
6465
+ /* Native */
6466
+ ;
6467
+ }
6446
6468
  } // Create component instance associated to the vm and the element.
6447
6469
 
6448
6470
 
@@ -7372,7 +7394,38 @@
7372
7394
 
7373
7395
  return reactiveMembrane.getReadOnlyProxy(obj);
7374
7396
  }
7375
- /* version: 2.5.2 */
7397
+ /*
7398
+ * Copyright (c) 2018, salesforce.com, inc.
7399
+ * All rights reserved.
7400
+ * SPDX-License-Identifier: MIT
7401
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
7402
+ */
7403
+
7404
+
7405
+ let hooksAreSet = false;
7406
+
7407
+ function overrideHooks(hooks) {
7408
+ const oldHooks = {};
7409
+
7410
+ if (!isUndefined$1(hooks.sanitizeHtmlContent)) {
7411
+ oldHooks.sanitizeHtmlContent = setSanitizeHtmlContentHook(hooks.sanitizeHtmlContent);
7412
+ }
7413
+
7414
+ return oldHooks;
7415
+ }
7416
+
7417
+ function setHooks(hooks) {
7418
+ assert.isFalse(hooksAreSet, 'Hooks are already overridden, only one definition is allowed.');
7419
+ overrideHooks(hooks);
7420
+ hooksAreSet = true;
7421
+ }
7422
+
7423
+ function setHooksForTest(hooks) {
7424
+ if (process.env.NODE_ENV !== 'production') {
7425
+ return overrideHooks(hooks);
7426
+ }
7427
+ }
7428
+ /* version: 2.5.6 */
7376
7429
 
7377
7430
  /*
7378
7431
  * Copyright (c) 2018, salesforce.com, inc.
@@ -7393,8 +7446,11 @@
7393
7446
  };
7394
7447
  }
7395
7448
 
7396
- const globalStylesheetsParentElement = document.head || document.body || document;
7397
- const supportsConstructableStyleSheets = isFunction$1(CSSStyleSheet.prototype.replaceSync);
7449
+ const globalStylesheetsParentElement = document.head || document.body || document; // This check for constructable stylesheets is similar to Fast's:
7450
+ // https://github.com/microsoft/fast/blob/d49d1ec/packages/web-components/fast-element/src/dom.ts#L51-L53
7451
+ // See also: https://github.com/whatwg/webidl/issues/1027#issuecomment-934510070
7452
+
7453
+ const supportsConstructableStyleSheets = isFunction$1(CSSStyleSheet.prototype.replaceSync) && isArray$1(document.adoptedStyleSheets);
7398
7454
  const styleElements = create(null);
7399
7455
  const styleSheets = create(null);
7400
7456
  const nodesToStyleSheets = new WeakMap();
@@ -7623,6 +7679,30 @@
7623
7679
  return element.getElementsByClassName(names);
7624
7680
  },
7625
7681
 
7682
+ getChildren(element) {
7683
+ return element.children;
7684
+ },
7685
+
7686
+ getChildNodes(element) {
7687
+ return element.childNodes;
7688
+ },
7689
+
7690
+ getFirstChild(element) {
7691
+ return element.firstChild;
7692
+ },
7693
+
7694
+ getFirstElementChild(element) {
7695
+ return element.firstElementChild;
7696
+ },
7697
+
7698
+ getLastChild(element) {
7699
+ return element.lastChild;
7700
+ },
7701
+
7702
+ getLastElementChild(element) {
7703
+ return element.lastElementChild;
7704
+ },
7705
+
7626
7706
  isConnected(node) {
7627
7707
  return node.isConnected;
7628
7708
  },
@@ -7930,7 +8010,7 @@
7930
8010
  });
7931
8011
  freeze(LightningElement);
7932
8012
  seal(LightningElement.prototype);
7933
- /* version: 2.5.2 */
8013
+ /* version: 2.5.6 */
7934
8014
 
7935
8015
  exports.LightningElement = LightningElement;
7936
8016
  exports.__unstable__ProfilerControl = profilerControl;
@@ -7950,6 +8030,8 @@
7950
8030
  exports.sanitizeAttribute = sanitizeAttribute;
7951
8031
  exports.setFeatureFlag = setFeatureFlag;
7952
8032
  exports.setFeatureFlagForTest = setFeatureFlagForTest;
8033
+ exports.setHooks = setHooks;
8034
+ exports.setHooksForTest = setHooksForTest;
7953
8035
  exports.swapComponent = swapComponent;
7954
8036
  exports.swapStyle = swapStyle;
7955
8037
  exports.swapTemplate = swapTemplate;
@@ -7959,4 +8041,4 @@
7959
8041
 
7960
8042
  Object.defineProperty(exports, '__esModule', { value: true });
7961
8043
 
7962
- })));
8044
+ }));