@lwrjs/everywhere 0.13.0-alpha.0 → 0.13.0-alpha.2
Sign up to get free protection for your applications and to get access to all the features.
- package/build/__generated_site_amd_modules__/1/application/amd/l/en-US/ai/amd-bootstrap/configuration/ci/-/-/s/86e5b35c91b01b4b7df42aded40a3e5d/config.js +12 -0
- package/build/__generated_site_amd_modules__/1/module/amd/1/l/en-US/mi/@lwrjs/app-service/amd-bootstrap/module/amd/v/0_13_0-alpha_2/s/8bce578258518655194bd71d1d72aad5/@lwrjs_app-service_amd-bootstrap_module_amd.js +14 -0
- package/build/__generated_site_amd_modules__/1/module/amd/1/l/en-US/mi/lwc/v/{6_3_4/s/5c26ade60a97bb24c64d3829320b13f6 → 6_6_1/s/eeee3bb1f188f86a6a28e9d5c983706c}/lwc.js +959 -579
- package/build/__generated_site_amd_modules__/1/module/amd/1/l/en-US/mi/lwr/everywhereAmd/v/{0_13_0-alpha_0 → 0_13_0-alpha_2}/s/cb931ebef2b89dcf8ab51456e3a68864/lwr_everywhereAmd.js +3 -3
- package/build/__generated_site_amd_modules__/1/module/amd/1/l/en-US/mi/lwr/init/v/{0_13_0-alpha_0 → 0_13_0-alpha_2}/s/f30361ad8ff7af505bf4d465c8499181/lwr_init.js +21 -21
- package/build/__generated_site_amd_modules__/1/module/amd/1/l/en-US/mi/lwr/loader/v/{0_13_0-alpha_0/s/589732f011b79219a57c1f4a08038efe → 0_13_0-alpha_2/s/e307ee0231427b79178dc8789d2591fc}/lwr_loader.js +4 -4
- package/build/__generated_site_amd_modules__/1/module/amd/1/l/en-US/mi/lwr/metrics/v/{0_13_0-alpha_0 → 0_13_0-alpha_2}/s/274c8343f810353bbad085a79709395f/lwr_metrics.js +1 -1
- package/build/__generated_site_amd_modules__/1/module/amd/1/l/en-US/mi/lwr/preInit/v/{0_13_0-alpha_0 → 0_13_0-alpha_2}/s/ec0fad0e38a96bb0b88c9f4553460347/lwr_preInit.js +1 -1
- package/build/__generated_site_amd_modules__/1/module/amd/1/l/en-US/mi/lwr/profiler/v/{0_13_0-alpha_0 → 0_13_0-alpha_2}/s/a152b8d35f12ca1b5147c5cd1ee155fb/lwr_profiler.js +1 -1
- package/build/__generated_site_amd_modules__/1/module/amd/1/l/en-US/mi/lwr/vault/v/{0_13_0-alpha_0 → 0_13_0-alpha_2}/s/c92abd8c1fec2d7eff62e4b097abbe14/lwr_vault.js +1 -1
- package/build/__generated_site_amd_modules__/1/resource/amd/lwr-error-shim.js/v/{0_13_0-alpha_0 → 0_13_0-alpha_2}/lwr-error-shim.js +1 -1
- package/build/__generated_site_amd_modules__/1/resource/amd/lwr-loader-shim.bundle.js/v/{0_13_0-alpha_0 → 0_13_0-alpha_2}/lwr-loader-shim.bundle.js +7 -7
- package/build/assets/amd/lwr-everywhere-debug.js +9 -9
- package/build/assets/amd/lwr-everywhere-min.js +2 -2
- package/build/assets/amd/lwr-everywhere.js +9 -9
- package/build/assets/core/lwr-everywhere-debug.js +5 -5
- package/build/assets/core/lwr-everywhere-min.js +1 -1
- package/build/assets/core/lwr-everywhere.js +5 -5
- package/build/assets/esm/lwr-everywhere-debug.js +1 -1
- package/build/assets/esm/lwr-everywhere-min.js +1 -1
- package/build/assets/esm/lwr-everywhere.js +1 -1
- package/package.json +9 -9
- package/build/__generated_site_amd_modules__/1/application/amd/l/en-US/ai/amd-bootstrap/configuration/ci/-/-/s/063276514e896851bb9af991a41a6bd4/config.js +0 -12
- package/build/__generated_site_amd_modules__/1/module/amd/1/l/en-US/mi/@lwrjs/app-service/amd-bootstrap/module/amd/v/0_13_0-alpha_0/s/8bce578258518655194bd71d1d72aad5/@lwrjs_app-service_amd-bootstrap_module_amd.js +0 -14
@@ -1,4 +1,4 @@
|
|
1
|
-
LWR.define('lwc/v/
|
1
|
+
LWR.define('lwc/v/6_6_1', ['exports'], (function (exports) { 'use strict';
|
2
2
|
|
3
3
|
/**
|
4
4
|
* Copyright (c) 2024 Salesforce, Inc.
|
@@ -148,6 +148,7 @@ LWR.define('lwc/v/6_3_4', ['exports'], (function (exports) { 'use strict';
|
|
148
148
|
} = String;
|
149
149
|
// No JSDocs here - see comment for Array.prototype
|
150
150
|
const {
|
151
|
+
charAt: StringCharAt,
|
151
152
|
charCodeAt: StringCharCodeAt,
|
152
153
|
replace: StringReplace,
|
153
154
|
split: StringSplit,
|
@@ -291,7 +292,8 @@ LWR.define('lwc/v/6_3_4', ['exports'], (function (exports) { 'use strict';
|
|
291
292
|
// These must be updated when the enum is updated.
|
292
293
|
// It's a bit annoying to do have to do this manually, but this makes the file tree-shakeable,
|
293
294
|
// passing the `verify-treeshakeable.js` test.
|
294
|
-
const
|
295
|
+
const allVersions = [58 /* APIVersion.V58_244_SUMMER_23 */, 59 /* APIVersion.V59_246_WINTER_24 */, 60 /* APIVersion.V60_248_SPRING_24 */, 61 /* APIVersion.V61_250_SUMMER_24 */, 62 /* APIVersion.V62_252_WINTER_25 */];
|
296
|
+
const LOWEST_API_VERSION = allVersions[0];
|
295
297
|
/**
|
296
298
|
*
|
297
299
|
* @param apiVersionFeature
|
@@ -440,9 +442,9 @@ LWR.define('lwc/v/6_3_4', ['exports'], (function (exports) { 'use strict';
|
|
440
442
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
441
443
|
*/
|
442
444
|
// Increment whenever the LWC template compiler changes
|
443
|
-
const LWC_VERSION = "6.
|
445
|
+
const LWC_VERSION = "6.6.1";
|
444
446
|
const LWC_VERSION_COMMENT_REGEX = /\/\*LWC compiler v([\d.]+)\*\/\s*}/;
|
445
|
-
/** version: 6.
|
447
|
+
/** version: 6.6.1 */
|
446
448
|
|
447
449
|
/**
|
448
450
|
* Copyright (c) 2024 Salesforce, Inc.
|
@@ -528,7 +530,7 @@ LWR.define('lwc/v/6_3_4', ['exports'], (function (exports) { 'use strict';
|
|
528
530
|
setFeatureFlag(name, value);
|
529
531
|
}
|
530
532
|
}
|
531
|
-
/** version: 6.
|
533
|
+
/** version: 6.6.1 */
|
532
534
|
|
533
535
|
/**
|
534
536
|
* Copyright (c) 2024 Salesforce, Inc.
|
@@ -783,15 +785,17 @@ LWR.define('lwc/v/6_3_4', ['exports'], (function (exports) { 'use strict';
|
|
783
785
|
if (len > 0) {
|
784
786
|
for (let i = 0; i < len; i++) {
|
785
787
|
const set = listeners[i];
|
786
|
-
|
787
|
-
|
788
|
-
|
789
|
-
|
790
|
-
|
791
|
-
//
|
792
|
-
const
|
793
|
-
|
788
|
+
const setLength = set.length;
|
789
|
+
// The length is usually 1, so avoid doing an indexOf when we know for certain
|
790
|
+
// that `this` is the first item in the array.
|
791
|
+
if (setLength > 1) {
|
792
|
+
// Swap with the last item before removal.
|
793
|
+
// (Avoiding splice here is a perf optimization, and the order doesn't matter.)
|
794
|
+
const index = ArrayIndexOf.call(set, this);
|
795
|
+
set[index] = set[setLength - 1];
|
794
796
|
}
|
797
|
+
// Remove the last item
|
798
|
+
ArrayPop.call(set);
|
795
799
|
}
|
796
800
|
listeners.length = 0;
|
797
801
|
}
|
@@ -1718,7 +1722,7 @@ LWR.define('lwc/v/6_3_4', ['exports'], (function (exports) { 'use strict';
|
|
1718
1722
|
valueMutated(originalTarget, key);
|
1719
1723
|
return true;
|
1720
1724
|
}
|
1721
|
-
/*LWC compiler v6.
|
1725
|
+
/*LWC compiler v6.6.1*/
|
1722
1726
|
}
|
1723
1727
|
const getterMap = new WeakMap();
|
1724
1728
|
const setterMap = new WeakMap();
|
@@ -1811,7 +1815,7 @@ LWR.define('lwc/v/6_3_4', ['exports'], (function (exports) { 'use strict';
|
|
1811
1815
|
/* istanbul ignore next */
|
1812
1816
|
return false;
|
1813
1817
|
}
|
1814
|
-
/*LWC compiler v6.
|
1818
|
+
/*LWC compiler v6.6.1*/
|
1815
1819
|
}
|
1816
1820
|
function extract(objectOrArray) {
|
1817
1821
|
if (isArray(objectOrArray)) {
|
@@ -2739,7 +2743,7 @@ LWR.define('lwc/v/6_3_4', ['exports'], (function (exports) { 'use strict';
|
|
2739
2743
|
}
|
2740
2744
|
|
2741
2745
|
/*
|
2742
|
-
* Copyright (c)
|
2746
|
+
* Copyright (c) 2024, Salesforce, Inc.
|
2743
2747
|
* All rights reserved.
|
2744
2748
|
* SPDX-License-Identifier: MIT
|
2745
2749
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
@@ -3428,7 +3432,7 @@ LWR.define('lwc/v/6_3_4', ['exports'], (function (exports) { 'use strict';
|
|
3428
3432
|
}
|
3429
3433
|
|
3430
3434
|
/*
|
3431
|
-
* Copyright (c)
|
3435
|
+
* Copyright (c) 2024, Salesforce, Inc.
|
3432
3436
|
* All rights reserved.
|
3433
3437
|
* SPDX-License-Identifier: MIT
|
3434
3438
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
@@ -3518,7 +3522,7 @@ LWR.define('lwc/v/6_3_4', ['exports'], (function (exports) { 'use strict';
|
|
3518
3522
|
}
|
3519
3523
|
function HTMLBridgeElementFactory(SuperClass, publicProperties, methods, observedFields, proto, hasCustomSuperClass) {
|
3520
3524
|
const HTMLBridgeElement = class extends SuperClass {
|
3521
|
-
/*LWC compiler v6.
|
3525
|
+
/*LWC compiler v6.6.1*/
|
3522
3526
|
};
|
3523
3527
|
// generating the hash table for attributes to avoid duplicate fields and facilitate validation
|
3524
3528
|
// and false positives in case of inheritance.
|
@@ -3630,125 +3634,448 @@ LWR.define('lwc/v/6_3_4', ['exports'], (function (exports) { 'use strict';
|
|
3630
3634
|
seal(BaseBridgeElement.prototype);
|
3631
3635
|
|
3632
3636
|
/*
|
3633
|
-
* Copyright (c)
|
3637
|
+
* Copyright (c) 2018, salesforce.com, inc.
|
3634
3638
|
* All rights reserved.
|
3635
3639
|
* SPDX-License-Identifier: MIT
|
3636
3640
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
3637
3641
|
*/
|
3638
|
-
|
3639
|
-
//
|
3640
|
-
|
3641
|
-
|
3642
|
-
|
3642
|
+
// These are only used for HMR in dev mode
|
3643
|
+
// The "pure" annotations are so that Rollup knows for sure it can remove these from prod mode
|
3644
|
+
let stylesheetsToCssContent = /*@__PURE__@*/new WeakMap();
|
3645
|
+
let cssContentToAbortControllers = /*@__PURE__@*/new Map();
|
3646
|
+
// Only used in LWC's Karma tests
|
3647
|
+
if (process.env.NODE_ENV === 'test-karma-lwc') {
|
3648
|
+
// Used to reset the global state between test runs
|
3649
|
+
window.__lwcResetStylesheetCache = () => {
|
3650
|
+
stylesheetsToCssContent = new WeakMap();
|
3651
|
+
cssContentToAbortControllers = new Map();
|
3652
|
+
};
|
3653
|
+
}
|
3654
|
+
function linkStylesheetToCssContentInDevMode(stylesheet, cssContent) {
|
3655
|
+
// Should never leak to prod; only used for HMR
|
3656
|
+
assertNotProd();
|
3657
|
+
let cssContents = stylesheetsToCssContent.get(stylesheet);
|
3658
|
+
if (isUndefined$1(cssContents)) {
|
3659
|
+
cssContents = new Set();
|
3660
|
+
stylesheetsToCssContent.set(stylesheet, cssContents);
|
3643
3661
|
}
|
3644
|
-
|
3645
|
-
|
3646
|
-
|
3647
|
-
|
3648
|
-
|
3662
|
+
cssContents.add(cssContent);
|
3663
|
+
}
|
3664
|
+
function getOrCreateAbortControllerInDevMode(cssContent) {
|
3665
|
+
// Should never leak to prod; only used for HMR
|
3666
|
+
assertNotProd();
|
3667
|
+
let abortController = cssContentToAbortControllers.get(cssContent);
|
3668
|
+
if (isUndefined$1(abortController)) {
|
3669
|
+
abortController = new AbortController();
|
3670
|
+
cssContentToAbortControllers.set(cssContent, abortController);
|
3671
|
+
}
|
3672
|
+
return abortController;
|
3673
|
+
}
|
3674
|
+
function getOrCreateAbortSignal(cssContent) {
|
3675
|
+
// abort controller/signal is only used for HMR in development
|
3676
|
+
if (process.env.NODE_ENV !== 'production') {
|
3677
|
+
return getOrCreateAbortControllerInDevMode(cssContent).signal;
|
3678
|
+
}
|
3679
|
+
return undefined;
|
3680
|
+
}
|
3681
|
+
function makeHostToken(token) {
|
3682
|
+
// Note: if this ever changes, update the `cssScopeTokens` returned by `@lwc/compiler`
|
3683
|
+
return `${token}-host`;
|
3684
|
+
}
|
3685
|
+
function createInlineStyleVNode(content) {
|
3686
|
+
return api.h('style', {
|
3687
|
+
key: 'style',
|
3688
|
+
// special key
|
3689
|
+
attrs: {
|
3690
|
+
type: 'text/css'
|
3649
3691
|
}
|
3650
|
-
|
3692
|
+
}, [api.t(content)]);
|
3693
|
+
}
|
3694
|
+
// TODO [#3733]: remove support for legacy scope tokens
|
3695
|
+
function updateStylesheetToken(vm, template, legacy) {
|
3696
|
+
const {
|
3697
|
+
elm,
|
3698
|
+
context,
|
3699
|
+
renderMode,
|
3700
|
+
shadowMode,
|
3701
|
+
renderer: {
|
3702
|
+
getClassList,
|
3703
|
+
removeAttribute,
|
3704
|
+
setAttribute
|
3705
|
+
}
|
3706
|
+
} = vm;
|
3707
|
+
const {
|
3708
|
+
stylesheets: newStylesheets
|
3709
|
+
} = template;
|
3710
|
+
const newStylesheetToken = legacy ? template.legacyStylesheetToken : template.stylesheetToken;
|
3711
|
+
const {
|
3712
|
+
stylesheets: newVmStylesheets
|
3713
|
+
} = vm;
|
3714
|
+
const isSyntheticShadow = renderMode === 1 /* RenderMode.Shadow */ && shadowMode === 1 /* ShadowMode.Synthetic */;
|
3715
|
+
const {
|
3716
|
+
hasScopedStyles
|
3717
|
+
} = context;
|
3718
|
+
let newToken;
|
3719
|
+
let newHasTokenInClass;
|
3720
|
+
let newHasTokenInAttribute;
|
3721
|
+
// Reset the styling token applied to the host element.
|
3722
|
+
let oldToken;
|
3723
|
+
let oldHasTokenInClass;
|
3724
|
+
let oldHasTokenInAttribute;
|
3725
|
+
if (legacy) {
|
3726
|
+
oldToken = context.legacyStylesheetToken;
|
3727
|
+
oldHasTokenInClass = context.hasLegacyTokenInClass;
|
3728
|
+
oldHasTokenInAttribute = context.hasLegacyTokenInAttribute;
|
3729
|
+
} else {
|
3730
|
+
oldToken = context.stylesheetToken;
|
3731
|
+
oldHasTokenInClass = context.hasTokenInClass;
|
3732
|
+
oldHasTokenInAttribute = context.hasTokenInAttribute;
|
3651
3733
|
}
|
3652
|
-
|
3653
|
-
|
3734
|
+
if (!isUndefined$1(oldToken)) {
|
3735
|
+
if (oldHasTokenInClass) {
|
3736
|
+
getClassList(elm).remove(makeHostToken(oldToken));
|
3737
|
+
}
|
3738
|
+
if (oldHasTokenInAttribute) {
|
3739
|
+
removeAttribute(elm, makeHostToken(oldToken));
|
3740
|
+
}
|
3654
3741
|
}
|
3655
|
-
|
3656
|
-
|
3657
|
-
|
3742
|
+
// Apply the new template styling token to the host element, if the new template has any
|
3743
|
+
// associated stylesheets. In the case of light DOM, also ensure there is at least one scoped stylesheet.
|
3744
|
+
const hasNewStylesheets = hasStyles(newStylesheets);
|
3745
|
+
const hasNewVmStylesheets = hasStyles(newVmStylesheets);
|
3746
|
+
if (hasNewStylesheets || hasNewVmStylesheets) {
|
3747
|
+
newToken = newStylesheetToken;
|
3658
3748
|
}
|
3659
|
-
|
3660
|
-
|
3749
|
+
// Set the new styling token on the host element
|
3750
|
+
if (!isUndefined$1(newToken)) {
|
3751
|
+
if (hasScopedStyles) {
|
3752
|
+
getClassList(elm).add(makeHostToken(newToken));
|
3753
|
+
newHasTokenInClass = true;
|
3754
|
+
}
|
3755
|
+
if (isSyntheticShadow) {
|
3756
|
+
setAttribute(elm, makeHostToken(newToken), '');
|
3757
|
+
newHasTokenInAttribute = true;
|
3758
|
+
}
|
3759
|
+
}
|
3760
|
+
// Update the styling tokens present on the context object.
|
3761
|
+
if (legacy) {
|
3762
|
+
context.legacyStylesheetToken = newToken;
|
3763
|
+
context.hasLegacyTokenInClass = newHasTokenInClass;
|
3764
|
+
context.hasLegacyTokenInAttribute = newHasTokenInAttribute;
|
3765
|
+
} else {
|
3766
|
+
context.stylesheetToken = newToken;
|
3767
|
+
context.hasTokenInClass = newHasTokenInClass;
|
3768
|
+
context.hasTokenInAttribute = newHasTokenInAttribute;
|
3661
3769
|
}
|
3662
3770
|
}
|
3663
|
-
|
3664
|
-
|
3665
|
-
|
3666
|
-
|
3667
|
-
|
3668
|
-
|
3669
|
-
|
3670
|
-
|
3671
|
-
|
3672
|
-
|
3673
|
-
|
3674
|
-
|
3675
|
-
|
3771
|
+
function evaluateStylesheetsContent(stylesheets, stylesheetToken, vm) {
|
3772
|
+
const content = [];
|
3773
|
+
let root;
|
3774
|
+
for (let i = 0; i < stylesheets.length; i++) {
|
3775
|
+
let stylesheet = stylesheets[i];
|
3776
|
+
if (isArray$1(stylesheet)) {
|
3777
|
+
ArrayPush$1.apply(content, evaluateStylesheetsContent(stylesheet, stylesheetToken, vm));
|
3778
|
+
} else {
|
3779
|
+
if (process.env.NODE_ENV !== 'production') {
|
3780
|
+
// Check for compiler version mismatch in dev mode only
|
3781
|
+
checkVersionMismatch(stylesheet, 'stylesheet');
|
3782
|
+
// in dev-mode, we support hot swapping of stylesheet, which means that
|
3783
|
+
// the component instance might be attempting to use an old version of
|
3784
|
+
// the stylesheet, while internally, we have a replacement for it.
|
3785
|
+
stylesheet = getStyleOrSwappedStyle(stylesheet);
|
3786
|
+
}
|
3787
|
+
const isScopedCss = stylesheet[KEY__SCOPED_CSS];
|
3788
|
+
if (lwcRuntimeFlags.DISABLE_LIGHT_DOM_UNSCOPED_CSS && !isScopedCss && vm.renderMode === 0 /* RenderMode.Light */) {
|
3789
|
+
logError('Unscoped CSS is not supported in Light DOM in this environment. Please use scoped CSS ' + '(*.scoped.css) instead of unscoped CSS (*.css). See also: https://sfdc.co/scoped-styles-light-dom');
|
3790
|
+
continue;
|
3791
|
+
}
|
3792
|
+
// Apply the scope token only if the stylesheet itself is scoped, or if we're rendering synthetic shadow.
|
3793
|
+
const scopeToken = isScopedCss || vm.shadowMode === 1 /* ShadowMode.Synthetic */ && vm.renderMode === 1 /* RenderMode.Shadow */ ? stylesheetToken : undefined;
|
3794
|
+
// Use the actual `:host` selector if we're rendering global CSS for light DOM, or if we're rendering
|
3795
|
+
// native shadow DOM. Synthetic shadow DOM never uses `:host`.
|
3796
|
+
const useActualHostSelector = vm.renderMode === 0 /* RenderMode.Light */ ? !isScopedCss : vm.shadowMode === 0 /* ShadowMode.Native */;
|
3797
|
+
// Use the native :dir() pseudoclass only in native shadow DOM. Otherwise, in synthetic shadow,
|
3798
|
+
// we use an attribute selector on the host to simulate :dir().
|
3799
|
+
let useNativeDirPseudoclass;
|
3800
|
+
if (vm.renderMode === 1 /* RenderMode.Shadow */) {
|
3801
|
+
useNativeDirPseudoclass = vm.shadowMode === 0 /* ShadowMode.Native */;
|
3802
|
+
} else {
|
3803
|
+
// Light DOM components should only render `[dir]` if they're inside of a synthetic shadow root.
|
3804
|
+
// At the top level (root is null) or inside of a native shadow root, they should use `:dir()`.
|
3805
|
+
if (isUndefined$1(root)) {
|
3806
|
+
// Only calculate the root once as necessary
|
3807
|
+
root = getNearestShadowComponent(vm);
|
3676
3808
|
}
|
3809
|
+
useNativeDirPseudoclass = isNull(root) || root.shadowMode === 0 /* ShadowMode.Native */;
|
3677
3810
|
}
|
3678
|
-
|
3679
|
-
|
3680
|
-
|
3681
|
-
let weakRefs = this._map.get(key);
|
3682
|
-
if (isUndefined$1(weakRefs)) {
|
3683
|
-
weakRefs = [];
|
3684
|
-
this._map.set(key, weakRefs);
|
3685
|
-
}
|
3686
|
-
return weakRefs;
|
3687
|
-
}
|
3688
|
-
get(key) {
|
3689
|
-
const weakRefs = this._getWeakRefs(key);
|
3690
|
-
const result = new Set();
|
3691
|
-
for (const weakRef of weakRefs) {
|
3692
|
-
const vm = weakRef.deref();
|
3693
|
-
if (!isUndefined$1(vm)) {
|
3694
|
-
result.add(vm);
|
3811
|
+
const cssContent = stylesheet(scopeToken, useActualHostSelector, useNativeDirPseudoclass);
|
3812
|
+
if (process.env.NODE_ENV !== 'production') {
|
3813
|
+
linkStylesheetToCssContentInDevMode(stylesheet, cssContent);
|
3695
3814
|
}
|
3815
|
+
ArrayPush$1.call(content, cssContent);
|
3696
3816
|
}
|
3697
|
-
return result;
|
3698
3817
|
}
|
3699
|
-
|
3700
|
-
|
3701
|
-
|
3702
|
-
|
3703
|
-
|
3704
|
-
|
3705
|
-
|
3706
|
-
|
3707
|
-
|
3708
|
-
|
3709
|
-
|
3710
|
-
|
3711
|
-
|
3818
|
+
return content;
|
3819
|
+
}
|
3820
|
+
function getStylesheetsContent(vm, template) {
|
3821
|
+
const {
|
3822
|
+
stylesheets,
|
3823
|
+
stylesheetToken
|
3824
|
+
} = template;
|
3825
|
+
const {
|
3826
|
+
stylesheets: vmStylesheets
|
3827
|
+
} = vm;
|
3828
|
+
let content = [];
|
3829
|
+
if (hasStyles(stylesheets)) {
|
3830
|
+
content = evaluateStylesheetsContent(stylesheets, stylesheetToken, vm);
|
3712
3831
|
}
|
3713
|
-
|
3714
|
-
|
3832
|
+
// VM (component) stylesheets apply after template stylesheets
|
3833
|
+
if (hasStyles(vmStylesheets)) {
|
3834
|
+
ArrayPush$1.apply(content, evaluateStylesheetsContent(vmStylesheets, stylesheetToken, vm));
|
3715
3835
|
}
|
3836
|
+
return content;
|
3716
3837
|
}
|
3717
|
-
|
3718
|
-
|
3719
|
-
|
3720
|
-
|
3721
|
-
|
3722
|
-
|
3723
|
-
|
3724
|
-
|
3725
|
-
const swappedTemplateMap = new WeakMap();
|
3726
|
-
const swappedComponentMap = new WeakMap();
|
3727
|
-
const swappedStyleMap = new WeakMap();
|
3728
|
-
// The important thing here is the weak values – VMs are transient (one per component instance) and should be GC'ed,
|
3729
|
-
// so we don't want to create strong references to them.
|
3730
|
-
// The weak keys are kind of useless, because Templates, LightningElementConstructors, and StylesheetFactories are
|
3731
|
-
// never GC'ed. But maybe they will be someday, so we may as well use weak keys too.
|
3732
|
-
const activeTemplates = new WeakMultiMap();
|
3733
|
-
const activeComponents = new WeakMultiMap();
|
3734
|
-
const activeStyles = new WeakMultiMap();
|
3735
|
-
function rehydrateHotTemplate(tpl) {
|
3736
|
-
const list = activeTemplates.get(tpl);
|
3737
|
-
for (const vm of list) {
|
3738
|
-
if (isFalse(vm.isDirty)) {
|
3739
|
-
// forcing the vm to rehydrate in the micro-task:
|
3740
|
-
markComponentAsDirty(vm);
|
3741
|
-
scheduleRehydration(vm);
|
3838
|
+
// It might be worth caching this to avoid doing the lookup repeatedly, but
|
3839
|
+
// perf testing has not shown it to be a huge improvement yet:
|
3840
|
+
// https://github.com/salesforce/lwc/pull/2460#discussion_r691208892
|
3841
|
+
function getNearestShadowComponent(vm) {
|
3842
|
+
let owner = vm;
|
3843
|
+
while (!isNull(owner)) {
|
3844
|
+
if (owner.renderMode === 1 /* RenderMode.Shadow */) {
|
3845
|
+
return owner;
|
3742
3846
|
}
|
3847
|
+
owner = owner.owner;
|
3743
3848
|
}
|
3744
|
-
|
3745
|
-
// they will get re-associated once these instances are rehydrated.
|
3746
|
-
activeTemplates.delete(tpl);
|
3747
|
-
return true;
|
3849
|
+
return owner;
|
3748
3850
|
}
|
3749
|
-
|
3750
|
-
|
3751
|
-
|
3851
|
+
/**
|
3852
|
+
* If the component that is currently being rendered uses scoped styles,
|
3853
|
+
* this returns the unique token for that scoped stylesheet. Otherwise
|
3854
|
+
* it returns null.
|
3855
|
+
* @param owner
|
3856
|
+
* @param legacy
|
3857
|
+
*/
|
3858
|
+
// TODO [#3733]: remove support for legacy scope tokens
|
3859
|
+
function getScopeTokenClass(owner, legacy) {
|
3860
|
+
const {
|
3861
|
+
cmpTemplate,
|
3862
|
+
context
|
3863
|
+
} = owner;
|
3864
|
+
return context.hasScopedStyles && (legacy ? cmpTemplate?.legacyStylesheetToken : cmpTemplate?.stylesheetToken) || null;
|
3865
|
+
}
|
3866
|
+
/**
|
3867
|
+
* This function returns the host style token for a custom element if it
|
3868
|
+
* exists. Otherwise it returns null.
|
3869
|
+
*
|
3870
|
+
* A host style token is applied to the component if scoped styles are used.
|
3871
|
+
* @param vnode
|
3872
|
+
*/
|
3873
|
+
function getStylesheetTokenHost(vnode) {
|
3874
|
+
const {
|
3875
|
+
template
|
3876
|
+
} = getComponentInternalDef(vnode.ctor);
|
3877
|
+
const {
|
3878
|
+
vm
|
3879
|
+
} = vnode;
|
3880
|
+
const {
|
3881
|
+
stylesheetToken
|
3882
|
+
} = template;
|
3883
|
+
return !isUndefined$1(stylesheetToken) && computeHasScopedStyles(template, vm) ? makeHostToken(stylesheetToken) : null;
|
3884
|
+
}
|
3885
|
+
function getNearestNativeShadowComponent(vm) {
|
3886
|
+
const owner = getNearestShadowComponent(vm);
|
3887
|
+
if (!isNull(owner) && owner.shadowMode === 1 /* ShadowMode.Synthetic */) {
|
3888
|
+
// Synthetic-within-native is impossible. So if the nearest shadow component is
|
3889
|
+
// synthetic, we know we won't find a native component if we go any further.
|
3890
|
+
return null;
|
3891
|
+
}
|
3892
|
+
return owner;
|
3893
|
+
}
|
3894
|
+
function createStylesheet(vm, stylesheets) {
|
3895
|
+
const {
|
3896
|
+
renderMode,
|
3897
|
+
shadowMode,
|
3898
|
+
renderer: {
|
3899
|
+
insertStylesheet
|
3900
|
+
}
|
3901
|
+
} = vm;
|
3902
|
+
if (renderMode === 1 /* RenderMode.Shadow */ && shadowMode === 1 /* ShadowMode.Synthetic */) {
|
3903
|
+
for (let i = 0; i < stylesheets.length; i++) {
|
3904
|
+
const stylesheet = stylesheets[i];
|
3905
|
+
insertStylesheet(stylesheet, undefined, getOrCreateAbortSignal(stylesheet));
|
3906
|
+
}
|
3907
|
+
} else if (vm.hydrated) {
|
3908
|
+
// Note: We need to ensure that during hydration, the stylesheets method is the same as those in ssr.
|
3909
|
+
// This works in the client, because the stylesheets are created, and cached in the VM
|
3910
|
+
// the first time the VM renders.
|
3911
|
+
// native shadow or light DOM, SSR
|
3912
|
+
return ArrayMap.call(stylesheets, createInlineStyleVNode);
|
3913
|
+
} else {
|
3914
|
+
// native shadow or light DOM, DOM renderer
|
3915
|
+
const root = getNearestNativeShadowComponent(vm);
|
3916
|
+
// null root means a global style
|
3917
|
+
const target = isNull(root) ? undefined : root.shadowRoot;
|
3918
|
+
for (let i = 0; i < stylesheets.length; i++) {
|
3919
|
+
const stylesheet = stylesheets[i];
|
3920
|
+
insertStylesheet(stylesheet, target, getOrCreateAbortSignal(stylesheet));
|
3921
|
+
}
|
3922
|
+
}
|
3923
|
+
return null;
|
3924
|
+
}
|
3925
|
+
function unrenderStylesheet(stylesheet) {
|
3926
|
+
// should never leak to prod; only used for HMR
|
3927
|
+
assertNotProd();
|
3928
|
+
const cssContents = stylesheetsToCssContent.get(stylesheet);
|
3929
|
+
/* istanbul ignore if */
|
3930
|
+
if (isUndefined$1(cssContents)) {
|
3931
|
+
throw new Error('Cannot unrender stylesheet which was never rendered');
|
3932
|
+
}
|
3933
|
+
for (const cssContent of cssContents) {
|
3934
|
+
const abortController = cssContentToAbortControllers.get(cssContent);
|
3935
|
+
/* istanbul ignore if */
|
3936
|
+
if (isUndefined$1(abortController)) {
|
3937
|
+
throw new Error('Cannot find AbortController for CSS content');
|
3938
|
+
}
|
3939
|
+
abortController.abort();
|
3940
|
+
// remove association with AbortController in case stylesheet is rendered again
|
3941
|
+
cssContentToAbortControllers.delete(cssContent);
|
3942
|
+
}
|
3943
|
+
}
|
3944
|
+
|
3945
|
+
/*
|
3946
|
+
* Copyright (c) 2023, salesforce.com, inc.
|
3947
|
+
* All rights reserved.
|
3948
|
+
* SPDX-License-Identifier: MIT
|
3949
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
3950
|
+
*/
|
3951
|
+
const supportsWeakRefs = typeof WeakRef === 'function' && typeof FinalizationRegistry === 'function';
|
3952
|
+
// In browsers that doesn't support WeakRefs, the values will still leak, but at least the keys won't
|
3953
|
+
class LegacyWeakMultiMap {
|
3954
|
+
constructor() {
|
3955
|
+
this._map = new WeakMap();
|
3956
|
+
}
|
3957
|
+
_getValues(key) {
|
3958
|
+
let values = this._map.get(key);
|
3959
|
+
if (isUndefined$1(values)) {
|
3960
|
+
values = new Set();
|
3961
|
+
this._map.set(key, values);
|
3962
|
+
}
|
3963
|
+
return values;
|
3964
|
+
}
|
3965
|
+
get(key) {
|
3966
|
+
return this._getValues(key);
|
3967
|
+
}
|
3968
|
+
add(key, vm) {
|
3969
|
+
const set = this._getValues(key);
|
3970
|
+
set.add(vm);
|
3971
|
+
}
|
3972
|
+
delete(key) {
|
3973
|
+
this._map.delete(key);
|
3974
|
+
}
|
3975
|
+
}
|
3976
|
+
// This implementation relies on the WeakRef/FinalizationRegistry proposal.
|
3977
|
+
// For some background, see: https://github.com/tc39/proposal-weakrefs
|
3978
|
+
class ModernWeakMultiMap {
|
3979
|
+
constructor() {
|
3980
|
+
this._map = new WeakMap();
|
3981
|
+
this._registry = new FinalizationRegistry(weakRefs => {
|
3982
|
+
// This should be considered an optional cleanup method to remove GC'ed values from their respective arrays.
|
3983
|
+
// JS VMs are not obligated to call FinalizationRegistry callbacks.
|
3984
|
+
// Work backwards, removing stale VMs
|
3985
|
+
for (let i = weakRefs.length - 1; i >= 0; i--) {
|
3986
|
+
const vm = weakRefs[i].deref();
|
3987
|
+
if (isUndefined$1(vm)) {
|
3988
|
+
ArraySplice.call(weakRefs, i, 1); // remove
|
3989
|
+
}
|
3990
|
+
}
|
3991
|
+
});
|
3992
|
+
}
|
3993
|
+
_getWeakRefs(key) {
|
3994
|
+
let weakRefs = this._map.get(key);
|
3995
|
+
if (isUndefined$1(weakRefs)) {
|
3996
|
+
weakRefs = [];
|
3997
|
+
this._map.set(key, weakRefs);
|
3998
|
+
}
|
3999
|
+
return weakRefs;
|
4000
|
+
}
|
4001
|
+
get(key) {
|
4002
|
+
const weakRefs = this._getWeakRefs(key);
|
4003
|
+
const result = new Set();
|
4004
|
+
for (const weakRef of weakRefs) {
|
4005
|
+
const vm = weakRef.deref();
|
4006
|
+
if (!isUndefined$1(vm)) {
|
4007
|
+
result.add(vm);
|
4008
|
+
}
|
4009
|
+
}
|
4010
|
+
return result;
|
4011
|
+
}
|
4012
|
+
add(key, value) {
|
4013
|
+
const weakRefs = this._getWeakRefs(key);
|
4014
|
+
// We could check for duplicate values here, but it doesn't seem worth it.
|
4015
|
+
// We transform the output into a Set anyway
|
4016
|
+
ArrayPush$1.call(weakRefs, new WeakRef(value));
|
4017
|
+
// It's important here not to leak the second argument, which is the "held value." The FinalizationRegistry
|
4018
|
+
// effectively creates a strong reference between the first argument (the "target") and the held value. When
|
4019
|
+
// the target is GC'ed, the callback is called, and then the held value is GC'ed.
|
4020
|
+
// Putting the key here would mean the key is not GC'ed until the value is GC'ed, which defeats the purpose
|
4021
|
+
// of the WeakMap. Whereas putting the weakRefs array here is fine, because it doesn't have a strong reference
|
4022
|
+
// to anything. See also this example:
|
4023
|
+
// https://gist.github.com/nolanlawson/79a3d36e8e6cc25c5048bb17c1795aea
|
4024
|
+
this._registry.register(value, weakRefs);
|
4025
|
+
}
|
4026
|
+
delete(key) {
|
4027
|
+
this._map.delete(key);
|
4028
|
+
}
|
4029
|
+
}
|
4030
|
+
const WeakMultiMap = supportsWeakRefs ? ModernWeakMultiMap : LegacyWeakMultiMap;
|
4031
|
+
|
4032
|
+
/*
|
4033
|
+
* Copyright (c) 2020, salesforce.com, inc.
|
4034
|
+
* All rights reserved.
|
4035
|
+
* SPDX-License-Identifier: MIT
|
4036
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
4037
|
+
*/
|
4038
|
+
let swappedTemplateMap = /*@__PURE__@*/new WeakMap();
|
4039
|
+
let swappedComponentMap = /*@__PURE__@*/new WeakMap();
|
4040
|
+
let swappedStyleMap = /*@__PURE__@*/new WeakMap();
|
4041
|
+
// The important thing here is the weak values – VMs are transient (one per component instance) and should be GC'ed,
|
4042
|
+
// so we don't want to create strong references to them.
|
4043
|
+
// The weak keys are kind of useless, because Templates, LightningElementConstructors, and StylesheetFactories are
|
4044
|
+
// never GC'ed. But maybe they will be someday, so we may as well use weak keys too.
|
4045
|
+
// The "pure" annotations are so that Rollup knows for sure it can remove these from prod mode
|
4046
|
+
let activeTemplates = /*@__PURE__@*/new WeakMultiMap();
|
4047
|
+
let activeComponents = /*@__PURE__@*/new WeakMultiMap();
|
4048
|
+
let activeStyles = /*@__PURE__@*/new WeakMultiMap();
|
4049
|
+
// Only used in LWC's Karma tests
|
4050
|
+
if (process.env.NODE_ENV === 'test-karma-lwc') {
|
4051
|
+
// Used to reset the global state between test runs
|
4052
|
+
window.__lwcResetHotSwaps = () => {
|
4053
|
+
swappedTemplateMap = new WeakMap();
|
4054
|
+
swappedComponentMap = new WeakMap();
|
4055
|
+
swappedStyleMap = new WeakMap();
|
4056
|
+
activeTemplates = new WeakMultiMap();
|
4057
|
+
activeComponents = new WeakMultiMap();
|
4058
|
+
activeStyles = new WeakMultiMap();
|
4059
|
+
};
|
4060
|
+
}
|
4061
|
+
function rehydrateHotTemplate(tpl) {
|
4062
|
+
const list = activeTemplates.get(tpl);
|
4063
|
+
for (const vm of list) {
|
4064
|
+
if (isFalse(vm.isDirty)) {
|
4065
|
+
// forcing the vm to rehydrate in the micro-task:
|
4066
|
+
markComponentAsDirty(vm);
|
4067
|
+
scheduleRehydration(vm);
|
4068
|
+
}
|
4069
|
+
}
|
4070
|
+
// Resetting the Set since these VMs are no longer related to this template, instead
|
4071
|
+
// they will get re-associated once these instances are rehydrated.
|
4072
|
+
activeTemplates.delete(tpl);
|
4073
|
+
return true;
|
4074
|
+
}
|
4075
|
+
function rehydrateHotStyle(style) {
|
4076
|
+
const activeVMs = activeStyles.get(style);
|
4077
|
+
unrenderStylesheet(style);
|
4078
|
+
for (const vm of activeVMs) {
|
3752
4079
|
// if a style definition is swapped, we must reset
|
3753
4080
|
// vm's template content in the next micro-task:
|
3754
4081
|
forceRehydration(vm);
|
@@ -3786,6 +4113,7 @@ LWR.define('lwc/v/6_3_4', ['exports'], (function (exports) { 'use strict';
|
|
3786
4113
|
}
|
3787
4114
|
function getTemplateOrSwappedTemplate(tpl) {
|
3788
4115
|
assertNotProd(); // this method should never leak to prod
|
4116
|
+
// TODO [#4154]: shows stale content when swapping content back and forth multiple times
|
3789
4117
|
const visited = new Set();
|
3790
4118
|
while (swappedTemplateMap.has(tpl) && !visited.has(tpl)) {
|
3791
4119
|
visited.add(tpl);
|
@@ -3795,6 +4123,7 @@ LWR.define('lwc/v/6_3_4', ['exports'], (function (exports) { 'use strict';
|
|
3795
4123
|
}
|
3796
4124
|
function getComponentOrSwappedComponent(Ctor) {
|
3797
4125
|
assertNotProd(); // this method should never leak to prod
|
4126
|
+
// TODO [#4154]: shows stale content when swapping content back and forth multiple times
|
3798
4127
|
const visited = new Set();
|
3799
4128
|
while (swappedComponentMap.has(Ctor) && !visited.has(Ctor)) {
|
3800
4129
|
visited.add(Ctor);
|
@@ -3804,6 +4133,7 @@ LWR.define('lwc/v/6_3_4', ['exports'], (function (exports) { 'use strict';
|
|
3804
4133
|
}
|
3805
4134
|
function getStyleOrSwappedStyle(style) {
|
3806
4135
|
assertNotProd(); // this method should never leak to prod
|
4136
|
+
// TODO [#4154]: shows stale content when swapping content back and forth multiple times
|
3807
4137
|
const visited = new Set();
|
3808
4138
|
while (swappedStyleMap.has(style) && !visited.has(style)) {
|
3809
4139
|
visited.add(style);
|
@@ -3811,6 +4141,22 @@ LWR.define('lwc/v/6_3_4', ['exports'], (function (exports) { 'use strict';
|
|
3811
4141
|
}
|
3812
4142
|
return style;
|
3813
4143
|
}
|
4144
|
+
function addActiveStylesheets(stylesheets, vm) {
|
4145
|
+
if (isUndefined$1(stylesheets) || isNull(stylesheets)) {
|
4146
|
+
// Ignore non-existent stylesheets
|
4147
|
+
return;
|
4148
|
+
}
|
4149
|
+
for (const stylesheet of flattenStylesheets(stylesheets)) {
|
4150
|
+
// this is necessary because we don't hold the list of styles
|
4151
|
+
// in the vm, we only hold the selected (already swapped template)
|
4152
|
+
// but the styles attached to the template might not be the actual
|
4153
|
+
// active ones, but the swapped versions of those.
|
4154
|
+
const swappedStylesheet = getStyleOrSwappedStyle(stylesheet);
|
4155
|
+
// this will allow us to keep track of the stylesheet that are
|
4156
|
+
// being used by a hot component
|
4157
|
+
activeStyles.add(swappedStylesheet, vm);
|
4158
|
+
}
|
4159
|
+
}
|
3814
4160
|
function setActiveVM(vm) {
|
3815
4161
|
assertNotProd(); // this method should never leak to prod
|
3816
4162
|
// tracking active component
|
@@ -3818,25 +4164,15 @@ LWR.define('lwc/v/6_3_4', ['exports'], (function (exports) { 'use strict';
|
|
3818
4164
|
// this will allow us to keep track of the hot components
|
3819
4165
|
activeComponents.add(Ctor, vm);
|
3820
4166
|
// tracking active template
|
3821
|
-
const
|
3822
|
-
if (
|
4167
|
+
const template = vm.cmpTemplate;
|
4168
|
+
if (!isNull(template)) {
|
3823
4169
|
// this will allow us to keep track of the templates that are
|
3824
4170
|
// being used by a hot component
|
3825
|
-
activeTemplates.add(
|
3826
|
-
//
|
3827
|
-
|
3828
|
-
|
3829
|
-
|
3830
|
-
// this is necessary because we don't hold the list of styles
|
3831
|
-
// in the vm, we only hold the selected (already swapped template)
|
3832
|
-
// but the styles attached to the template might not be the actual
|
3833
|
-
// active ones, but the swapped versions of those.
|
3834
|
-
const swappedStylesheet = getStyleOrSwappedStyle(stylesheet);
|
3835
|
-
// this will allow us to keep track of the stylesheet that are
|
3836
|
-
// being used by a hot component
|
3837
|
-
activeStyles.add(swappedStylesheet, vm);
|
3838
|
-
}
|
3839
|
-
}
|
4171
|
+
activeTemplates.add(template, vm);
|
4172
|
+
// Tracking active styles from the template or the VM. `template.stylesheets` are implicitly associated
|
4173
|
+
// (e.g. `foo.css` associated with `foo.html`), whereas `vm.stylesheets` are from `static stylesheets`.
|
4174
|
+
addActiveStylesheets(template.stylesheets, vm);
|
4175
|
+
addActiveStylesheets(vm.stylesheets, vm);
|
3840
4176
|
}
|
3841
4177
|
}
|
3842
4178
|
function swapTemplate(oldTpl, newTpl) {
|
@@ -4107,284 +4443,39 @@ LWR.define('lwc/v/6_3_4', ['exports'], (function (exports) { 'use strict';
|
|
4107
4443
|
// for some external services, e.g.: Locker Service, usually, all they care
|
4108
4444
|
// is about the shape of the constructor, the internals of it are not relevant
|
4109
4445
|
// because they don't have a way to mess with that.
|
4110
|
-
const {
|
4111
|
-
ctor,
|
4112
|
-
name,
|
4113
|
-
props,
|
4114
|
-
propsConfig,
|
4115
|
-
methods
|
4116
|
-
} = def;
|
4117
|
-
const publicProps = {};
|
4118
|
-
for (const key in props) {
|
4119
|
-
// avoid leaking the reference to the public props descriptors
|
4120
|
-
publicProps[key] = {
|
4121
|
-
config: propsConfig[key] || 0,
|
4122
|
-
// a property by default
|
4123
|
-
type: "any" /* PropDefType.any */,
|
4124
|
-
// no type inference for public services
|
4125
|
-
attr: htmlPropertyToAttribute(key)
|
4126
|
-
};
|
4127
|
-
}
|
4128
|
-
const publicMethods = {};
|
4129
|
-
for (const key in methods) {
|
4130
|
-
// avoid leaking the reference to the public method descriptors
|
4131
|
-
publicMethods[key] = methods[key].value;
|
4132
|
-
}
|
4133
|
-
return {
|
4134
|
-
ctor,
|
4135
|
-
name,
|
4136
|
-
props: publicProps,
|
4137
|
-
methods: publicMethods
|
4138
|
-
};
|
4139
|
-
}
|
4140
|
-
|
4141
|
-
/*
|
4142
|
-
* Copyright (c) 2018, salesforce.com, inc.
|
4143
|
-
* All rights reserved.
|
4144
|
-
* SPDX-License-Identifier: MIT
|
4145
|
-
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
4146
|
-
*/
|
4147
|
-
function makeHostToken(token) {
|
4148
|
-
// Note: if this ever changes, update the `cssScopeTokens` returned by `@lwc/compiler`
|
4149
|
-
return `${token}-host`;
|
4150
|
-
}
|
4151
|
-
function createInlineStyleVNode(content) {
|
4152
|
-
return api.h('style', {
|
4153
|
-
key: 'style',
|
4154
|
-
// special key
|
4155
|
-
attrs: {
|
4156
|
-
type: 'text/css'
|
4157
|
-
}
|
4158
|
-
}, [api.t(content)]);
|
4159
|
-
}
|
4160
|
-
// TODO [#3733]: remove support for legacy scope tokens
|
4161
|
-
function updateStylesheetToken(vm, template, legacy) {
|
4162
|
-
const {
|
4163
|
-
elm,
|
4164
|
-
context,
|
4165
|
-
renderMode,
|
4166
|
-
shadowMode,
|
4167
|
-
renderer: {
|
4168
|
-
getClassList,
|
4169
|
-
removeAttribute,
|
4170
|
-
setAttribute
|
4171
|
-
}
|
4172
|
-
} = vm;
|
4173
|
-
const {
|
4174
|
-
stylesheets: newStylesheets
|
4175
|
-
} = template;
|
4176
|
-
const newStylesheetToken = legacy ? template.legacyStylesheetToken : template.stylesheetToken;
|
4177
|
-
const {
|
4178
|
-
stylesheets: newVmStylesheets
|
4179
|
-
} = vm;
|
4180
|
-
const isSyntheticShadow = renderMode === 1 /* RenderMode.Shadow */ && shadowMode === 1 /* ShadowMode.Synthetic */;
|
4181
|
-
const {
|
4182
|
-
hasScopedStyles
|
4183
|
-
} = context;
|
4184
|
-
let newToken;
|
4185
|
-
let newHasTokenInClass;
|
4186
|
-
let newHasTokenInAttribute;
|
4187
|
-
// Reset the styling token applied to the host element.
|
4188
|
-
let oldToken;
|
4189
|
-
let oldHasTokenInClass;
|
4190
|
-
let oldHasTokenInAttribute;
|
4191
|
-
if (legacy) {
|
4192
|
-
oldToken = context.legacyStylesheetToken;
|
4193
|
-
oldHasTokenInClass = context.hasLegacyTokenInClass;
|
4194
|
-
oldHasTokenInAttribute = context.hasLegacyTokenInAttribute;
|
4195
|
-
} else {
|
4196
|
-
oldToken = context.stylesheetToken;
|
4197
|
-
oldHasTokenInClass = context.hasTokenInClass;
|
4198
|
-
oldHasTokenInAttribute = context.hasTokenInAttribute;
|
4199
|
-
}
|
4200
|
-
if (!isUndefined$1(oldToken)) {
|
4201
|
-
if (oldHasTokenInClass) {
|
4202
|
-
getClassList(elm).remove(makeHostToken(oldToken));
|
4203
|
-
}
|
4204
|
-
if (oldHasTokenInAttribute) {
|
4205
|
-
removeAttribute(elm, makeHostToken(oldToken));
|
4206
|
-
}
|
4207
|
-
}
|
4208
|
-
// Apply the new template styling token to the host element, if the new template has any
|
4209
|
-
// associated stylesheets. In the case of light DOM, also ensure there is at least one scoped stylesheet.
|
4210
|
-
const hasNewStylesheets = hasStyles(newStylesheets);
|
4211
|
-
const hasNewVmStylesheets = hasStyles(newVmStylesheets);
|
4212
|
-
if (hasNewStylesheets || hasNewVmStylesheets) {
|
4213
|
-
newToken = newStylesheetToken;
|
4214
|
-
}
|
4215
|
-
// Set the new styling token on the host element
|
4216
|
-
if (!isUndefined$1(newToken)) {
|
4217
|
-
if (hasScopedStyles) {
|
4218
|
-
getClassList(elm).add(makeHostToken(newToken));
|
4219
|
-
newHasTokenInClass = true;
|
4220
|
-
}
|
4221
|
-
if (isSyntheticShadow) {
|
4222
|
-
setAttribute(elm, makeHostToken(newToken), '');
|
4223
|
-
newHasTokenInAttribute = true;
|
4224
|
-
}
|
4225
|
-
}
|
4226
|
-
// Update the styling tokens present on the context object.
|
4227
|
-
if (legacy) {
|
4228
|
-
context.legacyStylesheetToken = newToken;
|
4229
|
-
context.hasLegacyTokenInClass = newHasTokenInClass;
|
4230
|
-
context.hasLegacyTokenInAttribute = newHasTokenInAttribute;
|
4231
|
-
} else {
|
4232
|
-
context.stylesheetToken = newToken;
|
4233
|
-
context.hasTokenInClass = newHasTokenInClass;
|
4234
|
-
context.hasTokenInAttribute = newHasTokenInAttribute;
|
4235
|
-
}
|
4236
|
-
}
|
4237
|
-
function evaluateStylesheetsContent(stylesheets, stylesheetToken, vm) {
|
4238
|
-
const content = [];
|
4239
|
-
let root;
|
4240
|
-
for (let i = 0; i < stylesheets.length; i++) {
|
4241
|
-
let stylesheet = stylesheets[i];
|
4242
|
-
if (isArray$1(stylesheet)) {
|
4243
|
-
ArrayPush$1.apply(content, evaluateStylesheetsContent(stylesheet, stylesheetToken, vm));
|
4244
|
-
} else {
|
4245
|
-
if (process.env.NODE_ENV !== 'production') {
|
4246
|
-
// Check for compiler version mismatch in dev mode only
|
4247
|
-
checkVersionMismatch(stylesheet, 'stylesheet');
|
4248
|
-
// in dev-mode, we support hot swapping of stylesheet, which means that
|
4249
|
-
// the component instance might be attempting to use an old version of
|
4250
|
-
// the stylesheet, while internally, we have a replacement for it.
|
4251
|
-
stylesheet = getStyleOrSwappedStyle(stylesheet);
|
4252
|
-
}
|
4253
|
-
const isScopedCss = stylesheet[KEY__SCOPED_CSS];
|
4254
|
-
if (lwcRuntimeFlags.DISABLE_LIGHT_DOM_UNSCOPED_CSS && !isScopedCss && vm.renderMode === 0 /* RenderMode.Light */) {
|
4255
|
-
logError('Unscoped CSS is not supported in Light DOM in this environment. Please use scoped CSS ' + '(*.scoped.css) instead of unscoped CSS (*.css). See also: https://sfdc.co/scoped-styles-light-dom');
|
4256
|
-
continue;
|
4257
|
-
}
|
4258
|
-
// Apply the scope token only if the stylesheet itself is scoped, or if we're rendering synthetic shadow.
|
4259
|
-
const scopeToken = isScopedCss || vm.shadowMode === 1 /* ShadowMode.Synthetic */ && vm.renderMode === 1 /* RenderMode.Shadow */ ? stylesheetToken : undefined;
|
4260
|
-
// Use the actual `:host` selector if we're rendering global CSS for light DOM, or if we're rendering
|
4261
|
-
// native shadow DOM. Synthetic shadow DOM never uses `:host`.
|
4262
|
-
const useActualHostSelector = vm.renderMode === 0 /* RenderMode.Light */ ? !isScopedCss : vm.shadowMode === 0 /* ShadowMode.Native */;
|
4263
|
-
// Use the native :dir() pseudoclass only in native shadow DOM. Otherwise, in synthetic shadow,
|
4264
|
-
// we use an attribute selector on the host to simulate :dir().
|
4265
|
-
let useNativeDirPseudoclass;
|
4266
|
-
if (vm.renderMode === 1 /* RenderMode.Shadow */) {
|
4267
|
-
useNativeDirPseudoclass = vm.shadowMode === 0 /* ShadowMode.Native */;
|
4268
|
-
} else {
|
4269
|
-
// Light DOM components should only render `[dir]` if they're inside of a synthetic shadow root.
|
4270
|
-
// At the top level (root is null) or inside of a native shadow root, they should use `:dir()`.
|
4271
|
-
if (isUndefined$1(root)) {
|
4272
|
-
// Only calculate the root once as necessary
|
4273
|
-
root = getNearestShadowComponent(vm);
|
4274
|
-
}
|
4275
|
-
useNativeDirPseudoclass = isNull(root) || root.shadowMode === 0 /* ShadowMode.Native */;
|
4276
|
-
}
|
4277
|
-
ArrayPush$1.call(content, stylesheet(scopeToken, useActualHostSelector, useNativeDirPseudoclass));
|
4278
|
-
}
|
4279
|
-
}
|
4280
|
-
return content;
|
4281
|
-
}
|
4282
|
-
function getStylesheetsContent(vm, template) {
|
4283
|
-
const {
|
4284
|
-
stylesheets,
|
4285
|
-
stylesheetToken
|
4286
|
-
} = template;
|
4287
|
-
const {
|
4288
|
-
stylesheets: vmStylesheets
|
4289
|
-
} = vm;
|
4290
|
-
let content = [];
|
4291
|
-
if (hasStyles(stylesheets)) {
|
4292
|
-
content = evaluateStylesheetsContent(stylesheets, stylesheetToken, vm);
|
4293
|
-
}
|
4294
|
-
// VM (component) stylesheets apply after template stylesheets
|
4295
|
-
if (hasStyles(vmStylesheets)) {
|
4296
|
-
ArrayPush$1.apply(content, evaluateStylesheetsContent(vmStylesheets, stylesheetToken, vm));
|
4297
|
-
}
|
4298
|
-
return content;
|
4299
|
-
}
|
4300
|
-
// It might be worth caching this to avoid doing the lookup repeatedly, but
|
4301
|
-
// perf testing has not shown it to be a huge improvement yet:
|
4302
|
-
// https://github.com/salesforce/lwc/pull/2460#discussion_r691208892
|
4303
|
-
function getNearestShadowComponent(vm) {
|
4304
|
-
let owner = vm;
|
4305
|
-
while (!isNull(owner)) {
|
4306
|
-
if (owner.renderMode === 1 /* RenderMode.Shadow */) {
|
4307
|
-
return owner;
|
4308
|
-
}
|
4309
|
-
owner = owner.owner;
|
4310
|
-
}
|
4311
|
-
return owner;
|
4312
|
-
}
|
4313
|
-
/**
|
4314
|
-
* If the component that is currently being rendered uses scoped styles,
|
4315
|
-
* this returns the unique token for that scoped stylesheet. Otherwise
|
4316
|
-
* it returns null.
|
4317
|
-
* @param owner
|
4318
|
-
* @param legacy
|
4319
|
-
*/
|
4320
|
-
// TODO [#3733]: remove support for legacy scope tokens
|
4321
|
-
function getScopeTokenClass(owner, legacy) {
|
4322
|
-
const {
|
4323
|
-
cmpTemplate,
|
4324
|
-
context
|
4325
|
-
} = owner;
|
4326
|
-
return context.hasScopedStyles && (legacy ? cmpTemplate?.legacyStylesheetToken : cmpTemplate?.stylesheetToken) || null;
|
4327
|
-
}
|
4328
|
-
/**
|
4329
|
-
* This function returns the host style token for a custom element if it
|
4330
|
-
* exists. Otherwise it returns null.
|
4331
|
-
*
|
4332
|
-
* A host style token is applied to the component if scoped styles are used.
|
4333
|
-
* @param vnode
|
4334
|
-
*/
|
4335
|
-
function getStylesheetTokenHost(vnode) {
|
4336
|
-
const {
|
4337
|
-
template
|
4338
|
-
} = getComponentInternalDef(vnode.ctor);
|
4339
|
-
const {
|
4340
|
-
vm
|
4341
|
-
} = vnode;
|
4342
|
-
const {
|
4343
|
-
stylesheetToken
|
4344
|
-
} = template;
|
4345
|
-
return !isUndefined$1(stylesheetToken) && computeHasScopedStyles(template, vm) ? makeHostToken(stylesheetToken) : null;
|
4346
|
-
}
|
4347
|
-
function getNearestNativeShadowComponent(vm) {
|
4348
|
-
const owner = getNearestShadowComponent(vm);
|
4349
|
-
if (!isNull(owner) && owner.shadowMode === 1 /* ShadowMode.Synthetic */) {
|
4350
|
-
// Synthetic-within-native is impossible. So if the nearest shadow component is
|
4351
|
-
// synthetic, we know we won't find a native component if we go any further.
|
4352
|
-
return null;
|
4353
|
-
}
|
4354
|
-
return owner;
|
4355
|
-
}
|
4356
|
-
function createStylesheet(vm, stylesheets) {
|
4357
|
-
const {
|
4358
|
-
renderMode,
|
4359
|
-
shadowMode,
|
4360
|
-
renderer: {
|
4361
|
-
insertStylesheet
|
4362
|
-
}
|
4363
|
-
} = vm;
|
4364
|
-
if (renderMode === 1 /* RenderMode.Shadow */ && shadowMode === 1 /* ShadowMode.Synthetic */) {
|
4365
|
-
for (let i = 0; i < stylesheets.length; i++) {
|
4366
|
-
insertStylesheet(stylesheets[i]);
|
4367
|
-
}
|
4368
|
-
} else if (vm.hydrated) {
|
4369
|
-
// Note: We need to ensure that during hydration, the stylesheets method is the same as those in ssr.
|
4370
|
-
// This works in the client, because the stylesheets are created, and cached in the VM
|
4371
|
-
// the first time the VM renders.
|
4372
|
-
// native shadow or light DOM, SSR
|
4373
|
-
return ArrayMap.call(stylesheets, createInlineStyleVNode);
|
4374
|
-
} else {
|
4375
|
-
// native shadow or light DOM, DOM renderer
|
4376
|
-
const root = getNearestNativeShadowComponent(vm);
|
4377
|
-
// null root means a global style
|
4378
|
-
const target = isNull(root) ? undefined : root.shadowRoot;
|
4379
|
-
for (let i = 0; i < stylesheets.length; i++) {
|
4380
|
-
insertStylesheet(stylesheets[i], target);
|
4381
|
-
}
|
4446
|
+
const {
|
4447
|
+
ctor,
|
4448
|
+
name,
|
4449
|
+
props,
|
4450
|
+
propsConfig,
|
4451
|
+
methods
|
4452
|
+
} = def;
|
4453
|
+
const publicProps = {};
|
4454
|
+
for (const key in props) {
|
4455
|
+
// avoid leaking the reference to the public props descriptors
|
4456
|
+
publicProps[key] = {
|
4457
|
+
config: propsConfig[key] || 0,
|
4458
|
+
// a property by default
|
4459
|
+
type: "any" /* PropDefType.any */,
|
4460
|
+
// no type inference for public services
|
4461
|
+
attr: htmlPropertyToAttribute(key)
|
4462
|
+
};
|
4382
4463
|
}
|
4383
|
-
|
4464
|
+
const publicMethods = {};
|
4465
|
+
for (const key in methods) {
|
4466
|
+
// avoid leaking the reference to the public method descriptors
|
4467
|
+
publicMethods[key] = methods[key].value;
|
4468
|
+
}
|
4469
|
+
return {
|
4470
|
+
ctor,
|
4471
|
+
name,
|
4472
|
+
props: publicProps,
|
4473
|
+
methods: publicMethods
|
4474
|
+
};
|
4384
4475
|
}
|
4385
4476
|
|
4386
4477
|
/*
|
4387
|
-
* Copyright (c)
|
4478
|
+
* Copyright (c) 2024, Salesforce, Inc.
|
4388
4479
|
* All rights reserved.
|
4389
4480
|
* SPDX-License-Identifier: MIT
|
4390
4481
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
@@ -4410,6 +4501,12 @@ LWR.define('lwc/v/6_3_4', ['exports'], (function (exports) { 'use strict';
|
|
4410
4501
|
function isVStatic(vnode) {
|
4411
4502
|
return vnode.type === 4 /* VNodeType.Static */;
|
4412
4503
|
}
|
4504
|
+
function isVStaticPartElement(vnode) {
|
4505
|
+
return vnode.type === 1 /* VStaticPartType.Element */;
|
4506
|
+
}
|
4507
|
+
function isVStaticPartText(vnode) {
|
4508
|
+
return vnode.type === 0 /* VStaticPartType.Text */;
|
4509
|
+
}
|
4413
4510
|
|
4414
4511
|
/*
|
4415
4512
|
* Copyright (c) 2018, salesforce.com, inc.
|
@@ -4420,9 +4517,12 @@ LWR.define('lwc/v/6_3_4', ['exports'], (function (exports) { 'use strict';
|
|
4420
4517
|
const ColonCharCode = 58;
|
4421
4518
|
function patchAttributes(oldVnode, vnode, renderer) {
|
4422
4519
|
const {
|
4423
|
-
|
4424
|
-
|
4425
|
-
} = vnode
|
4520
|
+
data,
|
4521
|
+
elm
|
4522
|
+
} = vnode;
|
4523
|
+
const {
|
4524
|
+
attrs
|
4525
|
+
} = data;
|
4426
4526
|
if (isUndefined$1(attrs)) {
|
4427
4527
|
return;
|
4428
4528
|
}
|
@@ -4431,9 +4531,8 @@ LWR.define('lwc/v/6_3_4', ['exports'], (function (exports) { 'use strict';
|
|
4431
4531
|
if (oldAttrs === attrs) {
|
4432
4532
|
return;
|
4433
4533
|
}
|
4434
|
-
|
4435
|
-
|
4436
|
-
} = vnode;
|
4534
|
+
// Note VStaticPartData does not contain the external property so it will always default to false.
|
4535
|
+
const external = 'external' in data ? data.external : false;
|
4437
4536
|
const {
|
4438
4537
|
setAttribute,
|
4439
4538
|
removeAttribute,
|
@@ -4549,8 +4648,7 @@ LWR.define('lwc/v/6_3_4', ['exports'], (function (exports) { 'use strict';
|
|
4549
4648
|
*/
|
4550
4649
|
const classNameToClassMap = create(null);
|
4551
4650
|
function getMapFromClassName(className) {
|
4552
|
-
|
4553
|
-
if (className == null) {
|
4651
|
+
if (isUndefined$1(className) || isNull(className) || className === '') {
|
4554
4652
|
return EmptyObject;
|
4555
4653
|
}
|
4556
4654
|
// computed class names must be string
|
@@ -4594,12 +4692,18 @@ LWR.define('lwc/v/6_3_4', ['exports'], (function (exports) { 'use strict';
|
|
4594
4692
|
if (oldClass === newClass) {
|
4595
4693
|
return;
|
4596
4694
|
}
|
4695
|
+
const newClassMap = getMapFromClassName(newClass);
|
4696
|
+
const oldClassMap = getMapFromClassName(oldClass);
|
4697
|
+
if (oldClassMap === newClassMap) {
|
4698
|
+
// These objects are cached by className string (`classNameToClassMap`), so we can only get here if there is
|
4699
|
+
// a key collision due to types, e.g. oldClass is `undefined` and newClass is `""` (empty string), or oldClass
|
4700
|
+
// is `1` (number) and newClass is `"1"` (string).
|
4701
|
+
return;
|
4702
|
+
}
|
4597
4703
|
const {
|
4598
4704
|
getClassList
|
4599
4705
|
} = renderer;
|
4600
4706
|
const classList = getClassList(elm);
|
4601
|
-
const newClassMap = getMapFromClassName(newClass);
|
4602
|
-
const oldClassMap = getMapFromClassName(oldClass);
|
4603
4707
|
let name;
|
4604
4708
|
for (name in oldClassMap) {
|
4605
4709
|
// remove only if it is not in the new class collection and it is not set from within the instance
|
@@ -4621,13 +4725,18 @@ LWR.define('lwc/v/6_3_4', ['exports'], (function (exports) { 'use strict';
|
|
4621
4725
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
4622
4726
|
*/
|
4623
4727
|
// The style property is a string when defined via an expression in the template.
|
4624
|
-
function patchStyleAttribute(oldVnode, vnode, renderer) {
|
4728
|
+
function patchStyleAttribute(oldVnode, vnode, renderer, owner) {
|
4625
4729
|
const {
|
4626
4730
|
elm,
|
4627
4731
|
data: {
|
4628
4732
|
style: newStyle
|
4629
4733
|
}
|
4630
4734
|
} = vnode;
|
4735
|
+
if (process.env.NODE_ENV !== 'production') {
|
4736
|
+
if (!isNull(newStyle) && !isUndefined$1(newStyle) && !isString(newStyle)) {
|
4737
|
+
logError(`Invalid 'style' attribute passed to <${elm.tagName.toLowerCase()}> is ignored. This attribute must be a string value.`, owner);
|
4738
|
+
}
|
4739
|
+
}
|
4631
4740
|
const oldStyle = isNull(oldVnode) ? undefined : oldVnode.data.style;
|
4632
4741
|
if (oldStyle === newStyle) {
|
4633
4742
|
return;
|
@@ -4651,9 +4760,12 @@ LWR.define('lwc/v/6_3_4', ['exports'], (function (exports) { 'use strict';
|
|
4651
4760
|
*/
|
4652
4761
|
function applyEventListeners(vnode, renderer) {
|
4653
4762
|
const {
|
4654
|
-
elm
|
4763
|
+
elm,
|
4764
|
+
data
|
4655
4765
|
} = vnode;
|
4656
|
-
const
|
4766
|
+
const {
|
4767
|
+
on
|
4768
|
+
} = data;
|
4657
4769
|
if (isUndefined$1(on)) {
|
4658
4770
|
return;
|
4659
4771
|
}
|
@@ -4751,11 +4863,51 @@ LWR.define('lwc/v/6_3_4', ['exports'], (function (exports) { 'use strict';
|
|
4751
4863
|
}
|
4752
4864
|
|
4753
4865
|
/*
|
4754
|
-
* Copyright (c)
|
4866
|
+
* Copyright (c) 2024, salesforce.com, inc.
|
4867
|
+
* All rights reserved.
|
4868
|
+
* SPDX-License-Identifier: MIT
|
4869
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
4870
|
+
*/
|
4871
|
+
function patchTextVNode(n1, n2, renderer) {
|
4872
|
+
n2.elm = n1.elm;
|
4873
|
+
if (n2.text !== n1.text) {
|
4874
|
+
updateTextContent$1(n2, renderer);
|
4875
|
+
}
|
4876
|
+
}
|
4877
|
+
function patchTextVStaticPart(n1, n2, renderer) {
|
4878
|
+
if (isNull(n1) || n2.text !== n1.text) {
|
4879
|
+
updateTextContent$1(n2, renderer);
|
4880
|
+
}
|
4881
|
+
}
|
4882
|
+
function updateTextContent$1(vnode, renderer) {
|
4883
|
+
const {
|
4884
|
+
elm,
|
4885
|
+
text
|
4886
|
+
} = vnode;
|
4887
|
+
const {
|
4888
|
+
setText
|
4889
|
+
} = renderer;
|
4890
|
+
if (process.env.NODE_ENV !== 'production') {
|
4891
|
+
unlockDomMutation();
|
4892
|
+
}
|
4893
|
+
setText(elm, text);
|
4894
|
+
if (process.env.NODE_ENV !== 'production') {
|
4895
|
+
lockDomMutation();
|
4896
|
+
}
|
4897
|
+
}
|
4898
|
+
|
4899
|
+
/*
|
4900
|
+
* Copyright (c) 2024, Salesforce, Inc.
|
4755
4901
|
* All rights reserved.
|
4756
4902
|
* SPDX-License-Identifier: MIT
|
4757
4903
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
4758
4904
|
*/
|
4905
|
+
/**
|
4906
|
+
* Given an array of static parts, mounts the DOM element to the part based on the staticPartId
|
4907
|
+
* @param root the root element
|
4908
|
+
* @param parts an array of VStaticParts
|
4909
|
+
* @param renderer the renderer to use
|
4910
|
+
*/
|
4759
4911
|
function traverseAndSetElements(root, parts, renderer) {
|
4760
4912
|
const numParts = parts.length;
|
4761
4913
|
// Optimization given that, in most cases, there will be one part, and it's just the root
|
@@ -4771,34 +4923,59 @@ LWR.define('lwc/v/6_3_4', ['exports'], (function (exports) { 'use strict';
|
|
4771
4923
|
for (const staticPart of parts) {
|
4772
4924
|
partIdsToParts.set(staticPart.partId, staticPart);
|
4773
4925
|
}
|
4774
|
-
|
4926
|
+
// Note that we traverse using `*Child`/`*Sibling` rather than `children` because the browser uses a linked
|
4927
|
+
// list under the hood to represent the DOM tree, so it's faster to do this than to create an underlying array
|
4928
|
+
// by calling `children`.
|
4775
4929
|
const {
|
4776
|
-
|
4777
|
-
|
4930
|
+
nextSibling,
|
4931
|
+
getFirstChild,
|
4932
|
+
getParentNode
|
4778
4933
|
} = renderer;
|
4779
|
-
|
4934
|
+
let numFoundParts = 0;
|
4780
4935
|
let partId = -1;
|
4936
|
+
// We should never traverse up to the root. We should exit early due to numFoundParts === numParts.
|
4937
|
+
// This is just a sanity check, in case the static parts generated by @lwc/template-compiler are wrong.
|
4938
|
+
function assertNotRoot(node) {
|
4939
|
+
if (process.env.NODE_ENV !== 'production') {
|
4940
|
+
assert.isFalse(node === root, `Reached the root without finding all parts. Found ${numFoundParts}, needed ${numParts}.`);
|
4941
|
+
}
|
4942
|
+
}
|
4781
4943
|
// Depth-first traversal. We assign a partId to each element, which is an integer based on traversal order.
|
4782
|
-
|
4783
|
-
|
4944
|
+
// This function is very hot, which is why it's micro-optimized. Note we don't use a stack at all; we traverse
|
4945
|
+
// using an algorithm that relies on the parentNode getter: https://stackoverflow.com/a/5285417
|
4946
|
+
// This is very slightly faster than a TreeWalker (~0.5% on js-framework-benchmark create-10k), but basically
|
4947
|
+
// the same idea.
|
4948
|
+
let node = root;
|
4949
|
+
while (!isNull(node)) {
|
4950
|
+
// visit node
|
4784
4951
|
partId++;
|
4785
4952
|
const part = partIdsToParts.get(partId);
|
4786
4953
|
if (!isUndefined$1(part)) {
|
4787
|
-
part.elm =
|
4788
|
-
|
4954
|
+
part.elm = node;
|
4955
|
+
numFoundParts++;
|
4956
|
+
if (numFoundParts === numParts) {
|
4789
4957
|
return; // perf optimization - stop traversing once we've found everything we need
|
4790
4958
|
}
|
4791
4959
|
}
|
4792
|
-
|
4793
|
-
|
4794
|
-
|
4795
|
-
|
4796
|
-
|
4797
|
-
|
4798
|
-
|
4799
|
-
|
4960
|
+
const child = getFirstChild(node);
|
4961
|
+
if (!isNull(child)) {
|
4962
|
+
// walk down
|
4963
|
+
node = child;
|
4964
|
+
} else {
|
4965
|
+
let sibling;
|
4966
|
+
while (isNull(sibling = nextSibling(node))) {
|
4967
|
+
// we never want to walk up from the root
|
4968
|
+
assertNotRoot(node);
|
4969
|
+
// walk up
|
4970
|
+
node = getParentNode(node);
|
4971
|
+
}
|
4972
|
+
// we never want to walk right from the root
|
4973
|
+
assertNotRoot(node);
|
4974
|
+
// walk right
|
4975
|
+
node = sibling;
|
4800
4976
|
}
|
4801
4977
|
}
|
4978
|
+
/* istanbul ignore next */
|
4802
4979
|
if (process.env.NODE_ENV !== 'production') {
|
4803
4980
|
assert.isTrue(numFoundParts === numParts, `Should have found all parts by now. Found ${numFoundParts}, needed ${numParts}.`);
|
4804
4981
|
}
|
@@ -4822,18 +4999,29 @@ LWR.define('lwc/v/6_3_4', ['exports'], (function (exports) { 'use strict';
|
|
4822
4999
|
traverseAndSetElements(root, parts, renderer);
|
4823
5000
|
// Currently only event listeners and refs are supported for static vnodes
|
4824
5001
|
for (const part of parts) {
|
4825
|
-
|
4826
|
-
|
4827
|
-
|
4828
|
-
|
5002
|
+
if (isVStaticPartElement(part)) {
|
5003
|
+
// Event listeners only need to be applied once when mounting
|
5004
|
+
applyEventListeners(part, renderer);
|
5005
|
+
// Refs must be updated after every render due to refVNodes getting reset before every render
|
5006
|
+
applyRefs(part, owner);
|
5007
|
+
patchAttributes(null, part, renderer);
|
5008
|
+
patchClassAttribute(null, part, renderer);
|
5009
|
+
patchStyleAttribute(null, part, renderer, owner);
|
5010
|
+
} else {
|
5011
|
+
if (process.env.NODE_ENV !== 'production' && !isVStaticPartText(part)) {
|
5012
|
+
throw new Error(`LWC internal error, encountered unknown static part type: ${part.type}`);
|
5013
|
+
}
|
5014
|
+
patchTextVStaticPart(null, part, renderer);
|
5015
|
+
}
|
4829
5016
|
}
|
4830
5017
|
}
|
4831
5018
|
/**
|
4832
|
-
*
|
5019
|
+
* Updates the static elements based on the content of the VStaticParts
|
4833
5020
|
* @param n1 the previous VStatic vnode
|
4834
5021
|
* @param n2 the current VStatic vnode
|
5022
|
+
* @param renderer the renderer to use
|
4835
5023
|
*/
|
4836
|
-
function patchStaticParts(n1, n2) {
|
5024
|
+
function patchStaticParts(n1, n2, renderer) {
|
4837
5025
|
const {
|
4838
5026
|
parts: currParts,
|
4839
5027
|
owner: currPartsOwner
|
@@ -4848,17 +5036,53 @@ LWR.define('lwc/v/6_3_4', ['exports'], (function (exports) { 'use strict';
|
|
4848
5036
|
assert.isTrue(currParts.length === prevParts?.length, 'Expected static parts to be the same for the same element. This is an error with the LWC framework itself.');
|
4849
5037
|
}
|
4850
5038
|
for (let i = 0; i < currParts.length; i++) {
|
5039
|
+
const prevPart = prevParts[i];
|
4851
5040
|
const part = currParts[i];
|
4852
5041
|
// Patch only occurs if the vnode is newly generated, which means the part.elm is always undefined
|
4853
5042
|
// Since the vnode and elements are the same we can safely assume that prevParts[i].elm is defined.
|
4854
|
-
part.elm =
|
4855
|
-
|
4856
|
-
|
5043
|
+
part.elm = prevPart.elm;
|
5044
|
+
if (process.env.NODE_ENV !== 'production' && prevPart.type !== part.type) {
|
5045
|
+
throw new Error(`LWC internal error, static part types do not match. Previous type was ${prevPart.type} and current type is ${part.type}`);
|
5046
|
+
}
|
5047
|
+
if (isVStaticPartElement(part)) {
|
5048
|
+
// Refs must be updated after every render due to refVNodes getting reset before every render
|
5049
|
+
applyRefs(part, currPartsOwner);
|
5050
|
+
patchAttributes(prevPart, part, renderer);
|
5051
|
+
patchClassAttribute(prevPart, part, renderer);
|
5052
|
+
patchStyleAttribute(prevPart, part, renderer, currPartsOwner);
|
5053
|
+
} else {
|
5054
|
+
patchTextVStaticPart(null, part, renderer);
|
5055
|
+
}
|
5056
|
+
}
|
5057
|
+
}
|
5058
|
+
/**
|
5059
|
+
* Mounts the hydration specific attributes
|
5060
|
+
* @param vnode the parent VStatic node
|
5061
|
+
* @param renderer the renderer to use
|
5062
|
+
*/
|
5063
|
+
function hydrateStaticParts(vnode, renderer) {
|
5064
|
+
const {
|
5065
|
+
parts,
|
5066
|
+
owner
|
5067
|
+
} = vnode;
|
5068
|
+
if (isUndefined$1(parts)) {
|
5069
|
+
return;
|
5070
|
+
}
|
5071
|
+
// Note, hydration doesn't patch attributes because hydration validation occurs before this routine
|
5072
|
+
// which guarantees that the elements are the same.
|
5073
|
+
// We only need to apply the parts for things that cannot be done on the server.
|
5074
|
+
for (const part of parts) {
|
5075
|
+
if (isVStaticPartElement(part)) {
|
5076
|
+
// Event listeners only need to be applied once when mounting
|
5077
|
+
applyEventListeners(part, renderer);
|
5078
|
+
// Refs must be updated after every render due to refVNodes getting reset before every render
|
5079
|
+
applyRefs(part, owner);
|
5080
|
+
}
|
4857
5081
|
}
|
4858
5082
|
}
|
4859
5083
|
|
4860
5084
|
/*
|
4861
|
-
* Copyright (c)
|
5085
|
+
* Copyright (c) 2024, Salesforce, Inc.
|
4862
5086
|
* All rights reserved.
|
4863
5087
|
* SPDX-License-Identifier: MIT
|
4864
5088
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
@@ -4893,7 +5117,7 @@ LWR.define('lwc/v/6_3_4', ['exports'], (function (exports) { 'use strict';
|
|
4893
5117
|
switch (n2.type) {
|
4894
5118
|
case 0 /* VNodeType.Text */:
|
4895
5119
|
// VText has no special capability, fallback to the owner's renderer
|
4896
|
-
|
5120
|
+
patchTextVNode(n1, n2, renderer);
|
4897
5121
|
break;
|
4898
5122
|
case 1 /* VNodeType.Comment */:
|
4899
5123
|
// VComment has no special capability, fallback to the owner's renderer
|
@@ -4940,12 +5164,6 @@ LWR.define('lwc/v/6_3_4', ['exports'], (function (exports) { 'use strict';
|
|
4940
5164
|
break;
|
4941
5165
|
}
|
4942
5166
|
}
|
4943
|
-
function patchText(n1, n2, renderer) {
|
4944
|
-
n2.elm = n1.elm;
|
4945
|
-
if (n2.text !== n1.text) {
|
4946
|
-
updateTextContent(n2, renderer);
|
4947
|
-
}
|
4948
|
-
}
|
4949
5167
|
function mountText(vnode, parent, anchor, renderer) {
|
4950
5168
|
const {
|
4951
5169
|
owner
|
@@ -4962,7 +5180,7 @@ LWR.define('lwc/v/6_3_4', ['exports'], (function (exports) { 'use strict';
|
|
4962
5180
|
// FIXME: Comment nodes should be static, we shouldn't need to diff them together. However
|
4963
5181
|
// it is the case today.
|
4964
5182
|
if (n2.text !== n1.text) {
|
4965
|
-
updateTextContent(n2, renderer);
|
5183
|
+
updateTextContent$1(n2, renderer);
|
4966
5184
|
}
|
4967
5185
|
}
|
4968
5186
|
function mountComment(vnode, parent, anchor, renderer) {
|
@@ -5022,7 +5240,7 @@ LWR.define('lwc/v/6_3_4', ['exports'], (function (exports) { 'use strict';
|
|
5022
5240
|
// slotAssignments can only apply to the top level element, never to a static part.
|
5023
5241
|
patchSlotAssignment(n1, n2, renderer);
|
5024
5242
|
// The `refs` object is blown away in every re-render, so we always need to re-apply them
|
5025
|
-
patchStaticParts(n1, n2);
|
5243
|
+
patchStaticParts(n1, n2, renderer);
|
5026
5244
|
}
|
5027
5245
|
function patchElement(n1, n2, renderer) {
|
5028
5246
|
const elm = n2.elm = n1.elm;
|
@@ -5038,22 +5256,23 @@ LWR.define('lwc/v/6_3_4', ['exports'], (function (exports) { 'use strict';
|
|
5038
5256
|
isSyntheticShadowDefined
|
5039
5257
|
} = renderer;
|
5040
5258
|
const elm = vnode.elm = cloneNode(vnode.fragment, true);
|
5259
|
+
// Define the root node shadow resolver
|
5041
5260
|
linkNodeToShadow(elm, owner, renderer);
|
5042
5261
|
applyElementRestrictions(elm, vnode);
|
5043
|
-
// Marks this node as Static to propagate the shadow resolver. must happen after elm is assigned to the proper shadow
|
5044
5262
|
const {
|
5045
5263
|
renderMode,
|
5046
5264
|
shadowMode
|
5047
5265
|
} = owner;
|
5048
5266
|
if (isSyntheticShadowDefined) {
|
5267
|
+
// Marks this node as Static to propagate the shadow resolver. must happen after elm is assigned to the proper shadow
|
5049
5268
|
if (shadowMode === 1 /* ShadowMode.Synthetic */ || renderMode === 0 /* RenderMode.Light */) {
|
5050
5269
|
elm[KEY__SHADOW_STATIC] = true;
|
5051
5270
|
}
|
5052
5271
|
}
|
5053
5272
|
// slotAssignments can only apply to the top level element, never to a static part.
|
5054
5273
|
patchSlotAssignment(null, vnode, renderer);
|
5055
|
-
insertNode(elm, parent, anchor, renderer);
|
5056
5274
|
mountStaticParts(elm, vnode, renderer);
|
5275
|
+
insertNode(elm, parent, anchor, renderer);
|
5057
5276
|
}
|
5058
5277
|
function mountCustomElement(vnode, parent, anchor, renderer) {
|
5059
5278
|
const {
|
@@ -5234,22 +5453,6 @@ LWR.define('lwc/v/6_3_4', ['exports'], (function (exports) { 'use strict';
|
|
5234
5453
|
}
|
5235
5454
|
}
|
5236
5455
|
}
|
5237
|
-
function updateTextContent(vnode, renderer) {
|
5238
|
-
const {
|
5239
|
-
elm,
|
5240
|
-
text
|
5241
|
-
} = vnode;
|
5242
|
-
const {
|
5243
|
-
setText
|
5244
|
-
} = renderer;
|
5245
|
-
if (process.env.NODE_ENV !== 'production') {
|
5246
|
-
unlockDomMutation();
|
5247
|
-
}
|
5248
|
-
setText(elm, text);
|
5249
|
-
if (process.env.NODE_ENV !== 'production') {
|
5250
|
-
lockDomMutation();
|
5251
|
-
}
|
5252
|
-
}
|
5253
5456
|
function insertFragmentOrNode(vnode, parent, anchor, renderer) {
|
5254
5457
|
if (process.env.NODE_ENV !== 'production') {
|
5255
5458
|
unlockDomMutation();
|
@@ -5293,15 +5496,18 @@ LWR.define('lwc/v/6_3_4', ['exports'], (function (exports) { 'use strict';
|
|
5293
5496
|
applyStaticClassAttribute(vnode, renderer);
|
5294
5497
|
applyStaticStyleAttribute(vnode, renderer);
|
5295
5498
|
}
|
5499
|
+
const {
|
5500
|
+
owner
|
5501
|
+
} = vnode;
|
5296
5502
|
// Attrs need to be applied to element before props IE11 will wipe out value on radio inputs if
|
5297
5503
|
// value is set before type=radio.
|
5298
5504
|
patchClassAttribute(oldVnode, vnode, renderer);
|
5299
|
-
patchStyleAttribute(oldVnode, vnode, renderer);
|
5505
|
+
patchStyleAttribute(oldVnode, vnode, renderer, owner);
|
5300
5506
|
patchAttributes(oldVnode, vnode, renderer);
|
5301
5507
|
patchProps(oldVnode, vnode, renderer);
|
5302
5508
|
patchSlotAssignment(oldVnode, vnode, renderer);
|
5303
5509
|
// The `refs` object is blown away in every re-render, so we always need to re-apply them
|
5304
|
-
applyRefs(vnode,
|
5510
|
+
applyRefs(vnode, owner);
|
5305
5511
|
}
|
5306
5512
|
function applyStyleScoping(elm, owner, renderer) {
|
5307
5513
|
const {
|
@@ -5699,7 +5905,7 @@ LWR.define('lwc/v/6_3_4', ['exports'], (function (exports) { 'use strict';
|
|
5699
5905
|
}
|
5700
5906
|
|
5701
5907
|
/*
|
5702
|
-
* Copyright (c)
|
5908
|
+
* Copyright (c) 2024, Salesforce, Inc.
|
5703
5909
|
* All rights reserved.
|
5704
5910
|
* SPDX-License-Identifier: MIT
|
5705
5911
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
@@ -5709,10 +5915,14 @@ LWR.define('lwc/v/6_3_4', ['exports'], (function (exports) { 'use strict';
|
|
5709
5915
|
ArrayPush$1.call(getVMBeingRendered().velements, vnode);
|
5710
5916
|
}
|
5711
5917
|
// [s]tatic [p]art
|
5712
|
-
function sp(partId, data) {
|
5918
|
+
function sp(partId, data, text) {
|
5919
|
+
// Static part will always have either text or data, it's guaranteed by the compiler.
|
5920
|
+
const type = isNull(text) ? 1 /* VStaticPartType.Element */ : 0 /* VStaticPartType.Text */;
|
5713
5921
|
return {
|
5922
|
+
type,
|
5714
5923
|
partId,
|
5715
5924
|
data,
|
5925
|
+
text,
|
5716
5926
|
elm: undefined // elm is defined later
|
5717
5927
|
};
|
5718
5928
|
}
|
@@ -5729,8 +5939,9 @@ LWR.define('lwc/v/6_3_4', ['exports'], (function (exports) { 'use strict';
|
|
5729
5939
|
};
|
5730
5940
|
}
|
5731
5941
|
// [st]atic node
|
5732
|
-
function st(
|
5942
|
+
function st(fragmentFactory, key, parts) {
|
5733
5943
|
const owner = getVMBeingRendered();
|
5944
|
+
const fragment = fragmentFactory(parts);
|
5734
5945
|
const vnode = {
|
5735
5946
|
type: 4 /* VNodeType.Static */,
|
5736
5947
|
sel: undefined,
|
@@ -5772,9 +5983,6 @@ LWR.define('lwc/v/6_3_4', ['exports'], (function (exports) { 'use strict';
|
|
5772
5983
|
// checking reserved internal data properties
|
5773
5984
|
assert.isFalse(data.className && data.classMap, `vnode.data.className and vnode.data.classMap ambiguous declaration.`);
|
5774
5985
|
assert.isFalse(data.styleDecls && data.style, `vnode.data.styleDecls and vnode.data.style ambiguous declaration.`);
|
5775
|
-
if (data.style && !isString(data.style)) {
|
5776
|
-
logError(`Invalid 'style' attribute passed to <${sel}> is ignored. This attribute must be a string value.`, vmBeingRendered);
|
5777
|
-
}
|
5778
5986
|
forEach.call(children, childVnode => {
|
5779
5987
|
if (childVnode != null) {
|
5780
5988
|
assert.isTrue('type' in childVnode && 'sel' in childVnode && 'elm' in childVnode && 'key' in childVnode, `${childVnode} is not a vnode.`);
|
@@ -5984,22 +6192,28 @@ LWR.define('lwc/v/6_3_4', ['exports'], (function (exports) { 'use strict';
|
|
5984
6192
|
if (isArray$1(vnode)) {
|
5985
6193
|
ArrayPush$1.apply(list, vnode);
|
5986
6194
|
} else {
|
6195
|
+
// `isArray` doesn't narrow this block properly...
|
5987
6196
|
ArrayPush$1.call(list, vnode);
|
5988
6197
|
}
|
5989
6198
|
if (process.env.NODE_ENV !== 'production') {
|
5990
6199
|
const vnodes = isArray$1(vnode) ? vnode : [vnode];
|
5991
6200
|
forEach.call(vnodes, childVnode => {
|
5992
|
-
|
6201
|
+
// Check that the child vnode is either an element or VStatic
|
6202
|
+
if (!isNull(childVnode) && (isVBaseElement(childVnode) || isVStatic(childVnode))) {
|
5993
6203
|
const {
|
5994
6204
|
key
|
5995
6205
|
} = childVnode;
|
6206
|
+
// In @lwc/engine-server the fragment doesn't have a tagName, default to the VM's tagName.
|
6207
|
+
const {
|
6208
|
+
tagName
|
6209
|
+
} = vmBeingRendered;
|
5996
6210
|
if (isString(key) || isNumber(key)) {
|
5997
6211
|
if (keyMap[key] === 1 && isUndefined$1(iterationError)) {
|
5998
|
-
iterationError = `Duplicated "key" attribute value
|
6212
|
+
iterationError = `Duplicated "key" attribute value in "<${tagName}>" for item number ${j}. A key with value "${key}" appears more than once in the iteration. Key values must be unique numbers or strings.`;
|
5999
6213
|
}
|
6000
6214
|
keyMap[key] = 1;
|
6001
6215
|
} else if (isUndefined$1(iterationError)) {
|
6002
|
-
iterationError = `Invalid "key" attribute value in "<${
|
6216
|
+
iterationError = `Invalid "key" attribute value in "<${tagName}>" for item number ${j}. Set a unique "key" value on all iterated child elements.`;
|
6003
6217
|
}
|
6004
6218
|
}
|
6005
6219
|
});
|
@@ -6032,6 +6246,7 @@ LWR.define('lwc/v/6_3_4', ['exports'], (function (exports) { 'use strict';
|
|
6032
6246
|
if (isArray$1(item)) {
|
6033
6247
|
ArrayPush$1.apply(flattened, item);
|
6034
6248
|
} else {
|
6249
|
+
// `isArray` doesn't narrow this block properly...
|
6035
6250
|
ArrayPush$1.call(flattened, item);
|
6036
6251
|
}
|
6037
6252
|
}
|
@@ -6349,7 +6564,7 @@ LWR.define('lwc/v/6_3_4', ['exports'], (function (exports) { 'use strict';
|
|
6349
6564
|
}
|
6350
6565
|
|
6351
6566
|
/*
|
6352
|
-
* Copyright (c)
|
6567
|
+
* Copyright (c) 2024, Salesforce, Inc.
|
6353
6568
|
* All rights reserved.
|
6354
6569
|
* SPDX-License-Identifier: MIT
|
6355
6570
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
@@ -6386,6 +6601,28 @@ LWR.define('lwc/v/6_3_4', ['exports'], (function (exports) { 'use strict';
|
|
6386
6601
|
}
|
6387
6602
|
}
|
6388
6603
|
}
|
6604
|
+
const browserExpressionSerializer = (partToken, classAttrToken) => {
|
6605
|
+
// This will insert the scoped style token as a static class attribute in the fragment
|
6606
|
+
// bypassing the need to call applyStyleScoping when mounting static parts.
|
6607
|
+
const type = StringCharAt.call(partToken, 0);
|
6608
|
+
switch (type) {
|
6609
|
+
case "c" /* STATIC_PART_TOKEN_ID.CLASS */:
|
6610
|
+
return classAttrToken;
|
6611
|
+
case "t" /* STATIC_PART_TOKEN_ID.TEXT */:
|
6612
|
+
// Using a single space here gives us a single empty text node
|
6613
|
+
return ' ';
|
6614
|
+
default:
|
6615
|
+
return '';
|
6616
|
+
}
|
6617
|
+
};
|
6618
|
+
// This function serializes the expressions generated by static content optimization.
|
6619
|
+
// Currently this is only needed for SSR.
|
6620
|
+
// TODO [#4078]: Split the implementation between @lwc/engine-dom and @lwc/engine-server
|
6621
|
+
function buildSerializeExpressionFn(parts) {
|
6622
|
+
{
|
6623
|
+
return browserExpressionSerializer;
|
6624
|
+
}
|
6625
|
+
}
|
6389
6626
|
// This should be a no-op outside of LWC's Karma tests, where it's not needed
|
6390
6627
|
let registerFragmentCache = noop;
|
6391
6628
|
// Only used in LWC's Karma tests
|
@@ -6407,7 +6644,7 @@ LWR.define('lwc/v/6_3_4', ['exports'], (function (exports) { 'use strict';
|
|
6407
6644
|
return (strings, ...keys) => {
|
6408
6645
|
const cache = create(null);
|
6409
6646
|
registerFragmentCache(cache);
|
6410
|
-
return function () {
|
6647
|
+
return function (parts) {
|
6411
6648
|
const {
|
6412
6649
|
context: {
|
6413
6650
|
hasScopedStyles,
|
@@ -6427,14 +6664,27 @@ LWR.define('lwc/v/6_3_4', ['exports'], (function (exports) { 'use strict';
|
|
6427
6664
|
if (hasStyleToken && isSyntheticShadow) {
|
6428
6665
|
cacheKey |= 2 /* FragmentCache.SHADOW_MODE_SYNTHETIC */;
|
6429
6666
|
}
|
6430
|
-
|
6431
|
-
|
6667
|
+
// Cache is only here to prevent calling innerHTML multiple times which doesn't happen on the server.
|
6668
|
+
{
|
6669
|
+
// Disable this on the server to prevent cache poisoning when expressions are used.
|
6670
|
+
const cached = cache[cacheKey];
|
6671
|
+
if (!isUndefined$1(cached)) {
|
6672
|
+
return cached;
|
6673
|
+
}
|
6432
6674
|
}
|
6433
6675
|
// If legacy stylesheet tokens are required, then add them to the rendered string
|
6434
6676
|
const stylesheetTokenToRender = stylesheetToken + (hasLegacyToken ? ` ${legacyStylesheetToken}` : '');
|
6435
6677
|
const classToken = hasScopedStyles && hasStyleToken ? ' ' + stylesheetTokenToRender : '';
|
6436
6678
|
const classAttrToken = hasScopedStyles && hasStyleToken ? ` class="${stylesheetTokenToRender}"` : '';
|
6437
6679
|
const attrToken = hasStyleToken && isSyntheticShadow ? ' ' + stylesheetTokenToRender : '';
|
6680
|
+
// In the browser, we provide the entire class attribute as a perf optimization to avoid applying it on mount.
|
6681
|
+
// The remaining class expression will be applied when the static parts are mounted.
|
6682
|
+
// In SSR, the entire class attribute (expression included) is assembled along with the fragment.
|
6683
|
+
// This is why in the browser we provide the entire class attribute and in SSR we only provide the class token.
|
6684
|
+
const exprClassToken = classAttrToken;
|
6685
|
+
// TODO [#3624]: The implementation of this function should be specific to @lwc/engine-dom and @lwc/engine-server.
|
6686
|
+
// Find a way to split this in a future refactor.
|
6687
|
+
const serializeExpression = buildSerializeExpressionFn();
|
6438
6688
|
let htmlFragment = '';
|
6439
6689
|
for (let i = 0, n = keys.length; i < n; i++) {
|
6440
6690
|
switch (keys[i]) {
|
@@ -6454,6 +6704,10 @@ LWR.define('lwc/v/6_3_4', ['exports'], (function (exports) { 'use strict';
|
|
6454
6704
|
// ${1}${2}
|
6455
6705
|
htmlFragment += strings[i] + classAttrToken + attrToken;
|
6456
6706
|
break;
|
6707
|
+
default:
|
6708
|
+
// expressions ${partId:attributeName/textId}
|
6709
|
+
htmlFragment += strings[i] + serializeExpression(keys[i], exprClassToken);
|
6710
|
+
break;
|
6457
6711
|
}
|
6458
6712
|
}
|
6459
6713
|
htmlFragment += strings[strings.length - 1];
|
@@ -7387,7 +7641,7 @@ LWR.define('lwc/v/6_3_4', ['exports'], (function (exports) { 'use strict';
|
|
7387
7641
|
scheduleRehydration(vm);
|
7388
7642
|
}
|
7389
7643
|
}
|
7390
|
-
function runFormAssociatedCustomElementCallback(vm, faceCb) {
|
7644
|
+
function runFormAssociatedCustomElementCallback(vm, faceCb, args) {
|
7391
7645
|
const {
|
7392
7646
|
renderMode,
|
7393
7647
|
shadowMode
|
@@ -7395,24 +7649,24 @@ LWR.define('lwc/v/6_3_4', ['exports'], (function (exports) { 'use strict';
|
|
7395
7649
|
if (shadowMode === 1 /* ShadowMode.Synthetic */ && renderMode !== 0 /* RenderMode.Light */) {
|
7396
7650
|
throw new Error('Form associated lifecycle methods are not available in synthetic shadow. Please use native shadow or light DOM.');
|
7397
7651
|
}
|
7398
|
-
invokeComponentCallback(vm, faceCb);
|
7652
|
+
invokeComponentCallback(vm, faceCb, args);
|
7399
7653
|
}
|
7400
|
-
function runFormAssociatedCallback(elm) {
|
7654
|
+
function runFormAssociatedCallback(elm, form) {
|
7401
7655
|
const vm = getAssociatedVM(elm);
|
7402
7656
|
const {
|
7403
7657
|
formAssociatedCallback
|
7404
7658
|
} = vm.def;
|
7405
7659
|
if (!isUndefined$1(formAssociatedCallback)) {
|
7406
|
-
runFormAssociatedCustomElementCallback(vm, formAssociatedCallback);
|
7660
|
+
runFormAssociatedCustomElementCallback(vm, formAssociatedCallback, [form]);
|
7407
7661
|
}
|
7408
7662
|
}
|
7409
|
-
function runFormDisabledCallback(elm) {
|
7663
|
+
function runFormDisabledCallback(elm, disabled) {
|
7410
7664
|
const vm = getAssociatedVM(elm);
|
7411
7665
|
const {
|
7412
7666
|
formDisabledCallback
|
7413
7667
|
} = vm.def;
|
7414
7668
|
if (!isUndefined$1(formDisabledCallback)) {
|
7415
|
-
runFormAssociatedCustomElementCallback(vm, formDisabledCallback);
|
7669
|
+
runFormAssociatedCustomElementCallback(vm, formDisabledCallback, [disabled]);
|
7416
7670
|
}
|
7417
7671
|
}
|
7418
7672
|
function runFormResetCallback(elm) {
|
@@ -7424,13 +7678,13 @@ LWR.define('lwc/v/6_3_4', ['exports'], (function (exports) { 'use strict';
|
|
7424
7678
|
runFormAssociatedCustomElementCallback(vm, formResetCallback);
|
7425
7679
|
}
|
7426
7680
|
}
|
7427
|
-
function runFormStateRestoreCallback(elm) {
|
7681
|
+
function runFormStateRestoreCallback(elm, state, reason) {
|
7428
7682
|
const vm = getAssociatedVM(elm);
|
7429
7683
|
const {
|
7430
7684
|
formStateRestoreCallback
|
7431
7685
|
} = vm.def;
|
7432
7686
|
if (!isUndefined$1(formStateRestoreCallback)) {
|
7433
|
-
runFormAssociatedCustomElementCallback(vm, formStateRestoreCallback);
|
7687
|
+
runFormAssociatedCustomElementCallback(vm, formStateRestoreCallback, [state, reason]);
|
7434
7688
|
}
|
7435
7689
|
}
|
7436
7690
|
function resetRefVNodes(vm) {
|
@@ -7800,9 +8054,12 @@ LWR.define('lwc/v/6_3_4', ['exports'], (function (exports) { 'use strict';
|
|
7800
8054
|
if (!hasCorrectNodeType(vnode, node, 3 /* EnvNodeTypes.TEXT */, renderer)) {
|
7801
8055
|
return handleMismatch(node, vnode, renderer);
|
7802
8056
|
}
|
8057
|
+
return updateTextContent(node, vnode, vnode.owner, renderer);
|
8058
|
+
}
|
8059
|
+
function updateTextContent(node, vnode, owner, renderer) {
|
7803
8060
|
if (process.env.NODE_ENV !== 'production') {
|
7804
8061
|
if (!textNodeContentsAreEqual(node, vnode, renderer)) {
|
7805
|
-
logWarn('Hydration mismatch: text values do not match, will recover from the difference',
|
8062
|
+
logWarn('Hydration mismatch: text values do not match, will recover from the difference', owner);
|
7806
8063
|
}
|
7807
8064
|
}
|
7808
8065
|
const {
|
@@ -7833,11 +8090,26 @@ LWR.define('lwc/v/6_3_4', ['exports'], (function (exports) { 'use strict';
|
|
7833
8090
|
return node;
|
7834
8091
|
}
|
7835
8092
|
function hydrateStaticElement(elm, vnode, renderer) {
|
7836
|
-
if (!hasCorrectNodeType(vnode, elm, 1 /* EnvNodeTypes.ELEMENT */, renderer) || !
|
8093
|
+
if (!hasCorrectNodeType(vnode, elm, 1 /* EnvNodeTypes.ELEMENT */, renderer) || !areCompatibleStaticNodes(vnode.fragment, elm, vnode, renderer)) {
|
8094
|
+
return handleMismatch(elm, vnode, renderer);
|
8095
|
+
}
|
8096
|
+
return hydrateStaticElementParts(elm, vnode, renderer);
|
8097
|
+
}
|
8098
|
+
function hydrateStaticElementParts(elm, vnode, renderer) {
|
8099
|
+
const {
|
8100
|
+
parts
|
8101
|
+
} = vnode;
|
8102
|
+
if (!isUndefined$1(parts)) {
|
8103
|
+
// Elements must first be set on the static part to validate against.
|
8104
|
+
traverseAndSetElements(elm, parts, renderer);
|
8105
|
+
}
|
8106
|
+
if (!haveCompatibleStaticParts(vnode, renderer)) {
|
7837
8107
|
return handleMismatch(elm, vnode, renderer);
|
7838
8108
|
}
|
7839
8109
|
vnode.elm = elm;
|
7840
|
-
|
8110
|
+
// Hydration only requires applying event listeners and refs.
|
8111
|
+
// All other expressions should be applied during SSR or through the handleMismatch routine.
|
8112
|
+
hydrateStaticParts(vnode, renderer);
|
7841
8113
|
return elm;
|
7842
8114
|
}
|
7843
8115
|
function hydrateFragment(elm, vnode, renderer) {
|
@@ -8045,9 +8317,12 @@ LWR.define('lwc/v/6_3_4', ['exports'], (function (exports) { 'use strict';
|
|
8045
8317
|
}
|
8046
8318
|
return false;
|
8047
8319
|
}
|
8048
|
-
const
|
8049
|
-
|
8050
|
-
|
8320
|
+
const {
|
8321
|
+
data
|
8322
|
+
} = vnode;
|
8323
|
+
const hasCompatibleAttrs = validateAttrs(vnode, elm, data, renderer, shouldValidateAttr);
|
8324
|
+
const hasCompatibleClass = shouldValidateAttr('class') ? validateClassAttr(vnode, elm, data, renderer) : true;
|
8325
|
+
const hasCompatibleStyle = shouldValidateAttr('style') ? validateStyleAttr(vnode, elm, data, renderer) : true;
|
8051
8326
|
return hasCompatibleAttrs && hasCompatibleClass && hasCompatibleStyle;
|
8052
8327
|
}
|
8053
8328
|
function attributeValuesAreEqual(vnodeValue, value) {
|
@@ -8063,12 +8338,10 @@ LWR.define('lwc/v/6_3_4', ['exports'], (function (exports) { 'use strict';
|
|
8063
8338
|
// In all other cases, the two values are not considered equal
|
8064
8339
|
return false;
|
8065
8340
|
}
|
8066
|
-
function validateAttrs(vnode, elm, renderer, shouldValidateAttr) {
|
8341
|
+
function validateAttrs(vnode, elm, data, renderer, shouldValidateAttr) {
|
8067
8342
|
const {
|
8068
|
-
|
8069
|
-
|
8070
|
-
}
|
8071
|
-
} = vnode;
|
8343
|
+
attrs = {}
|
8344
|
+
} = data;
|
8072
8345
|
let nodesAreCompatible = true;
|
8073
8346
|
// Validate attributes, though we could always recovery from those by running the update mods.
|
8074
8347
|
// Note: intentionally ONLY matching vnodes.attrs to elm.attrs, in case SSR is adding extra attributes.
|
@@ -8076,9 +8349,6 @@ LWR.define('lwc/v/6_3_4', ['exports'], (function (exports) { 'use strict';
|
|
8076
8349
|
if (!shouldValidateAttr(attrName)) {
|
8077
8350
|
continue;
|
8078
8351
|
}
|
8079
|
-
const {
|
8080
|
-
owner
|
8081
|
-
} = vnode;
|
8082
8352
|
const {
|
8083
8353
|
getAttribute
|
8084
8354
|
} = renderer;
|
@@ -8088,18 +8358,19 @@ LWR.define('lwc/v/6_3_4', ['exports'], (function (exports) { 'use strict';
|
|
8088
8358
|
const {
|
8089
8359
|
getProperty
|
8090
8360
|
} = renderer;
|
8091
|
-
logError(`Mismatch hydrating element <${getProperty(elm, 'tagName').toLowerCase()}>: attribute "${attrName}" has different values, expected "${attrValue}" but found ${isNull(elmAttrValue) ? 'null' : `"${elmAttrValue}"`}`, owner);
|
8361
|
+
logError(`Mismatch hydrating element <${getProperty(elm, 'tagName').toLowerCase()}>: attribute "${attrName}" has different values, expected "${attrValue}" but found ${isNull(elmAttrValue) ? 'null' : `"${elmAttrValue}"`}`, vnode.owner);
|
8092
8362
|
}
|
8093
8363
|
nodesAreCompatible = false;
|
8094
8364
|
}
|
8095
8365
|
}
|
8096
8366
|
return nodesAreCompatible;
|
8097
8367
|
}
|
8098
|
-
function validateClassAttr(vnode, elm, renderer) {
|
8368
|
+
function validateClassAttr(vnode, elm, data, renderer) {
|
8099
8369
|
const {
|
8100
|
-
data,
|
8101
8370
|
owner
|
8102
8371
|
} = vnode;
|
8372
|
+
// classMap is never available on VStaticPartData so it can default to undefined
|
8373
|
+
// casting to prevent TS error.
|
8103
8374
|
let {
|
8104
8375
|
className,
|
8105
8376
|
classMap
|
@@ -8179,13 +8450,12 @@ LWR.define('lwc/v/6_3_4', ['exports'], (function (exports) { 'use strict';
|
|
8179
8450
|
}
|
8180
8451
|
return nodesAreCompatible;
|
8181
8452
|
}
|
8182
|
-
function validateStyleAttr(vnode, elm, renderer) {
|
8453
|
+
function validateStyleAttr(vnode, elm, data, renderer) {
|
8454
|
+
// Note styleDecls is always undefined for VStaticPartData, casting here to default it to undefined
|
8183
8455
|
const {
|
8184
|
-
|
8185
|
-
|
8186
|
-
|
8187
|
-
}
|
8188
|
-
} = vnode;
|
8456
|
+
style,
|
8457
|
+
styleDecls
|
8458
|
+
} = data;
|
8189
8459
|
const {
|
8190
8460
|
getAttribute
|
8191
8461
|
} = renderer;
|
@@ -8226,7 +8496,7 @@ LWR.define('lwc/v/6_3_4', ['exports'], (function (exports) { 'use strict';
|
|
8226
8496
|
}
|
8227
8497
|
return nodesAreCompatible;
|
8228
8498
|
}
|
8229
|
-
function
|
8499
|
+
function areCompatibleStaticNodes(client, ssr, vnode, renderer) {
|
8230
8500
|
const {
|
8231
8501
|
getProperty,
|
8232
8502
|
getAttribute
|
@@ -8246,24 +8516,72 @@ LWR.define('lwc/v/6_3_4', ['exports'], (function (exports) { 'use strict';
|
|
8246
8516
|
if (!hasCorrectNodeType(vnode, ssr, 1 /* EnvNodeTypes.ELEMENT */, renderer)) {
|
8247
8517
|
return false;
|
8248
8518
|
}
|
8519
|
+
const {
|
8520
|
+
owner,
|
8521
|
+
parts
|
8522
|
+
} = vnode;
|
8249
8523
|
let isCompatibleElements = true;
|
8250
8524
|
if (getProperty(client, 'tagName') !== getProperty(ssr, 'tagName')) {
|
8251
8525
|
if (process.env.NODE_ENV !== 'production') {
|
8252
|
-
logError(`Hydration mismatch: expecting element with tag "${getProperty(client, 'tagName').toLowerCase()}" but found "${getProperty(ssr, 'tagName').toLowerCase()}".`,
|
8526
|
+
logError(`Hydration mismatch: expecting element with tag "${getProperty(client, 'tagName').toLowerCase()}" but found "${getProperty(ssr, 'tagName').toLowerCase()}".`, owner);
|
8253
8527
|
}
|
8254
8528
|
return false;
|
8255
8529
|
}
|
8256
8530
|
const clientAttrsNames = getProperty(client, 'getAttributeNames').call(client);
|
8257
8531
|
clientAttrsNames.forEach(attrName => {
|
8258
8532
|
if (getAttribute(client, attrName) !== getAttribute(ssr, attrName)) {
|
8259
|
-
if
|
8260
|
-
|
8533
|
+
// Check if the root element attributes have expressions, if it does then we need to delegate hydration
|
8534
|
+
// validation to haveCompatibleStaticParts.
|
8535
|
+
// Note if there are no parts then it is a fully static fragment.
|
8536
|
+
// partId === 0 will always refer to the root element, this is guaranteed by the compiler.
|
8537
|
+
if (parts?.[0].partId !== 0) {
|
8538
|
+
if (process.env.NODE_ENV !== 'production') {
|
8539
|
+
logError(`Mismatch hydrating element <${getProperty(client, 'tagName').toLowerCase()}>: attribute "${attrName}" has different values, expected "${getAttribute(client, attrName)}" but found "${getAttribute(ssr, attrName)}"`, owner);
|
8540
|
+
}
|
8541
|
+
isCompatibleElements = false;
|
8261
8542
|
}
|
8262
|
-
isCompatibleElements = false;
|
8263
8543
|
}
|
8264
8544
|
});
|
8265
8545
|
return isCompatibleElements;
|
8266
8546
|
}
|
8547
|
+
function haveCompatibleStaticParts(vnode, renderer) {
|
8548
|
+
const {
|
8549
|
+
parts,
|
8550
|
+
owner
|
8551
|
+
} = vnode;
|
8552
|
+
if (isUndefined$1(parts)) {
|
8553
|
+
return true;
|
8554
|
+
}
|
8555
|
+
// The validation here relies on 2 key invariants:
|
8556
|
+
// 1. It's never the case that `parts` is undefined on the server but defined on the client (or vice-versa)
|
8557
|
+
// 2. It's never the case that `parts` has one length on the server but another on the client
|
8558
|
+
for (const part of parts) {
|
8559
|
+
const {
|
8560
|
+
elm
|
8561
|
+
} = part;
|
8562
|
+
if (isVStaticPartElement(part)) {
|
8563
|
+
if (!hasCorrectNodeType(vnode, elm, 1 /* EnvNodeTypes.ELEMENT */, renderer)) {
|
8564
|
+
return false;
|
8565
|
+
}
|
8566
|
+
const {
|
8567
|
+
data
|
8568
|
+
} = part;
|
8569
|
+
const hasMatchingAttrs = validateAttrs(vnode, elm, data, renderer, () => true);
|
8570
|
+
const hasMatchingStyleAttr = validateStyleAttr(vnode, elm, data, renderer);
|
8571
|
+
const hasMatchingClass = validateClassAttr(vnode, elm, data, renderer);
|
8572
|
+
if (isFalse(hasMatchingAttrs && hasMatchingStyleAttr && hasMatchingClass)) {
|
8573
|
+
return false;
|
8574
|
+
}
|
8575
|
+
} else {
|
8576
|
+
// VStaticPartText
|
8577
|
+
if (!hasCorrectNodeType(vnode, elm, 3 /* EnvNodeTypes.TEXT */, renderer)) {
|
8578
|
+
return false;
|
8579
|
+
}
|
8580
|
+
updateTextContent(elm, part, owner, renderer);
|
8581
|
+
}
|
8582
|
+
}
|
8583
|
+
return true;
|
8584
|
+
}
|
8267
8585
|
|
8268
8586
|
/*
|
8269
8587
|
* Copyright (c) 2018, salesforce.com, inc.
|
@@ -8279,7 +8597,7 @@ LWR.define('lwc/v/6_3_4', ['exports'], (function (exports) { 'use strict';
|
|
8279
8597
|
}
|
8280
8598
|
|
8281
8599
|
/*
|
8282
|
-
* Copyright (c)
|
8600
|
+
* Copyright (c) 2024, Salesforce, Inc.
|
8283
8601
|
* All rights reserved.
|
8284
8602
|
* SPDX-License-Identifier: MIT
|
8285
8603
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
@@ -8336,9 +8654,9 @@ LWR.define('lwc/v/6_3_4', ['exports'], (function (exports) { 'use strict';
|
|
8336
8654
|
// we can at least warn when they use the most common mutation methods.
|
8337
8655
|
for (const prop of ARRAY_MUTATION_METHODS) {
|
8338
8656
|
const originalArrayMethod = getOriginalArrayMethod(prop);
|
8657
|
+
// Assertions used here because TypeScript can't handle mapping over our types
|
8339
8658
|
stylesheets[prop] = function arrayMutationWarningWrapper() {
|
8340
8659
|
reportTemplateViolation('stylesheets');
|
8341
|
-
// @ts-expect-error can't properly determine the right `this`
|
8342
8660
|
return originalArrayMethod.apply(this, arguments);
|
8343
8661
|
};
|
8344
8662
|
}
|
@@ -8520,7 +8838,7 @@ LWR.define('lwc/v/6_3_4', ['exports'], (function (exports) { 'use strict';
|
|
8520
8838
|
}
|
8521
8839
|
return getReadOnlyProxy(obj);
|
8522
8840
|
}
|
8523
|
-
/** version: 6.
|
8841
|
+
/** version: 6.6.1 */
|
8524
8842
|
|
8525
8843
|
/*
|
8526
8844
|
* Copyright (c) 2018, salesforce.com, inc.
|
@@ -8650,7 +8968,7 @@ LWR.define('lwc/v/6_3_4', ['exports'], (function (exports) { 'use strict';
|
|
8650
8968
|
stylesheet.replaceSync(content);
|
8651
8969
|
return stylesheet;
|
8652
8970
|
}
|
8653
|
-
function insertConstructableStylesheet(content, target, cacheData) {
|
8971
|
+
function insertConstructableStylesheet(content, target, cacheData, signal) {
|
8654
8972
|
const {
|
8655
8973
|
adoptedStyleSheets
|
8656
8974
|
} = target;
|
@@ -8659,10 +8977,32 @@ LWR.define('lwc/v/6_3_4', ['exports'], (function (exports) { 'use strict';
|
|
8659
8977
|
} = cacheData;
|
8660
8978
|
// The reason we prefer .push() rather than reassignment is for perf: https://github.com/salesforce/lwc/pull/2683
|
8661
8979
|
adoptedStyleSheets.push(stylesheet);
|
8980
|
+
if (process.env.NODE_ENV !== 'production') {
|
8981
|
+
/* istanbul ignore if */
|
8982
|
+
if (isUndefined$1(signal)) {
|
8983
|
+
throw new Error('Expected AbortSignal to be defined in dev mode');
|
8984
|
+
}
|
8985
|
+
// TODO [#4155]: unrendering should account for stylesheet content collisions
|
8986
|
+
signal.addEventListener('abort', () => {
|
8987
|
+
adoptedStyleSheets.splice(adoptedStyleSheets.indexOf(stylesheet), 1);
|
8988
|
+
stylesheetCache.delete(content);
|
8989
|
+
});
|
8990
|
+
}
|
8662
8991
|
}
|
8663
|
-
function insertStyleElement(content, target, cacheData) {
|
8992
|
+
function insertStyleElement(content, target, cacheData, signal) {
|
8664
8993
|
const elm = createStyleElement(content, cacheData);
|
8665
8994
|
target.appendChild(elm);
|
8995
|
+
if (process.env.NODE_ENV !== 'production') {
|
8996
|
+
/* istanbul ignore if */
|
8997
|
+
if (isUndefined$1(signal)) {
|
8998
|
+
throw new Error('Expected AbortSignal to be defined in dev mode');
|
8999
|
+
}
|
9000
|
+
// TODO [#4155]: unrendering should account for stylesheet content collisions
|
9001
|
+
signal.addEventListener('abort', () => {
|
9002
|
+
target.removeChild(elm);
|
9003
|
+
stylesheetCache.delete(content);
|
9004
|
+
});
|
9005
|
+
}
|
8666
9006
|
}
|
8667
9007
|
function getCacheData(content, useConstructableStylesheet) {
|
8668
9008
|
let cacheData = stylesheetCache.get(content);
|
@@ -8684,7 +9024,7 @@ LWR.define('lwc/v/6_3_4', ['exports'], (function (exports) { 'use strict';
|
|
8684
9024
|
}
|
8685
9025
|
return cacheData;
|
8686
9026
|
}
|
8687
|
-
function insertGlobalStylesheet(content) {
|
9027
|
+
function insertGlobalStylesheet(content, signal) {
|
8688
9028
|
// Force a <style> element for global stylesheets. See comment below.
|
8689
9029
|
const cacheData = getCacheData(content, false);
|
8690
9030
|
if (cacheData.global) {
|
@@ -8693,9 +9033,9 @@ LWR.define('lwc/v/6_3_4', ['exports'], (function (exports) { 'use strict';
|
|
8693
9033
|
}
|
8694
9034
|
cacheData.global = true; // mark inserted
|
8695
9035
|
// TODO [#2922]: use document.adoptedStyleSheets in supported browsers. Currently we can't, due to backwards compat.
|
8696
|
-
insertStyleElement(content, document.head, cacheData);
|
9036
|
+
insertStyleElement(content, document.head, cacheData, signal);
|
8697
9037
|
}
|
8698
|
-
function insertLocalStylesheet(content, target) {
|
9038
|
+
function insertLocalStylesheet(content, target, signal) {
|
8699
9039
|
const cacheData = getCacheData(content, supportsConstructableStylesheets);
|
8700
9040
|
let {
|
8701
9041
|
roots
|
@@ -8711,19 +9051,25 @@ LWR.define('lwc/v/6_3_4', ['exports'], (function (exports) { 'use strict';
|
|
8711
9051
|
// https://caniuse.com/mdn-api_document_adoptedstylesheets
|
8712
9052
|
// The reason we use it is for perf: https://github.com/salesforce/lwc/pull/2460
|
8713
9053
|
if (supportsConstructableStylesheets) {
|
8714
|
-
insertConstructableStylesheet(content, target, cacheData);
|
9054
|
+
insertConstructableStylesheet(content, target, cacheData, signal);
|
8715
9055
|
} else {
|
8716
9056
|
// Fall back to <style> element
|
8717
|
-
insertStyleElement(content, target, cacheData);
|
9057
|
+
insertStyleElement(content, target, cacheData, signal);
|
8718
9058
|
}
|
8719
9059
|
}
|
8720
|
-
|
9060
|
+
/**
|
9061
|
+
* Injects a stylesheet into the global (document) level or inside a shadow root.
|
9062
|
+
* @param content CSS content to insert
|
9063
|
+
* @param target ShadowRoot to insert into, or undefined if global (document) level
|
9064
|
+
* @param signal AbortSignal for aborting the stylesheet render. Used in dev mode for HMR to unrender stylesheets.
|
9065
|
+
*/
|
9066
|
+
function insertStylesheet(content, target, signal) {
|
8721
9067
|
if (isUndefined$1(target)) {
|
8722
9068
|
// global
|
8723
|
-
insertGlobalStylesheet(content);
|
9069
|
+
insertGlobalStylesheet(content, signal);
|
8724
9070
|
} else {
|
8725
9071
|
// local
|
8726
|
-
insertLocalStylesheet(content, target);
|
9072
|
+
insertLocalStylesheet(content, target, signal);
|
8727
9073
|
}
|
8728
9074
|
}
|
8729
9075
|
|
@@ -8733,25 +9079,19 @@ LWR.define('lwc/v/6_3_4', ['exports'], (function (exports) { 'use strict';
|
|
8733
9079
|
* SPDX-License-Identifier: MIT
|
8734
9080
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
8735
9081
|
*/
|
8736
|
-
const LIFECYCLE_CALLBACKS = {
|
8737
|
-
connectedCallback: connectRootElement,
|
8738
|
-
disconnectedCallback: disconnectRootElement,
|
8739
|
-
formAssociatedCallback: runFormAssociatedCallback,
|
8740
|
-
formDisabledCallback: runFormDisabledCallback,
|
8741
|
-
formResetCallback: runFormResetCallback,
|
8742
|
-
formStateRestoreCallback: runFormStateRestoreCallback
|
8743
|
-
};
|
8744
9082
|
const cachedConstructors = new Map();
|
8745
9083
|
const nativeLifecycleElementsToUpgradedByLWC = new WeakMap();
|
8746
9084
|
let elementBeingUpgradedByLWC = false;
|
8747
|
-
|
8748
|
-
|
8749
|
-
|
8750
|
-
|
8751
|
-
|
8752
|
-
|
9085
|
+
let BaseUpgradableConstructor;
|
9086
|
+
let BaseHTMLElement;
|
9087
|
+
function createBaseUpgradableConstructor() {
|
9088
|
+
// Creates a constructor that is intended to be used directly as a custom element, except that the upgradeCallback is
|
9089
|
+
// passed in to the constructor so LWC can reuse the same custom element constructor for multiple components.
|
9090
|
+
// Another benefit is that only LWC can create components that actually do anything – if you do
|
9091
|
+
// `customElements.define('x-foo')`, then you don't have access to the upgradeCallback, so it's a dummy custom element.
|
9092
|
+
// This class should be created once per tag name.
|
8753
9093
|
// TODO [#2972]: this class should expose observedAttributes as necessary
|
8754
|
-
class
|
9094
|
+
BaseUpgradableConstructor = class TheBaseUpgradableConstructor extends HTMLElement {
|
8755
9095
|
constructor(upgradeCallback, useNativeLifecycle) {
|
8756
9096
|
super();
|
8757
9097
|
if (useNativeLifecycle) {
|
@@ -8768,17 +9108,57 @@ LWR.define('lwc/v/6_3_4', ['exports'], (function (exports) { 'use strict';
|
|
8768
9108
|
// TODO [#2970]: LWC elements cannot be upgraded via new Ctor()
|
8769
9109
|
// Do we want to support this? Throw an error? Currently for backwards compat it's a no-op.
|
8770
9110
|
}
|
8771
|
-
|
8772
|
-
}
|
8773
|
-
UpgradableConstructor.formAssociated = isFormAssociated;
|
8774
|
-
for (const [propName, callback] of entries(LIFECYCLE_CALLBACKS)) {
|
8775
|
-
UpgradableConstructor.prototype[propName] = function () {
|
8776
|
-
// If the element is in the WeakMap (i.e. it's marked as native lifecycle), and if it was upgraded by LWC,
|
8777
|
-
// then it can use native lifecycle
|
9111
|
+
connectedCallback() {
|
8778
9112
|
if (isTrue(nativeLifecycleElementsToUpgradedByLWC.get(this))) {
|
8779
|
-
|
9113
|
+
connectRootElement(this);
|
8780
9114
|
}
|
8781
|
-
}
|
9115
|
+
}
|
9116
|
+
disconnectedCallback() {
|
9117
|
+
if (isTrue(nativeLifecycleElementsToUpgradedByLWC.get(this))) {
|
9118
|
+
disconnectRootElement(this);
|
9119
|
+
}
|
9120
|
+
}
|
9121
|
+
formAssociatedCallback(form) {
|
9122
|
+
if (isTrue(nativeLifecycleElementsToUpgradedByLWC.get(this))) {
|
9123
|
+
runFormAssociatedCallback(this, form);
|
9124
|
+
}
|
9125
|
+
}
|
9126
|
+
formDisabledCallback(disabled) {
|
9127
|
+
if (isTrue(nativeLifecycleElementsToUpgradedByLWC.get(this))) {
|
9128
|
+
runFormDisabledCallback(this, disabled);
|
9129
|
+
}
|
9130
|
+
}
|
9131
|
+
formResetCallback() {
|
9132
|
+
if (isTrue(nativeLifecycleElementsToUpgradedByLWC.get(this))) {
|
9133
|
+
runFormResetCallback(this);
|
9134
|
+
}
|
9135
|
+
}
|
9136
|
+
formStateRestoreCallback(state, reason) {
|
9137
|
+
if (isTrue(nativeLifecycleElementsToUpgradedByLWC.get(this))) {
|
9138
|
+
runFormStateRestoreCallback(this, state, reason);
|
9139
|
+
}
|
9140
|
+
}
|
9141
|
+
/*LWC compiler v6.6.1*/
|
9142
|
+
};
|
9143
|
+
BaseHTMLElement = HTMLElement; // cache to track if it changes
|
9144
|
+
}
|
9145
|
+
const createUpgradableConstructor = isFormAssociated => {
|
9146
|
+
if (HTMLElement !== BaseHTMLElement) {
|
9147
|
+
// If the global HTMLElement changes out from under our feet, then we need to create a new
|
9148
|
+
// BaseUpgradableConstructor from scratch (since it extends from HTMLElement). This can occur if
|
9149
|
+
// polyfills are in play, e.g. a polyfill for scoped custom element registries.
|
9150
|
+
// This workaround can potentially be removed when W-15361244 is resolved.
|
9151
|
+
createBaseUpgradableConstructor();
|
9152
|
+
}
|
9153
|
+
// Using a BaseUpgradableConstructor superclass here is a perf optimization to avoid
|
9154
|
+
// re-defining the same logic (connectedCallback, disconnectedCallback, etc.) over and over.
|
9155
|
+
class UpgradableConstructor extends BaseUpgradableConstructor {
|
9156
|
+
/*LWC compiler v6.6.1*/
|
9157
|
+
}
|
9158
|
+
if (isFormAssociated) {
|
9159
|
+
// Perf optimization - the vast majority of components have formAssociated=false,
|
9160
|
+
// so we can skip the setter in those cases, since undefined works the same as false.
|
9161
|
+
UpgradableConstructor.formAssociated = isFormAssociated;
|
8782
9162
|
}
|
8783
9163
|
return UpgradableConstructor;
|
8784
9164
|
};
|
@@ -8796,11 +9176,11 @@ LWR.define('lwc/v/6_3_4', ['exports'], (function (exports) { 'use strict';
|
|
8796
9176
|
}
|
8797
9177
|
const createCustomElement = (tagName, upgradeCallback, useNativeLifecycle, isFormAssociated) => {
|
8798
9178
|
const UpgradableConstructor = getUpgradableConstructor(tagName, isFormAssociated);
|
9179
|
+
if (Boolean(UpgradableConstructor.formAssociated) !== isFormAssociated) {
|
9180
|
+
throw new Error(`<${tagName}> was already registered with formAssociated=${UpgradableConstructor.formAssociated}. It cannot be re-registered with formAssociated=${isFormAssociated}. Please rename your component to have a different name than <${tagName}>`);
|
9181
|
+
}
|
8799
9182
|
elementBeingUpgradedByLWC = true;
|
8800
9183
|
try {
|
8801
|
-
if (UpgradableConstructor.formAssociated !== isFormAssociated) {
|
8802
|
-
throw new Error(`<${tagName}> was already registered with formAssociated=${UpgradableConstructor.formAssociated}. It cannot be re-registered with formAssociated=${isFormAssociated}. Please rename your component to have a different name than <${tagName}>`);
|
8803
|
-
}
|
8804
9184
|
return new UpgradableConstructor(upgradeCallback, useNativeLifecycle);
|
8805
9185
|
} finally {
|
8806
9186
|
elementBeingUpgradedByLWC = false;
|
@@ -8896,7 +9276,7 @@ LWR.define('lwc/v/6_3_4', ['exports'], (function (exports) { 'use strict';
|
|
8896
9276
|
function isNull(obj) {
|
8897
9277
|
return obj === null;
|
8898
9278
|
}
|
8899
|
-
/** version: 6.
|
9279
|
+
/** version: 6.6.1 */
|
8900
9280
|
|
8901
9281
|
/*
|
8902
9282
|
* Copyright (c) 2023, salesforce.com, inc.
|
@@ -8916,7 +9296,7 @@ LWR.define('lwc/v/6_3_4', ['exports'], (function (exports) { 'use strict';
|
|
8916
9296
|
this.setNewContext = setNewContext;
|
8917
9297
|
this.setDisconnectedCallback = setDisconnectedCallback;
|
8918
9298
|
}
|
8919
|
-
/*LWC compiler v6.
|
9299
|
+
/*LWC compiler v6.6.1*/
|
8920
9300
|
}
|
8921
9301
|
function registerContextConsumer(elm, adapterContextToken, subscriptionPayload) {
|
8922
9302
|
dispatchEvent(elm, new WireContextSubscriptionEvent(adapterContextToken, subscriptionPayload));
|
@@ -8971,6 +9351,9 @@ LWR.define('lwc/v/6_3_4', ['exports'], (function (exports) { 'use strict';
|
|
8971
9351
|
function previousSibling(node) {
|
8972
9352
|
return node.previousSibling;
|
8973
9353
|
}
|
9354
|
+
function getParentNode(node) {
|
9355
|
+
return node.parentNode;
|
9356
|
+
}
|
8974
9357
|
function attachShadow(element, options) {
|
8975
9358
|
// `shadowRoot` will be non-null in two cases:
|
8976
9359
|
// 1. upon initial load with an SSR-generated DOM, while in Shadow render mode
|
@@ -9095,6 +9478,7 @@ LWR.define('lwc/v/6_3_4', ['exports'], (function (exports) { 'use strict';
|
|
9095
9478
|
exports.getFirstElementChild = getFirstElementChild;
|
9096
9479
|
exports.getLastChild = getLastChild;
|
9097
9480
|
exports.getLastElementChild = getLastElementChild;
|
9481
|
+
exports.getParentNode = getParentNode;
|
9098
9482
|
exports.getProperty = getProperty;
|
9099
9483
|
exports.getTagName = getTagName;
|
9100
9484
|
exports.insert = insert;
|
@@ -9314,19 +9698,19 @@ LWR.define('lwc/v/6_3_4', ['exports'], (function (exports) { 'use strict';
|
|
9314
9698
|
attributeChangedCallback(name, oldValue, newValue) {
|
9315
9699
|
attributeChangedCallback.call(this, name, oldValue, newValue);
|
9316
9700
|
}
|
9317
|
-
formAssociatedCallback() {
|
9318
|
-
runFormAssociatedCallback(this);
|
9701
|
+
formAssociatedCallback(form) {
|
9702
|
+
runFormAssociatedCallback(this, form);
|
9319
9703
|
}
|
9320
|
-
formDisabledCallback() {
|
9321
|
-
runFormDisabledCallback(this);
|
9704
|
+
formDisabledCallback(disabled) {
|
9705
|
+
runFormDisabledCallback(this, disabled);
|
9322
9706
|
}
|
9323
9707
|
formResetCallback() {
|
9324
9708
|
runFormResetCallback(this);
|
9325
9709
|
}
|
9326
|
-
formStateRestoreCallback() {
|
9327
|
-
runFormStateRestoreCallback(this);
|
9710
|
+
formStateRestoreCallback(state, reason) {
|
9711
|
+
runFormStateRestoreCallback(this, state, reason);
|
9328
9712
|
}
|
9329
|
-
/*LWC compiler v6.
|
9713
|
+
/*LWC compiler v6.6.1*/
|
9330
9714
|
}, _a.observedAttributes = observedAttributes,
|
9331
9715
|
// Note CustomElementConstructor is not upgraded by LWC and inherits directly from HTMLElement which means it calls the native
|
9332
9716
|
// attachInternals API.
|
@@ -9390,9 +9774,6 @@ LWR.define('lwc/v/6_3_4', ['exports'], (function (exports) { 'use strict';
|
|
9390
9774
|
}
|
9391
9775
|
});
|
9392
9776
|
}
|
9393
|
-
// For some reason, JSDOC says "options.is" is a syntax error. And we can't disable the rule using
|
9394
|
-
// `eslint-disable-next-line` because that gets included in the JSDOC, so we need this workaround.
|
9395
|
-
/* eslint-disable jsdoc/valid-types */
|
9396
9777
|
/**
|
9397
9778
|
* EXPERIMENTAL: This function is almost identical to document.createElement with the slightly
|
9398
9779
|
* difference that in the options, you can pass the `is` property set to a Constructor instead of
|
@@ -9407,8 +9788,7 @@ LWR.define('lwc/v/6_3_4', ['exports'], (function (exports) { 'use strict';
|
|
9407
9788
|
* @example
|
9408
9789
|
* const el = createElement('x-foo', { is: FooCtor });
|
9409
9790
|
*/
|
9410
|
-
function createElement(
|
9411
|
-
sel, options) {
|
9791
|
+
function createElement(sel, options) {
|
9412
9792
|
if (!isObject(options) || isNull(options)) {
|
9413
9793
|
throw new TypeError(`"createElement" function expects an object as second parameter but received "${toString$1(options)}".`);
|
9414
9794
|
}
|
@@ -9559,7 +9939,7 @@ LWR.define('lwc/v/6_3_4', ['exports'], (function (exports) { 'use strict';
|
|
9559
9939
|
});
|
9560
9940
|
});
|
9561
9941
|
}
|
9562
|
-
/** version: 6.
|
9942
|
+
/** version: 6.6.1 */
|
9563
9943
|
|
9564
9944
|
exports.LightningElement = LightningElement;
|
9565
9945
|
exports.__unstable__ProfilerControl = profilerControl;
|