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
@@ -339,7 +339,7 @@ function htmlPropertyToAttribute(propName) {
339
339
  CACHED_PROPERTY_ATTRIBUTE_MAPPING.set(propName, attributeName);
340
340
  return attributeName;
341
341
  }
342
- /** version: 2.5.2 */
342
+ /** version: 2.5.6 */
343
343
 
344
344
  /*
345
345
  * Copyright (c) 2020, salesforce.com, inc.
@@ -390,6 +390,7 @@ const features = {
390
390
  ENABLE_HMR: null,
391
391
  ENABLE_INNER_OUTER_TEXT_PATCH: null,
392
392
  ENABLE_ELEMENT_PATCH: null,
393
+ ENABLE_FORCE_NATIVE_SHADOW_MODE_FOR_TEST: null,
393
394
  ENABLE_NODE_LIST_PATCH: null,
394
395
  ENABLE_HTML_COLLECTIONS_PATCH: null,
395
396
  ENABLE_NODE_PATCH: null,
@@ -459,7 +460,7 @@ function setFeatureFlagForTest(name, value) {
459
460
  setFeatureFlag(name, value);
460
461
  }
461
462
  }
462
- /** version: 2.5.2 */
463
+ /** version: 2.5.6 */
463
464
 
464
465
  /* proxy-compat-disable */
465
466
 
@@ -2831,9 +2832,9 @@ function attachShadow(vm) {
2831
2832
  }
2832
2833
  }
2833
2834
 
2834
- function warnIfInvokedDuringConstruction(vm, methodName) {
2835
+ function warnIfInvokedDuringConstruction(vm, methodOrPropName) {
2835
2836
  if (isBeingConstructed(vm)) {
2836
- 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.`);
2837
+ 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.`);
2837
2838
  }
2838
2839
  } // @ts-ignore
2839
2840
 
@@ -2993,76 +2994,12 @@ LightningElement.prototype = {
2993
2994
  } = vm;
2994
2995
 
2995
2996
  if (process.env.NODE_ENV !== 'production') {
2996
- warnIfInvokedDuringConstruction(vm, 'getBoundingClientRect');
2997
+ warnIfInvokedDuringConstruction(vm, 'getBoundingClientRect()');
2997
2998
  }
2998
2999
 
2999
3000
  return getBoundingClientRect(elm);
3000
3001
  },
3001
3002
 
3002
- querySelector(selectors) {
3003
- const vm = getAssociatedVM(this);
3004
- const {
3005
- elm,
3006
- renderer: {
3007
- querySelector
3008
- }
3009
- } = vm;
3010
-
3011
- if (process.env.NODE_ENV !== 'production') {
3012
- warnIfInvokedDuringConstruction(vm, 'querySelector');
3013
- }
3014
-
3015
- return querySelector(elm, selectors);
3016
- },
3017
-
3018
- querySelectorAll(selectors) {
3019
- const vm = getAssociatedVM(this);
3020
- const {
3021
- elm,
3022
- renderer: {
3023
- querySelectorAll
3024
- }
3025
- } = vm;
3026
-
3027
- if (process.env.NODE_ENV !== 'production') {
3028
- warnIfInvokedDuringConstruction(vm, 'querySelectorAll');
3029
- }
3030
-
3031
- return querySelectorAll(elm, selectors);
3032
- },
3033
-
3034
- getElementsByTagName(tagNameOrWildCard) {
3035
- const vm = getAssociatedVM(this);
3036
- const {
3037
- elm,
3038
- renderer: {
3039
- getElementsByTagName
3040
- }
3041
- } = vm;
3042
-
3043
- if (process.env.NODE_ENV !== 'production') {
3044
- warnIfInvokedDuringConstruction(vm, 'getElementsByTagName');
3045
- }
3046
-
3047
- return getElementsByTagName(elm, tagNameOrWildCard);
3048
- },
3049
-
3050
- getElementsByClassName(names) {
3051
- const vm = getAssociatedVM(this);
3052
- const {
3053
- elm,
3054
- renderer: {
3055
- getElementsByClassName
3056
- }
3057
- } = vm;
3058
-
3059
- if (process.env.NODE_ENV !== 'production') {
3060
- warnIfInvokedDuringConstruction(vm, 'getElementsByClassName');
3061
- }
3062
-
3063
- return getElementsByClassName(elm, names);
3064
- },
3065
-
3066
3003
  get isConnected() {
3067
3004
  const {
3068
3005
  elm,
@@ -3122,6 +3059,50 @@ LightningElement.prototype = {
3122
3059
  }
3123
3060
 
3124
3061
  };
3062
+ const queryAndChildGetterDescriptors = create(null);
3063
+ 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
3064
+
3065
+ for (const [elementProp, rendererMethod] of childGetters) {
3066
+ queryAndChildGetterDescriptors[elementProp] = {
3067
+ get() {
3068
+ const vm = getAssociatedVM(this);
3069
+ const {
3070
+ elm,
3071
+ renderer
3072
+ } = vm;
3073
+
3074
+ if (process.env.NODE_ENV !== 'production') {
3075
+ warnIfInvokedDuringConstruction(vm, elementProp);
3076
+ }
3077
+
3078
+ return renderer[rendererMethod](elm);
3079
+ }
3080
+
3081
+ };
3082
+ }
3083
+
3084
+ const queryMethods = ['getElementsByClassName', 'getElementsByTagName', 'querySelector', 'querySelectorAll']; // Generic passthrough for query APIs on HTMLElement to the relevant Renderer APIs
3085
+
3086
+ for (const queryMethod of queryMethods) {
3087
+ queryAndChildGetterDescriptors[queryMethod] = {
3088
+ value(arg) {
3089
+ const vm = getAssociatedVM(this);
3090
+ const {
3091
+ elm,
3092
+ renderer
3093
+ } = vm;
3094
+
3095
+ if (process.env.NODE_ENV !== 'production') {
3096
+ warnIfInvokedDuringConstruction(vm, `${queryMethod}()`);
3097
+ }
3098
+
3099
+ return renderer[queryMethod](elm, arg);
3100
+ }
3101
+
3102
+ };
3103
+ }
3104
+
3105
+ defineProperties(LightningElement.prototype, queryAndChildGetterDescriptors);
3125
3106
  const lightningBasedDescriptors = create(null);
3126
3107
 
3127
3108
  for (const propName in HTMLElementOriginalDescriptors) {
@@ -3712,15 +3693,14 @@ function registerTemplate(tpl) {
3712
3693
  return tpl;
3713
3694
  }
3714
3695
  /**
3715
- * EXPERIMENTAL: This function acts like a hook for Lightning Locker
3716
- * Service and other similar libraries to sanitize vulnerable attributes.
3717
- * This API is subject to change or being removed.
3696
+ * EXPERIMENTAL: This function acts like a hook for Lightning Locker Service and other similar
3697
+ * libraries to sanitize vulnerable attributes.
3718
3698
  */
3719
3699
 
3720
3700
 
3721
3701
  function sanitizeAttribute(tagName, namespaceUri, attrName, attrValue) {
3722
- // locker-service patches this function during runtime to sanitize vulnerable attributes.
3723
- // when ran off-core this function becomes a noop and returns the user authored value.
3702
+ // locker-service patches this function during runtime to sanitize vulnerable attributes. When
3703
+ // ran off-core this function becomes a noop and returns the user authored value.
3724
3704
  return attrValue;
3725
3705
  }
3726
3706
  /*
@@ -4721,6 +4701,38 @@ function getUpgradableConstructor(tagName, renderer) {
4721
4701
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
4722
4702
  */
4723
4703
 
4704
+ /**
4705
+ * EXPERIMENTAL: This function acts like a hook for Lightning Locker Service and other similar
4706
+ * libraries to sanitize HTML content. This hook process the content passed via the template to
4707
+ * lwc:inner-html directive.
4708
+ * It is meant to be overridden with setSanitizeHtmlContentHook
4709
+ */
4710
+
4711
+
4712
+ let sanitizeHtmlContentHook = () => {
4713
+ // locker-service patches this function during runtime to sanitize HTML content.
4714
+ throw new Error('sanitizeHtmlContent hook must be implemented.');
4715
+ };
4716
+ /**
4717
+ * Sets the sanitizeHtmlContentHook.
4718
+ *
4719
+ * @param newHookImpl
4720
+ * @returns oldHookImplementation.
4721
+ */
4722
+
4723
+
4724
+ function setSanitizeHtmlContentHook(newHookImpl) {
4725
+ const currentHook = sanitizeHtmlContentHook;
4726
+ sanitizeHtmlContentHook = newHookImpl;
4727
+ return currentHook;
4728
+ }
4729
+ /*
4730
+ * Copyright (c) 2018, salesforce.com, inc.
4731
+ * All rights reserved.
4732
+ * SPDX-License-Identifier: MIT
4733
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
4734
+ */
4735
+
4724
4736
 
4725
4737
  const SVG_NAMESPACE = 'http://www.w3.org/2000/svg';
4726
4738
  const SymbolIterator = Symbol.iterator;
@@ -5096,7 +5108,7 @@ function i(iterable, factory) {
5096
5108
  next = iterator.next();
5097
5109
  last = next.done; // template factory logic based on the previous collected value
5098
5110
 
5099
- const vnode = factory(value, j, j === 0, last);
5111
+ const vnode = factory(value, j, j === 0, last === true);
5100
5112
 
5101
5113
  if (isArray$1(vnode)) {
5102
5114
  ArrayPush$1.apply(list, vnode);
@@ -5362,25 +5374,29 @@ function sc(vnodes) {
5362
5374
 
5363
5375
  markAsDynamicChildren(vnodes);
5364
5376
  return vnodes;
5365
- }
5366
-
5367
- var api = /*#__PURE__*/Object.freeze({
5368
- __proto__: null,
5369
- h: h,
5370
- ti: ti,
5371
- s: s,
5372
- c: c,
5373
- i: i,
5374
- f: f,
5375
- t: t,
5376
- co: co,
5377
- d: d,
5378
- b: b,
5379
- k: k,
5380
- gid: gid,
5381
- fid: fid,
5382
- dc: dc,
5383
- sc: sc
5377
+ } // [s]anitize [h]tml [c]ontent
5378
+
5379
+
5380
+ function shc(content) {
5381
+ return sanitizeHtmlContentHook(content);
5382
+ }
5383
+
5384
+ const api = freeze({
5385
+ s,
5386
+ h,
5387
+ c,
5388
+ i,
5389
+ f,
5390
+ t,
5391
+ d,
5392
+ b,
5393
+ k,
5394
+ co,
5395
+ dc,
5396
+ ti,
5397
+ gid,
5398
+ fid,
5399
+ shc
5384
5400
  });
5385
5401
  /*
5386
5402
  * Copyright (c) 2018, salesforce.com, inc.
@@ -5394,12 +5410,12 @@ function makeHostToken(token) {
5394
5410
  }
5395
5411
 
5396
5412
  function createInlineStyleVNode(content) {
5397
- return h('style', {
5413
+ return api.h('style', {
5398
5414
  key: 'style',
5399
5415
  attrs: {
5400
5416
  type: 'text/css'
5401
5417
  }
5402
- }, [t(content)]);
5418
+ }, [api.t(content)]);
5403
5419
  }
5404
5420
 
5405
5421
  function updateStylesheetToken(vm, template) {
@@ -6246,6 +6262,12 @@ function createVM(elm, def, options) {
6246
6262
  vm.toString = () => {
6247
6263
  return `[object:vm ${def.name} (${vm.idx})]`;
6248
6264
  };
6265
+
6266
+ if (runtimeFlags.ENABLE_FORCE_NATIVE_SHADOW_MODE_FOR_TEST) {
6267
+ vm.shadowMode = 0
6268
+ /* Native */
6269
+ ;
6270
+ }
6249
6271
  } // Create component instance associated to the vm and the element.
6250
6272
 
6251
6273
 
@@ -7157,7 +7179,38 @@ function readonly(obj) {
7157
7179
 
7158
7180
  return reactiveMembrane.getReadOnlyProxy(obj);
7159
7181
  }
7160
- /* version: 2.5.2 */
7182
+ /*
7183
+ * Copyright (c) 2018, salesforce.com, inc.
7184
+ * All rights reserved.
7185
+ * SPDX-License-Identifier: MIT
7186
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
7187
+ */
7188
+
7189
+
7190
+ let hooksAreSet = false;
7191
+
7192
+ function overrideHooks(hooks) {
7193
+ const oldHooks = {};
7194
+
7195
+ if (!isUndefined$1(hooks.sanitizeHtmlContent)) {
7196
+ oldHooks.sanitizeHtmlContent = setSanitizeHtmlContentHook(hooks.sanitizeHtmlContent);
7197
+ }
7198
+
7199
+ return oldHooks;
7200
+ }
7201
+
7202
+ function setHooks(hooks) {
7203
+ assert.isFalse(hooksAreSet, 'Hooks are already overridden, only one definition is allowed.');
7204
+ overrideHooks(hooks);
7205
+ hooksAreSet = true;
7206
+ }
7207
+
7208
+ function setHooksForTest(hooks) {
7209
+ if (process.env.NODE_ENV !== 'production') {
7210
+ return overrideHooks(hooks);
7211
+ }
7212
+ }
7213
+ /* version: 2.5.6 */
7161
7214
 
7162
7215
  /*
7163
7216
  * Copyright (c) 2020, salesforce.com, inc.
@@ -7172,6 +7225,7 @@ var HostNodeType;
7172
7225
  (function (HostNodeType) {
7173
7226
  HostNodeType["Text"] = "text";
7174
7227
  HostNodeType["Comment"] = "comment";
7228
+ HostNodeType["Raw"] = "raw";
7175
7229
  HostNodeType["Element"] = "element";
7176
7230
  HostNodeType["ShadowRoot"] = "shadow-root";
7177
7231
  })(HostNodeType || (HostNodeType = {}));
@@ -7351,7 +7405,17 @@ const renderer = {
7351
7405
  }
7352
7406
 
7353
7407
  if (node.type === HostNodeType.Element) {
7354
- const attrName = htmlPropertyToAttribute(key); // Handle all the boolean properties.
7408
+ const attrName = htmlPropertyToAttribute(key);
7409
+
7410
+ if (key === 'innerHTML') {
7411
+ node.children = [{
7412
+ type: HostNodeType.Raw,
7413
+ parent: node,
7414
+ value
7415
+ }];
7416
+ return;
7417
+ } // Handle all the boolean properties.
7418
+
7355
7419
 
7356
7420
  if (isBooleanAttribute(attrName, node.name)) {
7357
7421
  return value === true ? this.setAttribute(node, attrName, '') : this.removeAttribute(node, attrName);
@@ -7483,6 +7547,12 @@ const renderer = {
7483
7547
  querySelectorAll: unsupportedMethod('querySelectorAll'),
7484
7548
  getElementsByTagName: unsupportedMethod('getElementsByTagName'),
7485
7549
  getElementsByClassName: unsupportedMethod('getElementsByClassName'),
7550
+ getChildren: unsupportedMethod('getChildren'),
7551
+ getChildNodes: unsupportedMethod('getChildNodes'),
7552
+ getFirstChild: unsupportedMethod('getFirstChild'),
7553
+ getFirstElementChild: unsupportedMethod('getFirstElementChild'),
7554
+ getLastChild: unsupportedMethod('getLastChild'),
7555
+ getLastElementChild: unsupportedMethod('getLastElementChild'),
7486
7556
 
7487
7557
  defineCustomElement(name, constructor, _options) {
7488
7558
  registerCustomElement(name, constructor);
@@ -7533,6 +7603,9 @@ function serializeChildNodes(children) {
7533
7603
  case HostNodeType.Comment:
7534
7604
  return `<!--${htmlEscape(child.value)}-->`;
7535
7605
 
7606
+ case HostNodeType.Raw:
7607
+ return child.value;
7608
+
7536
7609
  case HostNodeType.Element:
7537
7610
  return serializeElement(child);
7538
7611
  }
@@ -7628,7 +7701,7 @@ function renderComponent(tagName, Ctor, props = {}) {
7628
7701
 
7629
7702
  freeze(LightningElement);
7630
7703
  seal(LightningElement.prototype);
7631
- /* version: 2.5.2 */
7704
+ /* version: 2.5.6 */
7632
7705
 
7633
7706
  exports.LightningElement = LightningElement;
7634
7707
  exports.api = api$1;
@@ -7644,6 +7717,8 @@ exports.renderComponent = renderComponent;
7644
7717
  exports.sanitizeAttribute = sanitizeAttribute;
7645
7718
  exports.setFeatureFlag = setFeatureFlag;
7646
7719
  exports.setFeatureFlagForTest = setFeatureFlagForTest;
7720
+ exports.setHooks = setHooks;
7721
+ exports.setHooksForTest = setHooksForTest;
7647
7722
  exports.track = track;
7648
7723
  exports.unwrap = unwrap;
7649
7724
  exports.wire = wire;