lwc 2.20.2 → 2.21.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 +203 -171
- package/dist/engine-dom/iife/es2017/engine-dom.js +203 -171
- package/dist/engine-dom/iife/es2017/engine-dom.min.js +1 -1
- package/dist/engine-dom/iife/es2017/engine-dom_debug.js +193 -161
- package/dist/engine-dom/iife/es5/engine-dom.js +288 -254
- package/dist/engine-dom/iife/es5/engine-dom.min.js +1 -1
- package/dist/engine-dom/iife/es5/engine-dom_debug.js +278 -243
- package/dist/engine-dom/umd/es2017/engine-dom.js +203 -171
- package/dist/engine-dom/umd/es2017/engine-dom.min.js +1 -1
- package/dist/engine-dom/umd/es2017/engine-dom_debug.js +193 -161
- package/dist/engine-dom/umd/es5/engine-dom.js +288 -254
- package/dist/engine-dom/umd/es5/engine-dom.min.js +1 -1
- package/dist/engine-dom/umd/es5/engine-dom_debug.js +278 -243
- package/dist/engine-server/commonjs/es2017/engine-server.js +280 -258
- package/dist/engine-server/commonjs/es2017/engine-server.min.js +1 -1
- package/dist/engine-server/esm/es2017/engine-server.js +280 -258
- package/dist/synthetic-shadow/esm/es2017/synthetic-shadow.js +3 -3
- package/dist/synthetic-shadow/iife/es2017/synthetic-shadow.js +3 -3
- package/dist/synthetic-shadow/iife/es2017/synthetic-shadow_debug.js +3 -3
- package/dist/synthetic-shadow/iife/es5/synthetic-shadow.js +3 -3
- package/dist/synthetic-shadow/iife/es5/synthetic-shadow_debug.js +3 -3
- package/dist/synthetic-shadow/umd/es2017/synthetic-shadow.js +3 -3
- package/dist/synthetic-shadow/umd/es2017/synthetic-shadow_debug.js +3 -3
- package/dist/synthetic-shadow/umd/es5/synthetic-shadow.js +3 -3
- package/dist/synthetic-shadow/umd/es5/synthetic-shadow_debug.js +3 -3
- 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
|
@@ -305,9 +305,9 @@
|
|
|
305
305
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
306
306
|
*/
|
|
307
307
|
// Increment whenever the LWC template compiler changes
|
|
308
|
-
const LWC_VERSION = "2.
|
|
308
|
+
const LWC_VERSION = "2.21.0";
|
|
309
309
|
const LWC_VERSION_COMMENT_REGEX = /\/\*LWC compiler v([\d.]+)\*\/\s*}/;
|
|
310
|
-
/** version: 2.
|
|
310
|
+
/** version: 2.21.0 */
|
|
311
311
|
|
|
312
312
|
/*
|
|
313
313
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
@@ -461,7 +461,7 @@
|
|
|
461
461
|
setFeatureFlag(name, value);
|
|
462
462
|
}
|
|
463
463
|
}
|
|
464
|
-
/** version: 2.
|
|
464
|
+
/** version: 2.21.0 */
|
|
465
465
|
|
|
466
466
|
/*
|
|
467
467
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
@@ -3362,6 +3362,175 @@
|
|
|
3362
3362
|
};
|
|
3363
3363
|
}
|
|
3364
3364
|
|
|
3365
|
+
/*
|
|
3366
|
+
* Copyright (c) 2018, salesforce.com, inc.
|
|
3367
|
+
* All rights reserved.
|
|
3368
|
+
* SPDX-License-Identifier: MIT
|
|
3369
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
3370
|
+
*/
|
|
3371
|
+
function makeHostToken(token) {
|
|
3372
|
+
return `${token}-host`;
|
|
3373
|
+
}
|
|
3374
|
+
function createInlineStyleVNode(content) {
|
|
3375
|
+
return api.h('style', {
|
|
3376
|
+
key: 'style',
|
|
3377
|
+
attrs: {
|
|
3378
|
+
type: 'text/css',
|
|
3379
|
+
},
|
|
3380
|
+
}, [api.t(content)]);
|
|
3381
|
+
}
|
|
3382
|
+
function updateStylesheetToken(vm, template) {
|
|
3383
|
+
const { elm, context, renderMode, shadowMode, renderer: { getClassList, removeAttribute, setAttribute }, } = vm;
|
|
3384
|
+
const { stylesheets: newStylesheets, stylesheetToken: newStylesheetToken } = template;
|
|
3385
|
+
const isSyntheticShadow = renderMode === 1 /* RenderMode.Shadow */ && shadowMode === 1 /* ShadowMode.Synthetic */;
|
|
3386
|
+
const { hasScopedStyles } = context;
|
|
3387
|
+
let newToken;
|
|
3388
|
+
let newHasTokenInClass;
|
|
3389
|
+
let newHasTokenInAttribute;
|
|
3390
|
+
// Reset the styling token applied to the host element.
|
|
3391
|
+
const { stylesheetToken: oldToken, hasTokenInClass: oldHasTokenInClass, hasTokenInAttribute: oldHasTokenInAttribute, } = context;
|
|
3392
|
+
if (!isUndefined$1(oldToken)) {
|
|
3393
|
+
if (oldHasTokenInClass) {
|
|
3394
|
+
getClassList(elm).remove(makeHostToken(oldToken));
|
|
3395
|
+
}
|
|
3396
|
+
if (oldHasTokenInAttribute) {
|
|
3397
|
+
removeAttribute(elm, makeHostToken(oldToken));
|
|
3398
|
+
}
|
|
3399
|
+
}
|
|
3400
|
+
// Apply the new template styling token to the host element, if the new template has any
|
|
3401
|
+
// associated stylesheets. In the case of light DOM, also ensure there is at least one scoped stylesheet.
|
|
3402
|
+
if (!isUndefined$1(newStylesheets) && newStylesheets.length !== 0) {
|
|
3403
|
+
newToken = newStylesheetToken;
|
|
3404
|
+
}
|
|
3405
|
+
// Set the new styling token on the host element
|
|
3406
|
+
if (!isUndefined$1(newToken)) {
|
|
3407
|
+
if (hasScopedStyles) {
|
|
3408
|
+
getClassList(elm).add(makeHostToken(newToken));
|
|
3409
|
+
newHasTokenInClass = true;
|
|
3410
|
+
}
|
|
3411
|
+
if (isSyntheticShadow) {
|
|
3412
|
+
setAttribute(elm, makeHostToken(newToken), '');
|
|
3413
|
+
newHasTokenInAttribute = true;
|
|
3414
|
+
}
|
|
3415
|
+
}
|
|
3416
|
+
// Update the styling tokens present on the context object.
|
|
3417
|
+
context.stylesheetToken = newToken;
|
|
3418
|
+
context.hasTokenInClass = newHasTokenInClass;
|
|
3419
|
+
context.hasTokenInAttribute = newHasTokenInAttribute;
|
|
3420
|
+
}
|
|
3421
|
+
function evaluateStylesheetsContent(stylesheets, stylesheetToken, vm) {
|
|
3422
|
+
const content = [];
|
|
3423
|
+
let root;
|
|
3424
|
+
for (let i = 0; i < stylesheets.length; i++) {
|
|
3425
|
+
let stylesheet = stylesheets[i];
|
|
3426
|
+
if (isArray$1(stylesheet)) {
|
|
3427
|
+
ArrayPush$1.apply(content, evaluateStylesheetsContent(stylesheet, stylesheetToken, vm));
|
|
3428
|
+
}
|
|
3429
|
+
else {
|
|
3430
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
3431
|
+
// Check for compiler version mismatch in dev mode only
|
|
3432
|
+
checkVersionMismatch(stylesheet, 'stylesheet');
|
|
3433
|
+
// in dev-mode, we support hot swapping of stylesheet, which means that
|
|
3434
|
+
// the component instance might be attempting to use an old version of
|
|
3435
|
+
// the stylesheet, while internally, we have a replacement for it.
|
|
3436
|
+
stylesheet = getStyleOrSwappedStyle(stylesheet);
|
|
3437
|
+
}
|
|
3438
|
+
const isScopedCss = stylesheet[KEY__SCOPED_CSS];
|
|
3439
|
+
// Apply the scope token only if the stylesheet itself is scoped, or if we're rendering synthetic shadow.
|
|
3440
|
+
const scopeToken = isScopedCss ||
|
|
3441
|
+
(vm.shadowMode === 1 /* ShadowMode.Synthetic */ && vm.renderMode === 1 /* RenderMode.Shadow */)
|
|
3442
|
+
? stylesheetToken
|
|
3443
|
+
: undefined;
|
|
3444
|
+
// Use the actual `:host` selector if we're rendering global CSS for light DOM, or if we're rendering
|
|
3445
|
+
// native shadow DOM. Synthetic shadow DOM never uses `:host`.
|
|
3446
|
+
const useActualHostSelector = vm.renderMode === 0 /* RenderMode.Light */
|
|
3447
|
+
? !isScopedCss
|
|
3448
|
+
: vm.shadowMode === 0 /* ShadowMode.Native */;
|
|
3449
|
+
// Use the native :dir() pseudoclass only in native shadow DOM. Otherwise, in synthetic shadow,
|
|
3450
|
+
// we use an attribute selector on the host to simulate :dir().
|
|
3451
|
+
let useNativeDirPseudoclass;
|
|
3452
|
+
if (vm.renderMode === 1 /* RenderMode.Shadow */) {
|
|
3453
|
+
useNativeDirPseudoclass = vm.shadowMode === 0 /* ShadowMode.Native */;
|
|
3454
|
+
}
|
|
3455
|
+
else {
|
|
3456
|
+
// Light DOM components should only render `[dir]` if they're inside of a synthetic shadow root.
|
|
3457
|
+
// At the top level (root is null) or inside of a native shadow root, they should use `:dir()`.
|
|
3458
|
+
if (isUndefined$1(root)) {
|
|
3459
|
+
// Only calculate the root once as necessary
|
|
3460
|
+
root = getNearestShadowComponent(vm);
|
|
3461
|
+
}
|
|
3462
|
+
useNativeDirPseudoclass = isNull(root) || root.shadowMode === 0 /* ShadowMode.Native */;
|
|
3463
|
+
}
|
|
3464
|
+
ArrayPush$1.call(content, stylesheet(scopeToken, useActualHostSelector, useNativeDirPseudoclass));
|
|
3465
|
+
}
|
|
3466
|
+
}
|
|
3467
|
+
return content;
|
|
3468
|
+
}
|
|
3469
|
+
function getStylesheetsContent(vm, template) {
|
|
3470
|
+
const { stylesheets, stylesheetToken } = template;
|
|
3471
|
+
let content = [];
|
|
3472
|
+
if (!isUndefined$1(stylesheets) && stylesheets.length !== 0) {
|
|
3473
|
+
content = evaluateStylesheetsContent(stylesheets, stylesheetToken, vm);
|
|
3474
|
+
}
|
|
3475
|
+
return content;
|
|
3476
|
+
}
|
|
3477
|
+
// It might be worth caching this to avoid doing the lookup repeatedly, but
|
|
3478
|
+
// perf testing has not shown it to be a huge improvement yet:
|
|
3479
|
+
// https://github.com/salesforce/lwc/pull/2460#discussion_r691208892
|
|
3480
|
+
function getNearestShadowComponent(vm) {
|
|
3481
|
+
let owner = vm;
|
|
3482
|
+
while (!isNull(owner)) {
|
|
3483
|
+
if (owner.renderMode === 1 /* RenderMode.Shadow */) {
|
|
3484
|
+
return owner;
|
|
3485
|
+
}
|
|
3486
|
+
owner = owner.owner;
|
|
3487
|
+
}
|
|
3488
|
+
return owner;
|
|
3489
|
+
}
|
|
3490
|
+
/**
|
|
3491
|
+
* If the component that is currently being rendered uses scoped styles,
|
|
3492
|
+
* this returns the unique token for that scoped stylesheet. Otherwise
|
|
3493
|
+
* it returns null.
|
|
3494
|
+
*/
|
|
3495
|
+
function getScopeTokenClass(owner) {
|
|
3496
|
+
const { cmpTemplate, context } = owner;
|
|
3497
|
+
return (context.hasScopedStyles && (cmpTemplate === null || cmpTemplate === void 0 ? void 0 : cmpTemplate.stylesheetToken)) || null;
|
|
3498
|
+
}
|
|
3499
|
+
function getNearestNativeShadowComponent(vm) {
|
|
3500
|
+
const owner = getNearestShadowComponent(vm);
|
|
3501
|
+
if (!isNull(owner) && owner.shadowMode === 1 /* ShadowMode.Synthetic */) {
|
|
3502
|
+
// Synthetic-within-native is impossible. So if the nearest shadow component is
|
|
3503
|
+
// synthetic, we know we won't find a native component if we go any further.
|
|
3504
|
+
return null;
|
|
3505
|
+
}
|
|
3506
|
+
return owner;
|
|
3507
|
+
}
|
|
3508
|
+
function createStylesheet(vm, stylesheets) {
|
|
3509
|
+
const { renderMode, shadowMode, renderer: { ssr, insertStylesheet }, } = vm;
|
|
3510
|
+
if (renderMode === 1 /* RenderMode.Shadow */ && shadowMode === 1 /* ShadowMode.Synthetic */) {
|
|
3511
|
+
for (let i = 0; i < stylesheets.length; i++) {
|
|
3512
|
+
insertStylesheet(stylesheets[i]);
|
|
3513
|
+
}
|
|
3514
|
+
}
|
|
3515
|
+
else if (ssr || vm.hydrated) {
|
|
3516
|
+
// Note: We need to ensure that during hydration, the stylesheets method is the same as those in ssr.
|
|
3517
|
+
// This works in the client, because the stylesheets are created, and cached in the VM
|
|
3518
|
+
// the first time the VM renders.
|
|
3519
|
+
// native shadow or light DOM, SSR
|
|
3520
|
+
return ArrayMap.call(stylesheets, createInlineStyleVNode);
|
|
3521
|
+
}
|
|
3522
|
+
else {
|
|
3523
|
+
// native shadow or light DOM, DOM renderer
|
|
3524
|
+
const root = getNearestNativeShadowComponent(vm);
|
|
3525
|
+
// null root means a global style
|
|
3526
|
+
const target = isNull(root) ? undefined : root.shadowRoot;
|
|
3527
|
+
for (let i = 0; i < stylesheets.length; i++) {
|
|
3528
|
+
insertStylesheet(stylesheets[i], target);
|
|
3529
|
+
}
|
|
3530
|
+
}
|
|
3531
|
+
return null;
|
|
3532
|
+
}
|
|
3533
|
+
|
|
3365
3534
|
/*
|
|
3366
3535
|
* Copyright (c) 2020, salesforce.com, inc.
|
|
3367
3536
|
* All rights reserved.
|
|
@@ -3873,10 +4042,9 @@
|
|
|
3873
4042
|
}
|
|
3874
4043
|
// Set the scope token class for *.scoped.css styles
|
|
3875
4044
|
function setScopeTokenClassIfNecessary(elm, owner, renderer) {
|
|
3876
|
-
const
|
|
3877
|
-
|
|
3878
|
-
|
|
3879
|
-
if (!isUndefined$1(token) && context.hasScopedStyles) {
|
|
4045
|
+
const token = getScopeTokenClass(owner);
|
|
4046
|
+
if (!isNull(token)) {
|
|
4047
|
+
const { getClassList } = renderer;
|
|
3880
4048
|
// TODO [#2762]: this dot notation with add is probably problematic
|
|
3881
4049
|
// probably we should have a renderer api for just the add operation
|
|
3882
4050
|
getClassList(elm).add(token);
|
|
@@ -4639,166 +4807,6 @@
|
|
|
4639
4807
|
shc,
|
|
4640
4808
|
});
|
|
4641
4809
|
|
|
4642
|
-
/*
|
|
4643
|
-
* Copyright (c) 2018, salesforce.com, inc.
|
|
4644
|
-
* All rights reserved.
|
|
4645
|
-
* SPDX-License-Identifier: MIT
|
|
4646
|
-
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
4647
|
-
*/
|
|
4648
|
-
function makeHostToken(token) {
|
|
4649
|
-
return `${token}-host`;
|
|
4650
|
-
}
|
|
4651
|
-
function createInlineStyleVNode(content) {
|
|
4652
|
-
return api.h('style', {
|
|
4653
|
-
key: 'style',
|
|
4654
|
-
attrs: {
|
|
4655
|
-
type: 'text/css',
|
|
4656
|
-
},
|
|
4657
|
-
}, [api.t(content)]);
|
|
4658
|
-
}
|
|
4659
|
-
function updateStylesheetToken(vm, template) {
|
|
4660
|
-
const { elm, context, renderMode, shadowMode, renderer: { getClassList, removeAttribute, setAttribute }, } = vm;
|
|
4661
|
-
const { stylesheets: newStylesheets, stylesheetToken: newStylesheetToken } = template;
|
|
4662
|
-
const isSyntheticShadow = renderMode === 1 /* RenderMode.Shadow */ && shadowMode === 1 /* ShadowMode.Synthetic */;
|
|
4663
|
-
const { hasScopedStyles } = context;
|
|
4664
|
-
let newToken;
|
|
4665
|
-
let newHasTokenInClass;
|
|
4666
|
-
let newHasTokenInAttribute;
|
|
4667
|
-
// Reset the styling token applied to the host element.
|
|
4668
|
-
const { stylesheetToken: oldToken, hasTokenInClass: oldHasTokenInClass, hasTokenInAttribute: oldHasTokenInAttribute, } = context;
|
|
4669
|
-
if (!isUndefined$1(oldToken)) {
|
|
4670
|
-
if (oldHasTokenInClass) {
|
|
4671
|
-
getClassList(elm).remove(makeHostToken(oldToken));
|
|
4672
|
-
}
|
|
4673
|
-
if (oldHasTokenInAttribute) {
|
|
4674
|
-
removeAttribute(elm, makeHostToken(oldToken));
|
|
4675
|
-
}
|
|
4676
|
-
}
|
|
4677
|
-
// Apply the new template styling token to the host element, if the new template has any
|
|
4678
|
-
// associated stylesheets. In the case of light DOM, also ensure there is at least one scoped stylesheet.
|
|
4679
|
-
if (!isUndefined$1(newStylesheets) && newStylesheets.length !== 0) {
|
|
4680
|
-
newToken = newStylesheetToken;
|
|
4681
|
-
}
|
|
4682
|
-
// Set the new styling token on the host element
|
|
4683
|
-
if (!isUndefined$1(newToken)) {
|
|
4684
|
-
if (hasScopedStyles) {
|
|
4685
|
-
getClassList(elm).add(makeHostToken(newToken));
|
|
4686
|
-
newHasTokenInClass = true;
|
|
4687
|
-
}
|
|
4688
|
-
if (isSyntheticShadow) {
|
|
4689
|
-
setAttribute(elm, makeHostToken(newToken), '');
|
|
4690
|
-
newHasTokenInAttribute = true;
|
|
4691
|
-
}
|
|
4692
|
-
}
|
|
4693
|
-
// Update the styling tokens present on the context object.
|
|
4694
|
-
context.stylesheetToken = newToken;
|
|
4695
|
-
context.hasTokenInClass = newHasTokenInClass;
|
|
4696
|
-
context.hasTokenInAttribute = newHasTokenInAttribute;
|
|
4697
|
-
}
|
|
4698
|
-
function evaluateStylesheetsContent(stylesheets, stylesheetToken, vm) {
|
|
4699
|
-
const content = [];
|
|
4700
|
-
let root;
|
|
4701
|
-
for (let i = 0; i < stylesheets.length; i++) {
|
|
4702
|
-
let stylesheet = stylesheets[i];
|
|
4703
|
-
if (isArray$1(stylesheet)) {
|
|
4704
|
-
ArrayPush$1.apply(content, evaluateStylesheetsContent(stylesheet, stylesheetToken, vm));
|
|
4705
|
-
}
|
|
4706
|
-
else {
|
|
4707
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
4708
|
-
// Check for compiler version mismatch in dev mode only
|
|
4709
|
-
checkVersionMismatch(stylesheet, 'stylesheet');
|
|
4710
|
-
// in dev-mode, we support hot swapping of stylesheet, which means that
|
|
4711
|
-
// the component instance might be attempting to use an old version of
|
|
4712
|
-
// the stylesheet, while internally, we have a replacement for it.
|
|
4713
|
-
stylesheet = getStyleOrSwappedStyle(stylesheet);
|
|
4714
|
-
}
|
|
4715
|
-
const isScopedCss = stylesheet[KEY__SCOPED_CSS];
|
|
4716
|
-
// Apply the scope token only if the stylesheet itself is scoped, or if we're rendering synthetic shadow.
|
|
4717
|
-
const scopeToken = isScopedCss ||
|
|
4718
|
-
(vm.shadowMode === 1 /* ShadowMode.Synthetic */ && vm.renderMode === 1 /* RenderMode.Shadow */)
|
|
4719
|
-
? stylesheetToken
|
|
4720
|
-
: undefined;
|
|
4721
|
-
// Use the actual `:host` selector if we're rendering global CSS for light DOM, or if we're rendering
|
|
4722
|
-
// native shadow DOM. Synthetic shadow DOM never uses `:host`.
|
|
4723
|
-
const useActualHostSelector = vm.renderMode === 0 /* RenderMode.Light */
|
|
4724
|
-
? !isScopedCss
|
|
4725
|
-
: vm.shadowMode === 0 /* ShadowMode.Native */;
|
|
4726
|
-
// Use the native :dir() pseudoclass only in native shadow DOM. Otherwise, in synthetic shadow,
|
|
4727
|
-
// we use an attribute selector on the host to simulate :dir().
|
|
4728
|
-
let useNativeDirPseudoclass;
|
|
4729
|
-
if (vm.renderMode === 1 /* RenderMode.Shadow */) {
|
|
4730
|
-
useNativeDirPseudoclass = vm.shadowMode === 0 /* ShadowMode.Native */;
|
|
4731
|
-
}
|
|
4732
|
-
else {
|
|
4733
|
-
// Light DOM components should only render `[dir]` if they're inside of a synthetic shadow root.
|
|
4734
|
-
// At the top level (root is null) or inside of a native shadow root, they should use `:dir()`.
|
|
4735
|
-
if (isUndefined$1(root)) {
|
|
4736
|
-
// Only calculate the root once as necessary
|
|
4737
|
-
root = getNearestShadowComponent(vm);
|
|
4738
|
-
}
|
|
4739
|
-
useNativeDirPseudoclass = isNull(root) || root.shadowMode === 0 /* ShadowMode.Native */;
|
|
4740
|
-
}
|
|
4741
|
-
ArrayPush$1.call(content, stylesheet(scopeToken, useActualHostSelector, useNativeDirPseudoclass));
|
|
4742
|
-
}
|
|
4743
|
-
}
|
|
4744
|
-
return content;
|
|
4745
|
-
}
|
|
4746
|
-
function getStylesheetsContent(vm, template) {
|
|
4747
|
-
const { stylesheets, stylesheetToken } = template;
|
|
4748
|
-
let content = [];
|
|
4749
|
-
if (!isUndefined$1(stylesheets) && stylesheets.length !== 0) {
|
|
4750
|
-
content = evaluateStylesheetsContent(stylesheets, stylesheetToken, vm);
|
|
4751
|
-
}
|
|
4752
|
-
return content;
|
|
4753
|
-
}
|
|
4754
|
-
// It might be worth caching this to avoid doing the lookup repeatedly, but
|
|
4755
|
-
// perf testing has not shown it to be a huge improvement yet:
|
|
4756
|
-
// https://github.com/salesforce/lwc/pull/2460#discussion_r691208892
|
|
4757
|
-
function getNearestShadowComponent(vm) {
|
|
4758
|
-
let owner = vm;
|
|
4759
|
-
while (!isNull(owner)) {
|
|
4760
|
-
if (owner.renderMode === 1 /* RenderMode.Shadow */) {
|
|
4761
|
-
return owner;
|
|
4762
|
-
}
|
|
4763
|
-
owner = owner.owner;
|
|
4764
|
-
}
|
|
4765
|
-
return owner;
|
|
4766
|
-
}
|
|
4767
|
-
function getNearestNativeShadowComponent(vm) {
|
|
4768
|
-
const owner = getNearestShadowComponent(vm);
|
|
4769
|
-
if (!isNull(owner) && owner.shadowMode === 1 /* ShadowMode.Synthetic */) {
|
|
4770
|
-
// Synthetic-within-native is impossible. So if the nearest shadow component is
|
|
4771
|
-
// synthetic, we know we won't find a native component if we go any further.
|
|
4772
|
-
return null;
|
|
4773
|
-
}
|
|
4774
|
-
return owner;
|
|
4775
|
-
}
|
|
4776
|
-
function createStylesheet(vm, stylesheets) {
|
|
4777
|
-
const { renderMode, shadowMode, renderer: { ssr, insertStylesheet }, } = vm;
|
|
4778
|
-
if (renderMode === 1 /* RenderMode.Shadow */ && shadowMode === 1 /* ShadowMode.Synthetic */) {
|
|
4779
|
-
for (let i = 0; i < stylesheets.length; i++) {
|
|
4780
|
-
insertStylesheet(stylesheets[i]);
|
|
4781
|
-
}
|
|
4782
|
-
}
|
|
4783
|
-
else if (ssr || vm.hydrated) {
|
|
4784
|
-
// Note: We need to ensure that during hydration, the stylesheets method is the same as those in ssr.
|
|
4785
|
-
// This works in the client, because the stylesheets are created, and cached in the VM
|
|
4786
|
-
// the first time the VM renders.
|
|
4787
|
-
// native shadow or light DOM, SSR
|
|
4788
|
-
return ArrayMap.call(stylesheets, createInlineStyleVNode);
|
|
4789
|
-
}
|
|
4790
|
-
else {
|
|
4791
|
-
// native shadow or light DOM, DOM renderer
|
|
4792
|
-
const root = getNearestNativeShadowComponent(vm);
|
|
4793
|
-
// null root means a global style
|
|
4794
|
-
const target = isNull(root) ? undefined : root.shadowRoot;
|
|
4795
|
-
for (let i = 0; i < stylesheets.length; i++) {
|
|
4796
|
-
insertStylesheet(stylesheets[i], target);
|
|
4797
|
-
}
|
|
4798
|
-
}
|
|
4799
|
-
return null;
|
|
4800
|
-
}
|
|
4801
|
-
|
|
4802
4810
|
/*
|
|
4803
4811
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
4804
4812
|
* All rights reserved.
|
|
@@ -6576,8 +6584,24 @@
|
|
|
6576
6584
|
return nodesAreCompatible;
|
|
6577
6585
|
}
|
|
6578
6586
|
function validateClassAttr(vnode, elm, renderer) {
|
|
6579
|
-
const { data
|
|
6587
|
+
const { data, owner } = vnode;
|
|
6588
|
+
let { className, classMap } = data;
|
|
6580
6589
|
const { getProperty, getClassList } = renderer;
|
|
6590
|
+
const scopedToken = getScopeTokenClass(owner);
|
|
6591
|
+
// Classnames for scoped CSS are added directly to the DOM during rendering,
|
|
6592
|
+
// or to the VDOM on the server in the case of SSR. As such, these classnames
|
|
6593
|
+
// are never present in VDOM nodes in the browser.
|
|
6594
|
+
//
|
|
6595
|
+
// Consequently, hydration mismatches will occur if scoped CSS token classnames
|
|
6596
|
+
// are rendered during SSR. This needs to be accounted for when validating.
|
|
6597
|
+
if (scopedToken) {
|
|
6598
|
+
if (!isUndefined$1(className)) {
|
|
6599
|
+
className = `${scopedToken} ${className}`;
|
|
6600
|
+
}
|
|
6601
|
+
else if (!isUndefined$1(classMap)) {
|
|
6602
|
+
classMap = Object.assign(Object.assign({}, classMap), { [scopedToken]: true });
|
|
6603
|
+
}
|
|
6604
|
+
}
|
|
6581
6605
|
let nodesAreCompatible = true;
|
|
6582
6606
|
let vnodeClassName;
|
|
6583
6607
|
if (!isUndefined$1(className) && String(className) !== getProperty(elm, 'className')) {
|
|
@@ -6817,7 +6841,7 @@
|
|
|
6817
6841
|
}
|
|
6818
6842
|
return ctor;
|
|
6819
6843
|
}
|
|
6820
|
-
/* version: 2.
|
|
6844
|
+
/* version: 2.21.0 */
|
|
6821
6845
|
|
|
6822
6846
|
/*
|
|
6823
6847
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
@@ -7063,7 +7087,15 @@
|
|
|
7063
7087
|
return node.nextSibling;
|
|
7064
7088
|
}
|
|
7065
7089
|
function attachShadow(element, options) {
|
|
7066
|
-
|
|
7090
|
+
// `hydrating` will be true in two cases:
|
|
7091
|
+
// 1. upon initial load with an SSR-generated DOM, while in Shadow render mode
|
|
7092
|
+
// 2. when a webapp author places <c-app> in their static HTML and mounts their
|
|
7093
|
+
// root component with customeElement.define('c-app', Ctor)
|
|
7094
|
+
//
|
|
7095
|
+
// The second case can be treated as a failed hydration with nominal impact
|
|
7096
|
+
// to performance. However, because <c-app> won't have a <template shadowroot>
|
|
7097
|
+
// declarative child, `element.shadowRoot` is `null`.
|
|
7098
|
+
if (hydrating && element.shadowRoot) {
|
|
7067
7099
|
return element.shadowRoot;
|
|
7068
7100
|
}
|
|
7069
7101
|
return element.attachShadow(options);
|
|
@@ -7497,7 +7529,7 @@
|
|
|
7497
7529
|
});
|
|
7498
7530
|
freeze(LightningElement);
|
|
7499
7531
|
seal(LightningElement.prototype);
|
|
7500
|
-
/* version: 2.
|
|
7532
|
+
/* version: 2.21.0 */
|
|
7501
7533
|
|
|
7502
7534
|
exports.LightningElement = LightningElement;
|
|
7503
7535
|
exports.__unstable__ProfilerControl = profilerControl;
|