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
|
@@ -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.21.0";
|
|
303
303
|
const LWC_VERSION_COMMENT_REGEX = /\/\*LWC compiler v([\d.]+)\*\/\s*}/;
|
|
304
|
-
/** version: 2.
|
|
304
|
+
/** version: 2.21.0 */
|
|
305
305
|
|
|
306
306
|
/*
|
|
307
307
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
@@ -455,7 +455,7 @@ function setFeatureFlagForTest(name, value) {
|
|
|
455
455
|
setFeatureFlag(name, value);
|
|
456
456
|
}
|
|
457
457
|
}
|
|
458
|
-
/** version: 2.
|
|
458
|
+
/** version: 2.21.0 */
|
|
459
459
|
|
|
460
460
|
/*
|
|
461
461
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
@@ -3356,6 +3356,175 @@ function getComponentDef(Ctor) {
|
|
|
3356
3356
|
};
|
|
3357
3357
|
}
|
|
3358
3358
|
|
|
3359
|
+
/*
|
|
3360
|
+
* Copyright (c) 2018, salesforce.com, inc.
|
|
3361
|
+
* All rights reserved.
|
|
3362
|
+
* SPDX-License-Identifier: MIT
|
|
3363
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
3364
|
+
*/
|
|
3365
|
+
function makeHostToken(token) {
|
|
3366
|
+
return `${token}-host`;
|
|
3367
|
+
}
|
|
3368
|
+
function createInlineStyleVNode(content) {
|
|
3369
|
+
return api.h('style', {
|
|
3370
|
+
key: 'style',
|
|
3371
|
+
attrs: {
|
|
3372
|
+
type: 'text/css',
|
|
3373
|
+
},
|
|
3374
|
+
}, [api.t(content)]);
|
|
3375
|
+
}
|
|
3376
|
+
function updateStylesheetToken(vm, template) {
|
|
3377
|
+
const { elm, context, renderMode, shadowMode, renderer: { getClassList, removeAttribute, setAttribute }, } = vm;
|
|
3378
|
+
const { stylesheets: newStylesheets, stylesheetToken: newStylesheetToken } = template;
|
|
3379
|
+
const isSyntheticShadow = renderMode === 1 /* RenderMode.Shadow */ && shadowMode === 1 /* ShadowMode.Synthetic */;
|
|
3380
|
+
const { hasScopedStyles } = context;
|
|
3381
|
+
let newToken;
|
|
3382
|
+
let newHasTokenInClass;
|
|
3383
|
+
let newHasTokenInAttribute;
|
|
3384
|
+
// Reset the styling token applied to the host element.
|
|
3385
|
+
const { stylesheetToken: oldToken, hasTokenInClass: oldHasTokenInClass, hasTokenInAttribute: oldHasTokenInAttribute, } = context;
|
|
3386
|
+
if (!isUndefined$1(oldToken)) {
|
|
3387
|
+
if (oldHasTokenInClass) {
|
|
3388
|
+
getClassList(elm).remove(makeHostToken(oldToken));
|
|
3389
|
+
}
|
|
3390
|
+
if (oldHasTokenInAttribute) {
|
|
3391
|
+
removeAttribute(elm, makeHostToken(oldToken));
|
|
3392
|
+
}
|
|
3393
|
+
}
|
|
3394
|
+
// Apply the new template styling token to the host element, if the new template has any
|
|
3395
|
+
// associated stylesheets. In the case of light DOM, also ensure there is at least one scoped stylesheet.
|
|
3396
|
+
if (!isUndefined$1(newStylesheets) && newStylesheets.length !== 0) {
|
|
3397
|
+
newToken = newStylesheetToken;
|
|
3398
|
+
}
|
|
3399
|
+
// Set the new styling token on the host element
|
|
3400
|
+
if (!isUndefined$1(newToken)) {
|
|
3401
|
+
if (hasScopedStyles) {
|
|
3402
|
+
getClassList(elm).add(makeHostToken(newToken));
|
|
3403
|
+
newHasTokenInClass = true;
|
|
3404
|
+
}
|
|
3405
|
+
if (isSyntheticShadow) {
|
|
3406
|
+
setAttribute(elm, makeHostToken(newToken), '');
|
|
3407
|
+
newHasTokenInAttribute = true;
|
|
3408
|
+
}
|
|
3409
|
+
}
|
|
3410
|
+
// Update the styling tokens present on the context object.
|
|
3411
|
+
context.stylesheetToken = newToken;
|
|
3412
|
+
context.hasTokenInClass = newHasTokenInClass;
|
|
3413
|
+
context.hasTokenInAttribute = newHasTokenInAttribute;
|
|
3414
|
+
}
|
|
3415
|
+
function evaluateStylesheetsContent(stylesheets, stylesheetToken, vm) {
|
|
3416
|
+
const content = [];
|
|
3417
|
+
let root;
|
|
3418
|
+
for (let i = 0; i < stylesheets.length; i++) {
|
|
3419
|
+
let stylesheet = stylesheets[i];
|
|
3420
|
+
if (isArray$1(stylesheet)) {
|
|
3421
|
+
ArrayPush$1.apply(content, evaluateStylesheetsContent(stylesheet, stylesheetToken, vm));
|
|
3422
|
+
}
|
|
3423
|
+
else {
|
|
3424
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
3425
|
+
// Check for compiler version mismatch in dev mode only
|
|
3426
|
+
checkVersionMismatch(stylesheet, 'stylesheet');
|
|
3427
|
+
// in dev-mode, we support hot swapping of stylesheet, which means that
|
|
3428
|
+
// the component instance might be attempting to use an old version of
|
|
3429
|
+
// the stylesheet, while internally, we have a replacement for it.
|
|
3430
|
+
stylesheet = getStyleOrSwappedStyle(stylesheet);
|
|
3431
|
+
}
|
|
3432
|
+
const isScopedCss = stylesheet[KEY__SCOPED_CSS];
|
|
3433
|
+
// Apply the scope token only if the stylesheet itself is scoped, or if we're rendering synthetic shadow.
|
|
3434
|
+
const scopeToken = isScopedCss ||
|
|
3435
|
+
(vm.shadowMode === 1 /* ShadowMode.Synthetic */ && vm.renderMode === 1 /* RenderMode.Shadow */)
|
|
3436
|
+
? stylesheetToken
|
|
3437
|
+
: undefined;
|
|
3438
|
+
// Use the actual `:host` selector if we're rendering global CSS for light DOM, or if we're rendering
|
|
3439
|
+
// native shadow DOM. Synthetic shadow DOM never uses `:host`.
|
|
3440
|
+
const useActualHostSelector = vm.renderMode === 0 /* RenderMode.Light */
|
|
3441
|
+
? !isScopedCss
|
|
3442
|
+
: vm.shadowMode === 0 /* ShadowMode.Native */;
|
|
3443
|
+
// Use the native :dir() pseudoclass only in native shadow DOM. Otherwise, in synthetic shadow,
|
|
3444
|
+
// we use an attribute selector on the host to simulate :dir().
|
|
3445
|
+
let useNativeDirPseudoclass;
|
|
3446
|
+
if (vm.renderMode === 1 /* RenderMode.Shadow */) {
|
|
3447
|
+
useNativeDirPseudoclass = vm.shadowMode === 0 /* ShadowMode.Native */;
|
|
3448
|
+
}
|
|
3449
|
+
else {
|
|
3450
|
+
// Light DOM components should only render `[dir]` if they're inside of a synthetic shadow root.
|
|
3451
|
+
// At the top level (root is null) or inside of a native shadow root, they should use `:dir()`.
|
|
3452
|
+
if (isUndefined$1(root)) {
|
|
3453
|
+
// Only calculate the root once as necessary
|
|
3454
|
+
root = getNearestShadowComponent(vm);
|
|
3455
|
+
}
|
|
3456
|
+
useNativeDirPseudoclass = isNull(root) || root.shadowMode === 0 /* ShadowMode.Native */;
|
|
3457
|
+
}
|
|
3458
|
+
ArrayPush$1.call(content, stylesheet(scopeToken, useActualHostSelector, useNativeDirPseudoclass));
|
|
3459
|
+
}
|
|
3460
|
+
}
|
|
3461
|
+
return content;
|
|
3462
|
+
}
|
|
3463
|
+
function getStylesheetsContent(vm, template) {
|
|
3464
|
+
const { stylesheets, stylesheetToken } = template;
|
|
3465
|
+
let content = [];
|
|
3466
|
+
if (!isUndefined$1(stylesheets) && stylesheets.length !== 0) {
|
|
3467
|
+
content = evaluateStylesheetsContent(stylesheets, stylesheetToken, vm);
|
|
3468
|
+
}
|
|
3469
|
+
return content;
|
|
3470
|
+
}
|
|
3471
|
+
// It might be worth caching this to avoid doing the lookup repeatedly, but
|
|
3472
|
+
// perf testing has not shown it to be a huge improvement yet:
|
|
3473
|
+
// https://github.com/salesforce/lwc/pull/2460#discussion_r691208892
|
|
3474
|
+
function getNearestShadowComponent(vm) {
|
|
3475
|
+
let owner = vm;
|
|
3476
|
+
while (!isNull(owner)) {
|
|
3477
|
+
if (owner.renderMode === 1 /* RenderMode.Shadow */) {
|
|
3478
|
+
return owner;
|
|
3479
|
+
}
|
|
3480
|
+
owner = owner.owner;
|
|
3481
|
+
}
|
|
3482
|
+
return owner;
|
|
3483
|
+
}
|
|
3484
|
+
/**
|
|
3485
|
+
* If the component that is currently being rendered uses scoped styles,
|
|
3486
|
+
* this returns the unique token for that scoped stylesheet. Otherwise
|
|
3487
|
+
* it returns null.
|
|
3488
|
+
*/
|
|
3489
|
+
function getScopeTokenClass(owner) {
|
|
3490
|
+
const { cmpTemplate, context } = owner;
|
|
3491
|
+
return (context.hasScopedStyles && (cmpTemplate === null || cmpTemplate === void 0 ? void 0 : cmpTemplate.stylesheetToken)) || null;
|
|
3492
|
+
}
|
|
3493
|
+
function getNearestNativeShadowComponent(vm) {
|
|
3494
|
+
const owner = getNearestShadowComponent(vm);
|
|
3495
|
+
if (!isNull(owner) && owner.shadowMode === 1 /* ShadowMode.Synthetic */) {
|
|
3496
|
+
// Synthetic-within-native is impossible. So if the nearest shadow component is
|
|
3497
|
+
// synthetic, we know we won't find a native component if we go any further.
|
|
3498
|
+
return null;
|
|
3499
|
+
}
|
|
3500
|
+
return owner;
|
|
3501
|
+
}
|
|
3502
|
+
function createStylesheet(vm, stylesheets) {
|
|
3503
|
+
const { renderMode, shadowMode, renderer: { ssr, insertStylesheet }, } = vm;
|
|
3504
|
+
if (renderMode === 1 /* RenderMode.Shadow */ && shadowMode === 1 /* ShadowMode.Synthetic */) {
|
|
3505
|
+
for (let i = 0; i < stylesheets.length; i++) {
|
|
3506
|
+
insertStylesheet(stylesheets[i]);
|
|
3507
|
+
}
|
|
3508
|
+
}
|
|
3509
|
+
else if (ssr || vm.hydrated) {
|
|
3510
|
+
// Note: We need to ensure that during hydration, the stylesheets method is the same as those in ssr.
|
|
3511
|
+
// This works in the client, because the stylesheets are created, and cached in the VM
|
|
3512
|
+
// the first time the VM renders.
|
|
3513
|
+
// native shadow or light DOM, SSR
|
|
3514
|
+
return ArrayMap.call(stylesheets, createInlineStyleVNode);
|
|
3515
|
+
}
|
|
3516
|
+
else {
|
|
3517
|
+
// native shadow or light DOM, DOM renderer
|
|
3518
|
+
const root = getNearestNativeShadowComponent(vm);
|
|
3519
|
+
// null root means a global style
|
|
3520
|
+
const target = isNull(root) ? undefined : root.shadowRoot;
|
|
3521
|
+
for (let i = 0; i < stylesheets.length; i++) {
|
|
3522
|
+
insertStylesheet(stylesheets[i], target);
|
|
3523
|
+
}
|
|
3524
|
+
}
|
|
3525
|
+
return null;
|
|
3526
|
+
}
|
|
3527
|
+
|
|
3359
3528
|
/*
|
|
3360
3529
|
* Copyright (c) 2020, salesforce.com, inc.
|
|
3361
3530
|
* All rights reserved.
|
|
@@ -3867,10 +4036,9 @@ function setElementShadowToken(elm, token) {
|
|
|
3867
4036
|
}
|
|
3868
4037
|
// Set the scope token class for *.scoped.css styles
|
|
3869
4038
|
function setScopeTokenClassIfNecessary(elm, owner, renderer) {
|
|
3870
|
-
const
|
|
3871
|
-
|
|
3872
|
-
|
|
3873
|
-
if (!isUndefined$1(token) && context.hasScopedStyles) {
|
|
4039
|
+
const token = getScopeTokenClass(owner);
|
|
4040
|
+
if (!isNull(token)) {
|
|
4041
|
+
const { getClassList } = renderer;
|
|
3874
4042
|
// TODO [#2762]: this dot notation with add is probably problematic
|
|
3875
4043
|
// probably we should have a renderer api for just the add operation
|
|
3876
4044
|
getClassList(elm).add(token);
|
|
@@ -4633,166 +4801,6 @@ const api = freeze({
|
|
|
4633
4801
|
shc,
|
|
4634
4802
|
});
|
|
4635
4803
|
|
|
4636
|
-
/*
|
|
4637
|
-
* Copyright (c) 2018, salesforce.com, inc.
|
|
4638
|
-
* All rights reserved.
|
|
4639
|
-
* SPDX-License-Identifier: MIT
|
|
4640
|
-
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
4641
|
-
*/
|
|
4642
|
-
function makeHostToken(token) {
|
|
4643
|
-
return `${token}-host`;
|
|
4644
|
-
}
|
|
4645
|
-
function createInlineStyleVNode(content) {
|
|
4646
|
-
return api.h('style', {
|
|
4647
|
-
key: 'style',
|
|
4648
|
-
attrs: {
|
|
4649
|
-
type: 'text/css',
|
|
4650
|
-
},
|
|
4651
|
-
}, [api.t(content)]);
|
|
4652
|
-
}
|
|
4653
|
-
function updateStylesheetToken(vm, template) {
|
|
4654
|
-
const { elm, context, renderMode, shadowMode, renderer: { getClassList, removeAttribute, setAttribute }, } = vm;
|
|
4655
|
-
const { stylesheets: newStylesheets, stylesheetToken: newStylesheetToken } = template;
|
|
4656
|
-
const isSyntheticShadow = renderMode === 1 /* RenderMode.Shadow */ && shadowMode === 1 /* ShadowMode.Synthetic */;
|
|
4657
|
-
const { hasScopedStyles } = context;
|
|
4658
|
-
let newToken;
|
|
4659
|
-
let newHasTokenInClass;
|
|
4660
|
-
let newHasTokenInAttribute;
|
|
4661
|
-
// Reset the styling token applied to the host element.
|
|
4662
|
-
const { stylesheetToken: oldToken, hasTokenInClass: oldHasTokenInClass, hasTokenInAttribute: oldHasTokenInAttribute, } = context;
|
|
4663
|
-
if (!isUndefined$1(oldToken)) {
|
|
4664
|
-
if (oldHasTokenInClass) {
|
|
4665
|
-
getClassList(elm).remove(makeHostToken(oldToken));
|
|
4666
|
-
}
|
|
4667
|
-
if (oldHasTokenInAttribute) {
|
|
4668
|
-
removeAttribute(elm, makeHostToken(oldToken));
|
|
4669
|
-
}
|
|
4670
|
-
}
|
|
4671
|
-
// Apply the new template styling token to the host element, if the new template has any
|
|
4672
|
-
// associated stylesheets. In the case of light DOM, also ensure there is at least one scoped stylesheet.
|
|
4673
|
-
if (!isUndefined$1(newStylesheets) && newStylesheets.length !== 0) {
|
|
4674
|
-
newToken = newStylesheetToken;
|
|
4675
|
-
}
|
|
4676
|
-
// Set the new styling token on the host element
|
|
4677
|
-
if (!isUndefined$1(newToken)) {
|
|
4678
|
-
if (hasScopedStyles) {
|
|
4679
|
-
getClassList(elm).add(makeHostToken(newToken));
|
|
4680
|
-
newHasTokenInClass = true;
|
|
4681
|
-
}
|
|
4682
|
-
if (isSyntheticShadow) {
|
|
4683
|
-
setAttribute(elm, makeHostToken(newToken), '');
|
|
4684
|
-
newHasTokenInAttribute = true;
|
|
4685
|
-
}
|
|
4686
|
-
}
|
|
4687
|
-
// Update the styling tokens present on the context object.
|
|
4688
|
-
context.stylesheetToken = newToken;
|
|
4689
|
-
context.hasTokenInClass = newHasTokenInClass;
|
|
4690
|
-
context.hasTokenInAttribute = newHasTokenInAttribute;
|
|
4691
|
-
}
|
|
4692
|
-
function evaluateStylesheetsContent(stylesheets, stylesheetToken, vm) {
|
|
4693
|
-
const content = [];
|
|
4694
|
-
let root;
|
|
4695
|
-
for (let i = 0; i < stylesheets.length; i++) {
|
|
4696
|
-
let stylesheet = stylesheets[i];
|
|
4697
|
-
if (isArray$1(stylesheet)) {
|
|
4698
|
-
ArrayPush$1.apply(content, evaluateStylesheetsContent(stylesheet, stylesheetToken, vm));
|
|
4699
|
-
}
|
|
4700
|
-
else {
|
|
4701
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
4702
|
-
// Check for compiler version mismatch in dev mode only
|
|
4703
|
-
checkVersionMismatch(stylesheet, 'stylesheet');
|
|
4704
|
-
// in dev-mode, we support hot swapping of stylesheet, which means that
|
|
4705
|
-
// the component instance might be attempting to use an old version of
|
|
4706
|
-
// the stylesheet, while internally, we have a replacement for it.
|
|
4707
|
-
stylesheet = getStyleOrSwappedStyle(stylesheet);
|
|
4708
|
-
}
|
|
4709
|
-
const isScopedCss = stylesheet[KEY__SCOPED_CSS];
|
|
4710
|
-
// Apply the scope token only if the stylesheet itself is scoped, or if we're rendering synthetic shadow.
|
|
4711
|
-
const scopeToken = isScopedCss ||
|
|
4712
|
-
(vm.shadowMode === 1 /* ShadowMode.Synthetic */ && vm.renderMode === 1 /* RenderMode.Shadow */)
|
|
4713
|
-
? stylesheetToken
|
|
4714
|
-
: undefined;
|
|
4715
|
-
// Use the actual `:host` selector if we're rendering global CSS for light DOM, or if we're rendering
|
|
4716
|
-
// native shadow DOM. Synthetic shadow DOM never uses `:host`.
|
|
4717
|
-
const useActualHostSelector = vm.renderMode === 0 /* RenderMode.Light */
|
|
4718
|
-
? !isScopedCss
|
|
4719
|
-
: vm.shadowMode === 0 /* ShadowMode.Native */;
|
|
4720
|
-
// Use the native :dir() pseudoclass only in native shadow DOM. Otherwise, in synthetic shadow,
|
|
4721
|
-
// we use an attribute selector on the host to simulate :dir().
|
|
4722
|
-
let useNativeDirPseudoclass;
|
|
4723
|
-
if (vm.renderMode === 1 /* RenderMode.Shadow */) {
|
|
4724
|
-
useNativeDirPseudoclass = vm.shadowMode === 0 /* ShadowMode.Native */;
|
|
4725
|
-
}
|
|
4726
|
-
else {
|
|
4727
|
-
// Light DOM components should only render `[dir]` if they're inside of a synthetic shadow root.
|
|
4728
|
-
// At the top level (root is null) or inside of a native shadow root, they should use `:dir()`.
|
|
4729
|
-
if (isUndefined$1(root)) {
|
|
4730
|
-
// Only calculate the root once as necessary
|
|
4731
|
-
root = getNearestShadowComponent(vm);
|
|
4732
|
-
}
|
|
4733
|
-
useNativeDirPseudoclass = isNull(root) || root.shadowMode === 0 /* ShadowMode.Native */;
|
|
4734
|
-
}
|
|
4735
|
-
ArrayPush$1.call(content, stylesheet(scopeToken, useActualHostSelector, useNativeDirPseudoclass));
|
|
4736
|
-
}
|
|
4737
|
-
}
|
|
4738
|
-
return content;
|
|
4739
|
-
}
|
|
4740
|
-
function getStylesheetsContent(vm, template) {
|
|
4741
|
-
const { stylesheets, stylesheetToken } = template;
|
|
4742
|
-
let content = [];
|
|
4743
|
-
if (!isUndefined$1(stylesheets) && stylesheets.length !== 0) {
|
|
4744
|
-
content = evaluateStylesheetsContent(stylesheets, stylesheetToken, vm);
|
|
4745
|
-
}
|
|
4746
|
-
return content;
|
|
4747
|
-
}
|
|
4748
|
-
// It might be worth caching this to avoid doing the lookup repeatedly, but
|
|
4749
|
-
// perf testing has not shown it to be a huge improvement yet:
|
|
4750
|
-
// https://github.com/salesforce/lwc/pull/2460#discussion_r691208892
|
|
4751
|
-
function getNearestShadowComponent(vm) {
|
|
4752
|
-
let owner = vm;
|
|
4753
|
-
while (!isNull(owner)) {
|
|
4754
|
-
if (owner.renderMode === 1 /* RenderMode.Shadow */) {
|
|
4755
|
-
return owner;
|
|
4756
|
-
}
|
|
4757
|
-
owner = owner.owner;
|
|
4758
|
-
}
|
|
4759
|
-
return owner;
|
|
4760
|
-
}
|
|
4761
|
-
function getNearestNativeShadowComponent(vm) {
|
|
4762
|
-
const owner = getNearestShadowComponent(vm);
|
|
4763
|
-
if (!isNull(owner) && owner.shadowMode === 1 /* ShadowMode.Synthetic */) {
|
|
4764
|
-
// Synthetic-within-native is impossible. So if the nearest shadow component is
|
|
4765
|
-
// synthetic, we know we won't find a native component if we go any further.
|
|
4766
|
-
return null;
|
|
4767
|
-
}
|
|
4768
|
-
return owner;
|
|
4769
|
-
}
|
|
4770
|
-
function createStylesheet(vm, stylesheets) {
|
|
4771
|
-
const { renderMode, shadowMode, renderer: { ssr, insertStylesheet }, } = vm;
|
|
4772
|
-
if (renderMode === 1 /* RenderMode.Shadow */ && shadowMode === 1 /* ShadowMode.Synthetic */) {
|
|
4773
|
-
for (let i = 0; i < stylesheets.length; i++) {
|
|
4774
|
-
insertStylesheet(stylesheets[i]);
|
|
4775
|
-
}
|
|
4776
|
-
}
|
|
4777
|
-
else if (ssr || vm.hydrated) {
|
|
4778
|
-
// Note: We need to ensure that during hydration, the stylesheets method is the same as those in ssr.
|
|
4779
|
-
// This works in the client, because the stylesheets are created, and cached in the VM
|
|
4780
|
-
// the first time the VM renders.
|
|
4781
|
-
// native shadow or light DOM, SSR
|
|
4782
|
-
return ArrayMap.call(stylesheets, createInlineStyleVNode);
|
|
4783
|
-
}
|
|
4784
|
-
else {
|
|
4785
|
-
// native shadow or light DOM, DOM renderer
|
|
4786
|
-
const root = getNearestNativeShadowComponent(vm);
|
|
4787
|
-
// null root means a global style
|
|
4788
|
-
const target = isNull(root) ? undefined : root.shadowRoot;
|
|
4789
|
-
for (let i = 0; i < stylesheets.length; i++) {
|
|
4790
|
-
insertStylesheet(stylesheets[i], target);
|
|
4791
|
-
}
|
|
4792
|
-
}
|
|
4793
|
-
return null;
|
|
4794
|
-
}
|
|
4795
|
-
|
|
4796
4804
|
/*
|
|
4797
4805
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
4798
4806
|
* All rights reserved.
|
|
@@ -6570,8 +6578,24 @@ function validateAttrs(vnode, elm, renderer) {
|
|
|
6570
6578
|
return nodesAreCompatible;
|
|
6571
6579
|
}
|
|
6572
6580
|
function validateClassAttr(vnode, elm, renderer) {
|
|
6573
|
-
const { data
|
|
6581
|
+
const { data, owner } = vnode;
|
|
6582
|
+
let { className, classMap } = data;
|
|
6574
6583
|
const { getProperty, getClassList } = renderer;
|
|
6584
|
+
const scopedToken = getScopeTokenClass(owner);
|
|
6585
|
+
// Classnames for scoped CSS are added directly to the DOM during rendering,
|
|
6586
|
+
// or to the VDOM on the server in the case of SSR. As such, these classnames
|
|
6587
|
+
// are never present in VDOM nodes in the browser.
|
|
6588
|
+
//
|
|
6589
|
+
// Consequently, hydration mismatches will occur if scoped CSS token classnames
|
|
6590
|
+
// are rendered during SSR. This needs to be accounted for when validating.
|
|
6591
|
+
if (scopedToken) {
|
|
6592
|
+
if (!isUndefined$1(className)) {
|
|
6593
|
+
className = `${scopedToken} ${className}`;
|
|
6594
|
+
}
|
|
6595
|
+
else if (!isUndefined$1(classMap)) {
|
|
6596
|
+
classMap = Object.assign(Object.assign({}, classMap), { [scopedToken]: true });
|
|
6597
|
+
}
|
|
6598
|
+
}
|
|
6575
6599
|
let nodesAreCompatible = true;
|
|
6576
6600
|
let vnodeClassName;
|
|
6577
6601
|
if (!isUndefined$1(className) && String(className) !== getProperty(elm, 'className')) {
|
|
@@ -6811,7 +6835,7 @@ function getComponentConstructor(elm) {
|
|
|
6811
6835
|
}
|
|
6812
6836
|
return ctor;
|
|
6813
6837
|
}
|
|
6814
|
-
/* version: 2.
|
|
6838
|
+
/* version: 2.21.0 */
|
|
6815
6839
|
|
|
6816
6840
|
/*
|
|
6817
6841
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
@@ -7057,7 +7081,15 @@ function nextSibling(node) {
|
|
|
7057
7081
|
return node.nextSibling;
|
|
7058
7082
|
}
|
|
7059
7083
|
function attachShadow(element, options) {
|
|
7060
|
-
|
|
7084
|
+
// `hydrating` will be true in two cases:
|
|
7085
|
+
// 1. upon initial load with an SSR-generated DOM, while in Shadow render mode
|
|
7086
|
+
// 2. when a webapp author places <c-app> in their static HTML and mounts their
|
|
7087
|
+
// root component with customeElement.define('c-app', Ctor)
|
|
7088
|
+
//
|
|
7089
|
+
// The second case can be treated as a failed hydration with nominal impact
|
|
7090
|
+
// to performance. However, because <c-app> won't have a <template shadowroot>
|
|
7091
|
+
// declarative child, `element.shadowRoot` is `null`.
|
|
7092
|
+
if (hydrating && element.shadowRoot) {
|
|
7061
7093
|
return element.shadowRoot;
|
|
7062
7094
|
}
|
|
7063
7095
|
return element.attachShadow(options);
|
|
@@ -7491,6 +7523,6 @@ defineProperty(LightningElement, 'CustomElementConstructor', {
|
|
|
7491
7523
|
});
|
|
7492
7524
|
freeze(LightningElement);
|
|
7493
7525
|
seal(LightningElement.prototype);
|
|
7494
|
-
/* version: 2.
|
|
7526
|
+
/* version: 2.21.0 */
|
|
7495
7527
|
|
|
7496
7528
|
export { LightningElement, profilerControl as __unstable__ProfilerControl, api$1 as api, deprecatedBuildCustomElementConstructor as buildCustomElementConstructor, createContextProvider, createElement, freezeTemplate, getComponentConstructor, getComponentDef, hydrateComponent, isComponentConstructor, isNodeShadowed as isNodeFromTemplate, parseFragment, parseSVGFragment, readonly, register, registerComponent, registerDecorators, registerTemplate, renderer, sanitizeAttribute, setFeatureFlag, setFeatureFlagForTest, setHooks, swapComponent, swapStyle, swapTemplate, track, unwrap, wire };
|