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
|
@@ -294,7 +294,7 @@
|
|
|
294
294
|
CACHED_PROPERTY_ATTRIBUTE_MAPPING.set(propName, attributeName);
|
|
295
295
|
return attributeName;
|
|
296
296
|
}
|
|
297
|
-
/** version: 2.20.
|
|
297
|
+
/** version: 2.20.3 */
|
|
298
298
|
|
|
299
299
|
/*
|
|
300
300
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
@@ -2293,6 +2293,167 @@
|
|
|
2293
2293
|
};
|
|
2294
2294
|
}
|
|
2295
2295
|
|
|
2296
|
+
/*
|
|
2297
|
+
* Copyright (c) 2018, salesforce.com, inc.
|
|
2298
|
+
* All rights reserved.
|
|
2299
|
+
* SPDX-License-Identifier: MIT
|
|
2300
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
2301
|
+
*/
|
|
2302
|
+
function makeHostToken(token) {
|
|
2303
|
+
return `${token}-host`;
|
|
2304
|
+
}
|
|
2305
|
+
function createInlineStyleVNode(content) {
|
|
2306
|
+
return api.h('style', {
|
|
2307
|
+
key: 'style',
|
|
2308
|
+
attrs: {
|
|
2309
|
+
type: 'text/css',
|
|
2310
|
+
},
|
|
2311
|
+
}, [api.t(content)]);
|
|
2312
|
+
}
|
|
2313
|
+
function updateStylesheetToken(vm, template) {
|
|
2314
|
+
const { elm, context, renderMode, shadowMode, renderer: { getClassList, removeAttribute, setAttribute }, } = vm;
|
|
2315
|
+
const { stylesheets: newStylesheets, stylesheetToken: newStylesheetToken } = template;
|
|
2316
|
+
const isSyntheticShadow = renderMode === 1 /* RenderMode.Shadow */ && shadowMode === 1 /* ShadowMode.Synthetic */;
|
|
2317
|
+
const { hasScopedStyles } = context;
|
|
2318
|
+
let newToken;
|
|
2319
|
+
let newHasTokenInClass;
|
|
2320
|
+
let newHasTokenInAttribute;
|
|
2321
|
+
// Reset the styling token applied to the host element.
|
|
2322
|
+
const { stylesheetToken: oldToken, hasTokenInClass: oldHasTokenInClass, hasTokenInAttribute: oldHasTokenInAttribute, } = context;
|
|
2323
|
+
if (!isUndefined$1(oldToken)) {
|
|
2324
|
+
if (oldHasTokenInClass) {
|
|
2325
|
+
getClassList(elm).remove(makeHostToken(oldToken));
|
|
2326
|
+
}
|
|
2327
|
+
if (oldHasTokenInAttribute) {
|
|
2328
|
+
removeAttribute(elm, makeHostToken(oldToken));
|
|
2329
|
+
}
|
|
2330
|
+
}
|
|
2331
|
+
// Apply the new template styling token to the host element, if the new template has any
|
|
2332
|
+
// associated stylesheets. In the case of light DOM, also ensure there is at least one scoped stylesheet.
|
|
2333
|
+
if (!isUndefined$1(newStylesheets) && newStylesheets.length !== 0) {
|
|
2334
|
+
newToken = newStylesheetToken;
|
|
2335
|
+
}
|
|
2336
|
+
// Set the new styling token on the host element
|
|
2337
|
+
if (!isUndefined$1(newToken)) {
|
|
2338
|
+
if (hasScopedStyles) {
|
|
2339
|
+
getClassList(elm).add(makeHostToken(newToken));
|
|
2340
|
+
newHasTokenInClass = true;
|
|
2341
|
+
}
|
|
2342
|
+
if (isSyntheticShadow) {
|
|
2343
|
+
setAttribute(elm, makeHostToken(newToken), '');
|
|
2344
|
+
newHasTokenInAttribute = true;
|
|
2345
|
+
}
|
|
2346
|
+
}
|
|
2347
|
+
// Update the styling tokens present on the context object.
|
|
2348
|
+
context.stylesheetToken = newToken;
|
|
2349
|
+
context.hasTokenInClass = newHasTokenInClass;
|
|
2350
|
+
context.hasTokenInAttribute = newHasTokenInAttribute;
|
|
2351
|
+
}
|
|
2352
|
+
function evaluateStylesheetsContent(stylesheets, stylesheetToken, vm) {
|
|
2353
|
+
const content = [];
|
|
2354
|
+
let root;
|
|
2355
|
+
for (let i = 0; i < stylesheets.length; i++) {
|
|
2356
|
+
let stylesheet = stylesheets[i];
|
|
2357
|
+
if (isArray$1(stylesheet)) {
|
|
2358
|
+
ArrayPush$1.apply(content, evaluateStylesheetsContent(stylesheet, stylesheetToken, vm));
|
|
2359
|
+
}
|
|
2360
|
+
else {
|
|
2361
|
+
const isScopedCss = stylesheet[KEY__SCOPED_CSS];
|
|
2362
|
+
// Apply the scope token only if the stylesheet itself is scoped, or if we're rendering synthetic shadow.
|
|
2363
|
+
const scopeToken = isScopedCss ||
|
|
2364
|
+
(vm.shadowMode === 1 /* ShadowMode.Synthetic */ && vm.renderMode === 1 /* RenderMode.Shadow */)
|
|
2365
|
+
? stylesheetToken
|
|
2366
|
+
: undefined;
|
|
2367
|
+
// Use the actual `:host` selector if we're rendering global CSS for light DOM, or if we're rendering
|
|
2368
|
+
// native shadow DOM. Synthetic shadow DOM never uses `:host`.
|
|
2369
|
+
const useActualHostSelector = vm.renderMode === 0 /* RenderMode.Light */
|
|
2370
|
+
? !isScopedCss
|
|
2371
|
+
: vm.shadowMode === 0 /* ShadowMode.Native */;
|
|
2372
|
+
// Use the native :dir() pseudoclass only in native shadow DOM. Otherwise, in synthetic shadow,
|
|
2373
|
+
// we use an attribute selector on the host to simulate :dir().
|
|
2374
|
+
let useNativeDirPseudoclass;
|
|
2375
|
+
if (vm.renderMode === 1 /* RenderMode.Shadow */) {
|
|
2376
|
+
useNativeDirPseudoclass = vm.shadowMode === 0 /* ShadowMode.Native */;
|
|
2377
|
+
}
|
|
2378
|
+
else {
|
|
2379
|
+
// Light DOM components should only render `[dir]` if they're inside of a synthetic shadow root.
|
|
2380
|
+
// At the top level (root is null) or inside of a native shadow root, they should use `:dir()`.
|
|
2381
|
+
if (isUndefined$1(root)) {
|
|
2382
|
+
// Only calculate the root once as necessary
|
|
2383
|
+
root = getNearestShadowComponent(vm);
|
|
2384
|
+
}
|
|
2385
|
+
useNativeDirPseudoclass = isNull(root) || root.shadowMode === 0 /* ShadowMode.Native */;
|
|
2386
|
+
}
|
|
2387
|
+
ArrayPush$1.call(content, stylesheet(scopeToken, useActualHostSelector, useNativeDirPseudoclass));
|
|
2388
|
+
}
|
|
2389
|
+
}
|
|
2390
|
+
return content;
|
|
2391
|
+
}
|
|
2392
|
+
function getStylesheetsContent(vm, template) {
|
|
2393
|
+
const { stylesheets, stylesheetToken } = template;
|
|
2394
|
+
let content = [];
|
|
2395
|
+
if (!isUndefined$1(stylesheets) && stylesheets.length !== 0) {
|
|
2396
|
+
content = evaluateStylesheetsContent(stylesheets, stylesheetToken, vm);
|
|
2397
|
+
}
|
|
2398
|
+
return content;
|
|
2399
|
+
}
|
|
2400
|
+
// It might be worth caching this to avoid doing the lookup repeatedly, but
|
|
2401
|
+
// perf testing has not shown it to be a huge improvement yet:
|
|
2402
|
+
// https://github.com/salesforce/lwc/pull/2460#discussion_r691208892
|
|
2403
|
+
function getNearestShadowComponent(vm) {
|
|
2404
|
+
let owner = vm;
|
|
2405
|
+
while (!isNull(owner)) {
|
|
2406
|
+
if (owner.renderMode === 1 /* RenderMode.Shadow */) {
|
|
2407
|
+
return owner;
|
|
2408
|
+
}
|
|
2409
|
+
owner = owner.owner;
|
|
2410
|
+
}
|
|
2411
|
+
return owner;
|
|
2412
|
+
}
|
|
2413
|
+
/**
|
|
2414
|
+
* If the component that is currently being rendered uses scoped styles,
|
|
2415
|
+
* this returns the unique token for that scoped stylesheet. Otherwise
|
|
2416
|
+
* it returns null.
|
|
2417
|
+
*/
|
|
2418
|
+
function getScopeTokenClass(owner) {
|
|
2419
|
+
const { cmpTemplate, context } = owner;
|
|
2420
|
+
return (context.hasScopedStyles && (cmpTemplate === null || cmpTemplate === void 0 ? void 0 : cmpTemplate.stylesheetToken)) || null;
|
|
2421
|
+
}
|
|
2422
|
+
function getNearestNativeShadowComponent(vm) {
|
|
2423
|
+
const owner = getNearestShadowComponent(vm);
|
|
2424
|
+
if (!isNull(owner) && owner.shadowMode === 1 /* ShadowMode.Synthetic */) {
|
|
2425
|
+
// Synthetic-within-native is impossible. So if the nearest shadow component is
|
|
2426
|
+
// synthetic, we know we won't find a native component if we go any further.
|
|
2427
|
+
return null;
|
|
2428
|
+
}
|
|
2429
|
+
return owner;
|
|
2430
|
+
}
|
|
2431
|
+
function createStylesheet(vm, stylesheets) {
|
|
2432
|
+
const { renderMode, shadowMode, renderer: { ssr, insertStylesheet }, } = vm;
|
|
2433
|
+
if (renderMode === 1 /* RenderMode.Shadow */ && shadowMode === 1 /* ShadowMode.Synthetic */) {
|
|
2434
|
+
for (let i = 0; i < stylesheets.length; i++) {
|
|
2435
|
+
insertStylesheet(stylesheets[i]);
|
|
2436
|
+
}
|
|
2437
|
+
}
|
|
2438
|
+
else if (ssr || vm.hydrated) {
|
|
2439
|
+
// Note: We need to ensure that during hydration, the stylesheets method is the same as those in ssr.
|
|
2440
|
+
// This works in the client, because the stylesheets are created, and cached in the VM
|
|
2441
|
+
// the first time the VM renders.
|
|
2442
|
+
// native shadow or light DOM, SSR
|
|
2443
|
+
return ArrayMap.call(stylesheets, createInlineStyleVNode);
|
|
2444
|
+
}
|
|
2445
|
+
else {
|
|
2446
|
+
// native shadow or light DOM, DOM renderer
|
|
2447
|
+
const root = getNearestNativeShadowComponent(vm);
|
|
2448
|
+
// null root means a global style
|
|
2449
|
+
const target = isNull(root) ? undefined : root.shadowRoot;
|
|
2450
|
+
for (let i = 0; i < stylesheets.length; i++) {
|
|
2451
|
+
insertStylesheet(stylesheets[i], target);
|
|
2452
|
+
}
|
|
2453
|
+
}
|
|
2454
|
+
return null;
|
|
2455
|
+
}
|
|
2456
|
+
|
|
2296
2457
|
/*
|
|
2297
2458
|
* Copyright (c) 2020, salesforce.com, inc.
|
|
2298
2459
|
* All rights reserved.
|
|
@@ -2785,10 +2946,9 @@
|
|
|
2785
2946
|
}
|
|
2786
2947
|
// Set the scope token class for *.scoped.css styles
|
|
2787
2948
|
function setScopeTokenClassIfNecessary(elm, owner, renderer) {
|
|
2788
|
-
const
|
|
2789
|
-
|
|
2790
|
-
|
|
2791
|
-
if (!isUndefined$1(token) && context.hasScopedStyles) {
|
|
2949
|
+
const token = getScopeTokenClass(owner);
|
|
2950
|
+
if (!isNull(token)) {
|
|
2951
|
+
const { getClassList } = renderer;
|
|
2792
2952
|
// TODO [#2762]: this dot notation with add is probably problematic
|
|
2793
2953
|
// probably we should have a renderer api for just the add operation
|
|
2794
2954
|
getClassList(elm).add(token);
|
|
@@ -3408,158 +3568,6 @@
|
|
|
3408
3568
|
fid,
|
|
3409
3569
|
shc,
|
|
3410
3570
|
});
|
|
3411
|
-
|
|
3412
|
-
/*
|
|
3413
|
-
* Copyright (c) 2018, salesforce.com, inc.
|
|
3414
|
-
* All rights reserved.
|
|
3415
|
-
* SPDX-License-Identifier: MIT
|
|
3416
|
-
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
3417
|
-
*/
|
|
3418
|
-
function makeHostToken(token) {
|
|
3419
|
-
return `${token}-host`;
|
|
3420
|
-
}
|
|
3421
|
-
function createInlineStyleVNode(content) {
|
|
3422
|
-
return api.h('style', {
|
|
3423
|
-
key: 'style',
|
|
3424
|
-
attrs: {
|
|
3425
|
-
type: 'text/css',
|
|
3426
|
-
},
|
|
3427
|
-
}, [api.t(content)]);
|
|
3428
|
-
}
|
|
3429
|
-
function updateStylesheetToken(vm, template) {
|
|
3430
|
-
const { elm, context, renderMode, shadowMode, renderer: { getClassList, removeAttribute, setAttribute }, } = vm;
|
|
3431
|
-
const { stylesheets: newStylesheets, stylesheetToken: newStylesheetToken } = template;
|
|
3432
|
-
const isSyntheticShadow = renderMode === 1 /* RenderMode.Shadow */ && shadowMode === 1 /* ShadowMode.Synthetic */;
|
|
3433
|
-
const { hasScopedStyles } = context;
|
|
3434
|
-
let newToken;
|
|
3435
|
-
let newHasTokenInClass;
|
|
3436
|
-
let newHasTokenInAttribute;
|
|
3437
|
-
// Reset the styling token applied to the host element.
|
|
3438
|
-
const { stylesheetToken: oldToken, hasTokenInClass: oldHasTokenInClass, hasTokenInAttribute: oldHasTokenInAttribute, } = context;
|
|
3439
|
-
if (!isUndefined$1(oldToken)) {
|
|
3440
|
-
if (oldHasTokenInClass) {
|
|
3441
|
-
getClassList(elm).remove(makeHostToken(oldToken));
|
|
3442
|
-
}
|
|
3443
|
-
if (oldHasTokenInAttribute) {
|
|
3444
|
-
removeAttribute(elm, makeHostToken(oldToken));
|
|
3445
|
-
}
|
|
3446
|
-
}
|
|
3447
|
-
// Apply the new template styling token to the host element, if the new template has any
|
|
3448
|
-
// associated stylesheets. In the case of light DOM, also ensure there is at least one scoped stylesheet.
|
|
3449
|
-
if (!isUndefined$1(newStylesheets) && newStylesheets.length !== 0) {
|
|
3450
|
-
newToken = newStylesheetToken;
|
|
3451
|
-
}
|
|
3452
|
-
// Set the new styling token on the host element
|
|
3453
|
-
if (!isUndefined$1(newToken)) {
|
|
3454
|
-
if (hasScopedStyles) {
|
|
3455
|
-
getClassList(elm).add(makeHostToken(newToken));
|
|
3456
|
-
newHasTokenInClass = true;
|
|
3457
|
-
}
|
|
3458
|
-
if (isSyntheticShadow) {
|
|
3459
|
-
setAttribute(elm, makeHostToken(newToken), '');
|
|
3460
|
-
newHasTokenInAttribute = true;
|
|
3461
|
-
}
|
|
3462
|
-
}
|
|
3463
|
-
// Update the styling tokens present on the context object.
|
|
3464
|
-
context.stylesheetToken = newToken;
|
|
3465
|
-
context.hasTokenInClass = newHasTokenInClass;
|
|
3466
|
-
context.hasTokenInAttribute = newHasTokenInAttribute;
|
|
3467
|
-
}
|
|
3468
|
-
function evaluateStylesheetsContent(stylesheets, stylesheetToken, vm) {
|
|
3469
|
-
const content = [];
|
|
3470
|
-
let root;
|
|
3471
|
-
for (let i = 0; i < stylesheets.length; i++) {
|
|
3472
|
-
let stylesheet = stylesheets[i];
|
|
3473
|
-
if (isArray$1(stylesheet)) {
|
|
3474
|
-
ArrayPush$1.apply(content, evaluateStylesheetsContent(stylesheet, stylesheetToken, vm));
|
|
3475
|
-
}
|
|
3476
|
-
else {
|
|
3477
|
-
const isScopedCss = stylesheet[KEY__SCOPED_CSS];
|
|
3478
|
-
// Apply the scope token only if the stylesheet itself is scoped, or if we're rendering synthetic shadow.
|
|
3479
|
-
const scopeToken = isScopedCss ||
|
|
3480
|
-
(vm.shadowMode === 1 /* ShadowMode.Synthetic */ && vm.renderMode === 1 /* RenderMode.Shadow */)
|
|
3481
|
-
? stylesheetToken
|
|
3482
|
-
: undefined;
|
|
3483
|
-
// Use the actual `:host` selector if we're rendering global CSS for light DOM, or if we're rendering
|
|
3484
|
-
// native shadow DOM. Synthetic shadow DOM never uses `:host`.
|
|
3485
|
-
const useActualHostSelector = vm.renderMode === 0 /* RenderMode.Light */
|
|
3486
|
-
? !isScopedCss
|
|
3487
|
-
: vm.shadowMode === 0 /* ShadowMode.Native */;
|
|
3488
|
-
// Use the native :dir() pseudoclass only in native shadow DOM. Otherwise, in synthetic shadow,
|
|
3489
|
-
// we use an attribute selector on the host to simulate :dir().
|
|
3490
|
-
let useNativeDirPseudoclass;
|
|
3491
|
-
if (vm.renderMode === 1 /* RenderMode.Shadow */) {
|
|
3492
|
-
useNativeDirPseudoclass = vm.shadowMode === 0 /* ShadowMode.Native */;
|
|
3493
|
-
}
|
|
3494
|
-
else {
|
|
3495
|
-
// Light DOM components should only render `[dir]` if they're inside of a synthetic shadow root.
|
|
3496
|
-
// At the top level (root is null) or inside of a native shadow root, they should use `:dir()`.
|
|
3497
|
-
if (isUndefined$1(root)) {
|
|
3498
|
-
// Only calculate the root once as necessary
|
|
3499
|
-
root = getNearestShadowComponent(vm);
|
|
3500
|
-
}
|
|
3501
|
-
useNativeDirPseudoclass = isNull(root) || root.shadowMode === 0 /* ShadowMode.Native */;
|
|
3502
|
-
}
|
|
3503
|
-
ArrayPush$1.call(content, stylesheet(scopeToken, useActualHostSelector, useNativeDirPseudoclass));
|
|
3504
|
-
}
|
|
3505
|
-
}
|
|
3506
|
-
return content;
|
|
3507
|
-
}
|
|
3508
|
-
function getStylesheetsContent(vm, template) {
|
|
3509
|
-
const { stylesheets, stylesheetToken } = template;
|
|
3510
|
-
let content = [];
|
|
3511
|
-
if (!isUndefined$1(stylesheets) && stylesheets.length !== 0) {
|
|
3512
|
-
content = evaluateStylesheetsContent(stylesheets, stylesheetToken, vm);
|
|
3513
|
-
}
|
|
3514
|
-
return content;
|
|
3515
|
-
}
|
|
3516
|
-
// It might be worth caching this to avoid doing the lookup repeatedly, but
|
|
3517
|
-
// perf testing has not shown it to be a huge improvement yet:
|
|
3518
|
-
// https://github.com/salesforce/lwc/pull/2460#discussion_r691208892
|
|
3519
|
-
function getNearestShadowComponent(vm) {
|
|
3520
|
-
let owner = vm;
|
|
3521
|
-
while (!isNull(owner)) {
|
|
3522
|
-
if (owner.renderMode === 1 /* RenderMode.Shadow */) {
|
|
3523
|
-
return owner;
|
|
3524
|
-
}
|
|
3525
|
-
owner = owner.owner;
|
|
3526
|
-
}
|
|
3527
|
-
return owner;
|
|
3528
|
-
}
|
|
3529
|
-
function getNearestNativeShadowComponent(vm) {
|
|
3530
|
-
const owner = getNearestShadowComponent(vm);
|
|
3531
|
-
if (!isNull(owner) && owner.shadowMode === 1 /* ShadowMode.Synthetic */) {
|
|
3532
|
-
// Synthetic-within-native is impossible. So if the nearest shadow component is
|
|
3533
|
-
// synthetic, we know we won't find a native component if we go any further.
|
|
3534
|
-
return null;
|
|
3535
|
-
}
|
|
3536
|
-
return owner;
|
|
3537
|
-
}
|
|
3538
|
-
function createStylesheet(vm, stylesheets) {
|
|
3539
|
-
const { renderMode, shadowMode, renderer: { ssr, insertStylesheet }, } = vm;
|
|
3540
|
-
if (renderMode === 1 /* RenderMode.Shadow */ && shadowMode === 1 /* ShadowMode.Synthetic */) {
|
|
3541
|
-
for (let i = 0; i < stylesheets.length; i++) {
|
|
3542
|
-
insertStylesheet(stylesheets[i]);
|
|
3543
|
-
}
|
|
3544
|
-
}
|
|
3545
|
-
else if (ssr || vm.hydrated) {
|
|
3546
|
-
// Note: We need to ensure that during hydration, the stylesheets method is the same as those in ssr.
|
|
3547
|
-
// This works in the client, because the stylesheets are created, and cached in the VM
|
|
3548
|
-
// the first time the VM renders.
|
|
3549
|
-
// native shadow or light DOM, SSR
|
|
3550
|
-
return ArrayMap.call(stylesheets, createInlineStyleVNode);
|
|
3551
|
-
}
|
|
3552
|
-
else {
|
|
3553
|
-
// native shadow or light DOM, DOM renderer
|
|
3554
|
-
const root = getNearestNativeShadowComponent(vm);
|
|
3555
|
-
// null root means a global style
|
|
3556
|
-
const target = isNull(root) ? undefined : root.shadowRoot;
|
|
3557
|
-
for (let i = 0; i < stylesheets.length; i++) {
|
|
3558
|
-
insertStylesheet(stylesheets[i], target);
|
|
3559
|
-
}
|
|
3560
|
-
}
|
|
3561
|
-
return null;
|
|
3562
|
-
}
|
|
3563
3571
|
/** Indicates if operations should be logged by the profiler. */
|
|
3564
3572
|
let isProfilerEnabled = false;
|
|
3565
3573
|
/** The currently assigned profiler dispatcher. */
|
|
@@ -5085,8 +5093,24 @@
|
|
|
5085
5093
|
return nodesAreCompatible;
|
|
5086
5094
|
}
|
|
5087
5095
|
function validateClassAttr(vnode, elm, renderer) {
|
|
5088
|
-
const { data
|
|
5096
|
+
const { data, owner } = vnode;
|
|
5097
|
+
let { className, classMap } = data;
|
|
5089
5098
|
const { getProperty, getClassList } = renderer;
|
|
5099
|
+
const scopedToken = getScopeTokenClass(owner);
|
|
5100
|
+
// Classnames for scoped CSS are added directly to the DOM during rendering,
|
|
5101
|
+
// or to the VDOM on the server in the case of SSR. As such, these classnames
|
|
5102
|
+
// are never present in VDOM nodes in the browser.
|
|
5103
|
+
//
|
|
5104
|
+
// Consequently, hydration mismatches will occur if scoped CSS token classnames
|
|
5105
|
+
// are rendered during SSR. This needs to be accounted for when validating.
|
|
5106
|
+
if (scopedToken) {
|
|
5107
|
+
if (!isUndefined$1(className)) {
|
|
5108
|
+
className = `${scopedToken} ${className}`;
|
|
5109
|
+
}
|
|
5110
|
+
else if (!isUndefined$1(classMap)) {
|
|
5111
|
+
classMap = Object.assign(Object.assign({}, classMap), { [scopedToken]: true });
|
|
5112
|
+
}
|
|
5113
|
+
}
|
|
5090
5114
|
let nodesAreCompatible = true;
|
|
5091
5115
|
if (!isUndefined$1(className) && String(className) !== getProperty(elm, 'className')) {
|
|
5092
5116
|
// className is used when class is bound to an expr.
|
|
@@ -5213,7 +5237,7 @@
|
|
|
5213
5237
|
}
|
|
5214
5238
|
return ctor;
|
|
5215
5239
|
}
|
|
5216
|
-
/* version: 2.20.
|
|
5240
|
+
/* version: 2.20.3 */
|
|
5217
5241
|
|
|
5218
5242
|
/*
|
|
5219
5243
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
@@ -5237,9 +5261,6 @@
|
|
|
5237
5261
|
// Detect IE, via https://stackoverflow.com/a/9851769
|
|
5238
5262
|
const isIE11 = !isUndefined$1(document.documentMode);
|
|
5239
5263
|
const stylesheetCache = new Map();
|
|
5240
|
-
function isDocument(target) {
|
|
5241
|
-
return !isUndefined$1(target.head);
|
|
5242
|
-
}
|
|
5243
5264
|
function createFreshStyleElement(content) {
|
|
5244
5265
|
const elm = document.createElement('style');
|
|
5245
5266
|
elm.type = 'text/css';
|
|
@@ -5247,10 +5268,10 @@
|
|
|
5247
5268
|
return elm;
|
|
5248
5269
|
}
|
|
5249
5270
|
function createStyleElement(content, cacheData) {
|
|
5250
|
-
const {
|
|
5271
|
+
const { element, usedElement } = cacheData;
|
|
5251
5272
|
// If the <style> was already used, then we should clone it. We cannot insert
|
|
5252
5273
|
// the same <style> in two places in the DOM.
|
|
5253
|
-
if (
|
|
5274
|
+
if (usedElement) {
|
|
5254
5275
|
// For a mysterious reason, IE11 doesn't like the way we clone <style> nodes
|
|
5255
5276
|
// and will render the incorrect styles if we do things that way. It's just
|
|
5256
5277
|
// a perf optimization, so we can skip it for IE11.
|
|
@@ -5259,11 +5280,11 @@
|
|
|
5259
5280
|
}
|
|
5260
5281
|
// This `<style>` may be repeated multiple times in the DOM, so cache it. It's a bit
|
|
5261
5282
|
// faster to call `cloneNode()` on an existing node than to recreate it every time.
|
|
5262
|
-
return
|
|
5283
|
+
return element.cloneNode(true);
|
|
5263
5284
|
}
|
|
5264
5285
|
// We don't clone every time, because that would be a perf tax on the first time
|
|
5265
|
-
cacheData.
|
|
5266
|
-
return
|
|
5286
|
+
cacheData.usedElement = true;
|
|
5287
|
+
return element;
|
|
5267
5288
|
}
|
|
5268
5289
|
function createConstructableStylesheet(content) {
|
|
5269
5290
|
const stylesheet = new CSSStyleSheet();
|
|
@@ -5284,47 +5305,42 @@
|
|
|
5284
5305
|
}
|
|
5285
5306
|
function insertStyleElement(content, target, cacheData) {
|
|
5286
5307
|
const elm = createStyleElement(content, cacheData);
|
|
5287
|
-
|
|
5288
|
-
targetAnchorPoint.appendChild(elm);
|
|
5289
|
-
}
|
|
5290
|
-
function doInsertStylesheet(content, target, cacheData) {
|
|
5291
|
-
// Constructable stylesheets are only supported in certain browsers:
|
|
5292
|
-
// https://caniuse.com/mdn-api_document_adoptedstylesheets
|
|
5293
|
-
// The reason we use it is for perf: https://github.com/salesforce/lwc/pull/2460
|
|
5294
|
-
if (supportsConstructableStylesheets) {
|
|
5295
|
-
insertConstructableStylesheet(content, target, cacheData);
|
|
5296
|
-
}
|
|
5297
|
-
else {
|
|
5298
|
-
// Fall back to <style> element
|
|
5299
|
-
insertStyleElement(content, target, cacheData);
|
|
5300
|
-
}
|
|
5308
|
+
target.appendChild(elm);
|
|
5301
5309
|
}
|
|
5302
|
-
function getCacheData(content) {
|
|
5310
|
+
function getCacheData(content, useConstructableStylesheet) {
|
|
5303
5311
|
let cacheData = stylesheetCache.get(content);
|
|
5304
5312
|
if (isUndefined$1(cacheData)) {
|
|
5305
5313
|
cacheData = {
|
|
5306
|
-
stylesheet:
|
|
5307
|
-
|
|
5308
|
-
: createFreshStyleElement(content),
|
|
5314
|
+
stylesheet: undefined,
|
|
5315
|
+
element: undefined,
|
|
5309
5316
|
roots: undefined,
|
|
5310
5317
|
global: false,
|
|
5311
|
-
|
|
5318
|
+
usedElement: false,
|
|
5312
5319
|
};
|
|
5313
5320
|
stylesheetCache.set(content, cacheData);
|
|
5314
5321
|
}
|
|
5322
|
+
// Create <style> elements or CSSStyleSheets on-demand, as needed
|
|
5323
|
+
if (useConstructableStylesheet && isUndefined$1(cacheData.stylesheet)) {
|
|
5324
|
+
cacheData.stylesheet = createConstructableStylesheet(content);
|
|
5325
|
+
}
|
|
5326
|
+
else if (!useConstructableStylesheet && isUndefined$1(cacheData.element)) {
|
|
5327
|
+
cacheData.element = createFreshStyleElement(content);
|
|
5328
|
+
}
|
|
5315
5329
|
return cacheData;
|
|
5316
5330
|
}
|
|
5317
5331
|
function insertGlobalStylesheet(content) {
|
|
5318
|
-
|
|
5332
|
+
// Force a <style> element for global stylesheets. See comment below.
|
|
5333
|
+
const cacheData = getCacheData(content, false);
|
|
5319
5334
|
if (cacheData.global) {
|
|
5320
5335
|
// already inserted
|
|
5321
5336
|
return;
|
|
5322
5337
|
}
|
|
5323
5338
|
cacheData.global = true; // mark inserted
|
|
5324
|
-
|
|
5339
|
+
// TODO [#2922]: use document.adoptedStyleSheets in supported browsers. Currently we can't, due to backwards compat.
|
|
5340
|
+
insertStyleElement(content, document.head, cacheData);
|
|
5325
5341
|
}
|
|
5326
5342
|
function insertLocalStylesheet(content, target) {
|
|
5327
|
-
const cacheData = getCacheData(content);
|
|
5343
|
+
const cacheData = getCacheData(content, supportsConstructableStylesheets);
|
|
5328
5344
|
let { roots } = cacheData;
|
|
5329
5345
|
if (isUndefined$1(roots)) {
|
|
5330
5346
|
roots = cacheData.roots = new WeakSet(); // lazily initialize (not needed for global styles)
|
|
@@ -5334,7 +5350,16 @@
|
|
|
5334
5350
|
return;
|
|
5335
5351
|
}
|
|
5336
5352
|
roots.add(target); // mark inserted
|
|
5337
|
-
|
|
5353
|
+
// Constructable stylesheets are only supported in certain browsers:
|
|
5354
|
+
// https://caniuse.com/mdn-api_document_adoptedstylesheets
|
|
5355
|
+
// The reason we use it is for perf: https://github.com/salesforce/lwc/pull/2460
|
|
5356
|
+
if (supportsConstructableStylesheets) {
|
|
5357
|
+
insertConstructableStylesheet(content, target, cacheData);
|
|
5358
|
+
}
|
|
5359
|
+
else {
|
|
5360
|
+
// Fall back to <style> element
|
|
5361
|
+
insertStyleElement(content, target, cacheData);
|
|
5362
|
+
}
|
|
5338
5363
|
}
|
|
5339
5364
|
function insertStylesheet(content, target) {
|
|
5340
5365
|
if (isUndefined$1(target)) {
|
|
@@ -5449,7 +5474,15 @@
|
|
|
5449
5474
|
return node.nextSibling;
|
|
5450
5475
|
}
|
|
5451
5476
|
function attachShadow(element, options) {
|
|
5452
|
-
|
|
5477
|
+
// `hydrating` will be true in two cases:
|
|
5478
|
+
// 1. upon initial load with an SSR-generated DOM, while in Shadow render mode
|
|
5479
|
+
// 2. when a webapp author places <c-app> in their static HTML and mounts their
|
|
5480
|
+
// root component with customeElement.define('c-app', Ctor)
|
|
5481
|
+
//
|
|
5482
|
+
// The second case can be treated as a failed hydration with nominal impact
|
|
5483
|
+
// to performance. However, because <c-app> won't have a <template shadowroot>
|
|
5484
|
+
// declarative child, `element.shadowRoot` is `null`.
|
|
5485
|
+
if (hydrating && element.shadowRoot) {
|
|
5453
5486
|
return element.shadowRoot;
|
|
5454
5487
|
}
|
|
5455
5488
|
return element.attachShadow(options);
|
|
@@ -5869,7 +5902,7 @@
|
|
|
5869
5902
|
});
|
|
5870
5903
|
freeze(LightningElement);
|
|
5871
5904
|
seal(LightningElement.prototype);
|
|
5872
|
-
/* version: 2.20.
|
|
5905
|
+
/* version: 2.20.3 */
|
|
5873
5906
|
|
|
5874
5907
|
exports.LightningElement = LightningElement;
|
|
5875
5908
|
exports.__unstable__ProfilerControl = profilerControl;
|