lwc 2.20.0 → 2.20.3
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 +235 -202
- package/dist/engine-dom/iife/es2017/engine-dom.js +235 -202
- package/dist/engine-dom/iife/es2017/engine-dom.min.js +1 -1
- package/dist/engine-dom/iife/es2017/engine-dom_debug.js +225 -192
- package/dist/engine-dom/iife/es5/engine-dom.js +320 -285
- package/dist/engine-dom/iife/es5/engine-dom.min.js +1 -1
- package/dist/engine-dom/iife/es5/engine-dom_debug.js +310 -274
- package/dist/engine-dom/umd/es2017/engine-dom.js +235 -202
- package/dist/engine-dom/umd/es2017/engine-dom.min.js +1 -1
- package/dist/engine-dom/umd/es2017/engine-dom_debug.js +225 -192
- package/dist/engine-dom/umd/es5/engine-dom.js +320 -285
- package/dist/engine-dom/umd/es5/engine-dom.min.js +1 -1
- package/dist/engine-dom/umd/es5/engine-dom_debug.js +310 -274
- package/dist/engine-server/commonjs/es2017/engine-server.js +177 -169
- package/dist/engine-server/commonjs/es2017/engine-server.min.js +1 -1
- package/dist/engine-server/esm/es2017/engine-server.js +177 -169
- 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.20.
|
|
302
|
+
const LWC_VERSION = "2.20.3";
|
|
303
303
|
const LWC_VERSION_COMMENT_REGEX = /\/\*LWC compiler v([\d.]+)\*\/\s*}/;
|
|
304
|
-
/** version: 2.20.
|
|
304
|
+
/** version: 2.20.3 */
|
|
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.20.
|
|
458
|
+
/** version: 2.20.3 */
|
|
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.20.
|
|
6838
|
+
/* version: 2.20.3 */
|
|
6815
6839
|
|
|
6816
6840
|
/*
|
|
6817
6841
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
@@ -6844,9 +6868,6 @@ if (process.env.NODE_ENV === 'development') {
|
|
|
6844
6868
|
stylesheetCache.clear();
|
|
6845
6869
|
};
|
|
6846
6870
|
}
|
|
6847
|
-
function isDocument(target) {
|
|
6848
|
-
return !isUndefined$1(target.head);
|
|
6849
|
-
}
|
|
6850
6871
|
function createFreshStyleElement(content) {
|
|
6851
6872
|
const elm = document.createElement('style');
|
|
6852
6873
|
elm.type = 'text/css';
|
|
@@ -6854,10 +6875,10 @@ function createFreshStyleElement(content) {
|
|
|
6854
6875
|
return elm;
|
|
6855
6876
|
}
|
|
6856
6877
|
function createStyleElement(content, cacheData) {
|
|
6857
|
-
const {
|
|
6878
|
+
const { element, usedElement } = cacheData;
|
|
6858
6879
|
// If the <style> was already used, then we should clone it. We cannot insert
|
|
6859
6880
|
// the same <style> in two places in the DOM.
|
|
6860
|
-
if (
|
|
6881
|
+
if (usedElement) {
|
|
6861
6882
|
// For a mysterious reason, IE11 doesn't like the way we clone <style> nodes
|
|
6862
6883
|
// and will render the incorrect styles if we do things that way. It's just
|
|
6863
6884
|
// a perf optimization, so we can skip it for IE11.
|
|
@@ -6866,11 +6887,11 @@ function createStyleElement(content, cacheData) {
|
|
|
6866
6887
|
}
|
|
6867
6888
|
// This `<style>` may be repeated multiple times in the DOM, so cache it. It's a bit
|
|
6868
6889
|
// faster to call `cloneNode()` on an existing node than to recreate it every time.
|
|
6869
|
-
return
|
|
6890
|
+
return element.cloneNode(true);
|
|
6870
6891
|
}
|
|
6871
6892
|
// We don't clone every time, because that would be a perf tax on the first time
|
|
6872
|
-
cacheData.
|
|
6873
|
-
return
|
|
6893
|
+
cacheData.usedElement = true;
|
|
6894
|
+
return element;
|
|
6874
6895
|
}
|
|
6875
6896
|
function createConstructableStylesheet(content) {
|
|
6876
6897
|
const stylesheet = new CSSStyleSheet();
|
|
@@ -6891,47 +6912,42 @@ function insertConstructableStylesheet(content, target, cacheData) {
|
|
|
6891
6912
|
}
|
|
6892
6913
|
function insertStyleElement(content, target, cacheData) {
|
|
6893
6914
|
const elm = createStyleElement(content, cacheData);
|
|
6894
|
-
|
|
6895
|
-
targetAnchorPoint.appendChild(elm);
|
|
6896
|
-
}
|
|
6897
|
-
function doInsertStylesheet(content, target, cacheData) {
|
|
6898
|
-
// Constructable stylesheets are only supported in certain browsers:
|
|
6899
|
-
// https://caniuse.com/mdn-api_document_adoptedstylesheets
|
|
6900
|
-
// The reason we use it is for perf: https://github.com/salesforce/lwc/pull/2460
|
|
6901
|
-
if (supportsConstructableStylesheets) {
|
|
6902
|
-
insertConstructableStylesheet(content, target, cacheData);
|
|
6903
|
-
}
|
|
6904
|
-
else {
|
|
6905
|
-
// Fall back to <style> element
|
|
6906
|
-
insertStyleElement(content, target, cacheData);
|
|
6907
|
-
}
|
|
6915
|
+
target.appendChild(elm);
|
|
6908
6916
|
}
|
|
6909
|
-
function getCacheData(content) {
|
|
6917
|
+
function getCacheData(content, useConstructableStylesheet) {
|
|
6910
6918
|
let cacheData = stylesheetCache.get(content);
|
|
6911
6919
|
if (isUndefined$1(cacheData)) {
|
|
6912
6920
|
cacheData = {
|
|
6913
|
-
stylesheet:
|
|
6914
|
-
|
|
6915
|
-
: createFreshStyleElement(content),
|
|
6921
|
+
stylesheet: undefined,
|
|
6922
|
+
element: undefined,
|
|
6916
6923
|
roots: undefined,
|
|
6917
6924
|
global: false,
|
|
6918
|
-
|
|
6925
|
+
usedElement: false,
|
|
6919
6926
|
};
|
|
6920
6927
|
stylesheetCache.set(content, cacheData);
|
|
6921
6928
|
}
|
|
6929
|
+
// Create <style> elements or CSSStyleSheets on-demand, as needed
|
|
6930
|
+
if (useConstructableStylesheet && isUndefined$1(cacheData.stylesheet)) {
|
|
6931
|
+
cacheData.stylesheet = createConstructableStylesheet(content);
|
|
6932
|
+
}
|
|
6933
|
+
else if (!useConstructableStylesheet && isUndefined$1(cacheData.element)) {
|
|
6934
|
+
cacheData.element = createFreshStyleElement(content);
|
|
6935
|
+
}
|
|
6922
6936
|
return cacheData;
|
|
6923
6937
|
}
|
|
6924
6938
|
function insertGlobalStylesheet(content) {
|
|
6925
|
-
|
|
6939
|
+
// Force a <style> element for global stylesheets. See comment below.
|
|
6940
|
+
const cacheData = getCacheData(content, false);
|
|
6926
6941
|
if (cacheData.global) {
|
|
6927
6942
|
// already inserted
|
|
6928
6943
|
return;
|
|
6929
6944
|
}
|
|
6930
6945
|
cacheData.global = true; // mark inserted
|
|
6931
|
-
|
|
6946
|
+
// TODO [#2922]: use document.adoptedStyleSheets in supported browsers. Currently we can't, due to backwards compat.
|
|
6947
|
+
insertStyleElement(content, document.head, cacheData);
|
|
6932
6948
|
}
|
|
6933
6949
|
function insertLocalStylesheet(content, target) {
|
|
6934
|
-
const cacheData = getCacheData(content);
|
|
6950
|
+
const cacheData = getCacheData(content, supportsConstructableStylesheets);
|
|
6935
6951
|
let { roots } = cacheData;
|
|
6936
6952
|
if (isUndefined$1(roots)) {
|
|
6937
6953
|
roots = cacheData.roots = new WeakSet(); // lazily initialize (not needed for global styles)
|
|
@@ -6941,7 +6957,16 @@ function insertLocalStylesheet(content, target) {
|
|
|
6941
6957
|
return;
|
|
6942
6958
|
}
|
|
6943
6959
|
roots.add(target); // mark inserted
|
|
6944
|
-
|
|
6960
|
+
// Constructable stylesheets are only supported in certain browsers:
|
|
6961
|
+
// https://caniuse.com/mdn-api_document_adoptedstylesheets
|
|
6962
|
+
// The reason we use it is for perf: https://github.com/salesforce/lwc/pull/2460
|
|
6963
|
+
if (supportsConstructableStylesheets) {
|
|
6964
|
+
insertConstructableStylesheet(content, target, cacheData);
|
|
6965
|
+
}
|
|
6966
|
+
else {
|
|
6967
|
+
// Fall back to <style> element
|
|
6968
|
+
insertStyleElement(content, target, cacheData);
|
|
6969
|
+
}
|
|
6945
6970
|
}
|
|
6946
6971
|
function insertStylesheet(content, target) {
|
|
6947
6972
|
if (isUndefined$1(target)) {
|
|
@@ -7056,7 +7081,15 @@ function nextSibling(node) {
|
|
|
7056
7081
|
return node.nextSibling;
|
|
7057
7082
|
}
|
|
7058
7083
|
function attachShadow(element, options) {
|
|
7059
|
-
|
|
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) {
|
|
7060
7093
|
return element.shadowRoot;
|
|
7061
7094
|
}
|
|
7062
7095
|
return element.attachShadow(options);
|
|
@@ -7490,6 +7523,6 @@ defineProperty(LightningElement, 'CustomElementConstructor', {
|
|
|
7490
7523
|
});
|
|
7491
7524
|
freeze(LightningElement);
|
|
7492
7525
|
seal(LightningElement.prototype);
|
|
7493
|
-
/* version: 2.20.
|
|
7526
|
+
/* version: 2.20.3 */
|
|
7494
7527
|
|
|
7495
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 };
|