lwc 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.
- package/dist/engine-dom/esm/es2017/engine-dom.js +126 -18
- package/dist/engine-dom/iife/es2017/engine-dom.js +126 -18
- package/dist/engine-dom/iife/es2017/engine-dom.min.js +1 -1
- package/dist/engine-dom/iife/es2017/engine-dom_debug.js +104 -16
- package/dist/engine-dom/iife/es5/engine-dom.js +178 -38
- package/dist/engine-dom/iife/es5/engine-dom.min.js +1 -1
- package/dist/engine-dom/iife/es5/engine-dom_debug.js +147 -24
- package/dist/engine-dom/umd/es2017/engine-dom.js +126 -18
- package/dist/engine-dom/umd/es2017/engine-dom.min.js +1 -1
- package/dist/engine-dom/umd/es2017/engine-dom_debug.js +104 -16
- package/dist/engine-dom/umd/es5/engine-dom.js +178 -38
- package/dist/engine-dom/umd/es5/engine-dom.min.js +1 -1
- package/dist/engine-dom/umd/es5/engine-dom_debug.js +147 -24
- package/dist/engine-server/commonjs/es2017/engine-server.js +124 -16
- package/dist/engine-server/commonjs/es2017/engine-server.min.js +1 -1
- package/dist/engine-server/esm/es2017/engine-server.js +124 -16
- package/dist/synthetic-shadow/esm/es2017/synthetic-shadow.js +205 -168
- package/dist/synthetic-shadow/iife/es2017/synthetic-shadow.js +205 -168
- package/dist/synthetic-shadow/iife/es2017/synthetic-shadow.min.js +2 -2
- package/dist/synthetic-shadow/iife/es2017/synthetic-shadow_debug.js +195 -158
- package/dist/synthetic-shadow/iife/es5/synthetic-shadow.js +25 -11
- package/dist/synthetic-shadow/iife/es5/synthetic-shadow.min.js +2 -2
- package/dist/synthetic-shadow/iife/es5/synthetic-shadow_debug.js +25 -11
- package/dist/synthetic-shadow/umd/es2017/synthetic-shadow.js +205 -168
- package/dist/synthetic-shadow/umd/es2017/synthetic-shadow.min.js +2 -2
- package/dist/synthetic-shadow/umd/es2017/synthetic-shadow_debug.js +195 -158
- package/dist/synthetic-shadow/umd/es5/synthetic-shadow.js +25 -11
- package/dist/synthetic-shadow/umd/es5/synthetic-shadow.min.js +2 -2
- package/dist/synthetic-shadow/umd/es5/synthetic-shadow_debug.js +25 -11
- package/dist/wire-service/esm/es2017/wire-service.js +2 -2
- package/dist/wire-service/iife/es2017/wire-service.js +2 -2
- package/dist/wire-service/iife/es2017/wire-service_debug.js +2 -2
- package/dist/wire-service/iife/es5/wire-service.js +2 -2
- package/dist/wire-service/iife/es5/wire-service_debug.js +2 -2
- package/dist/wire-service/umd/es2017/wire-service.js +2 -2
- package/dist/wire-service/umd/es2017/wire-service_debug.js +2 -2
- package/dist/wire-service/umd/es5/wire-service.js +2 -2
- package/dist/wire-service/umd/es5/wire-service_debug.js +2 -2
- 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.
|
|
302
|
+
const LWC_VERSION = "2.24.0";
|
|
303
303
|
const LWC_VERSION_COMMENT_REGEX = /\/\*LWC compiler v([\d.]+)\*\/\s*}/;
|
|
304
|
-
/** version: 2.
|
|
304
|
+
/** version: 2.24.0 */
|
|
305
305
|
|
|
306
306
|
/**
|
|
307
307
|
* Copyright (C) 2018 salesforce.com, inc.
|
|
@@ -383,7 +383,7 @@ for (let i = 0, len = ElementPrototypeAriaPropertyNames.length; i < len; i += 1)
|
|
|
383
383
|
patch$1(propName);
|
|
384
384
|
}
|
|
385
385
|
}
|
|
386
|
-
/** version: 2.
|
|
386
|
+
/** version: 2.24.0 */
|
|
387
387
|
|
|
388
388
|
/**
|
|
389
389
|
* Copyright (C) 2018 salesforce.com, inc.
|
|
@@ -462,7 +462,7 @@ function setFeatureFlagForTest(name, value) {
|
|
|
462
462
|
setFeatureFlag(name, value);
|
|
463
463
|
}
|
|
464
464
|
}
|
|
465
|
-
/** version: 2.
|
|
465
|
+
/** version: 2.24.0 */
|
|
466
466
|
|
|
467
467
|
/*
|
|
468
468
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
@@ -596,6 +596,20 @@ function flattenStylesheets(stylesheets) {
|
|
|
596
596
|
}
|
|
597
597
|
return list;
|
|
598
598
|
}
|
|
599
|
+
// Set a ref (lwc:ref) on a VM, from a template API
|
|
600
|
+
function setRefVNode(vm, ref, vnode) {
|
|
601
|
+
if (process.env.NODE_ENV !== 'production' && isUndefined$1(vm.refVNodes)) {
|
|
602
|
+
throw new Error('refVNodes must be defined when setting a ref');
|
|
603
|
+
}
|
|
604
|
+
// If this method is called, then vm.refVNodes is set as the template has refs.
|
|
605
|
+
// If not, then something went wrong and we threw an error above.
|
|
606
|
+
const refVNodes = vm.refVNodes;
|
|
607
|
+
// In cases of conflict (two elements with the same ref), prefer, the last one,
|
|
608
|
+
// in depth-first traversal order.
|
|
609
|
+
if (!(ref in refVNodes) || refVNodes[ref].key < vnode.key) {
|
|
610
|
+
refVNodes[ref] = vnode;
|
|
611
|
+
}
|
|
612
|
+
}
|
|
599
613
|
|
|
600
614
|
/*
|
|
601
615
|
* Copyright (c) 2019, salesforce.com, inc.
|
|
@@ -1912,6 +1926,8 @@ function createBridgeToElementDescriptor(propName, descriptor) {
|
|
|
1912
1926
|
},
|
|
1913
1927
|
};
|
|
1914
1928
|
}
|
|
1929
|
+
const EMPTY_REFS = freeze(create(null));
|
|
1930
|
+
const refsCache = new WeakMap();
|
|
1915
1931
|
/**
|
|
1916
1932
|
* This class is the base class for any LWC element.
|
|
1917
1933
|
* Some elements directly extends this class, others implement it via inheritance.
|
|
@@ -2091,6 +2107,70 @@ LightningElement.prototype = {
|
|
|
2091
2107
|
}
|
|
2092
2108
|
return vm.shadowRoot;
|
|
2093
2109
|
},
|
|
2110
|
+
get refs() {
|
|
2111
|
+
const vm = getAssociatedVM(this);
|
|
2112
|
+
if (isUpdatingTemplate) {
|
|
2113
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
2114
|
+
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().`);
|
|
2115
|
+
}
|
|
2116
|
+
// If the template is in the process of being updated, then we don't want to go through the normal
|
|
2117
|
+
// process of returning the refs and caching them, because the state of the refs is unstable.
|
|
2118
|
+
// This can happen if e.g. a template contains `<div class={foo}></div>` and `foo` is computed
|
|
2119
|
+
// based on `this.refs.bar`.
|
|
2120
|
+
return;
|
|
2121
|
+
}
|
|
2122
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
2123
|
+
warnIfInvokedDuringConstruction(vm, 'refs');
|
|
2124
|
+
}
|
|
2125
|
+
const { refVNodes, hasRefVNodes, cmpTemplate } = vm;
|
|
2126
|
+
// If the `cmpTemplate` is null, that means that the template has not been rendered yet. Most likely this occurs
|
|
2127
|
+
// if `this.refs` is called during the `connectedCallback` phase. The DOM elements have not been rendered yet,
|
|
2128
|
+
// so log a warning. Note we also check `isBeingConstructed()` to avoid a double warning (due to
|
|
2129
|
+
// `warnIfInvokedDuringConstruction` above).
|
|
2130
|
+
if (process.env.NODE_ENV !== 'production' &&
|
|
2131
|
+
isNull(cmpTemplate) &&
|
|
2132
|
+
!isBeingConstructed(vm)) {
|
|
2133
|
+
logError(`this.refs is undefined for ${getComponentTag(vm)}. This is either because the attached template has no "lwc:ref" directive, or this.refs was ` +
|
|
2134
|
+
`invoked before renderedCallback(). Use this.refs only when the referenced HTML elements have ` +
|
|
2135
|
+
`been rendered to the DOM, such as within renderedCallback() or disconnectedCallback().`);
|
|
2136
|
+
}
|
|
2137
|
+
// For backwards compatibility with component written before template refs
|
|
2138
|
+
// were introduced, we return undefined if the template has no refs defined
|
|
2139
|
+
// anywhere. This fixes components that may want to add an expando called `refs`
|
|
2140
|
+
// and are checking if it exists with `if (this.refs)` before adding it.
|
|
2141
|
+
// Note it is not sufficient to just check if `refVNodes` is null or empty,
|
|
2142
|
+
// because a template may have `lwc:ref` defined within a falsy `if:true` block.
|
|
2143
|
+
if (!hasRefVNodes) {
|
|
2144
|
+
return;
|
|
2145
|
+
}
|
|
2146
|
+
// For templates that are using `lwc:ref`, if there are no refs currently available
|
|
2147
|
+
// (e.g. refs inside of a falsy `if:true` block), we return an empty object.
|
|
2148
|
+
if (isNull(refVNodes)) {
|
|
2149
|
+
return EMPTY_REFS;
|
|
2150
|
+
}
|
|
2151
|
+
// The refNodes can be cached based on the refVNodes, since the refVNodes
|
|
2152
|
+
// are recreated from scratch every time the template is rendered.
|
|
2153
|
+
// This happens with `vm.refVNodes = null` in `template.ts` in `@lwc/engine-core`.
|
|
2154
|
+
let refs = refsCache.get(refVNodes);
|
|
2155
|
+
if (isUndefined$1(refs)) {
|
|
2156
|
+
refs = create(null);
|
|
2157
|
+
for (const key of keys(refVNodes)) {
|
|
2158
|
+
refs[key] = refVNodes[key].elm;
|
|
2159
|
+
}
|
|
2160
|
+
freeze(refs);
|
|
2161
|
+
refsCache.set(refVNodes, refs);
|
|
2162
|
+
}
|
|
2163
|
+
return refs;
|
|
2164
|
+
},
|
|
2165
|
+
// For backwards compat, we allow component authors to set `refs` as an expando
|
|
2166
|
+
set refs(value) {
|
|
2167
|
+
defineProperty(this, 'refs', {
|
|
2168
|
+
configurable: true,
|
|
2169
|
+
enumerable: true,
|
|
2170
|
+
writable: true,
|
|
2171
|
+
value,
|
|
2172
|
+
});
|
|
2173
|
+
},
|
|
2094
2174
|
get shadowRoot() {
|
|
2095
2175
|
// From within the component instance, the shadowRoot is always reported as "closed".
|
|
2096
2176
|
// Authors should rely on this.template instead.
|
|
@@ -3679,13 +3759,27 @@ function isLiveBindingProp(sel, key) {
|
|
|
3679
3759
|
return sel === 'input' && (key === 'value' || key === 'checked');
|
|
3680
3760
|
}
|
|
3681
3761
|
function patchProps(oldVnode, vnode, renderer) {
|
|
3682
|
-
|
|
3683
|
-
|
|
3762
|
+
let { props } = vnode.data;
|
|
3763
|
+
const { spread } = vnode.data;
|
|
3764
|
+
if (isUndefined$1(props) && isUndefined$1(spread)) {
|
|
3684
3765
|
return;
|
|
3685
3766
|
}
|
|
3686
|
-
|
|
3687
|
-
if (
|
|
3688
|
-
|
|
3767
|
+
let oldProps;
|
|
3768
|
+
if (!isNull(oldVnode)) {
|
|
3769
|
+
oldProps = oldVnode.data.props;
|
|
3770
|
+
const oldSpread = oldVnode.data.spread;
|
|
3771
|
+
if (oldProps === props && oldSpread === spread) {
|
|
3772
|
+
return;
|
|
3773
|
+
}
|
|
3774
|
+
if (isUndefined$1(oldProps)) {
|
|
3775
|
+
oldProps = EmptyObject;
|
|
3776
|
+
}
|
|
3777
|
+
if (!isUndefined$1(oldSpread)) {
|
|
3778
|
+
oldProps = assign({}, oldProps, oldSpread);
|
|
3779
|
+
}
|
|
3780
|
+
}
|
|
3781
|
+
if (!isUndefined$1(spread)) {
|
|
3782
|
+
props = assign({}, props, spread);
|
|
3689
3783
|
}
|
|
3690
3784
|
const isFirstPatch = isNull(oldVnode);
|
|
3691
3785
|
const { elm, sel } = vnode;
|
|
@@ -3695,7 +3789,9 @@ function patchProps(oldVnode, vnode, renderer) {
|
|
|
3695
3789
|
// Set the property if it's the first time is is patched or if the previous property is
|
|
3696
3790
|
// different than the one previously set.
|
|
3697
3791
|
if (isFirstPatch ||
|
|
3698
|
-
cur !== (isLiveBindingProp(sel, key) ? getProperty(elm, key) : oldProps[key])
|
|
3792
|
+
cur !== (isLiveBindingProp(sel, key) ? getProperty(elm, key) : oldProps[key]) ||
|
|
3793
|
+
!(key in oldProps) // this is required because the above case will pass when `cur` is `undefined` and key is missing in `oldProps`
|
|
3794
|
+
) {
|
|
3699
3795
|
// Additional verification if properties are supported by the element
|
|
3700
3796
|
// Validation relies on html properties and public properties being defined on the element,
|
|
3701
3797
|
// SSR has its own custom validation.
|
|
@@ -4755,17 +4851,20 @@ function h(sel, data, children = EmptyArray) {
|
|
|
4755
4851
|
}
|
|
4756
4852
|
});
|
|
4757
4853
|
}
|
|
4758
|
-
|
|
4759
|
-
const
|
|
4760
|
-
return {
|
|
4854
|
+
const { key, ref } = data;
|
|
4855
|
+
const vnode = {
|
|
4761
4856
|
type: 2 /* VNodeType.Element */,
|
|
4762
4857
|
sel,
|
|
4763
4858
|
data,
|
|
4764
4859
|
children,
|
|
4765
|
-
elm,
|
|
4860
|
+
elm: undefined,
|
|
4766
4861
|
key,
|
|
4767
4862
|
owner: vmBeingRendered,
|
|
4768
4863
|
};
|
|
4864
|
+
if (!isUndefined$1(ref)) {
|
|
4865
|
+
setRefVNode(vmBeingRendered, ref, vnode);
|
|
4866
|
+
}
|
|
4867
|
+
return vnode;
|
|
4769
4868
|
}
|
|
4770
4869
|
// [t]ab[i]ndex function
|
|
4771
4870
|
function ti(value) {
|
|
@@ -4830,7 +4929,7 @@ function c(sel, Ctor, data, children = EmptyArray) {
|
|
|
4830
4929
|
});
|
|
4831
4930
|
}
|
|
4832
4931
|
}
|
|
4833
|
-
const { key } = data;
|
|
4932
|
+
const { key, ref } = data;
|
|
4834
4933
|
let elm, aChildren, vm;
|
|
4835
4934
|
const vnode = {
|
|
4836
4935
|
type: 3 /* VNodeType.CustomElement */,
|
|
@@ -4846,6 +4945,9 @@ function c(sel, Ctor, data, children = EmptyArray) {
|
|
|
4846
4945
|
vm,
|
|
4847
4946
|
};
|
|
4848
4947
|
addVNodeToChildLWC(vnode);
|
|
4948
|
+
if (!isUndefined$1(ref)) {
|
|
4949
|
+
setRefVNode(vmBeingRendered, ref, vnode);
|
|
4950
|
+
}
|
|
4849
4951
|
return vnode;
|
|
4850
4952
|
}
|
|
4851
4953
|
// [i]terable node
|
|
@@ -5374,6 +5476,10 @@ function evaluateTemplate(vm, html) {
|
|
|
5374
5476
|
// add the VM to the list of host VMs that can be re-rendered if html is swapped
|
|
5375
5477
|
setActiveVM(vm);
|
|
5376
5478
|
}
|
|
5479
|
+
// reset the refs; they will be set during the tmpl() instantiation
|
|
5480
|
+
const hasRefVNodes = Boolean(html.hasRefs);
|
|
5481
|
+
vm.hasRefVNodes = hasRefVNodes;
|
|
5482
|
+
vm.refVNodes = hasRefVNodes ? create(null) : null;
|
|
5377
5483
|
// right before producing the vnodes, we clear up all internal references
|
|
5378
5484
|
// to custom elements from the template.
|
|
5379
5485
|
vm.velements = [];
|
|
@@ -5732,6 +5838,8 @@ function createVM(elm, ctor, renderer, options) {
|
|
|
5732
5838
|
tagName,
|
|
5733
5839
|
mode,
|
|
5734
5840
|
owner,
|
|
5841
|
+
refVNodes: null,
|
|
5842
|
+
hasRefVNodes: false,
|
|
5735
5843
|
children: EmptyArray,
|
|
5736
5844
|
aChildren: EmptyArray,
|
|
5737
5845
|
velements: EmptyArray,
|
|
@@ -7134,7 +7242,7 @@ function getComponentConstructor(elm) {
|
|
|
7134
7242
|
}
|
|
7135
7243
|
return ctor;
|
|
7136
7244
|
}
|
|
7137
|
-
/* version: 2.
|
|
7245
|
+
/* version: 2.24.0 */
|
|
7138
7246
|
|
|
7139
7247
|
/*
|
|
7140
7248
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
@@ -7338,7 +7446,7 @@ function rendererFactory(baseRenderer) {
|
|
|
7338
7446
|
function isNull(obj) {
|
|
7339
7447
|
return obj === null;
|
|
7340
7448
|
}
|
|
7341
|
-
/** version: 2.
|
|
7449
|
+
/** version: 2.24.0 */
|
|
7342
7450
|
|
|
7343
7451
|
/*
|
|
7344
7452
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
@@ -7957,6 +8065,6 @@ defineProperty(LightningElement, 'CustomElementConstructor', {
|
|
|
7957
8065
|
});
|
|
7958
8066
|
freeze(LightningElement);
|
|
7959
8067
|
seal(LightningElement.prototype);
|
|
7960
|
-
/* version: 2.
|
|
8068
|
+
/* version: 2.24.0 */
|
|
7961
8069
|
|
|
7962
8070
|
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, rendererFactory, sanitizeAttribute, setFeatureFlag, setFeatureFlagForTest, setHooks, swapComponent, swapStyle, swapTemplate, track, unwrap, wire };
|
|
@@ -302,9 +302,9 @@ var LWC = (function (exports) {
|
|
|
302
302
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
303
303
|
*/
|
|
304
304
|
// Increment whenever the LWC template compiler changes
|
|
305
|
-
const LWC_VERSION = "2.
|
|
305
|
+
const LWC_VERSION = "2.24.0";
|
|
306
306
|
const LWC_VERSION_COMMENT_REGEX = /\/\*LWC compiler v([\d.]+)\*\/\s*}/;
|
|
307
|
-
/** version: 2.
|
|
307
|
+
/** version: 2.24.0 */
|
|
308
308
|
|
|
309
309
|
/**
|
|
310
310
|
* Copyright (C) 2018 salesforce.com, inc.
|
|
@@ -386,7 +386,7 @@ var LWC = (function (exports) {
|
|
|
386
386
|
patch$1(propName);
|
|
387
387
|
}
|
|
388
388
|
}
|
|
389
|
-
/** version: 2.
|
|
389
|
+
/** version: 2.24.0 */
|
|
390
390
|
|
|
391
391
|
/**
|
|
392
392
|
* Copyright (C) 2018 salesforce.com, inc.
|
|
@@ -465,7 +465,7 @@ var LWC = (function (exports) {
|
|
|
465
465
|
setFeatureFlag(name, value);
|
|
466
466
|
}
|
|
467
467
|
}
|
|
468
|
-
/** version: 2.
|
|
468
|
+
/** version: 2.24.0 */
|
|
469
469
|
|
|
470
470
|
/*
|
|
471
471
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
@@ -599,6 +599,20 @@ var LWC = (function (exports) {
|
|
|
599
599
|
}
|
|
600
600
|
return list;
|
|
601
601
|
}
|
|
602
|
+
// Set a ref (lwc:ref) on a VM, from a template API
|
|
603
|
+
function setRefVNode(vm, ref, vnode) {
|
|
604
|
+
if (process.env.NODE_ENV !== 'production' && isUndefined$1(vm.refVNodes)) {
|
|
605
|
+
throw new Error('refVNodes must be defined when setting a ref');
|
|
606
|
+
}
|
|
607
|
+
// If this method is called, then vm.refVNodes is set as the template has refs.
|
|
608
|
+
// If not, then something went wrong and we threw an error above.
|
|
609
|
+
const refVNodes = vm.refVNodes;
|
|
610
|
+
// In cases of conflict (two elements with the same ref), prefer, the last one,
|
|
611
|
+
// in depth-first traversal order.
|
|
612
|
+
if (!(ref in refVNodes) || refVNodes[ref].key < vnode.key) {
|
|
613
|
+
refVNodes[ref] = vnode;
|
|
614
|
+
}
|
|
615
|
+
}
|
|
602
616
|
|
|
603
617
|
/*
|
|
604
618
|
* Copyright (c) 2019, salesforce.com, inc.
|
|
@@ -1915,6 +1929,8 @@ var LWC = (function (exports) {
|
|
|
1915
1929
|
},
|
|
1916
1930
|
};
|
|
1917
1931
|
}
|
|
1932
|
+
const EMPTY_REFS = freeze(create(null));
|
|
1933
|
+
const refsCache = new WeakMap();
|
|
1918
1934
|
/**
|
|
1919
1935
|
* This class is the base class for any LWC element.
|
|
1920
1936
|
* Some elements directly extends this class, others implement it via inheritance.
|
|
@@ -2094,6 +2110,70 @@ var LWC = (function (exports) {
|
|
|
2094
2110
|
}
|
|
2095
2111
|
return vm.shadowRoot;
|
|
2096
2112
|
},
|
|
2113
|
+
get refs() {
|
|
2114
|
+
const vm = getAssociatedVM(this);
|
|
2115
|
+
if (isUpdatingTemplate) {
|
|
2116
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
2117
|
+
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().`);
|
|
2118
|
+
}
|
|
2119
|
+
// If the template is in the process of being updated, then we don't want to go through the normal
|
|
2120
|
+
// process of returning the refs and caching them, because the state of the refs is unstable.
|
|
2121
|
+
// This can happen if e.g. a template contains `<div class={foo}></div>` and `foo` is computed
|
|
2122
|
+
// based on `this.refs.bar`.
|
|
2123
|
+
return;
|
|
2124
|
+
}
|
|
2125
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
2126
|
+
warnIfInvokedDuringConstruction(vm, 'refs');
|
|
2127
|
+
}
|
|
2128
|
+
const { refVNodes, hasRefVNodes, cmpTemplate } = vm;
|
|
2129
|
+
// If the `cmpTemplate` is null, that means that the template has not been rendered yet. Most likely this occurs
|
|
2130
|
+
// if `this.refs` is called during the `connectedCallback` phase. The DOM elements have not been rendered yet,
|
|
2131
|
+
// so log a warning. Note we also check `isBeingConstructed()` to avoid a double warning (due to
|
|
2132
|
+
// `warnIfInvokedDuringConstruction` above).
|
|
2133
|
+
if (process.env.NODE_ENV !== 'production' &&
|
|
2134
|
+
isNull(cmpTemplate) &&
|
|
2135
|
+
!isBeingConstructed(vm)) {
|
|
2136
|
+
logError(`this.refs is undefined for ${getComponentTag(vm)}. This is either because the attached template has no "lwc:ref" directive, or this.refs was ` +
|
|
2137
|
+
`invoked before renderedCallback(). Use this.refs only when the referenced HTML elements have ` +
|
|
2138
|
+
`been rendered to the DOM, such as within renderedCallback() or disconnectedCallback().`);
|
|
2139
|
+
}
|
|
2140
|
+
// For backwards compatibility with component written before template refs
|
|
2141
|
+
// were introduced, we return undefined if the template has no refs defined
|
|
2142
|
+
// anywhere. This fixes components that may want to add an expando called `refs`
|
|
2143
|
+
// and are checking if it exists with `if (this.refs)` before adding it.
|
|
2144
|
+
// Note it is not sufficient to just check if `refVNodes` is null or empty,
|
|
2145
|
+
// because a template may have `lwc:ref` defined within a falsy `if:true` block.
|
|
2146
|
+
if (!hasRefVNodes) {
|
|
2147
|
+
return;
|
|
2148
|
+
}
|
|
2149
|
+
// For templates that are using `lwc:ref`, if there are no refs currently available
|
|
2150
|
+
// (e.g. refs inside of a falsy `if:true` block), we return an empty object.
|
|
2151
|
+
if (isNull(refVNodes)) {
|
|
2152
|
+
return EMPTY_REFS;
|
|
2153
|
+
}
|
|
2154
|
+
// The refNodes can be cached based on the refVNodes, since the refVNodes
|
|
2155
|
+
// are recreated from scratch every time the template is rendered.
|
|
2156
|
+
// This happens with `vm.refVNodes = null` in `template.ts` in `@lwc/engine-core`.
|
|
2157
|
+
let refs = refsCache.get(refVNodes);
|
|
2158
|
+
if (isUndefined$1(refs)) {
|
|
2159
|
+
refs = create(null);
|
|
2160
|
+
for (const key of keys(refVNodes)) {
|
|
2161
|
+
refs[key] = refVNodes[key].elm;
|
|
2162
|
+
}
|
|
2163
|
+
freeze(refs);
|
|
2164
|
+
refsCache.set(refVNodes, refs);
|
|
2165
|
+
}
|
|
2166
|
+
return refs;
|
|
2167
|
+
},
|
|
2168
|
+
// For backwards compat, we allow component authors to set `refs` as an expando
|
|
2169
|
+
set refs(value) {
|
|
2170
|
+
defineProperty(this, 'refs', {
|
|
2171
|
+
configurable: true,
|
|
2172
|
+
enumerable: true,
|
|
2173
|
+
writable: true,
|
|
2174
|
+
value,
|
|
2175
|
+
});
|
|
2176
|
+
},
|
|
2097
2177
|
get shadowRoot() {
|
|
2098
2178
|
// From within the component instance, the shadowRoot is always reported as "closed".
|
|
2099
2179
|
// Authors should rely on this.template instead.
|
|
@@ -3682,13 +3762,27 @@ var LWC = (function (exports) {
|
|
|
3682
3762
|
return sel === 'input' && (key === 'value' || key === 'checked');
|
|
3683
3763
|
}
|
|
3684
3764
|
function patchProps(oldVnode, vnode, renderer) {
|
|
3685
|
-
|
|
3686
|
-
|
|
3765
|
+
let { props } = vnode.data;
|
|
3766
|
+
const { spread } = vnode.data;
|
|
3767
|
+
if (isUndefined$1(props) && isUndefined$1(spread)) {
|
|
3687
3768
|
return;
|
|
3688
3769
|
}
|
|
3689
|
-
|
|
3690
|
-
if (
|
|
3691
|
-
|
|
3770
|
+
let oldProps;
|
|
3771
|
+
if (!isNull(oldVnode)) {
|
|
3772
|
+
oldProps = oldVnode.data.props;
|
|
3773
|
+
const oldSpread = oldVnode.data.spread;
|
|
3774
|
+
if (oldProps === props && oldSpread === spread) {
|
|
3775
|
+
return;
|
|
3776
|
+
}
|
|
3777
|
+
if (isUndefined$1(oldProps)) {
|
|
3778
|
+
oldProps = EmptyObject;
|
|
3779
|
+
}
|
|
3780
|
+
if (!isUndefined$1(oldSpread)) {
|
|
3781
|
+
oldProps = assign({}, oldProps, oldSpread);
|
|
3782
|
+
}
|
|
3783
|
+
}
|
|
3784
|
+
if (!isUndefined$1(spread)) {
|
|
3785
|
+
props = assign({}, props, spread);
|
|
3692
3786
|
}
|
|
3693
3787
|
const isFirstPatch = isNull(oldVnode);
|
|
3694
3788
|
const { elm, sel } = vnode;
|
|
@@ -3698,7 +3792,9 @@ var LWC = (function (exports) {
|
|
|
3698
3792
|
// Set the property if it's the first time is is patched or if the previous property is
|
|
3699
3793
|
// different than the one previously set.
|
|
3700
3794
|
if (isFirstPatch ||
|
|
3701
|
-
cur !== (isLiveBindingProp(sel, key) ? getProperty(elm, key) : oldProps[key])
|
|
3795
|
+
cur !== (isLiveBindingProp(sel, key) ? getProperty(elm, key) : oldProps[key]) ||
|
|
3796
|
+
!(key in oldProps) // this is required because the above case will pass when `cur` is `undefined` and key is missing in `oldProps`
|
|
3797
|
+
) {
|
|
3702
3798
|
// Additional verification if properties are supported by the element
|
|
3703
3799
|
// Validation relies on html properties and public properties being defined on the element,
|
|
3704
3800
|
// SSR has its own custom validation.
|
|
@@ -4758,17 +4854,20 @@ var LWC = (function (exports) {
|
|
|
4758
4854
|
}
|
|
4759
4855
|
});
|
|
4760
4856
|
}
|
|
4761
|
-
|
|
4762
|
-
const
|
|
4763
|
-
return {
|
|
4857
|
+
const { key, ref } = data;
|
|
4858
|
+
const vnode = {
|
|
4764
4859
|
type: 2 /* VNodeType.Element */,
|
|
4765
4860
|
sel,
|
|
4766
4861
|
data,
|
|
4767
4862
|
children,
|
|
4768
|
-
elm,
|
|
4863
|
+
elm: undefined,
|
|
4769
4864
|
key,
|
|
4770
4865
|
owner: vmBeingRendered,
|
|
4771
4866
|
};
|
|
4867
|
+
if (!isUndefined$1(ref)) {
|
|
4868
|
+
setRefVNode(vmBeingRendered, ref, vnode);
|
|
4869
|
+
}
|
|
4870
|
+
return vnode;
|
|
4772
4871
|
}
|
|
4773
4872
|
// [t]ab[i]ndex function
|
|
4774
4873
|
function ti(value) {
|
|
@@ -4833,7 +4932,7 @@ var LWC = (function (exports) {
|
|
|
4833
4932
|
});
|
|
4834
4933
|
}
|
|
4835
4934
|
}
|
|
4836
|
-
const { key } = data;
|
|
4935
|
+
const { key, ref } = data;
|
|
4837
4936
|
let elm, aChildren, vm;
|
|
4838
4937
|
const vnode = {
|
|
4839
4938
|
type: 3 /* VNodeType.CustomElement */,
|
|
@@ -4849,6 +4948,9 @@ var LWC = (function (exports) {
|
|
|
4849
4948
|
vm,
|
|
4850
4949
|
};
|
|
4851
4950
|
addVNodeToChildLWC(vnode);
|
|
4951
|
+
if (!isUndefined$1(ref)) {
|
|
4952
|
+
setRefVNode(vmBeingRendered, ref, vnode);
|
|
4953
|
+
}
|
|
4852
4954
|
return vnode;
|
|
4853
4955
|
}
|
|
4854
4956
|
// [i]terable node
|
|
@@ -5377,6 +5479,10 @@ var LWC = (function (exports) {
|
|
|
5377
5479
|
// add the VM to the list of host VMs that can be re-rendered if html is swapped
|
|
5378
5480
|
setActiveVM(vm);
|
|
5379
5481
|
}
|
|
5482
|
+
// reset the refs; they will be set during the tmpl() instantiation
|
|
5483
|
+
const hasRefVNodes = Boolean(html.hasRefs);
|
|
5484
|
+
vm.hasRefVNodes = hasRefVNodes;
|
|
5485
|
+
vm.refVNodes = hasRefVNodes ? create(null) : null;
|
|
5380
5486
|
// right before producing the vnodes, we clear up all internal references
|
|
5381
5487
|
// to custom elements from the template.
|
|
5382
5488
|
vm.velements = [];
|
|
@@ -5735,6 +5841,8 @@ var LWC = (function (exports) {
|
|
|
5735
5841
|
tagName,
|
|
5736
5842
|
mode,
|
|
5737
5843
|
owner,
|
|
5844
|
+
refVNodes: null,
|
|
5845
|
+
hasRefVNodes: false,
|
|
5738
5846
|
children: EmptyArray,
|
|
5739
5847
|
aChildren: EmptyArray,
|
|
5740
5848
|
velements: EmptyArray,
|
|
@@ -7137,7 +7245,7 @@ var LWC = (function (exports) {
|
|
|
7137
7245
|
}
|
|
7138
7246
|
return ctor;
|
|
7139
7247
|
}
|
|
7140
|
-
/* version: 2.
|
|
7248
|
+
/* version: 2.24.0 */
|
|
7141
7249
|
|
|
7142
7250
|
/*
|
|
7143
7251
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
@@ -7341,7 +7449,7 @@ var LWC = (function (exports) {
|
|
|
7341
7449
|
function isNull(obj) {
|
|
7342
7450
|
return obj === null;
|
|
7343
7451
|
}
|
|
7344
|
-
/** version: 2.
|
|
7452
|
+
/** version: 2.24.0 */
|
|
7345
7453
|
|
|
7346
7454
|
/*
|
|
7347
7455
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
@@ -7960,7 +8068,7 @@ var LWC = (function (exports) {
|
|
|
7960
8068
|
});
|
|
7961
8069
|
freeze(LightningElement);
|
|
7962
8070
|
seal(LightningElement.prototype);
|
|
7963
|
-
/* version: 2.
|
|
8071
|
+
/* version: 2.24.0 */
|
|
7964
8072
|
|
|
7965
8073
|
exports.LightningElement = LightningElement;
|
|
7966
8074
|
exports.__unstable__ProfilerControl = profilerControl;
|