lwc 2.5.3 → 2.5.7

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 +151 -101
  2. package/dist/engine-dom/iife/es2017/engine-dom.js +151 -100
  3. package/dist/engine-dom/iife/es2017/engine-dom.min.js +2 -2
  4. package/dist/engine-dom/iife/es2017/engine-dom_debug.js +139 -80
  5. package/dist/engine-dom/iife/es5/engine-dom.js +181 -109
  6. package/dist/engine-dom/iife/es5/engine-dom.min.js +2 -2
  7. package/dist/engine-dom/iife/es5/engine-dom_debug.js +167 -87
  8. package/dist/engine-dom/umd/es2017/engine-dom.js +151 -100
  9. package/dist/engine-dom/umd/es2017/engine-dom.min.js +2 -2
  10. package/dist/engine-dom/umd/es2017/engine-dom_debug.js +139 -80
  11. package/dist/engine-dom/umd/es5/engine-dom.js +181 -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 +167 -87
  14. package/dist/engine-server/commonjs/es2017/engine-server.js +151 -107
  15. package/dist/engine-server/commonjs/es2017/engine-server.min.js +2 -2
  16. package/dist/engine-server/esm/es2017/engine-server.js +151 -108
  17. package/dist/synthetic-shadow/esm/es2017/synthetic-shadow.js +46 -40
  18. package/dist/synthetic-shadow/iife/es2017/synthetic-shadow.js +46 -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 +45 -39
  21. package/dist/synthetic-shadow/iife/es5/synthetic-shadow.js +46 -40
  22. package/dist/synthetic-shadow/iife/es5/synthetic-shadow.min.js +2 -2
  23. package/dist/synthetic-shadow/iife/es5/synthetic-shadow_debug.js +45 -39
  24. package/dist/synthetic-shadow/umd/es2017/synthetic-shadow.js +46 -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 +45 -39
  27. package/dist/synthetic-shadow/umd/es5/synthetic-shadow.js +46 -40
  28. package/dist/synthetic-shadow/umd/es5/synthetic-shadow.min.js +2 -2
  29. package/dist/synthetic-shadow/umd/es5/synthetic-shadow_debug.js +45 -39
  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.min.js +1 -1
  35. package/dist/wire-service/iife/es5/wire-service_debug.js +2 -2
  36. package/dist/wire-service/umd/es2017/wire-service.js +2 -2
  37. package/dist/wire-service/umd/es2017/wire-service_debug.js +2 -2
  38. package/dist/wire-service/umd/es5/wire-service.js +2 -2
  39. package/dist/wire-service/umd/es5/wire-service.min.js +1 -1
  40. package/dist/wire-service/umd/es5/wire-service_debug.js +2 -2
  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.3 */
302
+ /** version: 2.5.7 */
303
303
 
304
304
  /*
305
305
  * Copyright (c) 2018, salesforce.com, inc.
@@ -479,7 +479,7 @@ function setFeatureFlagForTest(name, value) {
479
479
  setFeatureFlag(name, value);
480
480
  }
481
481
  }
482
- /** version: 2.5.3 */
482
+ /** version: 2.5.7 */
483
483
 
484
484
  /* proxy-compat-disable */
485
485
 
@@ -2851,9 +2851,9 @@ function attachShadow(vm) {
2851
2851
  }
2852
2852
  }
2853
2853
 
2854
- function warnIfInvokedDuringConstruction(vm, methodName) {
2854
+ function warnIfInvokedDuringConstruction(vm, methodOrPropName) {
2855
2855
  if (isBeingConstructed(vm)) {
2856
- 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.`);
2857
2857
  }
2858
2858
  } // @ts-ignore
2859
2859
 
@@ -3013,76 +3013,12 @@ LightningElement.prototype = {
3013
3013
  } = vm;
3014
3014
 
3015
3015
  if (process.env.NODE_ENV !== 'production') {
3016
- warnIfInvokedDuringConstruction(vm, 'getBoundingClientRect');
3016
+ warnIfInvokedDuringConstruction(vm, 'getBoundingClientRect()');
3017
3017
  }
3018
3018
 
3019
3019
  return getBoundingClientRect(elm);
3020
3020
  },
3021
3021
 
3022
- querySelector(selectors) {
3023
- const vm = getAssociatedVM(this);
3024
- const {
3025
- elm,
3026
- renderer: {
3027
- querySelector
3028
- }
3029
- } = vm;
3030
-
3031
- if (process.env.NODE_ENV !== 'production') {
3032
- warnIfInvokedDuringConstruction(vm, 'querySelector');
3033
- }
3034
-
3035
- return querySelector(elm, selectors);
3036
- },
3037
-
3038
- querySelectorAll(selectors) {
3039
- const vm = getAssociatedVM(this);
3040
- const {
3041
- elm,
3042
- renderer: {
3043
- querySelectorAll
3044
- }
3045
- } = vm;
3046
-
3047
- if (process.env.NODE_ENV !== 'production') {
3048
- warnIfInvokedDuringConstruction(vm, 'querySelectorAll');
3049
- }
3050
-
3051
- return querySelectorAll(elm, selectors);
3052
- },
3053
-
3054
- getElementsByTagName(tagNameOrWildCard) {
3055
- const vm = getAssociatedVM(this);
3056
- const {
3057
- elm,
3058
- renderer: {
3059
- getElementsByTagName
3060
- }
3061
- } = vm;
3062
-
3063
- if (process.env.NODE_ENV !== 'production') {
3064
- warnIfInvokedDuringConstruction(vm, 'getElementsByTagName');
3065
- }
3066
-
3067
- return getElementsByTagName(elm, tagNameOrWildCard);
3068
- },
3069
-
3070
- getElementsByClassName(names) {
3071
- const vm = getAssociatedVM(this);
3072
- const {
3073
- elm,
3074
- renderer: {
3075
- getElementsByClassName
3076
- }
3077
- } = vm;
3078
-
3079
- if (process.env.NODE_ENV !== 'production') {
3080
- warnIfInvokedDuringConstruction(vm, 'getElementsByClassName');
3081
- }
3082
-
3083
- return getElementsByClassName(elm, names);
3084
- },
3085
-
3086
3022
  get isConnected() {
3087
3023
  const {
3088
3024
  elm,
@@ -3142,6 +3078,55 @@ LightningElement.prototype = {
3142
3078
  }
3143
3079
 
3144
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
+ configurable: true,
3101
+ enumerable: true
3102
+ };
3103
+ }
3104
+
3105
+ const queryMethods = ['getElementsByClassName', 'getElementsByTagName', 'querySelector', 'querySelectorAll']; // Generic passthrough for query APIs on HTMLElement to the relevant Renderer APIs
3106
+
3107
+ for (const queryMethod of queryMethods) {
3108
+ queryAndChildGetterDescriptors[queryMethod] = {
3109
+ value(arg) {
3110
+ const vm = getAssociatedVM(this);
3111
+ const {
3112
+ elm,
3113
+ renderer
3114
+ } = vm;
3115
+
3116
+ if (process.env.NODE_ENV !== 'production') {
3117
+ warnIfInvokedDuringConstruction(vm, `${queryMethod}()`);
3118
+ }
3119
+
3120
+ return renderer[queryMethod](elm, arg);
3121
+ },
3122
+
3123
+ configurable: true,
3124
+ enumerable: true,
3125
+ writable: true
3126
+ };
3127
+ }
3128
+
3129
+ defineProperties(LightningElement.prototype, queryAndChildGetterDescriptors);
3145
3130
  const lightningBasedDescriptors = create(null);
3146
3131
 
3147
3132
  for (const propName in HTMLElementOriginalDescriptors) {
@@ -3732,15 +3717,14 @@ function registerTemplate(tpl) {
3732
3717
  return tpl;
3733
3718
  }
3734
3719
  /**
3735
- * EXPERIMENTAL: This function acts like a hook for Lightning Locker
3736
- * Service and other similar libraries to sanitize vulnerable attributes.
3737
- * This API is subject to change or being removed.
3720
+ * EXPERIMENTAL: This function acts like a hook for Lightning Locker Service and other similar
3721
+ * libraries to sanitize vulnerable attributes.
3738
3722
  */
3739
3723
 
3740
3724
 
3741
3725
  function sanitizeAttribute(tagName, namespaceUri, attrName, attrValue) {
3742
- // locker-service patches this function during runtime to sanitize vulnerable attributes.
3743
- // when ran off-core this function becomes a noop and returns the user authored value.
3726
+ // locker-service patches this function during runtime to sanitize vulnerable attributes. When
3727
+ // ran off-core this function becomes a noop and returns the user authored value.
3744
3728
  return attrValue;
3745
3729
  }
3746
3730
  /*
@@ -4296,7 +4280,7 @@ function createComponentDef(Ctor) {
4296
4280
  if (!isUndefined$1(ctorShadowSupportMode)) {
4297
4281
  assert.invariant(ctorShadowSupportMode === "any"
4298
4282
  /* Any */
4299
- || ctorShadowSupportMode === "default"
4283
+ || ctorShadowSupportMode === "reset"
4300
4284
  /* Default */
4301
4285
  , `Invalid value for static property shadowSupportMode: '${ctorShadowSupportMode}'`);
4302
4286
  }
@@ -4458,7 +4442,7 @@ const lightingElementDef = {
4458
4442
  renderMode: 1
4459
4443
  /* Shadow */
4460
4444
  ,
4461
- shadowSupportMode: "default"
4445
+ shadowSupportMode: "reset"
4462
4446
  /* Default */
4463
4447
  ,
4464
4448
  wire: EmptyObject,
@@ -5236,7 +5220,7 @@ function i(iterable, factory) {
5236
5220
  next = iterator.next();
5237
5221
  last = next.done; // template factory logic based on the previous collected value
5238
5222
 
5239
- const vnode = factory(value, j, j === 0, last);
5223
+ const vnode = factory(value, j, j === 0, last === true);
5240
5224
 
5241
5225
  if (isArray$1(vnode)) {
5242
5226
  ArrayPush$1.apply(list, vnode);
@@ -5503,24 +5487,48 @@ function sc(vnodes) {
5503
5487
  markAsDynamicChildren(vnodes);
5504
5488
  return vnodes;
5505
5489
  }
5490
+ /**
5491
+ * EXPERIMENTAL: This function acts like a hook for Lightning Locker Service and other similar
5492
+ * libraries to sanitize HTML content. This hook process the content passed via the template to
5493
+ * lwc:inner-html directive.
5494
+ * It is meant to be overridden with setSanitizeHtmlContentHook, it throws an error by default.
5495
+ */
5506
5496
 
5507
- var api = /*#__PURE__*/Object.freeze({
5508
- __proto__: null,
5509
- h: h,
5510
- ti: ti,
5511
- s: s,
5512
- c: c,
5513
- i: i,
5514
- f: f,
5515
- t: t,
5516
- co: co,
5517
- d: d,
5518
- b: b,
5519
- k: k,
5520
- gid: gid,
5521
- fid: fid,
5522
- dc: dc,
5523
- sc: sc
5497
+
5498
+ let sanitizeHtmlContentHook = () => {
5499
+ // locker-service patches this function during runtime to sanitize HTML content.
5500
+ throw new Error('sanitizeHtmlContent hook must be implemented.');
5501
+ };
5502
+ /**
5503
+ * Sets the sanitizeHtmlContentHook.
5504
+ */
5505
+
5506
+
5507
+ function setSanitizeHtmlContentHook(newHookImpl) {
5508
+ sanitizeHtmlContentHook = newHookImpl;
5509
+ } // [s]anitize [h]tml [c]ontent
5510
+
5511
+
5512
+ function shc(content) {
5513
+ return sanitizeHtmlContentHook(content);
5514
+ }
5515
+
5516
+ const api = freeze({
5517
+ s,
5518
+ h,
5519
+ c,
5520
+ i,
5521
+ f,
5522
+ t,
5523
+ d,
5524
+ b,
5525
+ k,
5526
+ co,
5527
+ dc,
5528
+ ti,
5529
+ gid,
5530
+ fid,
5531
+ shc
5524
5532
  });
5525
5533
  /*
5526
5534
  * Copyright (c) 2018, salesforce.com, inc.
@@ -5534,12 +5542,12 @@ function makeHostToken(token) {
5534
5542
  }
5535
5543
 
5536
5544
  function createInlineStyleVNode(content) {
5537
- return h('style', {
5545
+ return api.h('style', {
5538
5546
  key: 'style',
5539
5547
  attrs: {
5540
5548
  type: 'text/css'
5541
5549
  }
5542
- }, [t(content)]);
5550
+ }, [api.t(content)]);
5543
5551
  }
5544
5552
 
5545
5553
  function updateStylesheetToken(vm, template) {
@@ -7373,7 +7381,22 @@ function readonly(obj) {
7373
7381
 
7374
7382
  return reactiveMembrane.getReadOnlyProxy(obj);
7375
7383
  }
7376
- /* version: 2.5.3 */
7384
+ /*
7385
+ * Copyright (c) 2018, salesforce.com, inc.
7386
+ * All rights reserved.
7387
+ * SPDX-License-Identifier: MIT
7388
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
7389
+ */
7390
+
7391
+
7392
+ let hooksAreSet = false;
7393
+
7394
+ function setHooks(hooks) {
7395
+ assert.isFalse(hooksAreSet, 'Hooks are already overridden, only one definition is allowed.');
7396
+ hooksAreSet = true;
7397
+ setSanitizeHtmlContentHook(hooks.sanitizeHtmlContent);
7398
+ }
7399
+ /* version: 2.5.7 */
7377
7400
 
7378
7401
  /*
7379
7402
  * Copyright (c) 2018, salesforce.com, inc.
@@ -7394,8 +7417,11 @@ if (process.env.NODE_ENV === 'development') {
7394
7417
  };
7395
7418
  }
7396
7419
 
7397
- const globalStylesheetsParentElement = document.head || document.body || document;
7398
- const supportsConstructableStyleSheets = isFunction$1(CSSStyleSheet.prototype.replaceSync);
7420
+ const globalStylesheetsParentElement = document.head || document.body || document; // This check for constructable stylesheets is similar to Fast's:
7421
+ // https://github.com/microsoft/fast/blob/d49d1ec/packages/web-components/fast-element/src/dom.ts#L51-L53
7422
+ // See also: https://github.com/whatwg/webidl/issues/1027#issuecomment-934510070
7423
+
7424
+ const supportsConstructableStyleSheets = isFunction$1(CSSStyleSheet.prototype.replaceSync) && isArray$1(document.adoptedStyleSheets);
7399
7425
  const styleElements = create(null);
7400
7426
  const styleSheets = create(null);
7401
7427
  const nodesToStyleSheets = new WeakMap();
@@ -7624,6 +7650,30 @@ const renderer = {
7624
7650
  return element.getElementsByClassName(names);
7625
7651
  },
7626
7652
 
7653
+ getChildren(element) {
7654
+ return element.children;
7655
+ },
7656
+
7657
+ getChildNodes(element) {
7658
+ return element.childNodes;
7659
+ },
7660
+
7661
+ getFirstChild(element) {
7662
+ return element.firstChild;
7663
+ },
7664
+
7665
+ getFirstElementChild(element) {
7666
+ return element.firstElementChild;
7667
+ },
7668
+
7669
+ getLastChild(element) {
7670
+ return element.lastChild;
7671
+ },
7672
+
7673
+ getLastElementChild(element) {
7674
+ return element.lastElementChild;
7675
+ },
7676
+
7627
7677
  isConnected(node) {
7628
7678
  return node.isConnected;
7629
7679
  },
@@ -7931,6 +7981,6 @@ defineProperty(LightningElement, 'CustomElementConstructor', {
7931
7981
  });
7932
7982
  freeze(LightningElement);
7933
7983
  seal(LightningElement.prototype);
7934
- /* version: 2.5.3 */
7984
+ /* version: 2.5.7 */
7935
7985
 
7936
- 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 };
7986
+ 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, swapComponent, swapStyle, swapTemplate, track, unwrap, wire };