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