@lwc/engine-core 2.23.6 → 2.24.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.
@@ -111,6 +111,20 @@ function flattenStylesheets(stylesheets) {
111
111
  }
112
112
  return list;
113
113
  }
114
+ // Set a ref (lwc:ref) on a VM, from a template API
115
+ function setRefVNode(vm, ref, vnode) {
116
+ if (process.env.NODE_ENV !== 'production' && shared.isUndefined(vm.refVNodes)) {
117
+ throw new Error('refVNodes must be defined when setting a ref');
118
+ }
119
+ // If this method is called, then vm.refVNodes is set as the template has refs.
120
+ // If not, then something went wrong and we threw an error above.
121
+ const refVNodes = vm.refVNodes;
122
+ // In cases of conflict (two elements with the same ref), prefer, the last one,
123
+ // in depth-first traversal order.
124
+ if (!(ref in refVNodes) || refVNodes[ref].key < vnode.key) {
125
+ refVNodes[ref] = vnode;
126
+ }
127
+ }
114
128
 
115
129
  /*
116
130
  * Copyright (c) 2019, salesforce.com, inc.
@@ -1441,6 +1455,8 @@ function createBridgeToElementDescriptor(propName, descriptor) {
1441
1455
  },
1442
1456
  };
1443
1457
  }
1458
+ const EMPTY_REFS = shared.freeze(shared.create(null));
1459
+ const refsCache = new WeakMap();
1444
1460
  /**
1445
1461
  * This class is the base class for any LWC element.
1446
1462
  * Some elements directly extends this class, others implement it via inheritance.
@@ -1620,6 +1636,70 @@ LightningElement.prototype = {
1620
1636
  }
1621
1637
  return vm.shadowRoot;
1622
1638
  },
1639
+ get refs() {
1640
+ const vm = getAssociatedVM(this);
1641
+ if (isUpdatingTemplate) {
1642
+ if (process.env.NODE_ENV !== 'production') {
1643
+ logError(`this.refs should not be called while ${getComponentTag(vm)} is rendering. Use this.refs only when the DOM is stable, e.g. in renderedCallback().`);
1644
+ }
1645
+ // If the template is in the process of being updated, then we don't want to go through the normal
1646
+ // process of returning the refs and caching them, because the state of the refs is unstable.
1647
+ // This can happen if e.g. a template contains `<div class={foo}></div>` and `foo` is computed
1648
+ // based on `this.refs.bar`.
1649
+ return;
1650
+ }
1651
+ if (process.env.NODE_ENV !== 'production') {
1652
+ warnIfInvokedDuringConstruction(vm, 'refs');
1653
+ }
1654
+ const { refVNodes, hasRefVNodes, cmpTemplate } = vm;
1655
+ // If the `cmpTemplate` is null, that means that the template has not been rendered yet. Most likely this occurs
1656
+ // if `this.refs` is called during the `connectedCallback` phase. The DOM elements have not been rendered yet,
1657
+ // so log a warning. Note we also check `isBeingConstructed()` to avoid a double warning (due to
1658
+ // `warnIfInvokedDuringConstruction` above).
1659
+ if (process.env.NODE_ENV !== 'production' &&
1660
+ shared.isNull(cmpTemplate) &&
1661
+ !isBeingConstructed(vm)) {
1662
+ logError(`this.refs is undefined for ${getComponentTag(vm)}. This is either because the attached template has no "lwc:ref" directive, or this.refs was ` +
1663
+ `invoked before renderedCallback(). Use this.refs only when the referenced HTML elements have ` +
1664
+ `been rendered to the DOM, such as within renderedCallback() or disconnectedCallback().`);
1665
+ }
1666
+ // For backwards compatibility with component written before template refs
1667
+ // were introduced, we return undefined if the template has no refs defined
1668
+ // anywhere. This fixes components that may want to add an expando called `refs`
1669
+ // and are checking if it exists with `if (this.refs)` before adding it.
1670
+ // Note it is not sufficient to just check if `refVNodes` is null or empty,
1671
+ // because a template may have `lwc:ref` defined within a falsy `if:true` block.
1672
+ if (!hasRefVNodes) {
1673
+ return;
1674
+ }
1675
+ // For templates that are using `lwc:ref`, if there are no refs currently available
1676
+ // (e.g. refs inside of a falsy `if:true` block), we return an empty object.
1677
+ if (shared.isNull(refVNodes)) {
1678
+ return EMPTY_REFS;
1679
+ }
1680
+ // The refNodes can be cached based on the refVNodes, since the refVNodes
1681
+ // are recreated from scratch every time the template is rendered.
1682
+ // This happens with `vm.refVNodes = null` in `template.ts` in `@lwc/engine-core`.
1683
+ let refs = refsCache.get(refVNodes);
1684
+ if (shared.isUndefined(refs)) {
1685
+ refs = shared.create(null);
1686
+ for (const key of shared.keys(refVNodes)) {
1687
+ refs[key] = refVNodes[key].elm;
1688
+ }
1689
+ shared.freeze(refs);
1690
+ refsCache.set(refVNodes, refs);
1691
+ }
1692
+ return refs;
1693
+ },
1694
+ // For backwards compat, we allow component authors to set `refs` as an expando
1695
+ set refs(value) {
1696
+ shared.defineProperty(this, 'refs', {
1697
+ configurable: true,
1698
+ enumerable: true,
1699
+ writable: true,
1700
+ value,
1701
+ });
1702
+ },
1623
1703
  get shadowRoot() {
1624
1704
  // From within the component instance, the shadowRoot is always reported as "closed".
1625
1705
  // Authors should rely on this.template instead.
@@ -3223,13 +3303,27 @@ function isLiveBindingProp(sel, key) {
3223
3303
  return sel === 'input' && (key === 'value' || key === 'checked');
3224
3304
  }
3225
3305
  function patchProps(oldVnode, vnode, renderer) {
3226
- const { props } = vnode.data;
3227
- if (shared.isUndefined(props)) {
3306
+ let { props } = vnode.data;
3307
+ const { spread } = vnode.data;
3308
+ if (shared.isUndefined(props) && shared.isUndefined(spread)) {
3228
3309
  return;
3229
3310
  }
3230
- const oldProps = shared.isNull(oldVnode) ? EmptyObject : oldVnode.data.props;
3231
- if (oldProps === props) {
3232
- return;
3311
+ let oldProps;
3312
+ if (!shared.isNull(oldVnode)) {
3313
+ oldProps = oldVnode.data.props;
3314
+ const oldSpread = oldVnode.data.spread;
3315
+ if (oldProps === props && oldSpread === spread) {
3316
+ return;
3317
+ }
3318
+ if (shared.isUndefined(oldProps)) {
3319
+ oldProps = EmptyObject;
3320
+ }
3321
+ if (!shared.isUndefined(oldSpread)) {
3322
+ oldProps = shared.assign({}, oldProps, oldSpread);
3323
+ }
3324
+ }
3325
+ if (!shared.isUndefined(spread)) {
3326
+ props = shared.assign({}, props, spread);
3233
3327
  }
3234
3328
  const isFirstPatch = shared.isNull(oldVnode);
3235
3329
  const { elm, sel } = vnode;
@@ -3239,7 +3333,9 @@ function patchProps(oldVnode, vnode, renderer) {
3239
3333
  // Set the property if it's the first time is is patched or if the previous property is
3240
3334
  // different than the one previously set.
3241
3335
  if (isFirstPatch ||
3242
- cur !== (isLiveBindingProp(sel, key) ? getProperty(elm, key) : oldProps[key])) {
3336
+ cur !== (isLiveBindingProp(sel, key) ? getProperty(elm, key) : oldProps[key]) ||
3337
+ !(key in oldProps) // this is required because the above case will pass when `cur` is `undefined` and key is missing in `oldProps`
3338
+ ) {
3243
3339
  // Additional verification if properties are supported by the element
3244
3340
  // Validation relies on html properties and public properties being defined on the element,
3245
3341
  // SSR has its own custom validation.
@@ -4303,17 +4399,20 @@ function h(sel, data, children = EmptyArray) {
4303
4399
  }
4304
4400
  });
4305
4401
  }
4306
- let elm;
4307
- const { key } = data;
4308
- return {
4402
+ const { key, ref } = data;
4403
+ const vnode = {
4309
4404
  type: 2 /* VNodeType.Element */,
4310
4405
  sel,
4311
4406
  data,
4312
4407
  children,
4313
- elm,
4408
+ elm: undefined,
4314
4409
  key,
4315
4410
  owner: vmBeingRendered,
4316
4411
  };
4412
+ if (!shared.isUndefined(ref)) {
4413
+ setRefVNode(vmBeingRendered, ref, vnode);
4414
+ }
4415
+ return vnode;
4317
4416
  }
4318
4417
  // [t]ab[i]ndex function
4319
4418
  function ti(value) {
@@ -4378,7 +4477,7 @@ function c(sel, Ctor, data, children = EmptyArray) {
4378
4477
  });
4379
4478
  }
4380
4479
  }
4381
- const { key } = data;
4480
+ const { key, ref } = data;
4382
4481
  let elm, aChildren, vm;
4383
4482
  const vnode = {
4384
4483
  type: 3 /* VNodeType.CustomElement */,
@@ -4394,6 +4493,9 @@ function c(sel, Ctor, data, children = EmptyArray) {
4394
4493
  vm,
4395
4494
  };
4396
4495
  addVNodeToChildLWC(vnode);
4496
+ if (!shared.isUndefined(ref)) {
4497
+ setRefVNode(vmBeingRendered, ref, vnode);
4498
+ }
4397
4499
  return vnode;
4398
4500
  }
4399
4501
  // [i]terable node
@@ -4922,6 +5024,10 @@ function evaluateTemplate(vm, html) {
4922
5024
  // add the VM to the list of host VMs that can be re-rendered if html is swapped
4923
5025
  setActiveVM(vm);
4924
5026
  }
5027
+ // reset the refs; they will be set during the tmpl() instantiation
5028
+ const hasRefVNodes = Boolean(html.hasRefs);
5029
+ vm.hasRefVNodes = hasRefVNodes;
5030
+ vm.refVNodes = hasRefVNodes ? shared.create(null) : null;
4925
5031
  // right before producing the vnodes, we clear up all internal references
4926
5032
  // to custom elements from the template.
4927
5033
  vm.velements = [];
@@ -5280,6 +5386,8 @@ function createVM(elm, ctor, renderer, options) {
5280
5386
  tagName,
5281
5387
  mode,
5282
5388
  owner,
5389
+ refVNodes: null,
5390
+ hasRefVNodes: false,
5283
5391
  children: EmptyArray,
5284
5392
  aChildren: EmptyArray,
5285
5393
  velements: EmptyArray,
@@ -6725,4 +6833,4 @@ exports.swapTemplate = swapTemplate;
6725
6833
  exports.track = track;
6726
6834
  exports.unwrap = unwrap;
6727
6835
  exports.wire = wire;
6728
- /* version: 2.23.6 */
6836
+ /* version: 2.24.0 */
@@ -1,7 +1,7 @@
1
1
  /* proxy-compat-disable */
2
2
  import { lwcRuntimeFlags } from '@lwc/features';
3
3
  export { setFeatureFlag, setFeatureFlagForTest } from '@lwc/features';
4
- import { seal, create, isFunction as isFunction$1, ArrayPush as ArrayPush$1, isUndefined as isUndefined$1, ArrayIndexOf, ArraySplice, StringToLowerCase, isNull, ArrayJoin, isFrozen, defineProperty, hasOwnProperty as hasOwnProperty$1, assign, forEach, keys, AriaPropNameToAttrNameMap, getPropertyDescriptor, defineProperties, getOwnPropertyNames as getOwnPropertyNames$1, getPrototypeOf as getPrototypeOf$1, setPrototypeOf, isObject, assert, KEY__SYNTHETIC_MODE, isFalse, isTrue, toString as toString$1, getOwnPropertyDescriptor as getOwnPropertyDescriptor$1, LWC_VERSION_COMMENT_REGEX, LWC_VERSION, freeze, htmlPropertyToAttribute, ArraySlice, ArrayMap, isArray as isArray$1, KEY__SCOPED_CSS, StringCharCodeAt, XML_NAMESPACE, XLINK_NAMESPACE, isString, StringSlice, SVG_NAMESPACE, KEY__SHADOW_STATIC, KEY__SHADOW_RESOLVER, isNumber, StringReplace, noop, ArrayUnshift, ArrayCopyWithin, ArrayFill, ArraySort, ArrayReverse, ArrayShift, ArrayPop } from '@lwc/shared';
4
+ import { seal, create, isUndefined as isUndefined$1, isFunction as isFunction$1, ArrayPush as ArrayPush$1, ArrayIndexOf, ArraySplice, StringToLowerCase, isNull, ArrayJoin, isFrozen, defineProperty, hasOwnProperty as hasOwnProperty$1, assign, forEach, keys, AriaPropNameToAttrNameMap, getPropertyDescriptor, defineProperties, getOwnPropertyNames as getOwnPropertyNames$1, getPrototypeOf as getPrototypeOf$1, setPrototypeOf, isObject, freeze, assert, KEY__SYNTHETIC_MODE, isFalse, isTrue, toString as toString$1, getOwnPropertyDescriptor as getOwnPropertyDescriptor$1, LWC_VERSION_COMMENT_REGEX, LWC_VERSION, htmlPropertyToAttribute, ArraySlice, ArrayMap, isArray as isArray$1, KEY__SCOPED_CSS, StringCharCodeAt, XML_NAMESPACE, XLINK_NAMESPACE, isString, StringSlice, SVG_NAMESPACE, KEY__SHADOW_STATIC, KEY__SHADOW_RESOLVER, isNumber, StringReplace, noop, ArrayUnshift, ArrayCopyWithin, ArrayFill, ArraySort, ArrayReverse, ArrayShift, ArrayPop } from '@lwc/shared';
5
5
 
6
6
  /*
7
7
  * Copyright (c) 2018, salesforce.com, inc.
@@ -108,6 +108,20 @@ function flattenStylesheets(stylesheets) {
108
108
  }
109
109
  return list;
110
110
  }
111
+ // Set a ref (lwc:ref) on a VM, from a template API
112
+ function setRefVNode(vm, ref, vnode) {
113
+ if (process.env.NODE_ENV !== 'production' && isUndefined$1(vm.refVNodes)) {
114
+ throw new Error('refVNodes must be defined when setting a ref');
115
+ }
116
+ // If this method is called, then vm.refVNodes is set as the template has refs.
117
+ // If not, then something went wrong and we threw an error above.
118
+ const refVNodes = vm.refVNodes;
119
+ // In cases of conflict (two elements with the same ref), prefer, the last one,
120
+ // in depth-first traversal order.
121
+ if (!(ref in refVNodes) || refVNodes[ref].key < vnode.key) {
122
+ refVNodes[ref] = vnode;
123
+ }
124
+ }
111
125
 
112
126
  /*
113
127
  * Copyright (c) 2019, salesforce.com, inc.
@@ -1438,6 +1452,8 @@ function createBridgeToElementDescriptor(propName, descriptor) {
1438
1452
  },
1439
1453
  };
1440
1454
  }
1455
+ const EMPTY_REFS = freeze(create(null));
1456
+ const refsCache = new WeakMap();
1441
1457
  /**
1442
1458
  * This class is the base class for any LWC element.
1443
1459
  * Some elements directly extends this class, others implement it via inheritance.
@@ -1617,6 +1633,70 @@ LightningElement.prototype = {
1617
1633
  }
1618
1634
  return vm.shadowRoot;
1619
1635
  },
1636
+ get refs() {
1637
+ const vm = getAssociatedVM(this);
1638
+ if (isUpdatingTemplate) {
1639
+ if (process.env.NODE_ENV !== 'production') {
1640
+ logError(`this.refs should not be called while ${getComponentTag(vm)} is rendering. Use this.refs only when the DOM is stable, e.g. in renderedCallback().`);
1641
+ }
1642
+ // If the template is in the process of being updated, then we don't want to go through the normal
1643
+ // process of returning the refs and caching them, because the state of the refs is unstable.
1644
+ // This can happen if e.g. a template contains `<div class={foo}></div>` and `foo` is computed
1645
+ // based on `this.refs.bar`.
1646
+ return;
1647
+ }
1648
+ if (process.env.NODE_ENV !== 'production') {
1649
+ warnIfInvokedDuringConstruction(vm, 'refs');
1650
+ }
1651
+ const { refVNodes, hasRefVNodes, cmpTemplate } = vm;
1652
+ // If the `cmpTemplate` is null, that means that the template has not been rendered yet. Most likely this occurs
1653
+ // if `this.refs` is called during the `connectedCallback` phase. The DOM elements have not been rendered yet,
1654
+ // so log a warning. Note we also check `isBeingConstructed()` to avoid a double warning (due to
1655
+ // `warnIfInvokedDuringConstruction` above).
1656
+ if (process.env.NODE_ENV !== 'production' &&
1657
+ isNull(cmpTemplate) &&
1658
+ !isBeingConstructed(vm)) {
1659
+ logError(`this.refs is undefined for ${getComponentTag(vm)}. This is either because the attached template has no "lwc:ref" directive, or this.refs was ` +
1660
+ `invoked before renderedCallback(). Use this.refs only when the referenced HTML elements have ` +
1661
+ `been rendered to the DOM, such as within renderedCallback() or disconnectedCallback().`);
1662
+ }
1663
+ // For backwards compatibility with component written before template refs
1664
+ // were introduced, we return undefined if the template has no refs defined
1665
+ // anywhere. This fixes components that may want to add an expando called `refs`
1666
+ // and are checking if it exists with `if (this.refs)` before adding it.
1667
+ // Note it is not sufficient to just check if `refVNodes` is null or empty,
1668
+ // because a template may have `lwc:ref` defined within a falsy `if:true` block.
1669
+ if (!hasRefVNodes) {
1670
+ return;
1671
+ }
1672
+ // For templates that are using `lwc:ref`, if there are no refs currently available
1673
+ // (e.g. refs inside of a falsy `if:true` block), we return an empty object.
1674
+ if (isNull(refVNodes)) {
1675
+ return EMPTY_REFS;
1676
+ }
1677
+ // The refNodes can be cached based on the refVNodes, since the refVNodes
1678
+ // are recreated from scratch every time the template is rendered.
1679
+ // This happens with `vm.refVNodes = null` in `template.ts` in `@lwc/engine-core`.
1680
+ let refs = refsCache.get(refVNodes);
1681
+ if (isUndefined$1(refs)) {
1682
+ refs = create(null);
1683
+ for (const key of keys(refVNodes)) {
1684
+ refs[key] = refVNodes[key].elm;
1685
+ }
1686
+ freeze(refs);
1687
+ refsCache.set(refVNodes, refs);
1688
+ }
1689
+ return refs;
1690
+ },
1691
+ // For backwards compat, we allow component authors to set `refs` as an expando
1692
+ set refs(value) {
1693
+ defineProperty(this, 'refs', {
1694
+ configurable: true,
1695
+ enumerable: true,
1696
+ writable: true,
1697
+ value,
1698
+ });
1699
+ },
1620
1700
  get shadowRoot() {
1621
1701
  // From within the component instance, the shadowRoot is always reported as "closed".
1622
1702
  // Authors should rely on this.template instead.
@@ -3220,13 +3300,27 @@ function isLiveBindingProp(sel, key) {
3220
3300
  return sel === 'input' && (key === 'value' || key === 'checked');
3221
3301
  }
3222
3302
  function patchProps(oldVnode, vnode, renderer) {
3223
- const { props } = vnode.data;
3224
- if (isUndefined$1(props)) {
3303
+ let { props } = vnode.data;
3304
+ const { spread } = vnode.data;
3305
+ if (isUndefined$1(props) && isUndefined$1(spread)) {
3225
3306
  return;
3226
3307
  }
3227
- const oldProps = isNull(oldVnode) ? EmptyObject : oldVnode.data.props;
3228
- if (oldProps === props) {
3229
- return;
3308
+ let oldProps;
3309
+ if (!isNull(oldVnode)) {
3310
+ oldProps = oldVnode.data.props;
3311
+ const oldSpread = oldVnode.data.spread;
3312
+ if (oldProps === props && oldSpread === spread) {
3313
+ return;
3314
+ }
3315
+ if (isUndefined$1(oldProps)) {
3316
+ oldProps = EmptyObject;
3317
+ }
3318
+ if (!isUndefined$1(oldSpread)) {
3319
+ oldProps = assign({}, oldProps, oldSpread);
3320
+ }
3321
+ }
3322
+ if (!isUndefined$1(spread)) {
3323
+ props = assign({}, props, spread);
3230
3324
  }
3231
3325
  const isFirstPatch = isNull(oldVnode);
3232
3326
  const { elm, sel } = vnode;
@@ -3236,7 +3330,9 @@ function patchProps(oldVnode, vnode, renderer) {
3236
3330
  // Set the property if it's the first time is is patched or if the previous property is
3237
3331
  // different than the one previously set.
3238
3332
  if (isFirstPatch ||
3239
- cur !== (isLiveBindingProp(sel, key) ? getProperty(elm, key) : oldProps[key])) {
3333
+ cur !== (isLiveBindingProp(sel, key) ? getProperty(elm, key) : oldProps[key]) ||
3334
+ !(key in oldProps) // this is required because the above case will pass when `cur` is `undefined` and key is missing in `oldProps`
3335
+ ) {
3240
3336
  // Additional verification if properties are supported by the element
3241
3337
  // Validation relies on html properties and public properties being defined on the element,
3242
3338
  // SSR has its own custom validation.
@@ -4300,17 +4396,20 @@ function h(sel, data, children = EmptyArray) {
4300
4396
  }
4301
4397
  });
4302
4398
  }
4303
- let elm;
4304
- const { key } = data;
4305
- return {
4399
+ const { key, ref } = data;
4400
+ const vnode = {
4306
4401
  type: 2 /* VNodeType.Element */,
4307
4402
  sel,
4308
4403
  data,
4309
4404
  children,
4310
- elm,
4405
+ elm: undefined,
4311
4406
  key,
4312
4407
  owner: vmBeingRendered,
4313
4408
  };
4409
+ if (!isUndefined$1(ref)) {
4410
+ setRefVNode(vmBeingRendered, ref, vnode);
4411
+ }
4412
+ return vnode;
4314
4413
  }
4315
4414
  // [t]ab[i]ndex function
4316
4415
  function ti(value) {
@@ -4375,7 +4474,7 @@ function c(sel, Ctor, data, children = EmptyArray) {
4375
4474
  });
4376
4475
  }
4377
4476
  }
4378
- const { key } = data;
4477
+ const { key, ref } = data;
4379
4478
  let elm, aChildren, vm;
4380
4479
  const vnode = {
4381
4480
  type: 3 /* VNodeType.CustomElement */,
@@ -4391,6 +4490,9 @@ function c(sel, Ctor, data, children = EmptyArray) {
4391
4490
  vm,
4392
4491
  };
4393
4492
  addVNodeToChildLWC(vnode);
4493
+ if (!isUndefined$1(ref)) {
4494
+ setRefVNode(vmBeingRendered, ref, vnode);
4495
+ }
4394
4496
  return vnode;
4395
4497
  }
4396
4498
  // [i]terable node
@@ -4919,6 +5021,10 @@ function evaluateTemplate(vm, html) {
4919
5021
  // add the VM to the list of host VMs that can be re-rendered if html is swapped
4920
5022
  setActiveVM(vm);
4921
5023
  }
5024
+ // reset the refs; they will be set during the tmpl() instantiation
5025
+ const hasRefVNodes = Boolean(html.hasRefs);
5026
+ vm.hasRefVNodes = hasRefVNodes;
5027
+ vm.refVNodes = hasRefVNodes ? create(null) : null;
4922
5028
  // right before producing the vnodes, we clear up all internal references
4923
5029
  // to custom elements from the template.
4924
5030
  vm.velements = [];
@@ -5277,6 +5383,8 @@ function createVM(elm, ctor, renderer, options) {
5277
5383
  tagName,
5278
5384
  mode,
5279
5385
  owner,
5386
+ refVNodes: null,
5387
+ hasRefVNodes: false,
5280
5388
  children: EmptyArray,
5281
5389
  aChildren: EmptyArray,
5282
5390
  velements: EmptyArray,
@@ -6685,4 +6793,4 @@ function getComponentConstructor(elm) {
6685
6793
  }
6686
6794
 
6687
6795
  export { LightningElement, profilerControl as __unstable__ProfilerControl, api$1 as api, connectRootElement, createContextProvider, createVM, disconnectRootElement, freezeTemplate, getAssociatedVMIfPresent, getComponentConstructor, getComponentDef, getComponentHtmlPrototype, getUpgradableConstructor, hydrateRoot, isComponentConstructor, parseFragment, parseSVGFragment, readonly, register, registerComponent, registerDecorators, registerTemplate, sanitizeAttribute, setHooks, swapComponent, swapStyle, swapTemplate, track, unwrap, wire };
6688
- /* version: 2.23.6 */
6796
+ /* version: 2.24.0 */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lwc/engine-core",
3
- "version": "2.23.6",
3
+ "version": "2.24.0",
4
4
  "description": "Core LWC engine APIs.",
5
5
  "homepage": "https://lwc.dev/",
6
6
  "repository": {
@@ -24,8 +24,8 @@
24
24
  "types/"
25
25
  ],
26
26
  "dependencies": {
27
- "@lwc/features": "2.23.6",
28
- "@lwc/shared": "2.23.6"
27
+ "@lwc/features": "2.24.0",
28
+ "@lwc/shared": "2.24.0"
29
29
  },
30
30
  "devDependencies": {
31
31
  "observable-membrane": "2.0.0"
@@ -19,8 +19,12 @@ export interface LightningElementConstructor {
19
19
  shadowSupportMode?: ShadowSupportMode;
20
20
  }
21
21
  declare type HTMLElementTheGoodParts = Pick<Object, 'toString'> & Pick<HTMLElement, 'accessKey' | 'addEventListener' | 'children' | 'childNodes' | 'classList' | 'dir' | 'dispatchEvent' | 'draggable' | 'firstChild' | 'firstElementChild' | 'getAttribute' | 'getAttributeNS' | 'getBoundingClientRect' | 'getElementsByClassName' | 'getElementsByTagName' | 'hasAttribute' | 'hasAttributeNS' | 'hidden' | 'id' | 'isConnected' | 'lang' | 'lastChild' | 'lastElementChild' | 'querySelector' | 'querySelectorAll' | 'removeAttribute' | 'removeAttributeNS' | 'removeEventListener' | 'setAttribute' | 'setAttributeNS' | 'spellcheck' | 'tabIndex' | 'title'>;
22
+ declare type RefNodes = {
23
+ [name: string]: Element;
24
+ };
22
25
  export interface LightningElement extends HTMLElementTheGoodParts, AccessibleElementProperties {
23
26
  template: ShadowRoot | null;
27
+ refs: RefNodes;
24
28
  render(): Template;
25
29
  connectedCallback?(): void;
26
30
  disconnectedCallback?(): void;
@@ -12,6 +12,8 @@ export interface Template {
12
12
  stylesheetToken?: string;
13
13
  /** Render mode for the template. Could be light or undefined (which means it's shadow) */
14
14
  renderMode?: 'light';
15
+ /** True if this template contains template refs, undefined or false otherwise */
16
+ hasRefs?: boolean;
15
17
  }
16
18
  export declare let isUpdatingTemplate: boolean;
17
19
  export declare function getVMBeingRendered(): VM | null;
@@ -1,4 +1,6 @@
1
1
  import { StylesheetFactory, TemplateStylesheetFactories } from './stylesheet';
2
+ import { VM } from './vm';
3
+ import { VBaseElement } from './vnodes';
2
4
  declare type Callback = () => void;
3
5
  export declare const SPACE_CHAR = 32;
4
6
  export declare const EmptyObject: any;
@@ -14,4 +16,5 @@ export declare function cloneAndOmitKey(object: {
14
16
  [key: string]: any;
15
17
  };
16
18
  export declare function flattenStylesheets(stylesheets: TemplateStylesheetFactories): StylesheetFactory[];
19
+ export declare function setRefVNode(vm: VM, ref: string, vnode: VBaseElement): void;
17
20
  export {};
@@ -4,7 +4,7 @@ import { ComponentDef } from './def';
4
4
  import { LightningElement, LightningElementConstructor } from './base-lightning-element';
5
5
  import { ReactiveObserver } from './mutation-tracker';
6
6
  import { AccessorReactiveObserver } from './accessor-reactive-observer';
7
- import { VNodes, VCustomElement, VNode } from './vnodes';
7
+ import { VNodes, VCustomElement, VNode, VBaseElement } from './vnodes';
8
8
  declare type ShadowRootMode = 'open' | 'closed';
9
9
  export interface TemplateCache {
10
10
  [key: string]: any;
@@ -51,6 +51,9 @@ export interface Context {
51
51
  /** List of wire hooks that are invoked when the component gets disconnected. */
52
52
  wiredDisconnecting: Array<() => void>;
53
53
  }
54
+ export declare type RefVNodes = {
55
+ [name: string]: VBaseElement;
56
+ };
54
57
  export interface VM<N = HostNode, E = HostElement> {
55
58
  /** The host element */
56
59
  readonly elm: HostElement;
@@ -62,6 +65,10 @@ export interface VM<N = HostNode, E = HostElement> {
62
65
  readonly context: Context;
63
66
  /** The owner VM or null for root elements. */
64
67
  readonly owner: VM<N, E> | null;
68
+ /** References to elements rendered using lwc:ref (template refs) */
69
+ refVNodes: RefVNodes | null;
70
+ /** Whether this template has any references to elements (template refs) */
71
+ hasRefVNodes: boolean;
65
72
  /** Whether or not the VM was hydrated */
66
73
  readonly hydrated: boolean;
67
74
  /** Rendering operations associated with the VM */
@@ -72,9 +72,11 @@ export interface VNodeData {
72
72
  readonly on?: Readonly<Record<string, (event: Event) => any>>;
73
73
  readonly svg?: boolean;
74
74
  readonly renderer?: RendererAPI;
75
+ readonly spread?: Readonly<Record<string, any>>;
75
76
  }
76
77
  export interface VElementData extends VNodeData {
77
78
  readonly key: Key;
79
+ readonly ref?: string;
78
80
  }
79
81
  export declare function isVBaseElement(vnode: VNode): vnode is VElement | VCustomElement;
80
82
  export declare function isSameVnode(vnode1: VNode, vnode2: VNode): boolean;