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
@@ -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.3 */
342
+ /** version: 2.5.7 */
343
343
 
344
344
  /*
345
345
  * Copyright (c) 2020, salesforce.com, inc.
@@ -460,7 +460,7 @@ function setFeatureFlagForTest(name, value) {
460
460
  setFeatureFlag(name, value);
461
461
  }
462
462
  }
463
- /** version: 2.5.3 */
463
+ /** version: 2.5.7 */
464
464
 
465
465
  /* proxy-compat-disable */
466
466
 
@@ -2832,9 +2832,9 @@ function attachShadow(vm) {
2832
2832
  }
2833
2833
  }
2834
2834
 
2835
- function warnIfInvokedDuringConstruction(vm, methodName) {
2835
+ function warnIfInvokedDuringConstruction(vm, methodOrPropName) {
2836
2836
  if (isBeingConstructed(vm)) {
2837
- 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.`);
2838
2838
  }
2839
2839
  } // @ts-ignore
2840
2840
 
@@ -2994,76 +2994,12 @@ LightningElement.prototype = {
2994
2994
  } = vm;
2995
2995
 
2996
2996
  if (process.env.NODE_ENV !== 'production') {
2997
- warnIfInvokedDuringConstruction(vm, 'getBoundingClientRect');
2997
+ warnIfInvokedDuringConstruction(vm, 'getBoundingClientRect()');
2998
2998
  }
2999
2999
 
3000
3000
  return getBoundingClientRect(elm);
3001
3001
  },
3002
3002
 
3003
- querySelector(selectors) {
3004
- const vm = getAssociatedVM(this);
3005
- const {
3006
- elm,
3007
- renderer: {
3008
- querySelector
3009
- }
3010
- } = vm;
3011
-
3012
- if (process.env.NODE_ENV !== 'production') {
3013
- warnIfInvokedDuringConstruction(vm, 'querySelector');
3014
- }
3015
-
3016
- return querySelector(elm, selectors);
3017
- },
3018
-
3019
- querySelectorAll(selectors) {
3020
- const vm = getAssociatedVM(this);
3021
- const {
3022
- elm,
3023
- renderer: {
3024
- querySelectorAll
3025
- }
3026
- } = vm;
3027
-
3028
- if (process.env.NODE_ENV !== 'production') {
3029
- warnIfInvokedDuringConstruction(vm, 'querySelectorAll');
3030
- }
3031
-
3032
- return querySelectorAll(elm, selectors);
3033
- },
3034
-
3035
- getElementsByTagName(tagNameOrWildCard) {
3036
- const vm = getAssociatedVM(this);
3037
- const {
3038
- elm,
3039
- renderer: {
3040
- getElementsByTagName
3041
- }
3042
- } = vm;
3043
-
3044
- if (process.env.NODE_ENV !== 'production') {
3045
- warnIfInvokedDuringConstruction(vm, 'getElementsByTagName');
3046
- }
3047
-
3048
- return getElementsByTagName(elm, tagNameOrWildCard);
3049
- },
3050
-
3051
- getElementsByClassName(names) {
3052
- const vm = getAssociatedVM(this);
3053
- const {
3054
- elm,
3055
- renderer: {
3056
- getElementsByClassName
3057
- }
3058
- } = vm;
3059
-
3060
- if (process.env.NODE_ENV !== 'production') {
3061
- warnIfInvokedDuringConstruction(vm, 'getElementsByClassName');
3062
- }
3063
-
3064
- return getElementsByClassName(elm, names);
3065
- },
3066
-
3067
3003
  get isConnected() {
3068
3004
  const {
3069
3005
  elm,
@@ -3123,6 +3059,55 @@ LightningElement.prototype = {
3123
3059
  }
3124
3060
 
3125
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
+ configurable: true,
3082
+ enumerable: true
3083
+ };
3084
+ }
3085
+
3086
+ const queryMethods = ['getElementsByClassName', 'getElementsByTagName', 'querySelector', 'querySelectorAll']; // Generic passthrough for query APIs on HTMLElement to the relevant Renderer APIs
3087
+
3088
+ for (const queryMethod of queryMethods) {
3089
+ queryAndChildGetterDescriptors[queryMethod] = {
3090
+ value(arg) {
3091
+ const vm = getAssociatedVM(this);
3092
+ const {
3093
+ elm,
3094
+ renderer
3095
+ } = vm;
3096
+
3097
+ if (process.env.NODE_ENV !== 'production') {
3098
+ warnIfInvokedDuringConstruction(vm, `${queryMethod}()`);
3099
+ }
3100
+
3101
+ return renderer[queryMethod](elm, arg);
3102
+ },
3103
+
3104
+ configurable: true,
3105
+ enumerable: true,
3106
+ writable: true
3107
+ };
3108
+ }
3109
+
3110
+ defineProperties(LightningElement.prototype, queryAndChildGetterDescriptors);
3126
3111
  const lightningBasedDescriptors = create(null);
3127
3112
 
3128
3113
  for (const propName in HTMLElementOriginalDescriptors) {
@@ -3713,15 +3698,14 @@ function registerTemplate(tpl) {
3713
3698
  return tpl;
3714
3699
  }
3715
3700
  /**
3716
- * EXPERIMENTAL: This function acts like a hook for Lightning Locker
3717
- * Service and other similar libraries to sanitize vulnerable attributes.
3718
- * This API is subject to change or being removed.
3701
+ * EXPERIMENTAL: This function acts like a hook for Lightning Locker Service and other similar
3702
+ * libraries to sanitize vulnerable attributes.
3719
3703
  */
3720
3704
 
3721
3705
 
3722
3706
  function sanitizeAttribute(tagName, namespaceUri, attrName, attrValue) {
3723
- // locker-service patches this function during runtime to sanitize vulnerable attributes.
3724
- // when ran off-core this function becomes a noop and returns the user authored value.
3707
+ // locker-service patches this function during runtime to sanitize vulnerable attributes. When
3708
+ // ran off-core this function becomes a noop and returns the user authored value.
3725
3709
  return attrValue;
3726
3710
  }
3727
3711
  /*
@@ -4157,7 +4141,7 @@ function createComponentDef(Ctor) {
4157
4141
  if (!isUndefined$1(ctorShadowSupportMode)) {
4158
4142
  assert.invariant(ctorShadowSupportMode === "any"
4159
4143
  /* Any */
4160
- || ctorShadowSupportMode === "default"
4144
+ || ctorShadowSupportMode === "reset"
4161
4145
  /* Default */
4162
4146
  , `Invalid value for static property shadowSupportMode: '${ctorShadowSupportMode}'`);
4163
4147
  }
@@ -4319,7 +4303,7 @@ const lightingElementDef = {
4319
4303
  renderMode: 1
4320
4304
  /* Shadow */
4321
4305
  ,
4322
- shadowSupportMode: "default"
4306
+ shadowSupportMode: "reset"
4323
4307
  /* Default */
4324
4308
  ,
4325
4309
  wire: EmptyObject,
@@ -5097,7 +5081,7 @@ function i(iterable, factory) {
5097
5081
  next = iterator.next();
5098
5082
  last = next.done; // template factory logic based on the previous collected value
5099
5083
 
5100
- const vnode = factory(value, j, j === 0, last);
5084
+ const vnode = factory(value, j, j === 0, last === true);
5101
5085
 
5102
5086
  if (isArray$1(vnode)) {
5103
5087
  ArrayPush$1.apply(list, vnode);
@@ -5364,24 +5348,48 @@ function sc(vnodes) {
5364
5348
  markAsDynamicChildren(vnodes);
5365
5349
  return vnodes;
5366
5350
  }
5351
+ /**
5352
+ * EXPERIMENTAL: This function acts like a hook for Lightning Locker Service and other similar
5353
+ * libraries to sanitize HTML content. This hook process the content passed via the template to
5354
+ * lwc:inner-html directive.
5355
+ * It is meant to be overridden with setSanitizeHtmlContentHook, it throws an error by default.
5356
+ */
5367
5357
 
5368
- var api = /*#__PURE__*/Object.freeze({
5369
- __proto__: null,
5370
- h: h,
5371
- ti: ti,
5372
- s: s,
5373
- c: c,
5374
- i: i,
5375
- f: f,
5376
- t: t,
5377
- co: co,
5378
- d: d,
5379
- b: b,
5380
- k: k,
5381
- gid: gid,
5382
- fid: fid,
5383
- dc: dc,
5384
- sc: sc
5358
+
5359
+ let sanitizeHtmlContentHook = () => {
5360
+ // locker-service patches this function during runtime to sanitize HTML content.
5361
+ throw new Error('sanitizeHtmlContent hook must be implemented.');
5362
+ };
5363
+ /**
5364
+ * Sets the sanitizeHtmlContentHook.
5365
+ */
5366
+
5367
+
5368
+ function setSanitizeHtmlContentHook(newHookImpl) {
5369
+ sanitizeHtmlContentHook = newHookImpl;
5370
+ } // [s]anitize [h]tml [c]ontent
5371
+
5372
+
5373
+ function shc(content) {
5374
+ return sanitizeHtmlContentHook(content);
5375
+ }
5376
+
5377
+ const api = freeze({
5378
+ s,
5379
+ h,
5380
+ c,
5381
+ i,
5382
+ f,
5383
+ t,
5384
+ d,
5385
+ b,
5386
+ k,
5387
+ co,
5388
+ dc,
5389
+ ti,
5390
+ gid,
5391
+ fid,
5392
+ shc
5385
5393
  });
5386
5394
  /*
5387
5395
  * Copyright (c) 2018, salesforce.com, inc.
@@ -5395,12 +5403,12 @@ function makeHostToken(token) {
5395
5403
  }
5396
5404
 
5397
5405
  function createInlineStyleVNode(content) {
5398
- return h('style', {
5406
+ return api.h('style', {
5399
5407
  key: 'style',
5400
5408
  attrs: {
5401
5409
  type: 'text/css'
5402
5410
  }
5403
- }, [t(content)]);
5411
+ }, [api.t(content)]);
5404
5412
  }
5405
5413
 
5406
5414
  function updateStylesheetToken(vm, template) {
@@ -7164,7 +7172,22 @@ function readonly(obj) {
7164
7172
 
7165
7173
  return reactiveMembrane.getReadOnlyProxy(obj);
7166
7174
  }
7167
- /* version: 2.5.3 */
7175
+ /*
7176
+ * Copyright (c) 2018, salesforce.com, inc.
7177
+ * All rights reserved.
7178
+ * SPDX-License-Identifier: MIT
7179
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
7180
+ */
7181
+
7182
+
7183
+ let hooksAreSet = false;
7184
+
7185
+ function setHooks(hooks) {
7186
+ assert.isFalse(hooksAreSet, 'Hooks are already overridden, only one definition is allowed.');
7187
+ hooksAreSet = true;
7188
+ setSanitizeHtmlContentHook(hooks.sanitizeHtmlContent);
7189
+ }
7190
+ /* version: 2.5.7 */
7168
7191
 
7169
7192
  /*
7170
7193
  * Copyright (c) 2020, salesforce.com, inc.
@@ -7179,6 +7202,7 @@ var HostNodeType;
7179
7202
  (function (HostNodeType) {
7180
7203
  HostNodeType["Text"] = "text";
7181
7204
  HostNodeType["Comment"] = "comment";
7205
+ HostNodeType["Raw"] = "raw";
7182
7206
  HostNodeType["Element"] = "element";
7183
7207
  HostNodeType["ShadowRoot"] = "shadow-root";
7184
7208
  })(HostNodeType || (HostNodeType = {}));
@@ -7193,7 +7217,7 @@ var HostNodeType;
7193
7217
  const CLASSNAMES_SEPARATOR = /\s+/g;
7194
7218
 
7195
7219
  function classNameToTokenList(value) {
7196
- return new Set(value.trim().split(CLASSNAMES_SEPARATOR));
7220
+ return new Set(value.split(CLASSNAMES_SEPARATOR).filter(str => str.length));
7197
7221
  }
7198
7222
 
7199
7223
  function tokenListToClassName(values) {
@@ -7358,7 +7382,17 @@ const renderer = {
7358
7382
  }
7359
7383
 
7360
7384
  if (node.type === HostNodeType.Element) {
7361
- const attrName = htmlPropertyToAttribute(key); // Handle all the boolean properties.
7385
+ const attrName = htmlPropertyToAttribute(key);
7386
+
7387
+ if (key === 'innerHTML') {
7388
+ node.children = [{
7389
+ type: HostNodeType.Raw,
7390
+ parent: node,
7391
+ value
7392
+ }];
7393
+ return;
7394
+ } // Handle all the boolean properties.
7395
+
7362
7396
 
7363
7397
  if (isBooleanAttribute(attrName, node.name)) {
7364
7398
  return value === true ? this.setAttribute(node, attrName, '') : this.removeAttribute(node, attrName);
@@ -7452,18 +7486,18 @@ const renderer = {
7452
7486
  },
7453
7487
 
7454
7488
  setCSSStyleProperty(element, name, value, important) {
7455
- let styleAttribute = element.attributes.find(attr => attr.name === 'style' && isNull(attr.namespace));
7489
+ const styleAttribute = element.attributes.find(attr => attr.name === 'style' && isNull(attr.namespace));
7490
+ const serializedProperty = `${name}: ${value}${important ? ' !important' : ''}`;
7456
7491
 
7457
7492
  if (isUndefined$1(styleAttribute)) {
7458
- styleAttribute = {
7493
+ element.attributes.push({
7459
7494
  name: 'style',
7460
7495
  namespace: null,
7461
- value: ''
7462
- };
7463
- element.attributes.push(styleAttribute);
7496
+ value: serializedProperty
7497
+ });
7498
+ } else {
7499
+ styleAttribute.value += `; ${serializedProperty}`;
7464
7500
  }
7465
-
7466
- styleAttribute.value = `${styleAttribute.value}; ${name}: ${value}${important ? ' !important' : ''}`;
7467
7501
  },
7468
7502
 
7469
7503
  isConnected(node) {
@@ -7490,6 +7524,12 @@ const renderer = {
7490
7524
  querySelectorAll: unsupportedMethod('querySelectorAll'),
7491
7525
  getElementsByTagName: unsupportedMethod('getElementsByTagName'),
7492
7526
  getElementsByClassName: unsupportedMethod('getElementsByClassName'),
7527
+ getChildren: unsupportedMethod('getChildren'),
7528
+ getChildNodes: unsupportedMethod('getChildNodes'),
7529
+ getFirstChild: unsupportedMethod('getFirstChild'),
7530
+ getFirstElementChild: unsupportedMethod('getFirstElementChild'),
7531
+ getLastChild: unsupportedMethod('getLastChild'),
7532
+ getLastElementChild: unsupportedMethod('getLastElementChild'),
7493
7533
 
7494
7534
  defineCustomElement(name, constructor, _options) {
7495
7535
  registerCustomElement(name, constructor);
@@ -7540,6 +7580,9 @@ function serializeChildNodes(children) {
7540
7580
  case HostNodeType.Comment:
7541
7581
  return `<!--${htmlEscape(child.value)}-->`;
7542
7582
 
7583
+ case HostNodeType.Raw:
7584
+ return child.value;
7585
+
7543
7586
  case HostNodeType.Element:
7544
7587
  return serializeElement(child);
7545
7588
  }
@@ -7635,7 +7678,7 @@ function renderComponent(tagName, Ctor, props = {}) {
7635
7678
 
7636
7679
  freeze(LightningElement);
7637
7680
  seal(LightningElement.prototype);
7638
- /* version: 2.5.3 */
7681
+ /* version: 2.5.7 */
7639
7682
 
7640
7683
  exports.LightningElement = LightningElement;
7641
7684
  exports.api = api$1;
@@ -7651,6 +7694,7 @@ exports.renderComponent = renderComponent;
7651
7694
  exports.sanitizeAttribute = sanitizeAttribute;
7652
7695
  exports.setFeatureFlag = setFeatureFlag;
7653
7696
  exports.setFeatureFlagForTest = setFeatureFlagForTest;
7697
+ exports.setHooks = setHooks;
7654
7698
  exports.track = track;
7655
7699
  exports.unwrap = unwrap;
7656
7700
  exports.wire = wire;