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
|
@@ -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.20.
|
|
308
|
+
const LWC_VERSION = "2.20.3";
|
|
309
309
|
const LWC_VERSION_COMMENT_REGEX = /\/\*LWC compiler v([\d.]+)\*\/\s*}/;
|
|
310
|
-
/** version: 2.20.
|
|
310
|
+
/** version: 2.20.3 */
|
|
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.20.
|
|
464
|
+
/** version: 2.20.3 */
|
|
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.20.
|
|
6844
|
+
/* version: 2.20.3 */
|
|
6821
6845
|
|
|
6822
6846
|
/*
|
|
6823
6847
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
@@ -6850,9 +6874,6 @@
|
|
|
6850
6874
|
stylesheetCache.clear();
|
|
6851
6875
|
};
|
|
6852
6876
|
}
|
|
6853
|
-
function isDocument(target) {
|
|
6854
|
-
return !isUndefined$1(target.head);
|
|
6855
|
-
}
|
|
6856
6877
|
function createFreshStyleElement(content) {
|
|
6857
6878
|
const elm = document.createElement('style');
|
|
6858
6879
|
elm.type = 'text/css';
|
|
@@ -6860,10 +6881,10 @@
|
|
|
6860
6881
|
return elm;
|
|
6861
6882
|
}
|
|
6862
6883
|
function createStyleElement(content, cacheData) {
|
|
6863
|
-
const {
|
|
6884
|
+
const { element, usedElement } = cacheData;
|
|
6864
6885
|
// If the <style> was already used, then we should clone it. We cannot insert
|
|
6865
6886
|
// the same <style> in two places in the DOM.
|
|
6866
|
-
if (
|
|
6887
|
+
if (usedElement) {
|
|
6867
6888
|
// For a mysterious reason, IE11 doesn't like the way we clone <style> nodes
|
|
6868
6889
|
// and will render the incorrect styles if we do things that way. It's just
|
|
6869
6890
|
// a perf optimization, so we can skip it for IE11.
|
|
@@ -6872,11 +6893,11 @@
|
|
|
6872
6893
|
}
|
|
6873
6894
|
// This `<style>` may be repeated multiple times in the DOM, so cache it. It's a bit
|
|
6874
6895
|
// faster to call `cloneNode()` on an existing node than to recreate it every time.
|
|
6875
|
-
return
|
|
6896
|
+
return element.cloneNode(true);
|
|
6876
6897
|
}
|
|
6877
6898
|
// We don't clone every time, because that would be a perf tax on the first time
|
|
6878
|
-
cacheData.
|
|
6879
|
-
return
|
|
6899
|
+
cacheData.usedElement = true;
|
|
6900
|
+
return element;
|
|
6880
6901
|
}
|
|
6881
6902
|
function createConstructableStylesheet(content) {
|
|
6882
6903
|
const stylesheet = new CSSStyleSheet();
|
|
@@ -6897,47 +6918,42 @@
|
|
|
6897
6918
|
}
|
|
6898
6919
|
function insertStyleElement(content, target, cacheData) {
|
|
6899
6920
|
const elm = createStyleElement(content, cacheData);
|
|
6900
|
-
|
|
6901
|
-
targetAnchorPoint.appendChild(elm);
|
|
6902
|
-
}
|
|
6903
|
-
function doInsertStylesheet(content, target, cacheData) {
|
|
6904
|
-
// Constructable stylesheets are only supported in certain browsers:
|
|
6905
|
-
// https://caniuse.com/mdn-api_document_adoptedstylesheets
|
|
6906
|
-
// The reason we use it is for perf: https://github.com/salesforce/lwc/pull/2460
|
|
6907
|
-
if (supportsConstructableStylesheets) {
|
|
6908
|
-
insertConstructableStylesheet(content, target, cacheData);
|
|
6909
|
-
}
|
|
6910
|
-
else {
|
|
6911
|
-
// Fall back to <style> element
|
|
6912
|
-
insertStyleElement(content, target, cacheData);
|
|
6913
|
-
}
|
|
6921
|
+
target.appendChild(elm);
|
|
6914
6922
|
}
|
|
6915
|
-
function getCacheData(content) {
|
|
6923
|
+
function getCacheData(content, useConstructableStylesheet) {
|
|
6916
6924
|
let cacheData = stylesheetCache.get(content);
|
|
6917
6925
|
if (isUndefined$1(cacheData)) {
|
|
6918
6926
|
cacheData = {
|
|
6919
|
-
stylesheet:
|
|
6920
|
-
|
|
6921
|
-
: createFreshStyleElement(content),
|
|
6927
|
+
stylesheet: undefined,
|
|
6928
|
+
element: undefined,
|
|
6922
6929
|
roots: undefined,
|
|
6923
6930
|
global: false,
|
|
6924
|
-
|
|
6931
|
+
usedElement: false,
|
|
6925
6932
|
};
|
|
6926
6933
|
stylesheetCache.set(content, cacheData);
|
|
6927
6934
|
}
|
|
6935
|
+
// Create <style> elements or CSSStyleSheets on-demand, as needed
|
|
6936
|
+
if (useConstructableStylesheet && isUndefined$1(cacheData.stylesheet)) {
|
|
6937
|
+
cacheData.stylesheet = createConstructableStylesheet(content);
|
|
6938
|
+
}
|
|
6939
|
+
else if (!useConstructableStylesheet && isUndefined$1(cacheData.element)) {
|
|
6940
|
+
cacheData.element = createFreshStyleElement(content);
|
|
6941
|
+
}
|
|
6928
6942
|
return cacheData;
|
|
6929
6943
|
}
|
|
6930
6944
|
function insertGlobalStylesheet(content) {
|
|
6931
|
-
|
|
6945
|
+
// Force a <style> element for global stylesheets. See comment below.
|
|
6946
|
+
const cacheData = getCacheData(content, false);
|
|
6932
6947
|
if (cacheData.global) {
|
|
6933
6948
|
// already inserted
|
|
6934
6949
|
return;
|
|
6935
6950
|
}
|
|
6936
6951
|
cacheData.global = true; // mark inserted
|
|
6937
|
-
|
|
6952
|
+
// TODO [#2922]: use document.adoptedStyleSheets in supported browsers. Currently we can't, due to backwards compat.
|
|
6953
|
+
insertStyleElement(content, document.head, cacheData);
|
|
6938
6954
|
}
|
|
6939
6955
|
function insertLocalStylesheet(content, target) {
|
|
6940
|
-
const cacheData = getCacheData(content);
|
|
6956
|
+
const cacheData = getCacheData(content, supportsConstructableStylesheets);
|
|
6941
6957
|
let { roots } = cacheData;
|
|
6942
6958
|
if (isUndefined$1(roots)) {
|
|
6943
6959
|
roots = cacheData.roots = new WeakSet(); // lazily initialize (not needed for global styles)
|
|
@@ -6947,7 +6963,16 @@
|
|
|
6947
6963
|
return;
|
|
6948
6964
|
}
|
|
6949
6965
|
roots.add(target); // mark inserted
|
|
6950
|
-
|
|
6966
|
+
// Constructable stylesheets are only supported in certain browsers:
|
|
6967
|
+
// https://caniuse.com/mdn-api_document_adoptedstylesheets
|
|
6968
|
+
// The reason we use it is for perf: https://github.com/salesforce/lwc/pull/2460
|
|
6969
|
+
if (supportsConstructableStylesheets) {
|
|
6970
|
+
insertConstructableStylesheet(content, target, cacheData);
|
|
6971
|
+
}
|
|
6972
|
+
else {
|
|
6973
|
+
// Fall back to <style> element
|
|
6974
|
+
insertStyleElement(content, target, cacheData);
|
|
6975
|
+
}
|
|
6951
6976
|
}
|
|
6952
6977
|
function insertStylesheet(content, target) {
|
|
6953
6978
|
if (isUndefined$1(target)) {
|
|
@@ -7062,7 +7087,15 @@
|
|
|
7062
7087
|
return node.nextSibling;
|
|
7063
7088
|
}
|
|
7064
7089
|
function attachShadow(element, options) {
|
|
7065
|
-
|
|
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) {
|
|
7066
7099
|
return element.shadowRoot;
|
|
7067
7100
|
}
|
|
7068
7101
|
return element.attachShadow(options);
|
|
@@ -7496,7 +7529,7 @@
|
|
|
7496
7529
|
});
|
|
7497
7530
|
freeze(LightningElement);
|
|
7498
7531
|
seal(LightningElement.prototype);
|
|
7499
|
-
/* version: 2.20.
|
|
7532
|
+
/* version: 2.20.3 */
|
|
7500
7533
|
|
|
7501
7534
|
exports.LightningElement = LightningElement;
|
|
7502
7535
|
exports.__unstable__ProfilerControl = profilerControl;
|