lwc 2.23.6 → 2.25.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 +147 -20
- package/dist/engine-dom/iife/es2017/engine-dom.js +147 -20
- package/dist/engine-dom/iife/es2017/engine-dom.min.js +1 -1
- package/dist/engine-dom/iife/es2017/engine-dom_debug.js +125 -18
- package/dist/engine-dom/iife/es5/engine-dom.js +202 -41
- package/dist/engine-dom/iife/es5/engine-dom.min.js +1 -1
- package/dist/engine-dom/iife/es5/engine-dom_debug.js +171 -27
- package/dist/engine-dom/umd/es2017/engine-dom.js +147 -20
- package/dist/engine-dom/umd/es2017/engine-dom.min.js +1 -1
- package/dist/engine-dom/umd/es2017/engine-dom_debug.js +125 -18
- package/dist/engine-dom/umd/es5/engine-dom.js +202 -41
- package/dist/engine-dom/umd/es5/engine-dom.min.js +1 -1
- package/dist/engine-dom/umd/es5/engine-dom_debug.js +171 -27
- package/dist/engine-server/commonjs/es2017/engine-server.js +125 -17
- package/dist/engine-server/commonjs/es2017/engine-server.min.js +1 -1
- package/dist/engine-server/esm/es2017/engine-server.js +125 -17
- 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
|
@@ -349,7 +349,7 @@
|
|
|
349
349
|
CACHED_PROPERTY_ATTRIBUTE_MAPPING.set(propName, attributeName);
|
|
350
350
|
return attributeName;
|
|
351
351
|
}
|
|
352
|
-
/** version: 2.
|
|
352
|
+
/** version: 2.25.0 */
|
|
353
353
|
|
|
354
354
|
/**
|
|
355
355
|
* Copyright (C) 2018 salesforce.com, inc.
|
|
@@ -443,7 +443,7 @@
|
|
|
443
443
|
patch$1(propName);
|
|
444
444
|
}
|
|
445
445
|
}
|
|
446
|
-
/** version: 2.
|
|
446
|
+
/** version: 2.25.0 */
|
|
447
447
|
|
|
448
448
|
/**
|
|
449
449
|
* Copyright (C) 2018 salesforce.com, inc.
|
|
@@ -618,6 +618,19 @@
|
|
|
618
618
|
|
|
619
619
|
return result;
|
|
620
620
|
}
|
|
621
|
+
|
|
622
|
+
|
|
623
|
+
function setRefVNode(vm, ref, vnode) {
|
|
624
|
+
// If not, then something went wrong and we threw an error above.
|
|
625
|
+
|
|
626
|
+
|
|
627
|
+
var refVNodes = vm.refVNodes; // In cases of conflict (two elements with the same ref), prefer, the last one,
|
|
628
|
+
// in depth-first traversal order.
|
|
629
|
+
|
|
630
|
+
if (!(ref in refVNodes) || refVNodes[ref].key < vnode.key) {
|
|
631
|
+
refVNodes[ref] = vnode;
|
|
632
|
+
}
|
|
633
|
+
}
|
|
621
634
|
/*
|
|
622
635
|
* Copyright (c) 2019, salesforce.com, inc.
|
|
623
636
|
* All rights reserved.
|
|
@@ -1771,13 +1784,15 @@
|
|
|
1771
1784
|
}
|
|
1772
1785
|
};
|
|
1773
1786
|
}
|
|
1787
|
+
|
|
1788
|
+
var EMPTY_REFS = freeze(create(null));
|
|
1789
|
+
var refsCache = new WeakMap();
|
|
1774
1790
|
/**
|
|
1775
1791
|
* This class is the base class for any LWC element.
|
|
1776
1792
|
* Some elements directly extends this class, others implement it via inheritance.
|
|
1777
1793
|
**/
|
|
1778
1794
|
// @ts-ignore
|
|
1779
1795
|
|
|
1780
|
-
|
|
1781
1796
|
var LightningElement = function LightningElement() {
|
|
1782
1797
|
// This should be as performant as possible, while any initialization should be done lazily
|
|
1783
1798
|
if (isNull(vmBeingConstructed)) {
|
|
@@ -1949,6 +1964,77 @@
|
|
|
1949
1964
|
return vm.shadowRoot;
|
|
1950
1965
|
},
|
|
1951
1966
|
|
|
1967
|
+
get refs() {
|
|
1968
|
+
var vm = getAssociatedVM(this);
|
|
1969
|
+
|
|
1970
|
+
if (isUpdatingTemplate) {
|
|
1971
|
+
// process of returning the refs and caching them, because the state of the refs is unstable.
|
|
1972
|
+
// This can happen if e.g. a template contains `<div class={foo}></div>` and `foo` is computed
|
|
1973
|
+
// based on `this.refs.bar`.
|
|
1974
|
+
|
|
1975
|
+
|
|
1976
|
+
return;
|
|
1977
|
+
}
|
|
1978
|
+
|
|
1979
|
+
var refVNodes = vm.refVNodes,
|
|
1980
|
+
hasRefVNodes = vm.hasRefVNodes;
|
|
1981
|
+
vm.cmpTemplate; // If the `cmpTemplate` is null, that means that the template has not been rendered yet. Most likely this occurs
|
|
1982
|
+
// were introduced, we return undefined if the template has no refs defined
|
|
1983
|
+
// anywhere. This fixes components that may want to add an expando called `refs`
|
|
1984
|
+
// and are checking if it exists with `if (this.refs)` before adding it.
|
|
1985
|
+
// Note it is not sufficient to just check if `refVNodes` is null or empty,
|
|
1986
|
+
// because a template may have `lwc:ref` defined within a falsy `if:true` block.
|
|
1987
|
+
|
|
1988
|
+
|
|
1989
|
+
if (!hasRefVNodes) {
|
|
1990
|
+
return;
|
|
1991
|
+
} // For templates that are using `lwc:ref`, if there are no refs currently available
|
|
1992
|
+
// (e.g. refs inside of a falsy `if:true` block), we return an empty object.
|
|
1993
|
+
|
|
1994
|
+
|
|
1995
|
+
if (isNull(refVNodes)) {
|
|
1996
|
+
return EMPTY_REFS;
|
|
1997
|
+
} // The refNodes can be cached based on the refVNodes, since the refVNodes
|
|
1998
|
+
// are recreated from scratch every time the template is rendered.
|
|
1999
|
+
// This happens with `vm.refVNodes = null` in `template.ts` in `@lwc/engine-core`.
|
|
2000
|
+
|
|
2001
|
+
|
|
2002
|
+
var refs = refsCache.get(refVNodes);
|
|
2003
|
+
|
|
2004
|
+
if (isUndefined$1(refs)) {
|
|
2005
|
+
refs = create(null);
|
|
2006
|
+
|
|
2007
|
+
var _iterator3 = _createForOfIteratorHelper(keys(refVNodes)),
|
|
2008
|
+
_step3;
|
|
2009
|
+
|
|
2010
|
+
try {
|
|
2011
|
+
for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
|
|
2012
|
+
var key = _step3.value;
|
|
2013
|
+
refs[key] = refVNodes[key].elm;
|
|
2014
|
+
}
|
|
2015
|
+
} catch (err) {
|
|
2016
|
+
_iterator3.e(err);
|
|
2017
|
+
} finally {
|
|
2018
|
+
_iterator3.f();
|
|
2019
|
+
}
|
|
2020
|
+
|
|
2021
|
+
freeze(refs);
|
|
2022
|
+
refsCache.set(refVNodes, refs);
|
|
2023
|
+
}
|
|
2024
|
+
|
|
2025
|
+
return refs;
|
|
2026
|
+
},
|
|
2027
|
+
|
|
2028
|
+
// For backwards compat, we allow component authors to set `refs` as an expando
|
|
2029
|
+
set refs(value) {
|
|
2030
|
+
defineProperty(this, 'refs', {
|
|
2031
|
+
configurable: true,
|
|
2032
|
+
enumerable: true,
|
|
2033
|
+
writable: true,
|
|
2034
|
+
value: value
|
|
2035
|
+
});
|
|
2036
|
+
},
|
|
2037
|
+
|
|
1952
2038
|
get shadowRoot() {
|
|
1953
2039
|
// From within the component instance, the shadowRoot is always reported as "closed".
|
|
1954
2040
|
// Authors should rely on this.template instead.
|
|
@@ -3121,6 +3207,18 @@
|
|
|
3121
3207
|
context = owner.context;
|
|
3122
3208
|
return context.hasScopedStyles && (cmpTemplate === null || cmpTemplate === void 0 ? void 0 : cmpTemplate.stylesheetToken) || null;
|
|
3123
3209
|
}
|
|
3210
|
+
/**
|
|
3211
|
+
* This function returns the host style token for a custom element if it
|
|
3212
|
+
* exists. Otherwise it returns null.
|
|
3213
|
+
*/
|
|
3214
|
+
|
|
3215
|
+
|
|
3216
|
+
function getStylesheetTokenHost(vnode) {
|
|
3217
|
+
var _getComponentInternal = getComponentInternalDef(vnode.ctor),
|
|
3218
|
+
stylesheetToken = _getComponentInternal.template.stylesheetToken;
|
|
3219
|
+
|
|
3220
|
+
return !isUndefined$1(stylesheetToken) ? makeHostToken(stylesheetToken) : null;
|
|
3221
|
+
}
|
|
3124
3222
|
|
|
3125
3223
|
function getNearestNativeShadowComponent(vm) {
|
|
3126
3224
|
var owner = getNearestShadowComponent(vm);
|
|
@@ -3260,6 +3358,12 @@
|
|
|
3260
3358
|
function isSameVnode(vnode1, vnode2) {
|
|
3261
3359
|
return vnode1.key === vnode2.key && vnode1.sel === vnode2.sel;
|
|
3262
3360
|
}
|
|
3361
|
+
|
|
3362
|
+
function isVCustomElement(vnode) {
|
|
3363
|
+
return vnode.type === 3
|
|
3364
|
+
/* VNodeType.CustomElement */
|
|
3365
|
+
;
|
|
3366
|
+
}
|
|
3263
3367
|
/*
|
|
3264
3368
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
3265
3369
|
* All rights reserved.
|
|
@@ -3326,15 +3430,33 @@
|
|
|
3326
3430
|
|
|
3327
3431
|
function patchProps(oldVnode, vnode, renderer) {
|
|
3328
3432
|
var props = vnode.data.props;
|
|
3433
|
+
var spread = vnode.data.spread;
|
|
3329
3434
|
|
|
3330
|
-
if (isUndefined$1(props)) {
|
|
3435
|
+
if (isUndefined$1(props) && isUndefined$1(spread)) {
|
|
3331
3436
|
return;
|
|
3332
3437
|
}
|
|
3333
3438
|
|
|
3334
|
-
var oldProps
|
|
3439
|
+
var oldProps;
|
|
3335
3440
|
|
|
3336
|
-
if (
|
|
3337
|
-
|
|
3441
|
+
if (!isNull(oldVnode)) {
|
|
3442
|
+
oldProps = oldVnode.data.props;
|
|
3443
|
+
var oldSpread = oldVnode.data.spread;
|
|
3444
|
+
|
|
3445
|
+
if (oldProps === props && oldSpread === spread) {
|
|
3446
|
+
return;
|
|
3447
|
+
}
|
|
3448
|
+
|
|
3449
|
+
if (isUndefined$1(oldProps)) {
|
|
3450
|
+
oldProps = EmptyObject;
|
|
3451
|
+
}
|
|
3452
|
+
|
|
3453
|
+
if (!isUndefined$1(oldSpread)) {
|
|
3454
|
+
oldProps = assign({}, oldProps, oldSpread);
|
|
3455
|
+
}
|
|
3456
|
+
}
|
|
3457
|
+
|
|
3458
|
+
if (!isUndefined$1(spread)) {
|
|
3459
|
+
props = assign({}, props, spread);
|
|
3338
3460
|
}
|
|
3339
3461
|
|
|
3340
3462
|
var isFirstPatch = isNull(oldVnode);
|
|
@@ -3347,7 +3469,8 @@
|
|
|
3347
3469
|
var cur = props[key]; // Set the property if it's the first time is is patched or if the previous property is
|
|
3348
3470
|
// different than the one previously set.
|
|
3349
3471
|
|
|
3350
|
-
if (isFirstPatch || cur !== (isLiveBindingProp(sel, key) ? getProperty(elm, key) : oldProps[key]))
|
|
3472
|
+
if (isFirstPatch || cur !== (isLiveBindingProp(sel, key) ? getProperty(elm, key) : oldProps[key]) || !(key in oldProps) // this is required because the above case will pass when `cur` is `undefined` and key is missing in `oldProps`
|
|
3473
|
+
) {
|
|
3351
3474
|
|
|
3352
3475
|
setProperty(elm, key, cur);
|
|
3353
3476
|
}
|
|
@@ -4316,19 +4439,25 @@
|
|
|
4316
4439
|
var children = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : EmptyArray;
|
|
4317
4440
|
var vmBeingRendered = getVMBeingRendered();
|
|
4318
4441
|
|
|
4319
|
-
var
|
|
4320
|
-
|
|
4321
|
-
|
|
4442
|
+
var key = data.key,
|
|
4443
|
+
ref = data.ref;
|
|
4444
|
+
var vnode = {
|
|
4322
4445
|
type: 2
|
|
4323
4446
|
/* VNodeType.Element */
|
|
4324
4447
|
,
|
|
4325
4448
|
sel: sel,
|
|
4326
4449
|
data: data,
|
|
4327
4450
|
children: children,
|
|
4328
|
-
elm:
|
|
4451
|
+
elm: undefined,
|
|
4329
4452
|
key: key,
|
|
4330
4453
|
owner: vmBeingRendered
|
|
4331
4454
|
};
|
|
4455
|
+
|
|
4456
|
+
if (!isUndefined$1(ref)) {
|
|
4457
|
+
setRefVNode(vmBeingRendered, ref, vnode);
|
|
4458
|
+
}
|
|
4459
|
+
|
|
4460
|
+
return vnode;
|
|
4332
4461
|
} // [t]ab[i]ndex function
|
|
4333
4462
|
|
|
4334
4463
|
|
|
@@ -4374,7 +4503,8 @@
|
|
|
4374
4503
|
var children = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : EmptyArray;
|
|
4375
4504
|
var vmBeingRendered = getVMBeingRendered();
|
|
4376
4505
|
|
|
4377
|
-
var key = data.key
|
|
4506
|
+
var key = data.key,
|
|
4507
|
+
ref = data.ref;
|
|
4378
4508
|
var elm, aChildren, vm;
|
|
4379
4509
|
var vnode = {
|
|
4380
4510
|
type: 3
|
|
@@ -4392,6 +4522,11 @@
|
|
|
4392
4522
|
vm: vm
|
|
4393
4523
|
};
|
|
4394
4524
|
addVNodeToChildLWC(vnode);
|
|
4525
|
+
|
|
4526
|
+
if (!isUndefined$1(ref)) {
|
|
4527
|
+
setRefVNode(vmBeingRendered, ref, vnode);
|
|
4528
|
+
}
|
|
4529
|
+
|
|
4395
4530
|
return vnode;
|
|
4396
4531
|
} // [i]terable node
|
|
4397
4532
|
|
|
@@ -4891,9 +5026,13 @@
|
|
|
4891
5026
|
context.styleVNodes = stylesheetsContent.length === 0 ? null : createStylesheet(vm, stylesheetsContent);
|
|
4892
5027
|
}
|
|
4893
5028
|
|
|
4894
|
-
if ("production" !== 'production') ; //
|
|
4895
|
-
|
|
5029
|
+
if ("production" !== 'production') ; // reset the refs; they will be set during the tmpl() instantiation
|
|
5030
|
+
|
|
4896
5031
|
|
|
5032
|
+
var hasRefVNodes = Boolean(html.hasRefs);
|
|
5033
|
+
vm.hasRefVNodes = hasRefVNodes;
|
|
5034
|
+
vm.refVNodes = hasRefVNodes ? create(null) : null; // right before producing the vnodes, we clear up all internal references
|
|
5035
|
+
// to custom elements from the template.
|
|
4897
5036
|
|
|
4898
5037
|
vm.velements = []; // Set the global flag that template is being updated
|
|
4899
5038
|
|
|
@@ -5256,6 +5395,8 @@
|
|
|
5256
5395
|
tagName: tagName,
|
|
5257
5396
|
mode: mode,
|
|
5258
5397
|
owner: owner,
|
|
5398
|
+
refVNodes: null,
|
|
5399
|
+
hasRefVNodes: false,
|
|
5259
5400
|
children: EmptyArray,
|
|
5260
5401
|
aChildren: EmptyArray,
|
|
5261
5402
|
velements: EmptyArray,
|
|
@@ -6378,7 +6519,8 @@
|
|
|
6378
6519
|
classMap = data.classMap;
|
|
6379
6520
|
var getProperty = renderer.getProperty,
|
|
6380
6521
|
getClassList = renderer.getClassList;
|
|
6381
|
-
var scopedToken = getScopeTokenClass(owner);
|
|
6522
|
+
var scopedToken = getScopeTokenClass(owner);
|
|
6523
|
+
var stylesheetTokenHost = isVCustomElement(vnode) ? getStylesheetTokenHost(vnode) : null; // Classnames for scoped CSS are added directly to the DOM during rendering,
|
|
6382
6524
|
// or to the VDOM on the server in the case of SSR. As such, these classnames
|
|
6383
6525
|
// are never present in VDOM nodes in the browser.
|
|
6384
6526
|
//
|
|
@@ -6387,9 +6529,11 @@
|
|
|
6387
6529
|
|
|
6388
6530
|
if (scopedToken) {
|
|
6389
6531
|
if (!isUndefined$1(className)) {
|
|
6390
|
-
className = "".concat(scopedToken, " ").concat(className);
|
|
6532
|
+
className = isNull(stylesheetTokenHost) ? "".concat(scopedToken, " ").concat(className) : "".concat(scopedToken, " ").concat(className, " ").concat(stylesheetTokenHost);
|
|
6391
6533
|
} else if (!isUndefined$1(classMap)) {
|
|
6392
|
-
classMap = Object.assign(Object.assign({}, classMap), _defineProperty({}, scopedToken, true));
|
|
6534
|
+
classMap = Object.assign(Object.assign(Object.assign({}, classMap), _defineProperty({}, scopedToken, true)), isNull(stylesheetTokenHost) ? {} : _defineProperty({}, stylesheetTokenHost, true));
|
|
6535
|
+
} else {
|
|
6536
|
+
className = isNull(stylesheetTokenHost) ? "".concat(scopedToken) : "".concat(scopedToken, " ").concat(stylesheetTokenHost);
|
|
6393
6537
|
}
|
|
6394
6538
|
}
|
|
6395
6539
|
|
|
@@ -6560,7 +6704,7 @@
|
|
|
6560
6704
|
|
|
6561
6705
|
return ctor;
|
|
6562
6706
|
}
|
|
6563
|
-
/* version: 2.
|
|
6707
|
+
/* version: 2.25.0 */
|
|
6564
6708
|
|
|
6565
6709
|
/*
|
|
6566
6710
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
@@ -6779,7 +6923,7 @@
|
|
|
6779
6923
|
function isNull(obj) {
|
|
6780
6924
|
return obj === null;
|
|
6781
6925
|
}
|
|
6782
|
-
/** version: 2.
|
|
6926
|
+
/** version: 2.25.0 */
|
|
6783
6927
|
|
|
6784
6928
|
/*
|
|
6785
6929
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
@@ -6928,18 +7072,18 @@
|
|
|
6928
7072
|
var wrapperTags = topLevelWrappingMap[getTagName(html)];
|
|
6929
7073
|
|
|
6930
7074
|
if (!isUndefined(wrapperTags)) {
|
|
6931
|
-
var
|
|
6932
|
-
|
|
7075
|
+
var _iterator6 = _createForOfIteratorHelper(wrapperTags),
|
|
7076
|
+
_step6;
|
|
6933
7077
|
|
|
6934
7078
|
try {
|
|
6935
|
-
for (
|
|
6936
|
-
var wrapperTag =
|
|
7079
|
+
for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
|
|
7080
|
+
var wrapperTag = _step6.value;
|
|
6937
7081
|
html = "<".concat(wrapperTag, ">").concat(html, "</").concat(wrapperTag, ">");
|
|
6938
7082
|
}
|
|
6939
7083
|
} catch (err) {
|
|
6940
|
-
|
|
7084
|
+
_iterator6.e(err);
|
|
6941
7085
|
} finally {
|
|
6942
|
-
|
|
7086
|
+
_iterator6.f();
|
|
6943
7087
|
}
|
|
6944
7088
|
} // For IE11, the document title must not be undefined, but it can be an empty string
|
|
6945
7089
|
// https://developer.mozilla.org/en-US/docs/Web/API/DOMImplementation/createHTMLDocument#browser_compatibility
|
|
@@ -7502,7 +7646,7 @@
|
|
|
7502
7646
|
});
|
|
7503
7647
|
freeze(LightningElement);
|
|
7504
7648
|
seal(LightningElement.prototype);
|
|
7505
|
-
/* version: 2.
|
|
7649
|
+
/* version: 2.25.0 */
|
|
7506
7650
|
|
|
7507
7651
|
exports.LightningElement = LightningElement;
|
|
7508
7652
|
exports.__unstable__ProfilerControl = profilerControl;
|
|
@@ -436,9 +436,9 @@ function htmlEscape(str, attrMode = false) {
|
|
|
436
436
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
437
437
|
*/
|
|
438
438
|
// Increment whenever the LWC template compiler changes
|
|
439
|
-
const LWC_VERSION = "2.
|
|
439
|
+
const LWC_VERSION = "2.25.0";
|
|
440
440
|
const LWC_VERSION_COMMENT_REGEX = /\/\*LWC compiler v([\d.]+)\*\/\s*}/;
|
|
441
|
-
/** version: 2.
|
|
441
|
+
/** version: 2.25.0 */
|
|
442
442
|
|
|
443
443
|
/*
|
|
444
444
|
* Copyright (c) 2020, salesforce.com, inc.
|
|
@@ -549,7 +549,7 @@ function setFeatureFlagForTest(name, value) {
|
|
|
549
549
|
setFeatureFlag(name, value);
|
|
550
550
|
}
|
|
551
551
|
}
|
|
552
|
-
/** version: 2.
|
|
552
|
+
/** version: 2.25.0 */
|
|
553
553
|
|
|
554
554
|
/* proxy-compat-disable */
|
|
555
555
|
|
|
@@ -600,6 +600,20 @@ function flattenStylesheets(stylesheets) {
|
|
|
600
600
|
}
|
|
601
601
|
return list;
|
|
602
602
|
}
|
|
603
|
+
// Set a ref (lwc:ref) on a VM, from a template API
|
|
604
|
+
function setRefVNode(vm, ref, vnode) {
|
|
605
|
+
if (process.env.NODE_ENV !== 'production' && isUndefined$1(vm.refVNodes)) {
|
|
606
|
+
throw new Error('refVNodes must be defined when setting a ref');
|
|
607
|
+
}
|
|
608
|
+
// If this method is called, then vm.refVNodes is set as the template has refs.
|
|
609
|
+
// If not, then something went wrong and we threw an error above.
|
|
610
|
+
const refVNodes = vm.refVNodes;
|
|
611
|
+
// In cases of conflict (two elements with the same ref), prefer, the last one,
|
|
612
|
+
// in depth-first traversal order.
|
|
613
|
+
if (!(ref in refVNodes) || refVNodes[ref].key < vnode.key) {
|
|
614
|
+
refVNodes[ref] = vnode;
|
|
615
|
+
}
|
|
616
|
+
}
|
|
603
617
|
|
|
604
618
|
/*
|
|
605
619
|
* Copyright (c) 2019, salesforce.com, inc.
|
|
@@ -1834,6 +1848,8 @@ function createBridgeToElementDescriptor(propName, descriptor) {
|
|
|
1834
1848
|
},
|
|
1835
1849
|
};
|
|
1836
1850
|
}
|
|
1851
|
+
const EMPTY_REFS = freeze(create(null));
|
|
1852
|
+
const refsCache = new WeakMap();
|
|
1837
1853
|
/**
|
|
1838
1854
|
* This class is the base class for any LWC element.
|
|
1839
1855
|
* Some elements directly extends this class, others implement it via inheritance.
|
|
@@ -2012,6 +2028,70 @@ LightningElement.prototype = {
|
|
|
2012
2028
|
}
|
|
2013
2029
|
return vm.shadowRoot;
|
|
2014
2030
|
},
|
|
2031
|
+
get refs() {
|
|
2032
|
+
const vm = getAssociatedVM(this);
|
|
2033
|
+
if (isUpdatingTemplate) {
|
|
2034
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
2035
|
+
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().`);
|
|
2036
|
+
}
|
|
2037
|
+
// If the template is in the process of being updated, then we don't want to go through the normal
|
|
2038
|
+
// process of returning the refs and caching them, because the state of the refs is unstable.
|
|
2039
|
+
// This can happen if e.g. a template contains `<div class={foo}></div>` and `foo` is computed
|
|
2040
|
+
// based on `this.refs.bar`.
|
|
2041
|
+
return;
|
|
2042
|
+
}
|
|
2043
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
2044
|
+
warnIfInvokedDuringConstruction(vm, 'refs');
|
|
2045
|
+
}
|
|
2046
|
+
const { refVNodes, hasRefVNodes, cmpTemplate } = vm;
|
|
2047
|
+
// If the `cmpTemplate` is null, that means that the template has not been rendered yet. Most likely this occurs
|
|
2048
|
+
// if `this.refs` is called during the `connectedCallback` phase. The DOM elements have not been rendered yet,
|
|
2049
|
+
// so log a warning. Note we also check `isBeingConstructed()` to avoid a double warning (due to
|
|
2050
|
+
// `warnIfInvokedDuringConstruction` above).
|
|
2051
|
+
if (process.env.NODE_ENV !== 'production' &&
|
|
2052
|
+
isNull(cmpTemplate) &&
|
|
2053
|
+
!isBeingConstructed(vm)) {
|
|
2054
|
+
logError(`this.refs is undefined for ${getComponentTag(vm)}. This is either because the attached template has no "lwc:ref" directive, or this.refs was ` +
|
|
2055
|
+
`invoked before renderedCallback(). Use this.refs only when the referenced HTML elements have ` +
|
|
2056
|
+
`been rendered to the DOM, such as within renderedCallback() or disconnectedCallback().`);
|
|
2057
|
+
}
|
|
2058
|
+
// For backwards compatibility with component written before template refs
|
|
2059
|
+
// were introduced, we return undefined if the template has no refs defined
|
|
2060
|
+
// anywhere. This fixes components that may want to add an expando called `refs`
|
|
2061
|
+
// and are checking if it exists with `if (this.refs)` before adding it.
|
|
2062
|
+
// Note it is not sufficient to just check if `refVNodes` is null or empty,
|
|
2063
|
+
// because a template may have `lwc:ref` defined within a falsy `if:true` block.
|
|
2064
|
+
if (!hasRefVNodes) {
|
|
2065
|
+
return;
|
|
2066
|
+
}
|
|
2067
|
+
// For templates that are using `lwc:ref`, if there are no refs currently available
|
|
2068
|
+
// (e.g. refs inside of a falsy `if:true` block), we return an empty object.
|
|
2069
|
+
if (isNull(refVNodes)) {
|
|
2070
|
+
return EMPTY_REFS;
|
|
2071
|
+
}
|
|
2072
|
+
// The refNodes can be cached based on the refVNodes, since the refVNodes
|
|
2073
|
+
// are recreated from scratch every time the template is rendered.
|
|
2074
|
+
// This happens with `vm.refVNodes = null` in `template.ts` in `@lwc/engine-core`.
|
|
2075
|
+
let refs = refsCache.get(refVNodes);
|
|
2076
|
+
if (isUndefined$1(refs)) {
|
|
2077
|
+
refs = create(null);
|
|
2078
|
+
for (const key of keys(refVNodes)) {
|
|
2079
|
+
refs[key] = refVNodes[key].elm;
|
|
2080
|
+
}
|
|
2081
|
+
freeze(refs);
|
|
2082
|
+
refsCache.set(refVNodes, refs);
|
|
2083
|
+
}
|
|
2084
|
+
return refs;
|
|
2085
|
+
},
|
|
2086
|
+
// For backwards compat, we allow component authors to set `refs` as an expando
|
|
2087
|
+
set refs(value) {
|
|
2088
|
+
defineProperty(this, 'refs', {
|
|
2089
|
+
configurable: true,
|
|
2090
|
+
enumerable: true,
|
|
2091
|
+
writable: true,
|
|
2092
|
+
value,
|
|
2093
|
+
});
|
|
2094
|
+
},
|
|
2015
2095
|
get shadowRoot() {
|
|
2016
2096
|
// From within the component instance, the shadowRoot is always reported as "closed".
|
|
2017
2097
|
// Authors should rely on this.template instead.
|
|
@@ -3434,13 +3514,27 @@ function isLiveBindingProp(sel, key) {
|
|
|
3434
3514
|
return sel === 'input' && (key === 'value' || key === 'checked');
|
|
3435
3515
|
}
|
|
3436
3516
|
function patchProps(oldVnode, vnode, renderer) {
|
|
3437
|
-
|
|
3438
|
-
|
|
3517
|
+
let { props } = vnode.data;
|
|
3518
|
+
const { spread } = vnode.data;
|
|
3519
|
+
if (isUndefined$1(props) && isUndefined$1(spread)) {
|
|
3439
3520
|
return;
|
|
3440
3521
|
}
|
|
3441
|
-
|
|
3442
|
-
if (
|
|
3443
|
-
|
|
3522
|
+
let oldProps;
|
|
3523
|
+
if (!isNull(oldVnode)) {
|
|
3524
|
+
oldProps = oldVnode.data.props;
|
|
3525
|
+
const oldSpread = oldVnode.data.spread;
|
|
3526
|
+
if (oldProps === props && oldSpread === spread) {
|
|
3527
|
+
return;
|
|
3528
|
+
}
|
|
3529
|
+
if (isUndefined$1(oldProps)) {
|
|
3530
|
+
oldProps = EmptyObject;
|
|
3531
|
+
}
|
|
3532
|
+
if (!isUndefined$1(oldSpread)) {
|
|
3533
|
+
oldProps = assign({}, oldProps, oldSpread);
|
|
3534
|
+
}
|
|
3535
|
+
}
|
|
3536
|
+
if (!isUndefined$1(spread)) {
|
|
3537
|
+
props = assign({}, props, spread);
|
|
3444
3538
|
}
|
|
3445
3539
|
const isFirstPatch = isNull(oldVnode);
|
|
3446
3540
|
const { elm, sel } = vnode;
|
|
@@ -3450,7 +3544,9 @@ function patchProps(oldVnode, vnode, renderer) {
|
|
|
3450
3544
|
// Set the property if it's the first time is is patched or if the previous property is
|
|
3451
3545
|
// different than the one previously set.
|
|
3452
3546
|
if (isFirstPatch ||
|
|
3453
|
-
cur !== (isLiveBindingProp(sel, key) ? getProperty(elm, key) : oldProps[key])
|
|
3547
|
+
cur !== (isLiveBindingProp(sel, key) ? getProperty(elm, key) : oldProps[key]) ||
|
|
3548
|
+
!(key in oldProps) // this is required because the above case will pass when `cur` is `undefined` and key is missing in `oldProps`
|
|
3549
|
+
) {
|
|
3454
3550
|
setProperty(elm, key, cur);
|
|
3455
3551
|
}
|
|
3456
3552
|
}
|
|
@@ -4494,17 +4590,20 @@ function h(sel, data, children = EmptyArray) {
|
|
|
4494
4590
|
}
|
|
4495
4591
|
});
|
|
4496
4592
|
}
|
|
4497
|
-
|
|
4498
|
-
const
|
|
4499
|
-
return {
|
|
4593
|
+
const { key, ref } = data;
|
|
4594
|
+
const vnode = {
|
|
4500
4595
|
type: 2 /* VNodeType.Element */,
|
|
4501
4596
|
sel,
|
|
4502
4597
|
data,
|
|
4503
4598
|
children,
|
|
4504
|
-
elm,
|
|
4599
|
+
elm: undefined,
|
|
4505
4600
|
key,
|
|
4506
4601
|
owner: vmBeingRendered,
|
|
4507
4602
|
};
|
|
4603
|
+
if (!isUndefined$1(ref)) {
|
|
4604
|
+
setRefVNode(vmBeingRendered, ref, vnode);
|
|
4605
|
+
}
|
|
4606
|
+
return vnode;
|
|
4508
4607
|
}
|
|
4509
4608
|
// [t]ab[i]ndex function
|
|
4510
4609
|
function ti(value) {
|
|
@@ -4569,7 +4668,7 @@ function c(sel, Ctor, data, children = EmptyArray) {
|
|
|
4569
4668
|
});
|
|
4570
4669
|
}
|
|
4571
4670
|
}
|
|
4572
|
-
const { key } = data;
|
|
4671
|
+
const { key, ref } = data;
|
|
4573
4672
|
let elm, aChildren, vm;
|
|
4574
4673
|
const vnode = {
|
|
4575
4674
|
type: 3 /* VNodeType.CustomElement */,
|
|
@@ -4585,6 +4684,9 @@ function c(sel, Ctor, data, children = EmptyArray) {
|
|
|
4585
4684
|
vm,
|
|
4586
4685
|
};
|
|
4587
4686
|
addVNodeToChildLWC(vnode);
|
|
4687
|
+
if (!isUndefined$1(ref)) {
|
|
4688
|
+
setRefVNode(vmBeingRendered, ref, vnode);
|
|
4689
|
+
}
|
|
4588
4690
|
return vnode;
|
|
4589
4691
|
}
|
|
4590
4692
|
// [i]terable node
|
|
@@ -5074,6 +5176,10 @@ function evaluateTemplate(vm, html) {
|
|
|
5074
5176
|
// add the VM to the list of host VMs that can be re-rendered if html is swapped
|
|
5075
5177
|
setActiveVM(vm);
|
|
5076
5178
|
}
|
|
5179
|
+
// reset the refs; they will be set during the tmpl() instantiation
|
|
5180
|
+
const hasRefVNodes = Boolean(html.hasRefs);
|
|
5181
|
+
vm.hasRefVNodes = hasRefVNodes;
|
|
5182
|
+
vm.refVNodes = hasRefVNodes ? create(null) : null;
|
|
5077
5183
|
// right before producing the vnodes, we clear up all internal references
|
|
5078
5184
|
// to custom elements from the template.
|
|
5079
5185
|
vm.velements = [];
|
|
@@ -5426,6 +5532,8 @@ function createVM(elm, ctor, renderer, options) {
|
|
|
5426
5532
|
tagName,
|
|
5427
5533
|
mode,
|
|
5428
5534
|
owner,
|
|
5535
|
+
refVNodes: null,
|
|
5536
|
+
hasRefVNodes: false,
|
|
5429
5537
|
children: EmptyArray,
|
|
5430
5538
|
aChildren: EmptyArray,
|
|
5431
5539
|
velements: EmptyArray,
|
|
@@ -6303,7 +6411,7 @@ function freezeTemplate(tmpl) {
|
|
|
6303
6411
|
});
|
|
6304
6412
|
}
|
|
6305
6413
|
}
|
|
6306
|
-
/* version: 2.
|
|
6414
|
+
/* version: 2.25.0 */
|
|
6307
6415
|
|
|
6308
6416
|
/*
|
|
6309
6417
|
* Copyright (c) 2020, salesforce.com, inc.
|
|
@@ -6673,7 +6781,7 @@ const renderer = {
|
|
|
6673
6781
|
*/
|
|
6674
6782
|
function serializeAttributes(attributes) {
|
|
6675
6783
|
return attributes
|
|
6676
|
-
.map((attr) => attr.value.length ? `${attr.name}
|
|
6784
|
+
.map((attr) => attr.value.length ? `${attr.name}="${htmlEscape(attr.value, true)}"` : attr.name)
|
|
6677
6785
|
.join(' ');
|
|
6678
6786
|
}
|
|
6679
6787
|
function serializeChildNodes(children) {
|
|
@@ -6773,7 +6881,7 @@ function renderComponent(tagName, Ctor, props = {}) {
|
|
|
6773
6881
|
*/
|
|
6774
6882
|
freeze(LightningElement);
|
|
6775
6883
|
seal(LightningElement.prototype);
|
|
6776
|
-
/* version: 2.
|
|
6884
|
+
/* version: 2.25.0 */
|
|
6777
6885
|
|
|
6778
6886
|
exports.LightningElement = LightningElement;
|
|
6779
6887
|
exports.api = api$1;
|