lwc 2.20.4 → 2.22.0

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 (35) hide show
  1. package/dist/engine-dom/esm/es2017/engine-dom.js +181 -127
  2. package/dist/engine-dom/iife/es2017/engine-dom.js +181 -127
  3. package/dist/engine-dom/iife/es2017/engine-dom.min.js +1 -1
  4. package/dist/engine-dom/iife/es2017/engine-dom_debug.js +168 -115
  5. package/dist/engine-dom/iife/es5/engine-dom.js +226 -147
  6. package/dist/engine-dom/iife/es5/engine-dom.min.js +1 -1
  7. package/dist/engine-dom/iife/es5/engine-dom_debug.js +201 -119
  8. package/dist/engine-dom/umd/es2017/engine-dom.js +181 -127
  9. package/dist/engine-dom/umd/es2017/engine-dom.min.js +1 -1
  10. package/dist/engine-dom/umd/es2017/engine-dom_debug.js +168 -115
  11. package/dist/engine-dom/umd/es5/engine-dom.js +226 -147
  12. package/dist/engine-dom/umd/es5/engine-dom.min.js +1 -1
  13. package/dist/engine-dom/umd/es5/engine-dom_debug.js +201 -119
  14. package/dist/engine-server/commonjs/es2017/engine-server.js +89 -318
  15. package/dist/engine-server/commonjs/es2017/engine-server.min.js +1 -1
  16. package/dist/engine-server/esm/es2017/engine-server.js +89 -318
  17. package/dist/synthetic-shadow/esm/es2017/synthetic-shadow.js +3 -3
  18. package/dist/synthetic-shadow/iife/es2017/synthetic-shadow.js +3 -3
  19. package/dist/synthetic-shadow/iife/es2017/synthetic-shadow_debug.js +3 -3
  20. package/dist/synthetic-shadow/iife/es5/synthetic-shadow.js +3 -3
  21. package/dist/synthetic-shadow/iife/es5/synthetic-shadow_debug.js +3 -3
  22. package/dist/synthetic-shadow/umd/es2017/synthetic-shadow.js +3 -3
  23. package/dist/synthetic-shadow/umd/es2017/synthetic-shadow_debug.js +3 -3
  24. package/dist/synthetic-shadow/umd/es5/synthetic-shadow.js +3 -3
  25. package/dist/synthetic-shadow/umd/es5/synthetic-shadow_debug.js +3 -3
  26. package/dist/wire-service/esm/es2017/wire-service.js +2 -2
  27. package/dist/wire-service/iife/es2017/wire-service.js +2 -2
  28. package/dist/wire-service/iife/es2017/wire-service_debug.js +2 -2
  29. package/dist/wire-service/iife/es5/wire-service.js +2 -2
  30. package/dist/wire-service/iife/es5/wire-service_debug.js +2 -2
  31. package/dist/wire-service/umd/es2017/wire-service.js +2 -2
  32. package/dist/wire-service/umd/es2017/wire-service_debug.js +2 -2
  33. package/dist/wire-service/umd/es5/wire-service.js +2 -2
  34. package/dist/wire-service/umd/es5/wire-service_debug.js +2 -2
  35. package/package.json +7 -7
@@ -299,9 +299,9 @@ function htmlPropertyToAttribute(propName) {
299
299
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
300
300
  */
301
301
  // Increment whenever the LWC template compiler changes
302
- const LWC_VERSION = "2.20.4";
302
+ const LWC_VERSION = "2.22.0";
303
303
  const LWC_VERSION_COMMENT_REGEX = /\/\*LWC compiler v([\d.]+)\*\/\s*}/;
304
- /** version: 2.20.4 */
304
+ /** version: 2.22.0 */
305
305
 
306
306
  /*
307
307
  * Copyright (c) 2018, salesforce.com, inc.
@@ -455,7 +455,7 @@ function setFeatureFlagForTest(name, value) {
455
455
  setFeatureFlag(name, value);
456
456
  }
457
457
  }
458
- /** version: 2.20.4 */
458
+ /** version: 2.22.0 */
459
459
 
460
460
  /*
461
461
  * Copyright (c) 2018, salesforce.com, inc.
@@ -687,18 +687,21 @@ class ReactiveObserver {
687
687
  ArrayPush$1.call(this.listeners, reactiveObservers);
688
688
  }
689
689
  }
690
-
691
- /*
692
- * Copyright (c) 2018, salesforce.com, inc.
693
- * All rights reserved.
694
- * SPDX-License-Identifier: MIT
695
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
696
- */
697
690
  function componentValueMutated(vm, key) {
698
- valueMutated(vm.component, key);
691
+ // On the server side, we don't need mutation tracking. Skipping it improves performance.
692
+ {
693
+ valueMutated(vm.component, key);
694
+ }
699
695
  }
700
696
  function componentValueObserved(vm, key) {
701
- valueObserved(vm.component, key);
697
+ // On the server side, we don't need mutation tracking. Skipping it improves performance.
698
+ {
699
+ valueObserved(vm.component, key);
700
+ }
701
+ }
702
+ function createReactiveObserver(callback) {
703
+ // On the server side, we don't need mutation tracking. Skipping it improves performance.
704
+ return new ReactiveObserver(callback) ;
702
705
  }
703
706
 
704
707
  /*
@@ -1820,7 +1823,24 @@ const reactiveMembrane = new ObservableMembrane({
1820
1823
  * change or being removed.
1821
1824
  */
1822
1825
  function unwrap(value) {
1823
- return reactiveMembrane.unwrapProxy(value);
1826
+ // On the server side, we don't need mutation tracking. Skipping it improves performance.
1827
+ return reactiveMembrane.unwrapProxy(value) ;
1828
+ }
1829
+ function getReadOnlyProxy(value) {
1830
+ // We must return a frozen wrapper around the value, so that child components cannot mutate properties passed to
1831
+ // them from their parents. This applies to both the client and server.
1832
+ return reactiveMembrane.getReadOnlyProxy(value);
1833
+ }
1834
+ function getReactiveProxy(value) {
1835
+ // On the server side, we don't need mutation tracking. Skipping it improves performance.
1836
+ return reactiveMembrane.getProxy(value) ;
1837
+ }
1838
+ // Making the component instance a live value when using Locker to support expandos.
1839
+ function markLockerLiveObject(obj) {
1840
+ // On the server side, we don't need mutation tracking. Skipping it improves performance.
1841
+ {
1842
+ obj[lockerLivePropertyKey] = undefined;
1843
+ }
1824
1844
  }
1825
1845
 
1826
1846
  /*
@@ -1910,8 +1930,7 @@ const LightningElement = function () {
1910
1930
  vm.setHook = setHook;
1911
1931
  vm.getHook = getHook;
1912
1932
  }
1913
- // Making the component instance a live value when using Locker to support expandos.
1914
- this[lockerLivePropertyKey] = undefined;
1933
+ markLockerLiveObject(this);
1915
1934
  // Linking elm, shadow root and component with the VM.
1916
1935
  associateVM(component, vm);
1917
1936
  associateVM(elm, vm);
@@ -2180,6 +2199,45 @@ function createObservedFieldPropertyDescriptor(key) {
2180
2199
  configurable: true,
2181
2200
  };
2182
2201
  }
2202
+ class AccessorReactiveObserver extends ReactiveObserver {
2203
+ constructor(vm, set) {
2204
+ super(() => {
2205
+ if (isFalse(this.debouncing)) {
2206
+ this.debouncing = true;
2207
+ addCallbackToNextTick(() => {
2208
+ if (isTrue(this.debouncing)) {
2209
+ const { value } = this;
2210
+ const { isDirty: dirtyStateBeforeSetterCall, component, idx } = vm;
2211
+ set.call(component, value);
2212
+ // de-bouncing after the call to the original setter to prevent
2213
+ // infinity loop if the setter itself is mutating things that
2214
+ // were accessed during the previous invocation.
2215
+ this.debouncing = false;
2216
+ if (isTrue(vm.isDirty) && isFalse(dirtyStateBeforeSetterCall) && idx > 0) {
2217
+ // immediate rehydration due to a setter driven mutation, otherwise
2218
+ // the component will get rendered on the second tick, which it is not
2219
+ // desirable.
2220
+ rerenderVM(vm);
2221
+ }
2222
+ }
2223
+ });
2224
+ }
2225
+ });
2226
+ this.debouncing = false;
2227
+ }
2228
+ reset(value) {
2229
+ super.reset();
2230
+ this.debouncing = false;
2231
+ if (arguments.length > 0) {
2232
+ this.value = value;
2233
+ }
2234
+ }
2235
+ }
2236
+ function createAccessorReactiveObserver(vm, set) {
2237
+ // On the server side, we don't need mutation tracking. Skipping it improves performance.
2238
+ return new AccessorReactiveObserver(vm, set)
2239
+ ;
2240
+ }
2183
2241
 
2184
2242
  /*
2185
2243
  * Copyright (c) 2018, salesforce.com, inc.
@@ -2228,50 +2286,6 @@ function createPublicPropertyDescriptor(key) {
2228
2286
  configurable: true
2229
2287
  };
2230
2288
  }
2231
- class AccessorReactiveObserver extends ReactiveObserver {
2232
- constructor(vm, set) {
2233
- super(() => {
2234
- if (isFalse(this.debouncing)) {
2235
- this.debouncing = true;
2236
- addCallbackToNextTick(() => {
2237
- if (isTrue(this.debouncing)) {
2238
- const {
2239
- value
2240
- } = this;
2241
- const {
2242
- isDirty: dirtyStateBeforeSetterCall,
2243
- component,
2244
- idx
2245
- } = vm;
2246
- set.call(component, value); // de-bouncing after the call to the original setter to prevent
2247
- // infinity loop if the setter itself is mutating things that
2248
- // were accessed during the previous invocation.
2249
-
2250
- this.debouncing = false;
2251
-
2252
- if (isTrue(vm.isDirty) && isFalse(dirtyStateBeforeSetterCall) && idx > 0) {
2253
- // immediate rehydration due to a setter driven mutation, otherwise
2254
- // the component will get rendered on the second tick, which it is not
2255
- // desirable.
2256
- rerenderVM(vm);
2257
- }
2258
- }
2259
- });
2260
- }
2261
- });
2262
- this.debouncing = false;
2263
- }
2264
-
2265
- reset(value) {
2266
- super.reset();
2267
- this.debouncing = false;
2268
-
2269
- if (arguments.length > 0) {
2270
- this.value = value;
2271
- }
2272
- }
2273
-
2274
- }
2275
2289
  function createPublicAccessorDescriptor(key, descriptor) {
2276
2290
  const {
2277
2291
  get,
@@ -2312,7 +2326,7 @@ function createPublicAccessorDescriptor(key, descriptor) {
2312
2326
  let ro = vm.oar[key];
2313
2327
 
2314
2328
  if (isUndefined$1(ro)) {
2315
- ro = vm.oar[key] = new AccessorReactiveObserver(vm, set);
2329
+ ro = vm.oar[key] = createAccessorReactiveObserver(vm, set);
2316
2330
  } // every time we invoke this setter from outside (through this wrapper setter)
2317
2331
  // we should reset the value and then debounce just in case there is a pending
2318
2332
  // invocation the next tick that is not longer relevant since the value is changing
@@ -2344,7 +2358,7 @@ function createPublicAccessorDescriptor(key, descriptor) {
2344
2358
  */
2345
2359
  function track(target) {
2346
2360
  if (arguments.length === 1) {
2347
- return reactiveMembrane.getProxy(target);
2361
+ return getReactiveProxy(target);
2348
2362
  }
2349
2363
  if (process.env.NODE_ENV !== 'production') {
2350
2364
  assert.fail(`@track decorator can only be used with one argument to return a trackable object, or as a decorator function.`);
@@ -2365,7 +2379,7 @@ function internalTrackDecorator(key) {
2365
2379
  assert.invariant(!isInvokingRender, `${vmBeingRendered}.render() method has side effects on the state of ${vm}.${toString$1(key)}`);
2366
2380
  assert.invariant(!isUpdatingTemplate, `Updating the template of ${vmBeingRendered} has side effects on the state of ${vm}.${toString$1(key)}`);
2367
2381
  }
2368
- const reactiveOrAnyValue = reactiveMembrane.getProxy(newValue);
2382
+ const reactiveOrAnyValue = getReactiveProxy(newValue);
2369
2383
  if (reactiveOrAnyValue !== vm.cmpFields[key]) {
2370
2384
  vm.cmpFields[key] = reactiveOrAnyValue;
2371
2385
  componentValueMutated(vm, key);
@@ -2757,7 +2771,7 @@ function createSetter(key) {
2757
2771
  fn = cachedSetterByKey[key] = function (newValue) {
2758
2772
  const vm = getAssociatedVM(this);
2759
2773
  const { setHook } = vm;
2760
- newValue = reactiveMembrane.getReadOnlyProxy(newValue);
2774
+ newValue = getReadOnlyProxy(newValue);
2761
2775
  setHook(vm.component, key, newValue);
2762
2776
  };
2763
2777
  }
@@ -3897,10 +3911,11 @@ function mountElement(vnode, parent, anchor, renderer) {
3897
3911
  const { sel, owner, data: { svg }, } = vnode;
3898
3912
  const { createElement } = renderer;
3899
3913
  const namespace = isTrue(svg) ? SVG_NAMESPACE : undefined;
3900
- const elm = createElement(sel, namespace);
3914
+ const elm = (vnode.elm = createElement(sel, namespace));
3901
3915
  linkNodeToShadow(elm, owner, renderer);
3902
- fallbackElmHook(elm, vnode, renderer);
3903
- vnode.elm = elm;
3916
+ applyStyleScoping(elm, owner, renderer);
3917
+ applyDomManual(elm, vnode);
3918
+ applyElementRestrictions(elm, vnode);
3904
3919
  patchElementPropsAndAttrs$1(null, vnode, renderer);
3905
3920
  insertNode(elm, parent, anchor, renderer);
3906
3921
  mountVNodes(vnode.children, elm, renderer, null);
@@ -3915,6 +3930,7 @@ function mountStatic(vnode, parent, anchor, renderer) {
3915
3930
  const { cloneNode, isSyntheticShadowDefined } = renderer;
3916
3931
  const elm = (vnode.elm = cloneNode(vnode.fragment, true));
3917
3932
  linkNodeToShadow(elm, owner, renderer);
3933
+ applyElementRestrictions(elm, vnode);
3918
3934
  // Marks this node as Static to propagate the shadow resolver. must happen after elm is assigned to the proper shadow
3919
3935
  const { renderMode, shadowMode } = owner;
3920
3936
  if (isSyntheticShadowDefined) {
@@ -3922,10 +3938,6 @@ function mountStatic(vnode, parent, anchor, renderer) {
3922
3938
  elm[KEY__SHADOW_STATIC] = true;
3923
3939
  }
3924
3940
  }
3925
- if (process.env.NODE_ENV !== 'production') {
3926
- const isLight = renderMode === 0 /* RenderMode.Light */;
3927
- patchElementWithRestrictions(elm, { isPortal: false, isLight });
3928
- }
3929
3941
  insertNode(elm, parent, anchor, renderer);
3930
3942
  }
3931
3943
  function mountCustomElement(vnode, parent, anchor, renderer) {
@@ -3942,9 +3954,10 @@ function mountCustomElement(vnode, parent, anchor, renderer) {
3942
3954
  // the custom element from the registry is expecting an upgrade callback
3943
3955
  vm = createViewModelHook(elm, vnode, renderer);
3944
3956
  });
3945
- linkNodeToShadow(elm, owner, renderer);
3946
3957
  vnode.elm = elm;
3947
3958
  vnode.vm = vm;
3959
+ linkNodeToShadow(elm, owner, renderer);
3960
+ applyStyleScoping(elm, owner, renderer);
3948
3961
  if (vm) {
3949
3962
  allocateChildren(vnode, vm);
3950
3963
  }
@@ -4028,22 +4041,6 @@ function unmountVNodes(vnodes, parent, renderer, doRemove = false, start = 0, en
4028
4041
  function isVNode(vnode) {
4029
4042
  return vnode != null;
4030
4043
  }
4031
- function observeElementChildNodes(elm) {
4032
- elm.$domManual$ = true;
4033
- }
4034
- function setElementShadowToken(elm, token) {
4035
- elm.$shadowToken$ = token;
4036
- }
4037
- // Set the scope token class for *.scoped.css styles
4038
- function setScopeTokenClassIfNecessary(elm, owner, renderer) {
4039
- const token = getScopeTokenClass(owner);
4040
- if (!isNull(token)) {
4041
- const { getClassList } = renderer;
4042
- // TODO [#2762]: this dot notation with add is probably problematic
4043
- // probably we should have a renderer api for just the add operation
4044
- getClassList(elm).add(token);
4045
- }
4046
- }
4047
4044
  function linkNodeToShadow(elm, owner, renderer) {
4048
4045
  const { renderRoot, renderMode, shadowMode } = owner;
4049
4046
  const { isSyntheticShadowDefined } = renderer;
@@ -4096,31 +4093,37 @@ function patchElementPropsAndAttrs$1(oldVnode, vnode, renderer) {
4096
4093
  patchAttributes(oldVnode, vnode, renderer);
4097
4094
  patchProps(oldVnode, vnode, renderer);
4098
4095
  }
4099
- function fallbackElmHook(elm, vnode, renderer) {
4100
- const { owner } = vnode;
4101
- setScopeTokenClassIfNecessary(elm, owner, renderer);
4102
- if (owner.shadowMode === 1 /* ShadowMode.Synthetic */) {
4103
- const { data: { context }, } = vnode;
4104
- const { stylesheetToken } = owner.context;
4105
- if (!isUndefined$1(context) &&
4106
- !isUndefined$1(context.lwc) &&
4107
- context.lwc.dom === "manual" /* LwcDomMode.Manual */) {
4108
- // this element will now accept any manual content inserted into it
4109
- observeElementChildNodes(elm);
4110
- }
4111
- if (!isUndefined$1(stylesheetToken)) {
4112
- // when running in synthetic shadow mode, we need to set the shadowToken value
4113
- // into each element from the template, so they can be styled accordingly.
4114
- setElementShadowToken(elm, stylesheetToken);
4115
- }
4096
+ function applyStyleScoping(elm, owner, renderer) {
4097
+ // Set the class name for `*.scoped.css` style scoping.
4098
+ const scopeToken = getScopeTokenClass(owner);
4099
+ if (!isNull(scopeToken)) {
4100
+ const { getClassList } = renderer;
4101
+ // TODO [#2762]: this dot notation with add is probably problematic
4102
+ // probably we should have a renderer api for just the add operation
4103
+ getClassList(elm).add(scopeToken);
4104
+ }
4105
+ // Set property element for synthetic shadow DOM style scoping.
4106
+ const { stylesheetToken: syntheticToken } = owner.context;
4107
+ if (owner.shadowMode === 1 /* ShadowMode.Synthetic */ && !isUndefined$1(syntheticToken)) {
4108
+ elm.$shadowToken$ = syntheticToken;
4109
+ }
4110
+ }
4111
+ function applyDomManual(elm, vnode) {
4112
+ var _a;
4113
+ const { owner, data: { context }, } = vnode;
4114
+ if (owner.shadowMode === 1 /* ShadowMode.Synthetic */ && ((_a = context === null || context === void 0 ? void 0 : context.lwc) === null || _a === void 0 ? void 0 : _a.dom) === "manual" /* LwcDomMode.Manual */) {
4115
+ elm.$domManual$ = true;
4116
4116
  }
4117
+ }
4118
+ function applyElementRestrictions(elm, vnode) {
4119
+ var _a, _b;
4117
4120
  if (process.env.NODE_ENV !== 'production') {
4118
- const { data: { context }, } = vnode;
4119
- const isPortal = !isUndefined$1(context) &&
4120
- !isUndefined$1(context.lwc) &&
4121
- context.lwc.dom === "manual" /* LwcDomMode.Manual */;
4122
- const isLight = owner.renderMode === 0 /* RenderMode.Light */;
4123
- patchElementWithRestrictions(elm, { isPortal, isLight });
4121
+ const isPortal = vnode.type === 2 /* VNodeType.Element */ && ((_b = (_a = vnode.data.context) === null || _a === void 0 ? void 0 : _a.lwc) === null || _b === void 0 ? void 0 : _b.dom) === "manual" /* LwcDomMode.Manual */;
4122
+ const isLight = vnode.owner.renderMode === 0 /* RenderMode.Light */;
4123
+ patchElementWithRestrictions(elm, {
4124
+ isPortal,
4125
+ isLight,
4126
+ });
4124
4127
  }
4125
4128
  }
4126
4129
  function allocateChildren(vnode, vm) {
@@ -4155,15 +4158,6 @@ function createViewModelHook(elm, vnode, renderer) {
4155
4158
  return vm;
4156
4159
  }
4157
4160
  const { sel, mode, ctor, owner } = vnode;
4158
- setScopeTokenClassIfNecessary(elm, owner, renderer);
4159
- if (owner.shadowMode === 1 /* ShadowMode.Synthetic */) {
4160
- const { stylesheetToken } = owner.context;
4161
- // when running in synthetic shadow mode, we need to set the shadowToken value
4162
- // into each element from the template, so they can be styled accordingly.
4163
- if (!isUndefined$1(stylesheetToken)) {
4164
- setElementShadowToken(elm, stylesheetToken);
4165
- }
4166
- }
4167
4161
  vm = createVM(elm, ctor, renderer, {
4168
4162
  mode,
4169
4163
  owner,
@@ -5213,7 +5207,7 @@ function getComponentRegisteredTemplate(Ctor) {
5213
5207
  return signedTemplateMap.get(Ctor);
5214
5208
  }
5215
5209
  function getTemplateReactiveObserver(vm) {
5216
- return new ReactiveObserver(() => {
5210
+ return createReactiveObserver(() => {
5217
5211
  const { isDirty } = vm;
5218
5212
  if (isFalse(isDirty)) {
5219
5213
  markComponentAsDirty(vm);
@@ -6028,7 +6022,7 @@ function createMethodDataCallback(vm, method) {
6028
6022
  function createConfigWatcher(component, configCallback, callbackWhenConfigIsReady) {
6029
6023
  let hasPendingConfig = false; // creating the reactive observer for reactive params when needed
6030
6024
 
6031
- const ro = new ReactiveObserver(() => {
6025
+ const ro = createReactiveObserver(() => {
6032
6026
  if (hasPendingConfig === false) {
6033
6027
  hasPendingConfig = true; // collect new config in the micro-task
6034
6028
 
@@ -6324,7 +6318,7 @@ function readonly(obj) {
6324
6318
  assert.fail('@readonly cannot be used as a decorator just yet, use it as a function with one argument to produce a readonly version of the provided value.');
6325
6319
  }
6326
6320
  }
6327
- return reactiveMembrane.getReadOnlyProxy(obj);
6321
+ return getReadOnlyProxy(obj);
6328
6322
  }
6329
6323
 
6330
6324
  /*
@@ -6835,7 +6829,7 @@ function getComponentConstructor(elm) {
6835
6829
  }
6836
6830
  return ctor;
6837
6831
  }
6838
- /* version: 2.20.4 */
6832
+ /* version: 2.22.0 */
6839
6833
 
6840
6834
  /*
6841
6835
  * Copyright (c) 2018, salesforce.com, inc.
@@ -6979,6 +6973,69 @@ function insertStylesheet(content, target) {
6979
6973
  }
6980
6974
  }
6981
6975
 
6976
+ /*
6977
+ * Copyright (c) 2018, salesforce.com, inc.
6978
+ * All rights reserved.
6979
+ * SPDX-License-Identifier: MIT
6980
+ * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6981
+ */
6982
+ const SUPPORTS_TEMPLATE = typeof HTMLTemplateElement === 'function';
6983
+ let createFragment;
6984
+ if (SUPPORTS_TEMPLATE) {
6985
+ // Parse the fragment HTML string into DOM
6986
+ createFragment = function (html) {
6987
+ const template = document.createElement('template');
6988
+ template.innerHTML = html;
6989
+ return template.content.firstChild;
6990
+ };
6991
+ }
6992
+ else {
6993
+ // In browsers that don't support <template> (e.g. IE11), we need to be careful to wrap elements like
6994
+ // <td> in the proper container elements (e.g. <tbody>), because otherwise they will be parsed as null.
6995
+ // Via https://github.com/webcomponents/polyfills/blob/ee1db33/packages/template/template.js#L273-L280
6996
+ // With other elements added from:
6997
+ // https://github.com/sindresorhus/html-tags/blob/95dcdd5/index.js
6998
+ // Using the test:
6999
+ // document.createRange().createContextualFragment(`<${tag}></${tag}>`).firstChild === null
7000
+ // And omitting <html>, <head>, and <body> as these are not practical in an LWC component.
7001
+ const topLevelWrappingMap = {
7002
+ caption: ['table'],
7003
+ col: ['colgroup', 'table'],
7004
+ colgroup: ['table'],
7005
+ option: ['select'],
7006
+ tbody: ['table'],
7007
+ td: ['tr', 'tbody', 'table'],
7008
+ th: ['tr', 'tbody', 'table'],
7009
+ thead: ['table'],
7010
+ tfoot: ['table'],
7011
+ tr: ['tbody', 'table'],
7012
+ };
7013
+ // Via https://github.com/webcomponents/polyfills/blob/ee1db33/packages/template/template.js#L282-L288
7014
+ const getTagName = function (text) {
7015
+ return (/<([a-z][^/\0>\x20\t\r\n\f]+)/i.exec(text) || ['', ''])[1].toLowerCase();
7016
+ };
7017
+ // Via https://github.com/webcomponents/polyfills/blob/ee1db33/packages/template/template.js#L295-L320
7018
+ createFragment = function (html) {
7019
+ const wrapperTags = topLevelWrappingMap[getTagName(html)];
7020
+ if (!isUndefined$1(wrapperTags)) {
7021
+ for (const wrapperTag of wrapperTags) {
7022
+ html = `<${wrapperTag}>${html}</${wrapperTag}>`;
7023
+ }
7024
+ }
7025
+ // For IE11, the document title must not be undefined, but it can be an empty string
7026
+ // https://developer.mozilla.org/en-US/docs/Web/API/DOMImplementation/createHTMLDocument#browser_compatibility
7027
+ const doc = document.implementation.createHTMLDocument('');
7028
+ doc.body.innerHTML = html;
7029
+ let content = doc.body;
7030
+ if (!isUndefined$1(wrapperTags)) {
7031
+ for (let i = 0; i < wrapperTags.length; i++) {
7032
+ content = content.firstChild;
7033
+ }
7034
+ }
7035
+ return content.firstChild;
7036
+ };
7037
+ }
7038
+
6982
7039
  /*
6983
7040
  * Copyright (c) 2018, salesforce.com, inc.
6984
7041
  * All rights reserved.
@@ -7057,9 +7114,6 @@ const isSyntheticShadowDefined = hasOwnProperty$1.call(Element.prototype, KEY__S
7057
7114
  function cloneNode(node, deep) {
7058
7115
  return node.cloneNode(deep);
7059
7116
  }
7060
- function createFragment(html) {
7061
- return document.createRange().createContextualFragment(html).firstChild;
7062
- }
7063
7117
  function createElement$1(tagName, namespace) {
7064
7118
  return isUndefined$1(namespace)
7065
7119
  ? document.createElement(tagName)
@@ -7523,6 +7577,6 @@ defineProperty(LightningElement, 'CustomElementConstructor', {
7523
7577
  });
7524
7578
  freeze(LightningElement);
7525
7579
  seal(LightningElement.prototype);
7526
- /* version: 2.20.4 */
7580
+ /* version: 2.22.0 */
7527
7581
 
7528
7582
  export { LightningElement, profilerControl as __unstable__ProfilerControl, api$1 as api, deprecatedBuildCustomElementConstructor as buildCustomElementConstructor, createContextProvider, createElement, freezeTemplate, getComponentConstructor, getComponentDef, hydrateComponent, isComponentConstructor, isNodeShadowed as isNodeFromTemplate, parseFragment, parseSVGFragment, readonly, register, registerComponent, registerDecorators, registerTemplate, renderer, sanitizeAttribute, setFeatureFlag, setFeatureFlagForTest, setHooks, swapComponent, swapStyle, swapTemplate, track, unwrap, wire };