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
@@ -299,7 +299,7 @@ function htmlPropertyToAttribute(propName) {
299
299
  CACHED_PROPERTY_ATTRIBUTE_MAPPING.set(propName, attributeName);
300
300
  return attributeName;
301
301
  }
302
- /** version: 2.5.2 */
302
+ /** version: 2.5.6 */
303
303
 
304
304
  /*
305
305
  * Copyright (c) 2018, salesforce.com, inc.
@@ -409,6 +409,7 @@ const features = {
409
409
  ENABLE_HMR: null,
410
410
  ENABLE_INNER_OUTER_TEXT_PATCH: null,
411
411
  ENABLE_ELEMENT_PATCH: null,
412
+ ENABLE_FORCE_NATIVE_SHADOW_MODE_FOR_TEST: null,
412
413
  ENABLE_NODE_LIST_PATCH: null,
413
414
  ENABLE_HTML_COLLECTIONS_PATCH: null,
414
415
  ENABLE_NODE_PATCH: null,
@@ -478,7 +479,7 @@ function setFeatureFlagForTest(name, value) {
478
479
  setFeatureFlag(name, value);
479
480
  }
480
481
  }
481
- /** version: 2.5.2 */
482
+ /** version: 2.5.6 */
482
483
 
483
484
  /* proxy-compat-disable */
484
485
 
@@ -2850,9 +2851,9 @@ function attachShadow(vm) {
2850
2851
  }
2851
2852
  }
2852
2853
 
2853
- function warnIfInvokedDuringConstruction(vm, methodName) {
2854
+ function warnIfInvokedDuringConstruction(vm, methodOrPropName) {
2854
2855
  if (isBeingConstructed(vm)) {
2855
- 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.`);
2856
+ 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.`);
2856
2857
  }
2857
2858
  } // @ts-ignore
2858
2859
 
@@ -3012,76 +3013,12 @@ LightningElement.prototype = {
3012
3013
  } = vm;
3013
3014
 
3014
3015
  if (process.env.NODE_ENV !== 'production') {
3015
- warnIfInvokedDuringConstruction(vm, 'getBoundingClientRect');
3016
+ warnIfInvokedDuringConstruction(vm, 'getBoundingClientRect()');
3016
3017
  }
3017
3018
 
3018
3019
  return getBoundingClientRect(elm);
3019
3020
  },
3020
3021
 
3021
- querySelector(selectors) {
3022
- const vm = getAssociatedVM(this);
3023
- const {
3024
- elm,
3025
- renderer: {
3026
- querySelector
3027
- }
3028
- } = vm;
3029
-
3030
- if (process.env.NODE_ENV !== 'production') {
3031
- warnIfInvokedDuringConstruction(vm, 'querySelector');
3032
- }
3033
-
3034
- return querySelector(elm, selectors);
3035
- },
3036
-
3037
- querySelectorAll(selectors) {
3038
- const vm = getAssociatedVM(this);
3039
- const {
3040
- elm,
3041
- renderer: {
3042
- querySelectorAll
3043
- }
3044
- } = vm;
3045
-
3046
- if (process.env.NODE_ENV !== 'production') {
3047
- warnIfInvokedDuringConstruction(vm, 'querySelectorAll');
3048
- }
3049
-
3050
- return querySelectorAll(elm, selectors);
3051
- },
3052
-
3053
- getElementsByTagName(tagNameOrWildCard) {
3054
- const vm = getAssociatedVM(this);
3055
- const {
3056
- elm,
3057
- renderer: {
3058
- getElementsByTagName
3059
- }
3060
- } = vm;
3061
-
3062
- if (process.env.NODE_ENV !== 'production') {
3063
- warnIfInvokedDuringConstruction(vm, 'getElementsByTagName');
3064
- }
3065
-
3066
- return getElementsByTagName(elm, tagNameOrWildCard);
3067
- },
3068
-
3069
- getElementsByClassName(names) {
3070
- const vm = getAssociatedVM(this);
3071
- const {
3072
- elm,
3073
- renderer: {
3074
- getElementsByClassName
3075
- }
3076
- } = vm;
3077
-
3078
- if (process.env.NODE_ENV !== 'production') {
3079
- warnIfInvokedDuringConstruction(vm, 'getElementsByClassName');
3080
- }
3081
-
3082
- return getElementsByClassName(elm, names);
3083
- },
3084
-
3085
3022
  get isConnected() {
3086
3023
  const {
3087
3024
  elm,
@@ -3141,6 +3078,50 @@ LightningElement.prototype = {
3141
3078
  }
3142
3079
 
3143
3080
  };
3081
+ const queryAndChildGetterDescriptors = create(null);
3082
+ 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
3083
+
3084
+ for (const [elementProp, rendererMethod] of childGetters) {
3085
+ queryAndChildGetterDescriptors[elementProp] = {
3086
+ get() {
3087
+ const vm = getAssociatedVM(this);
3088
+ const {
3089
+ elm,
3090
+ renderer
3091
+ } = vm;
3092
+
3093
+ if (process.env.NODE_ENV !== 'production') {
3094
+ warnIfInvokedDuringConstruction(vm, elementProp);
3095
+ }
3096
+
3097
+ return renderer[rendererMethod](elm);
3098
+ }
3099
+
3100
+ };
3101
+ }
3102
+
3103
+ const queryMethods = ['getElementsByClassName', 'getElementsByTagName', 'querySelector', 'querySelectorAll']; // Generic passthrough for query APIs on HTMLElement to the relevant Renderer APIs
3104
+
3105
+ for (const queryMethod of queryMethods) {
3106
+ queryAndChildGetterDescriptors[queryMethod] = {
3107
+ value(arg) {
3108
+ const vm = getAssociatedVM(this);
3109
+ const {
3110
+ elm,
3111
+ renderer
3112
+ } = vm;
3113
+
3114
+ if (process.env.NODE_ENV !== 'production') {
3115
+ warnIfInvokedDuringConstruction(vm, `${queryMethod}()`);
3116
+ }
3117
+
3118
+ return renderer[queryMethod](elm, arg);
3119
+ }
3120
+
3121
+ };
3122
+ }
3123
+
3124
+ defineProperties(LightningElement.prototype, queryAndChildGetterDescriptors);
3144
3125
  const lightningBasedDescriptors = create(null);
3145
3126
 
3146
3127
  for (const propName in HTMLElementOriginalDescriptors) {
@@ -3731,15 +3712,14 @@ function registerTemplate(tpl) {
3731
3712
  return tpl;
3732
3713
  }
3733
3714
  /**
3734
- * EXPERIMENTAL: This function acts like a hook for Lightning Locker
3735
- * Service and other similar libraries to sanitize vulnerable attributes.
3736
- * This API is subject to change or being removed.
3715
+ * EXPERIMENTAL: This function acts like a hook for Lightning Locker Service and other similar
3716
+ * libraries to sanitize vulnerable attributes.
3737
3717
  */
3738
3718
 
3739
3719
 
3740
3720
  function sanitizeAttribute(tagName, namespaceUri, attrName, attrValue) {
3741
- // locker-service patches this function during runtime to sanitize vulnerable attributes.
3742
- // when ran off-core this function becomes a noop and returns the user authored value.
3721
+ // locker-service patches this function during runtime to sanitize vulnerable attributes. When
3722
+ // ran off-core this function becomes a noop and returns the user authored value.
3743
3723
  return attrValue;
3744
3724
  }
3745
3725
  /*
@@ -4860,6 +4840,38 @@ function getUpgradableConstructor(tagName, renderer) {
4860
4840
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
4861
4841
  */
4862
4842
 
4843
+ /**
4844
+ * EXPERIMENTAL: This function acts like a hook for Lightning Locker Service and other similar
4845
+ * libraries to sanitize HTML content. This hook process the content passed via the template to
4846
+ * lwc:inner-html directive.
4847
+ * It is meant to be overridden with setSanitizeHtmlContentHook
4848
+ */
4849
+
4850
+
4851
+ let sanitizeHtmlContentHook = () => {
4852
+ // locker-service patches this function during runtime to sanitize HTML content.
4853
+ throw new Error('sanitizeHtmlContent hook must be implemented.');
4854
+ };
4855
+ /**
4856
+ * Sets the sanitizeHtmlContentHook.
4857
+ *
4858
+ * @param newHookImpl
4859
+ * @returns oldHookImplementation.
4860
+ */
4861
+
4862
+
4863
+ function setSanitizeHtmlContentHook(newHookImpl) {
4864
+ const currentHook = sanitizeHtmlContentHook;
4865
+ sanitizeHtmlContentHook = newHookImpl;
4866
+ return currentHook;
4867
+ }
4868
+ /*
4869
+ * Copyright (c) 2018, salesforce.com, inc.
4870
+ * All rights reserved.
4871
+ * SPDX-License-Identifier: MIT
4872
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
4873
+ */
4874
+
4863
4875
 
4864
4876
  const SVG_NAMESPACE = 'http://www.w3.org/2000/svg';
4865
4877
  const SymbolIterator = Symbol.iterator;
@@ -5235,7 +5247,7 @@ function i(iterable, factory) {
5235
5247
  next = iterator.next();
5236
5248
  last = next.done; // template factory logic based on the previous collected value
5237
5249
 
5238
- const vnode = factory(value, j, j === 0, last);
5250
+ const vnode = factory(value, j, j === 0, last === true);
5239
5251
 
5240
5252
  if (isArray$1(vnode)) {
5241
5253
  ArrayPush$1.apply(list, vnode);
@@ -5501,25 +5513,29 @@ function sc(vnodes) {
5501
5513
 
5502
5514
  markAsDynamicChildren(vnodes);
5503
5515
  return vnodes;
5504
- }
5505
-
5506
- var api = /*#__PURE__*/Object.freeze({
5507
- __proto__: null,
5508
- h: h,
5509
- ti: ti,
5510
- s: s,
5511
- c: c,
5512
- i: i,
5513
- f: f,
5514
- t: t,
5515
- co: co,
5516
- d: d,
5517
- b: b,
5518
- k: k,
5519
- gid: gid,
5520
- fid: fid,
5521
- dc: dc,
5522
- sc: sc
5516
+ } // [s]anitize [h]tml [c]ontent
5517
+
5518
+
5519
+ function shc(content) {
5520
+ return sanitizeHtmlContentHook(content);
5521
+ }
5522
+
5523
+ const api = freeze({
5524
+ s,
5525
+ h,
5526
+ c,
5527
+ i,
5528
+ f,
5529
+ t,
5530
+ d,
5531
+ b,
5532
+ k,
5533
+ co,
5534
+ dc,
5535
+ ti,
5536
+ gid,
5537
+ fid,
5538
+ shc
5523
5539
  });
5524
5540
  /*
5525
5541
  * Copyright (c) 2018, salesforce.com, inc.
@@ -5533,12 +5549,12 @@ function makeHostToken(token) {
5533
5549
  }
5534
5550
 
5535
5551
  function createInlineStyleVNode(content) {
5536
- return h('style', {
5552
+ return api.h('style', {
5537
5553
  key: 'style',
5538
5554
  attrs: {
5539
5555
  type: 'text/css'
5540
5556
  }
5541
- }, [t(content)]);
5557
+ }, [api.t(content)]);
5542
5558
  }
5543
5559
 
5544
5560
  function updateStylesheetToken(vm, template) {
@@ -6437,6 +6453,12 @@ function createVM(elm, def, options) {
6437
6453
  vm.toString = () => {
6438
6454
  return `[object:vm ${def.name} (${vm.idx})]`;
6439
6455
  };
6456
+
6457
+ if (runtimeFlags.ENABLE_FORCE_NATIVE_SHADOW_MODE_FOR_TEST) {
6458
+ vm.shadowMode = 0
6459
+ /* Native */
6460
+ ;
6461
+ }
6440
6462
  } // Create component instance associated to the vm and the element.
6441
6463
 
6442
6464
 
@@ -7366,7 +7388,38 @@ function readonly(obj) {
7366
7388
 
7367
7389
  return reactiveMembrane.getReadOnlyProxy(obj);
7368
7390
  }
7369
- /* version: 2.5.2 */
7391
+ /*
7392
+ * Copyright (c) 2018, salesforce.com, inc.
7393
+ * All rights reserved.
7394
+ * SPDX-License-Identifier: MIT
7395
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
7396
+ */
7397
+
7398
+
7399
+ let hooksAreSet = false;
7400
+
7401
+ function overrideHooks(hooks) {
7402
+ const oldHooks = {};
7403
+
7404
+ if (!isUndefined$1(hooks.sanitizeHtmlContent)) {
7405
+ oldHooks.sanitizeHtmlContent = setSanitizeHtmlContentHook(hooks.sanitizeHtmlContent);
7406
+ }
7407
+
7408
+ return oldHooks;
7409
+ }
7410
+
7411
+ function setHooks(hooks) {
7412
+ assert.isFalse(hooksAreSet, 'Hooks are already overridden, only one definition is allowed.');
7413
+ overrideHooks(hooks);
7414
+ hooksAreSet = true;
7415
+ }
7416
+
7417
+ function setHooksForTest(hooks) {
7418
+ if (process.env.NODE_ENV !== 'production') {
7419
+ return overrideHooks(hooks);
7420
+ }
7421
+ }
7422
+ /* version: 2.5.6 */
7370
7423
 
7371
7424
  /*
7372
7425
  * Copyright (c) 2018, salesforce.com, inc.
@@ -7387,8 +7440,11 @@ if (process.env.NODE_ENV === 'development') {
7387
7440
  };
7388
7441
  }
7389
7442
 
7390
- const globalStylesheetsParentElement = document.head || document.body || document;
7391
- const supportsConstructableStyleSheets = isFunction$1(CSSStyleSheet.prototype.replaceSync);
7443
+ const globalStylesheetsParentElement = document.head || document.body || document; // This check for constructable stylesheets is similar to Fast's:
7444
+ // https://github.com/microsoft/fast/blob/d49d1ec/packages/web-components/fast-element/src/dom.ts#L51-L53
7445
+ // See also: https://github.com/whatwg/webidl/issues/1027#issuecomment-934510070
7446
+
7447
+ const supportsConstructableStyleSheets = isFunction$1(CSSStyleSheet.prototype.replaceSync) && isArray$1(document.adoptedStyleSheets);
7392
7448
  const styleElements = create(null);
7393
7449
  const styleSheets = create(null);
7394
7450
  const nodesToStyleSheets = new WeakMap();
@@ -7617,6 +7673,30 @@ const renderer = {
7617
7673
  return element.getElementsByClassName(names);
7618
7674
  },
7619
7675
 
7676
+ getChildren(element) {
7677
+ return element.children;
7678
+ },
7679
+
7680
+ getChildNodes(element) {
7681
+ return element.childNodes;
7682
+ },
7683
+
7684
+ getFirstChild(element) {
7685
+ return element.firstChild;
7686
+ },
7687
+
7688
+ getFirstElementChild(element) {
7689
+ return element.firstElementChild;
7690
+ },
7691
+
7692
+ getLastChild(element) {
7693
+ return element.lastChild;
7694
+ },
7695
+
7696
+ getLastElementChild(element) {
7697
+ return element.lastElementChild;
7698
+ },
7699
+
7620
7700
  isConnected(node) {
7621
7701
  return node.isConnected;
7622
7702
  },
@@ -7924,6 +8004,6 @@ defineProperty(LightningElement, 'CustomElementConstructor', {
7924
8004
  });
7925
8005
  freeze(LightningElement);
7926
8006
  seal(LightningElement.prototype);
7927
- /* version: 2.5.2 */
8007
+ /* version: 2.5.6 */
7928
8008
 
7929
- export { LightningElement, profilerControl as __unstable__ProfilerControl, api$1 as api, deprecatedBuildCustomElementConstructor as buildCustomElementConstructor, createContextProvider, createElement, getComponentConstructor, getComponentDef, isComponentConstructor, isNodeFromTemplate, readonly, register, registerComponent, registerDecorators, registerTemplate, sanitizeAttribute, setFeatureFlag, setFeatureFlagForTest, swapComponent, swapStyle, swapTemplate, track, unwrap, wire };
8009
+ export { LightningElement, profilerControl as __unstable__ProfilerControl, api$1 as api, deprecatedBuildCustomElementConstructor as buildCustomElementConstructor, createContextProvider, createElement, getComponentConstructor, getComponentDef, isComponentConstructor, isNodeFromTemplate, readonly, register, registerComponent, registerDecorators, registerTemplate, sanitizeAttribute, setFeatureFlag, setFeatureFlagForTest, setHooks, setHooksForTest, swapComponent, swapStyle, swapTemplate, track, unwrap, wire };