@lwrjs/everywhere 0.15.0-alpha.9 → 0.15.0
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/4c8430eb6183d31993bda7e543613b61/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_15_0/s/3aba11034f11c8d5598c93bfca4d4690/@lwrjs_app-service_amd-bootstrap_module_amd.js +21 -0
- package/build/__generated_site_amd_modules__/1/module/amd/1/l/en-US/mi/lwc/v/{7_2_1/s/78ef23818e3b886f8d3d93ec49c1ee0c → 8_9_0/s/1bc4b836e34db15a047501ddb6736861}/lwc.js +765 -361
- package/build/__generated_site_amd_modules__/1/module/amd/1/l/en-US/mi/lwr/everywhereAmd/v/{0_15_0-alpha_9 → 0_15_0}/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_15_0-alpha_9 → 0_15_0}/s/d7186d4fbbc58762dab0d51cc1f0afb8/lwr_init.js +21 -21
- package/build/__generated_site_amd_modules__/1/module/amd/1/l/en-US/mi/lwr/loader/v/{0_15_0-alpha_9/s/7edffb77383cd80d95fd815015af66f4 → 0_15_0/s/e19e3d6744c6be97d51c14dcd528d321}/lwr_loader.js +4 -4
- package/build/__generated_site_amd_modules__/1/module/amd/1/l/en-US/mi/lwr/metrics/v/{0_15_0-alpha_9 → 0_15_0}/s/fb8c5dd340c69fdf7ded52d3eba633b9/lwr_metrics.js +1 -1
- package/build/__generated_site_amd_modules__/1/module/amd/1/l/en-US/mi/lwr/preInit/v/{0_15_0-alpha_9 → 0_15_0}/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_15_0-alpha_9 → 0_15_0}/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_15_0-alpha_9 → 0_15_0}/s/c92abd8c1fec2d7eff62e4b097abbe14/lwr_vault.js +1 -1
- package/build/__generated_site_amd_modules__/1/resource/amd/lwr-error-shim.js/v/{0_15_0-alpha_9 → 0_15_0}/lwr-error-shim.js +1 -1
- package/build/__generated_site_amd_modules__/1/resource/amd/lwr-loader-shim.bundle.js/v/{0_15_0-alpha_9 → 0_15_0}/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/839e22d3117741c86486d7c30b25a350/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_15_0-alpha_9/s/272183c0b6e02561b7c96a1b23473837/@lwrjs_app-service_amd-bootstrap_module_amd.js +0 -14
@@ -1,4 +1,4 @@
|
|
1
|
-
LWR.define('lwc/v/
|
1
|
+
LWR.define('lwc/v/8_9_0', ['exports'], (function (exports) { 'use strict';
|
2
2
|
|
3
3
|
/**
|
4
4
|
* Copyright (c) 2024 Salesforce, Inc.
|
@@ -82,6 +82,8 @@ LWR.define('lwc/v/7_2_1', ['exports'], (function (exports) { 'use strict';
|
|
82
82
|
getOwnPropertyDescriptors,
|
83
83
|
/** Detached {@linkcode Object.getOwnPropertyNames}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyNames MDN Reference}. */
|
84
84
|
getOwnPropertyNames: getOwnPropertyNames$1,
|
85
|
+
/** Detached {@linkcode Object.getOwnPropertySymbols}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertySymbols MDN Reference}. */
|
86
|
+
getOwnPropertySymbols: getOwnPropertySymbols$1,
|
85
87
|
/** Detached {@linkcode Object.getPrototypeOf}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getPrototypeOf MDN Reference}. */
|
86
88
|
getPrototypeOf: getPrototypeOf$1,
|
87
89
|
/** Detached {@linkcode Object.hasOwnProperty}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/hasOwnProperty MDN Reference}. */
|
@@ -95,28 +97,25 @@ LWR.define('lwc/v/7_2_1', ['exports'], (function (exports) { 'use strict';
|
|
95
97
|
/** Detached {@linkcode Object.setPrototypeOf}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/setPrototypeOf MDN Reference}. */
|
96
98
|
setPrototypeOf
|
97
99
|
} = Object;
|
98
|
-
/** Detached {@linkcode Array.isArray}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/isArray MDN Reference}. */
|
99
100
|
const {
|
100
|
-
isArray
|
101
|
+
/** Detached {@linkcode Array.isArray}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/isArray MDN Reference}. */
|
102
|
+
isArray: isArray$1,
|
103
|
+
/** Detached {@linkcode Array.from}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/from MDN Reference}. */
|
104
|
+
from: ArrayFrom
|
101
105
|
} = Array;
|
102
106
|
// For some reason, JSDoc don't get picked up for multiple renamed destructured constants (even
|
103
107
|
// though it works fine for one, e.g. isArray), so comments for these are added to the export
|
104
108
|
// statement, rather than this declaration.
|
105
109
|
const {
|
106
|
-
concat: ArrayConcat$1,
|
107
110
|
copyWithin: ArrayCopyWithin,
|
108
111
|
every: ArrayEvery,
|
109
112
|
fill: ArrayFill,
|
110
113
|
filter: ArrayFilter,
|
111
|
-
find: ArrayFind,
|
112
|
-
findIndex: ArrayFindIndex,
|
113
|
-
includes: ArrayIncludes,
|
114
114
|
indexOf: ArrayIndexOf,
|
115
115
|
join: ArrayJoin,
|
116
116
|
map: ArrayMap,
|
117
117
|
pop: ArrayPop,
|
118
118
|
push: ArrayPush$1,
|
119
|
-
reduce: ArrayReduce,
|
120
119
|
reverse: ArrayReverse,
|
121
120
|
shift: ArrayShift,
|
122
121
|
slice: ArraySlice,
|
@@ -202,7 +201,7 @@ LWR.define('lwc/v/7_2_1', ['exports'], (function (exports) { 'use strict';
|
|
202
201
|
* @returns `true` if the value is a function.
|
203
202
|
*/
|
204
203
|
// Replacing `Function` with a narrower type that works for all our use cases is tricky...
|
205
|
-
// eslint-disable-next-line @typescript-eslint/
|
204
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
|
206
205
|
function isFunction$1(obj) {
|
207
206
|
return typeof obj === 'function';
|
208
207
|
}
|
@@ -293,7 +292,7 @@ LWR.define('lwc/v/7_2_1', ['exports'], (function (exports) { 'use strict';
|
|
293
292
|
// These must be updated when the enum is updated.
|
294
293
|
// It's a bit annoying to do have to do this manually, but this makes the file tree-shakeable,
|
295
294
|
// passing the `verify-treeshakeable.js` test.
|
296
|
-
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 */];
|
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 */, 63 /* APIVersion.V63_254_SPRING_25 */];
|
297
296
|
const LOWEST_API_VERSION = allVersions[0];
|
298
297
|
/**
|
299
298
|
*
|
@@ -317,6 +316,8 @@ LWR.define('lwc/v/7_2_1', ['exports'], (function (exports) { 'use strict';
|
|
317
316
|
case 9 /* APIFeature.ENABLE_THIS_DOT_STYLE */:
|
318
317
|
case 10 /* APIFeature.TEMPLATE_CLASS_NAME_OBJECT_BINDING */:
|
319
318
|
return apiVersion >= 62 /* APIVersion.V62_252_WINTER_25 */;
|
319
|
+
case 11 /* APIFeature.ENABLE_COMPLEX_TEMPLATE_EXPRESSIONS */:
|
320
|
+
return apiVersion >= 63 /* APIVersion.V63_254_SPRING_25 */;
|
320
321
|
}
|
321
322
|
}
|
322
323
|
|
@@ -348,6 +349,9 @@ LWR.define('lwc/v/7_2_1', ['exports'], (function (exports) { 'use strict';
|
|
348
349
|
// Synthetic creation of all AOM property descriptors for Custom Elements
|
349
350
|
forEach.call(AriaPropertyNames, propName => {
|
350
351
|
const attrName = StringToLowerCase.call(StringReplace.call(propName, /^aria/, () => 'aria-'));
|
352
|
+
// These type assertions are because the map types are a 1:1 mapping of ariaX to aria-x.
|
353
|
+
// TypeScript knows we have one of ariaX | ariaY and one of aria-x | aria-y, and tries to
|
354
|
+
// prevent us from doing ariaX: aria-y, but we that it's safe.
|
351
355
|
AriaAttrNameToPropNameMap[attrName] = propName;
|
352
356
|
AriaPropNameToAttrNameMap[propName] = attrName;
|
353
357
|
});
|
@@ -371,6 +375,7 @@ LWR.define('lwc/v/7_2_1', ['exports'], (function (exports) { 'use strict';
|
|
371
375
|
const KEY__SHADOW_TOKEN = '$shadowToken$';
|
372
376
|
const KEY__SYNTHETIC_MODE = '$$lwc-synthetic-mode';
|
373
377
|
const KEY__SCOPED_CSS = '$scoped$';
|
378
|
+
const KEY__NATIVE_ONLY_CSS = '$nativeOnly$';
|
374
379
|
const KEY__NATIVE_GET_ELEMENT_BY_ID = '$nativeGetElementById$';
|
375
380
|
const KEY__NATIVE_QUERY_SELECTOR_ALL = '$nativeQuerySelectorAll$';
|
376
381
|
const XML_NAMESPACE = 'http://www.w3.org/XML/1998/namespace';
|
@@ -446,9 +451,81 @@ LWR.define('lwc/v/7_2_1', ['exports'], (function (exports) { 'use strict';
|
|
446
451
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
447
452
|
*/
|
448
453
|
// Increment whenever the LWC template compiler changes
|
449
|
-
const LWC_VERSION = "
|
454
|
+
const LWC_VERSION = "8.9.0";
|
450
455
|
const LWC_VERSION_COMMENT_REGEX = /\/\*LWC compiler v([\d.]+)\*\/\s*}/;
|
451
|
-
|
456
|
+
|
457
|
+
/*
|
458
|
+
* Copyright (c) 2024, Salesforce, Inc.
|
459
|
+
* All rights reserved.
|
460
|
+
* SPDX-License-Identifier: MIT
|
461
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
462
|
+
*/
|
463
|
+
let hooksAreSet = false;
|
464
|
+
/**
|
465
|
+
* EXPERIMENTAL: This function acts like a hook for Lightning Locker Service and other similar
|
466
|
+
* libraries to sanitize HTML content. This hook process the content passed via the template to
|
467
|
+
* lwc:inner-html directive.
|
468
|
+
* It is meant to be overridden via `setHooks`; it throws an error by default.
|
469
|
+
*/
|
470
|
+
let sanitizeHtmlContent = () => {
|
471
|
+
// locker-service patches this function during runtime to sanitize HTML content.
|
472
|
+
throw new Error('sanitizeHtmlContent hook must be implemented.');
|
473
|
+
};
|
474
|
+
function setHooks(hooks) {
|
475
|
+
isFalse$1(hooksAreSet, 'Hooks are already overridden, only one definition is allowed.');
|
476
|
+
hooksAreSet = true;
|
477
|
+
sanitizeHtmlContent = hooks.sanitizeHtmlContent;
|
478
|
+
}
|
479
|
+
const DECLARATION_DELIMITER = /;(?![^(]*\))/g;
|
480
|
+
const PROPERTY_DELIMITER = /:(.+)/s; // `/s` (dotAll) required to match styles across newlines, e.g. `color: \n red;`
|
481
|
+
// Borrowed from Vue template compiler.
|
482
|
+
// https://github.com/vuejs/vue/blob/531371b818b0e31a989a06df43789728f23dc4e8/src/platforms/web/util/style.js#L5-L16
|
483
|
+
function parseStyleText(cssText) {
|
484
|
+
const styleMap = {};
|
485
|
+
const declarations = cssText.split(DECLARATION_DELIMITER);
|
486
|
+
for (const declaration of declarations) {
|
487
|
+
if (declaration) {
|
488
|
+
const [prop, value] = declaration.split(PROPERTY_DELIMITER);
|
489
|
+
if (prop !== undefined && value !== undefined) {
|
490
|
+
styleMap[prop.trim()] = value.trim();
|
491
|
+
}
|
492
|
+
}
|
493
|
+
}
|
494
|
+
return styleMap;
|
495
|
+
}
|
496
|
+
function flattenStylesheets(stylesheets) {
|
497
|
+
const list = [];
|
498
|
+
for (const stylesheet of stylesheets) {
|
499
|
+
if (!isArray$1(stylesheet)) {
|
500
|
+
list.push(stylesheet);
|
501
|
+
} else {
|
502
|
+
list.push(...flattenStylesheets(stylesheet));
|
503
|
+
}
|
504
|
+
}
|
505
|
+
return list;
|
506
|
+
}
|
507
|
+
|
508
|
+
/*
|
509
|
+
* Copyright (c) 2024, salesforce.com, inc.
|
510
|
+
* All rights reserved.
|
511
|
+
* SPDX-License-Identifier: MIT
|
512
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
513
|
+
*/
|
514
|
+
let trustedSignals;
|
515
|
+
function setTrustedSignalSet(signals) {
|
516
|
+
isFalse$1(trustedSignals, 'Trusted Signal Set is already set!');
|
517
|
+
trustedSignals = signals;
|
518
|
+
}
|
519
|
+
function isTrustedSignal(target) {
|
520
|
+
if (!trustedSignals) {
|
521
|
+
// The runtime didn't set a trustedSignals set
|
522
|
+
// this check should only be performed for runtimes that care about filtering signals to track
|
523
|
+
// our default behavior should be to track all signals
|
524
|
+
return true;
|
525
|
+
}
|
526
|
+
return trustedSignals.has(target);
|
527
|
+
}
|
528
|
+
/** version: 8.9.0 */
|
452
529
|
|
453
530
|
/**
|
454
531
|
* Copyright (c) 2024 Salesforce, Inc.
|
@@ -535,7 +612,7 @@ LWR.define('lwc/v/7_2_1', ['exports'], (function (exports) { 'use strict';
|
|
535
612
|
setFeatureFlag(name, value);
|
536
613
|
}
|
537
614
|
}
|
538
|
-
/** version:
|
615
|
+
/** version: 8.9.0 */
|
539
616
|
|
540
617
|
/**
|
541
618
|
* Copyright (c) 2024 Salesforce, Inc.
|
@@ -686,7 +763,7 @@ LWR.define('lwc/v/7_2_1', ['exports'], (function (exports) { 'use strict';
|
|
686
763
|
}
|
687
764
|
alreadyLoggedMessages.add(msg);
|
688
765
|
}
|
689
|
-
// In
|
766
|
+
// In Vitest tests, reduce the warning and error verbosity by not printing the callstack
|
690
767
|
if (process.env.NODE_ENV === 'test') {
|
691
768
|
/* eslint-disable-next-line no-console */
|
692
769
|
console[method](msg);
|
@@ -710,7 +787,201 @@ LWR.define('lwc/v/7_2_1', ['exports'], (function (exports) { 'use strict';
|
|
710
787
|
}
|
711
788
|
|
712
789
|
/*
|
713
|
-
* Copyright (c)
|
790
|
+
* Copyright (c) 2018, salesforce.com, inc.
|
791
|
+
* All rights reserved.
|
792
|
+
* SPDX-License-Identifier: MIT
|
793
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
794
|
+
*/
|
795
|
+
let nextTickCallbackQueue = [];
|
796
|
+
const SPACE_CHAR = 32;
|
797
|
+
const EmptyObject = seal(create(null));
|
798
|
+
const EmptyArray = seal([]);
|
799
|
+
function flushCallbackQueue() {
|
800
|
+
if (process.env.NODE_ENV !== 'production') {
|
801
|
+
if (nextTickCallbackQueue.length === 0) {
|
802
|
+
throw new Error(`Internal Error: If callbackQueue is scheduled, it is because there must be at least one callback on this pending queue.`);
|
803
|
+
}
|
804
|
+
}
|
805
|
+
const callbacks = nextTickCallbackQueue;
|
806
|
+
nextTickCallbackQueue = []; // reset to a new queue
|
807
|
+
for (let i = 0, len = callbacks.length; i < len; i += 1) {
|
808
|
+
callbacks[i]();
|
809
|
+
}
|
810
|
+
}
|
811
|
+
function addCallbackToNextTick(callback) {
|
812
|
+
if (process.env.NODE_ENV !== 'production') {
|
813
|
+
if (!isFunction$1(callback)) {
|
814
|
+
throw new Error(`Internal Error: addCallbackToNextTick() can only accept a function callback`);
|
815
|
+
}
|
816
|
+
}
|
817
|
+
if (nextTickCallbackQueue.length === 0) {
|
818
|
+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
819
|
+
Promise.resolve().then(flushCallbackQueue);
|
820
|
+
}
|
821
|
+
ArrayPush$1.call(nextTickCallbackQueue, callback);
|
822
|
+
}
|
823
|
+
function guid() {
|
824
|
+
function s4() {
|
825
|
+
return Math.floor((1 + Math.random()) * 0x10000).toString(16).substring(1);
|
826
|
+
}
|
827
|
+
return s4() + s4() + '-' + s4() + '-' + s4() + '-' + s4() + '-' + s4() + s4() + s4();
|
828
|
+
}
|
829
|
+
// Make a shallow copy of an object but omit the given key
|
830
|
+
function cloneAndOmitKey(object, keyToOmit) {
|
831
|
+
const result = {};
|
832
|
+
for (const key of keys(object)) {
|
833
|
+
if (key !== keyToOmit) {
|
834
|
+
result[key] = object[key];
|
835
|
+
}
|
836
|
+
}
|
837
|
+
return result;
|
838
|
+
}
|
839
|
+
// Throw an error if we're running in prod mode. Ensures code is truly removed from prod mode.
|
840
|
+
function assertNotProd() {
|
841
|
+
/* istanbul ignore if */
|
842
|
+
if (process.env.NODE_ENV === 'production') {
|
843
|
+
// this method should never leak to prod
|
844
|
+
throw new ReferenceError();
|
845
|
+
}
|
846
|
+
}
|
847
|
+
function shouldBeFormAssociated(Ctor) {
|
848
|
+
const ctorFormAssociated = Boolean(Ctor.formAssociated);
|
849
|
+
const apiVersion = getComponentAPIVersion(Ctor);
|
850
|
+
const apiFeatureEnabled = isAPIFeatureEnabled(7 /* APIFeature.ENABLE_ELEMENT_INTERNALS_AND_FACE */, apiVersion);
|
851
|
+
if (process.env.NODE_ENV !== 'production' && ctorFormAssociated && !apiFeatureEnabled) {
|
852
|
+
const tagName = getComponentRegisteredName(Ctor);
|
853
|
+
logWarnOnce(`Component <${tagName}> set static formAssociated to true, but form ` + `association is not enabled because the API version is ${apiVersion}. To enable form association, ` + `update the LWC component API version to 61 or above. https://lwc.dev/guide/versioning`);
|
854
|
+
}
|
855
|
+
return ctorFormAssociated && apiFeatureEnabled;
|
856
|
+
}
|
857
|
+
|
858
|
+
/*
|
859
|
+
* Copyright (c) 2024, Salesforce, Inc.
|
860
|
+
* All rights reserved.
|
861
|
+
* SPDX-License-Identifier: MIT
|
862
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
863
|
+
*/
|
864
|
+
//
|
865
|
+
// Do additional mutation tracking for DevTools performance profiling, in dev mode only.
|
866
|
+
//
|
867
|
+
const reactiveObserversToVMs = new WeakMap();
|
868
|
+
const targetsToPropertyKeys = new WeakMap();
|
869
|
+
let mutationLogs = [];
|
870
|
+
// Create a human-readable member access notation like `obj.foo` or `arr[1]`,
|
871
|
+
// handling edge cases like `obj[Symbol("bar")]` and `obj["spaces here"]`
|
872
|
+
function toPrettyMemberNotation(parent, child) {
|
873
|
+
if (isUndefined$1(parent)) {
|
874
|
+
// Bare prop, just stringify the child
|
875
|
+
return toString$1(child);
|
876
|
+
} else if (!isString(child)) {
|
877
|
+
// Symbol/number, e.g. `obj[Symbol("foo")]` or `obj[1234]`
|
878
|
+
return `${toString$1(parent)}[${toString$1(child)}]`;
|
879
|
+
} else if (/^\w+$/.test(child)) {
|
880
|
+
// Dot-notation-safe string, e.g. `obj.foo`
|
881
|
+
return `${toString$1(parent)}.${child}`;
|
882
|
+
} else {
|
883
|
+
// Bracket-notation-requiring string, e.g. `obj["prop with spaces"]`
|
884
|
+
return `${toString$1(parent)}[${JSON.stringify(child)}]`;
|
885
|
+
}
|
886
|
+
}
|
887
|
+
function safelyCallGetter(target, key) {
|
888
|
+
// Arbitrary getters can throw. We don't want to throw an error just due to dev-mode-only mutation tracking
|
889
|
+
// (which is only used for performance debugging) so ignore errors here.
|
890
|
+
try {
|
891
|
+
return target[key];
|
892
|
+
} catch (_err) {
|
893
|
+
/* ignore */
|
894
|
+
}
|
895
|
+
}
|
896
|
+
/**
|
897
|
+
* Flush all the logs we've written so far and return the current logs.
|
898
|
+
*/
|
899
|
+
function getAndFlushMutationLogs() {
|
900
|
+
assertNotProd();
|
901
|
+
const result = mutationLogs;
|
902
|
+
mutationLogs = [];
|
903
|
+
return result;
|
904
|
+
}
|
905
|
+
/**
|
906
|
+
* Log a new mutation for this reactive observer.
|
907
|
+
* @param reactiveObserver - relevant ReactiveObserver
|
908
|
+
* @param target - target object that is being observed
|
909
|
+
* @param key - key (property) that was mutated
|
910
|
+
*/
|
911
|
+
function logMutation(reactiveObserver, target, key) {
|
912
|
+
assertNotProd();
|
913
|
+
const parentKey = targetsToPropertyKeys.get(target);
|
914
|
+
const vm = reactiveObserversToVMs.get(reactiveObserver);
|
915
|
+
/* istanbul ignore if */
|
916
|
+
if (isUndefined$1(vm)) {
|
917
|
+
// VM should only be undefined in Vitest tests, where a reactive observer is not always associated with a VM
|
918
|
+
// because the unit tests just create Reactive Observers on-the-fly.
|
919
|
+
// Note we could explicitly target Vitest with `process.env.NODE_ENV === 'test'`, but then that would also
|
920
|
+
// affect our downstream consumers' Jest/Vitest tests, and we don't want to throw an error just for a logger.
|
921
|
+
if (process.env.NODE_ENV === 'test-karma-lwc') {
|
922
|
+
throw new Error('The VM should always be defined except possibly in unit tests');
|
923
|
+
}
|
924
|
+
} else {
|
925
|
+
const prop = toPrettyMemberNotation(parentKey, key);
|
926
|
+
ArrayPush$1.call(mutationLogs, {
|
927
|
+
vm,
|
928
|
+
prop
|
929
|
+
});
|
930
|
+
}
|
931
|
+
}
|
932
|
+
/**
|
933
|
+
* Flush logs associated with a given VM.
|
934
|
+
* @param vm - given VM
|
935
|
+
*/
|
936
|
+
function flushMutationLogsForVM(vm) {
|
937
|
+
assertNotProd();
|
938
|
+
mutationLogs = ArrayFilter.call(mutationLogs, log => log.vm !== vm);
|
939
|
+
}
|
940
|
+
/**
|
941
|
+
* Mark this ReactiveObserver as related to this VM. This is only needed for mutation tracking in dev mode.
|
942
|
+
* @param reactiveObserver
|
943
|
+
* @param vm
|
944
|
+
*/
|
945
|
+
function associateReactiveObserverWithVM(reactiveObserver, vm) {
|
946
|
+
assertNotProd();
|
947
|
+
reactiveObserversToVMs.set(reactiveObserver, vm);
|
948
|
+
}
|
949
|
+
/**
|
950
|
+
* Deeply track all objects in a target and associate with a given key.
|
951
|
+
* @param key - key associated with the object in the component
|
952
|
+
* @param target - tracked target object
|
953
|
+
*/
|
954
|
+
function trackTargetForMutationLogging(key, target) {
|
955
|
+
assertNotProd();
|
956
|
+
if (targetsToPropertyKeys.has(target)) {
|
957
|
+
// Guard against recursive objects - don't traverse forever
|
958
|
+
return;
|
959
|
+
}
|
960
|
+
if (isObject(target) && !isNull(target)) {
|
961
|
+
// only track non-primitives; others are invalid as WeakMap keys
|
962
|
+
targetsToPropertyKeys.set(target, key);
|
963
|
+
// Deeply traverse arrays and objects to track every object within
|
964
|
+
if (isArray$1(target)) {
|
965
|
+
for (let i = 0; i < target.length; i++) {
|
966
|
+
trackTargetForMutationLogging(toPrettyMemberNotation(key, i), safelyCallGetter(target, i));
|
967
|
+
}
|
968
|
+
} else {
|
969
|
+
// Track only own property names and symbols (including non-enumerated)
|
970
|
+
// This is consistent with what observable-membrane does:
|
971
|
+
// https://github.com/salesforce/observable-membrane/blob/b85417f/src/base-handler.ts#L142-L143
|
972
|
+
// Note this code path is very hot, hence doing two separate for-loops rather than creating a new array.
|
973
|
+
for (const prop of getOwnPropertyNames$1(target)) {
|
974
|
+
trackTargetForMutationLogging(toPrettyMemberNotation(key, prop), safelyCallGetter(target, prop));
|
975
|
+
}
|
976
|
+
for (const prop of getOwnPropertySymbols$1(target)) {
|
977
|
+
trackTargetForMutationLogging(toPrettyMemberNotation(key, prop), safelyCallGetter(target, prop));
|
978
|
+
}
|
979
|
+
}
|
980
|
+
}
|
981
|
+
}
|
982
|
+
|
983
|
+
/*
|
984
|
+
* Copyright (c) 2024, Salesforce, Inc.
|
714
985
|
* All rights reserved.
|
715
986
|
* SPDX-License-Identifier: MIT
|
716
987
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
@@ -733,6 +1004,9 @@ LWR.define('lwc/v/7_2_1', ['exports'], (function (exports) { 'use strict';
|
|
733
1004
|
if (!isUndefined$1(reactiveObservers)) {
|
734
1005
|
for (let i = 0, len = reactiveObservers.length; i < len; i += 1) {
|
735
1006
|
const ro = reactiveObservers[i];
|
1007
|
+
if (process.env.NODE_ENV !== 'production') {
|
1008
|
+
logMutation(ro, target, key);
|
1009
|
+
}
|
736
1010
|
ro.notify();
|
737
1011
|
}
|
738
1012
|
}
|
@@ -906,7 +1180,7 @@ LWR.define('lwc/v/7_2_1', ['exports'], (function (exports) { 'use strict';
|
|
906
1180
|
// We check check the following to ensure re-render is subscribed at the correct time.
|
907
1181
|
// 1. The template is currently being rendered (there is a template reactive observer)
|
908
1182
|
// 2. There was a call to a getter to access the signal (happens during vnode generation)
|
909
|
-
if (lwcRuntimeFlags.ENABLE_EXPERIMENTAL_SIGNALS && isObject(target) && !isNull(target) && 'value' in target && 'subscribe' in target && isFunction$1(target.subscribe) &&
|
1183
|
+
if (lwcRuntimeFlags.ENABLE_EXPERIMENTAL_SIGNALS && isObject(target) && !isNull(target) && 'value' in target && 'subscribe' in target && isFunction$1(target.subscribe) && isTrustedSignal(target) &&
|
910
1184
|
// Only subscribe if a template is being rendered by the engine
|
911
1185
|
tro.isObserving()) {
|
912
1186
|
// Subscribe the template reactive observer's notify method, which will mark the vm as dirty and schedule hydration.
|
@@ -918,103 +1192,6 @@ LWR.define('lwc/v/7_2_1', ['exports'], (function (exports) { 'use strict';
|
|
918
1192
|
return new ReactiveObserver(callback);
|
919
1193
|
}
|
920
1194
|
|
921
|
-
/*
|
922
|
-
* Copyright (c) 2018, salesforce.com, inc.
|
923
|
-
* All rights reserved.
|
924
|
-
* SPDX-License-Identifier: MIT
|
925
|
-
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
926
|
-
*/
|
927
|
-
let nextTickCallbackQueue = [];
|
928
|
-
const SPACE_CHAR = 32;
|
929
|
-
const EmptyObject = seal(create(null));
|
930
|
-
const EmptyArray = seal([]);
|
931
|
-
function flushCallbackQueue() {
|
932
|
-
if (process.env.NODE_ENV !== 'production') {
|
933
|
-
if (nextTickCallbackQueue.length === 0) {
|
934
|
-
throw new Error(`Internal Error: If callbackQueue is scheduled, it is because there must be at least one callback on this pending queue.`);
|
935
|
-
}
|
936
|
-
}
|
937
|
-
const callbacks = nextTickCallbackQueue;
|
938
|
-
nextTickCallbackQueue = []; // reset to a new queue
|
939
|
-
for (let i = 0, len = callbacks.length; i < len; i += 1) {
|
940
|
-
callbacks[i]();
|
941
|
-
}
|
942
|
-
}
|
943
|
-
function addCallbackToNextTick(callback) {
|
944
|
-
if (process.env.NODE_ENV !== 'production') {
|
945
|
-
if (!isFunction$1(callback)) {
|
946
|
-
throw new Error(`Internal Error: addCallbackToNextTick() can only accept a function callback`);
|
947
|
-
}
|
948
|
-
}
|
949
|
-
if (nextTickCallbackQueue.length === 0) {
|
950
|
-
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
951
|
-
Promise.resolve().then(flushCallbackQueue);
|
952
|
-
}
|
953
|
-
ArrayPush$1.call(nextTickCallbackQueue, callback);
|
954
|
-
}
|
955
|
-
function guid() {
|
956
|
-
function s4() {
|
957
|
-
return Math.floor((1 + Math.random()) * 0x10000).toString(16).substring(1);
|
958
|
-
}
|
959
|
-
return s4() + s4() + '-' + s4() + '-' + s4() + '-' + s4() + '-' + s4() + s4() + s4();
|
960
|
-
}
|
961
|
-
// Borrowed from Vue template compiler.
|
962
|
-
// https://github.com/vuejs/vue/blob/531371b818b0e31a989a06df43789728f23dc4e8/src/platforms/web/util/style.js#L5-L16
|
963
|
-
const DECLARATION_DELIMITER = /;(?![^(]*\))/g;
|
964
|
-
const PROPERTY_DELIMITER = /:(.+)/;
|
965
|
-
function parseStyleText(cssText) {
|
966
|
-
const styleMap = {};
|
967
|
-
const declarations = cssText.split(DECLARATION_DELIMITER);
|
968
|
-
for (const declaration of declarations) {
|
969
|
-
if (declaration) {
|
970
|
-
const [prop, value] = declaration.split(PROPERTY_DELIMITER);
|
971
|
-
if (prop !== undefined && value !== undefined) {
|
972
|
-
styleMap[prop.trim()] = value.trim();
|
973
|
-
}
|
974
|
-
}
|
975
|
-
}
|
976
|
-
return styleMap;
|
977
|
-
}
|
978
|
-
// Make a shallow copy of an object but omit the given key
|
979
|
-
function cloneAndOmitKey(object, keyToOmit) {
|
980
|
-
const result = {};
|
981
|
-
for (const key of keys(object)) {
|
982
|
-
if (key !== keyToOmit) {
|
983
|
-
result[key] = object[key];
|
984
|
-
}
|
985
|
-
}
|
986
|
-
return result;
|
987
|
-
}
|
988
|
-
function flattenStylesheets(stylesheets) {
|
989
|
-
const list = [];
|
990
|
-
for (const stylesheet of stylesheets) {
|
991
|
-
if (!isArray$1(stylesheet)) {
|
992
|
-
list.push(stylesheet);
|
993
|
-
} else {
|
994
|
-
list.push(...flattenStylesheets(stylesheet));
|
995
|
-
}
|
996
|
-
}
|
997
|
-
return list;
|
998
|
-
}
|
999
|
-
// Throw an error if we're running in prod mode. Ensures code is truly removed from prod mode.
|
1000
|
-
function assertNotProd() {
|
1001
|
-
/* istanbul ignore if */
|
1002
|
-
if (process.env.NODE_ENV === 'production') {
|
1003
|
-
// this method should never leak to prod
|
1004
|
-
throw new ReferenceError();
|
1005
|
-
}
|
1006
|
-
}
|
1007
|
-
function shouldBeFormAssociated(Ctor) {
|
1008
|
-
const ctorFormAssociated = Boolean(Ctor.formAssociated);
|
1009
|
-
const apiVersion = getComponentAPIVersion(Ctor);
|
1010
|
-
const apiFeatureEnabled = isAPIFeatureEnabled(7 /* APIFeature.ENABLE_ELEMENT_INTERNALS_AND_FACE */, apiVersion);
|
1011
|
-
if (process.env.NODE_ENV !== 'production' && ctorFormAssociated && !apiFeatureEnabled) {
|
1012
|
-
const tagName = getComponentRegisteredName(Ctor);
|
1013
|
-
logWarnOnce(`Component <${tagName}> set static formAssociated to true, but form ` + `association is not enabled because the API version is ${apiVersion}. To enable form association, ` + `update the LWC component API version to 61 or above. https://lwc.dev/guide/versioning`);
|
1014
|
-
}
|
1015
|
-
return ctorFormAssociated && apiFeatureEnabled;
|
1016
|
-
}
|
1017
|
-
|
1018
1195
|
/*
|
1019
1196
|
* Copyright (c) 2020, salesforce.com, inc.
|
1020
1197
|
* All rights reserved.
|
@@ -1070,8 +1247,9 @@ LWR.define('lwc/v/7_2_1', ['exports'], (function (exports) { 'use strict';
|
|
1070
1247
|
return this.getAttribute(attrName);
|
1071
1248
|
},
|
1072
1249
|
set(newValue) {
|
1073
|
-
// TODO [#3284]:
|
1074
|
-
//
|
1250
|
+
// TODO [#3284]: According to the spec, IDL nullable type values
|
1251
|
+
// (null and undefined) should remove the attribute; however, we
|
1252
|
+
// only do so in the case of null for historical reasons.
|
1075
1253
|
// See also https://github.com/w3c/aria/issues/1858
|
1076
1254
|
if (isNull(newValue)) {
|
1077
1255
|
this.removeAttribute(attrName);
|
@@ -1085,6 +1263,8 @@ LWR.define('lwc/v/7_2_1', ['exports'], (function (exports) { 'use strict';
|
|
1085
1263
|
};
|
1086
1264
|
}
|
1087
1265
|
}
|
1266
|
+
// Add descriptors for ARIA attributes
|
1267
|
+
for (const [attrName, propName] of entries(AriaAttrNameToPropNameMap)) {}
|
1088
1268
|
|
1089
1269
|
/*
|
1090
1270
|
* Copyright (c) 2018, salesforce.com, inc.
|
@@ -1719,7 +1899,7 @@ LWR.define('lwc/v/7_2_1', ['exports'], (function (exports) { 'use strict';
|
|
1719
1899
|
valueMutated(originalTarget, key);
|
1720
1900
|
return true;
|
1721
1901
|
}
|
1722
|
-
/*LWC compiler
|
1902
|
+
/*LWC compiler v8.9.0*/
|
1723
1903
|
}
|
1724
1904
|
const getterMap = new WeakMap();
|
1725
1905
|
const setterMap = new WeakMap();
|
@@ -1812,7 +1992,7 @@ LWR.define('lwc/v/7_2_1', ['exports'], (function (exports) { 'use strict';
|
|
1812
1992
|
/* istanbul ignore next */
|
1813
1993
|
return false;
|
1814
1994
|
}
|
1815
|
-
/*LWC compiler
|
1995
|
+
/*LWC compiler v8.9.0*/
|
1816
1996
|
}
|
1817
1997
|
function extract(objectOrArray) {
|
1818
1998
|
if (isArray(objectOrArray)) {
|
@@ -2041,7 +2221,7 @@ LWR.define('lwc/v/7_2_1', ['exports'], (function (exports) { 'use strict';
|
|
2041
2221
|
} = elm;
|
2042
2222
|
try {
|
2043
2223
|
return await (await fetch(href)).text();
|
2044
|
-
} catch (
|
2224
|
+
} catch (_err) {
|
2045
2225
|
logWarnOnce(`Ignoring cross-origin stylesheet in migrate mode: ${href}`);
|
2046
2226
|
// ignore errors with cross-origin stylesheets - nothing we can do for those
|
2047
2227
|
return '';
|
@@ -2811,6 +2991,9 @@ LWR.define('lwc/v/7_2_1', ['exports'], (function (exports) { 'use strict';
|
|
2811
2991
|
});
|
2812
2992
|
}
|
2813
2993
|
});
|
2994
|
+
if (process.env.NODE_ENV !== 'production') {
|
2995
|
+
associateReactiveObserverWithVM(ro, getAssociatedVM(component));
|
2996
|
+
}
|
2814
2997
|
const computeConfigAndUpdate = () => {
|
2815
2998
|
let config;
|
2816
2999
|
ro.observe(() => config = configCallback(component));
|
@@ -3092,7 +3275,9 @@ LWR.define('lwc/v/7_2_1', ['exports'], (function (exports) { 'use strict';
|
|
3092
3275
|
* SPDX-License-Identifier: MIT
|
3093
3276
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
3094
3277
|
*/
|
3095
|
-
function track(target
|
3278
|
+
function track(target,
|
3279
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
3280
|
+
context) {
|
3096
3281
|
if (arguments.length === 1) {
|
3097
3282
|
return getReactiveProxy(target);
|
3098
3283
|
}
|
@@ -3121,6 +3306,9 @@ LWR.define('lwc/v/7_2_1', ['exports'], (function (exports) { 'use strict';
|
|
3121
3306
|
}
|
3122
3307
|
}
|
3123
3308
|
const reactiveOrAnyValue = getReactiveProxy(newValue);
|
3309
|
+
if (process.env.NODE_ENV !== 'production') {
|
3310
|
+
trackTargetForMutationLogging(key, newValue);
|
3311
|
+
}
|
3124
3312
|
updateComponentValue(vm, key, reactiveOrAnyValue);
|
3125
3313
|
},
|
3126
3314
|
enumerable: true,
|
@@ -3565,7 +3753,7 @@ LWR.define('lwc/v/7_2_1', ['exports'], (function (exports) { 'use strict';
|
|
3565
3753
|
}
|
3566
3754
|
function HTMLBridgeElementFactory(SuperClass, publicProperties, methods, observedFields, proto, hasCustomSuperClass) {
|
3567
3755
|
const HTMLBridgeElement = class extends SuperClass {
|
3568
|
-
/*LWC compiler
|
3756
|
+
/*LWC compiler v8.9.0*/
|
3569
3757
|
};
|
3570
3758
|
// generating the hash table for attributes to avoid duplicate fields and facilitate validation
|
3571
3759
|
// and false positives in case of inheritance.
|
@@ -3792,7 +3980,8 @@ LWR.define('lwc/v/7_2_1', ['exports'], (function (exports) { 'use strict';
|
|
3792
3980
|
// Set the new styling token on the host element
|
3793
3981
|
if (!isUndefined$1(newToken)) {
|
3794
3982
|
if (hasScopedStyles) {
|
3795
|
-
|
3983
|
+
const hostScopeTokenClass = makeHostToken(newToken);
|
3984
|
+
getClassList(elm).add(hostScopeTokenClass);
|
3796
3985
|
newHasTokenInClass = true;
|
3797
3986
|
}
|
3798
3987
|
if (isSyntheticShadow) {
|
@@ -3827,21 +4016,26 @@ LWR.define('lwc/v/7_2_1', ['exports'], (function (exports) { 'use strict';
|
|
3827
4016
|
// the stylesheet, while internally, we have a replacement for it.
|
3828
4017
|
stylesheet = getStyleOrSwappedStyle(stylesheet);
|
3829
4018
|
}
|
3830
|
-
const isScopedCss = stylesheet[KEY__SCOPED_CSS];
|
3831
|
-
|
4019
|
+
const isScopedCss = isTrue(stylesheet[KEY__SCOPED_CSS]);
|
4020
|
+
const isNativeOnlyCss = isTrue(stylesheet[KEY__NATIVE_ONLY_CSS]);
|
4021
|
+
const {
|
4022
|
+
renderMode,
|
4023
|
+
shadowMode
|
4024
|
+
} = vm;
|
4025
|
+
if (lwcRuntimeFlags.DISABLE_LIGHT_DOM_UNSCOPED_CSS && !isScopedCss && renderMode === 0 /* RenderMode.Light */) {
|
3832
4026
|
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');
|
3833
4027
|
continue;
|
3834
4028
|
}
|
3835
4029
|
// Apply the scope token only if the stylesheet itself is scoped, or if we're rendering synthetic shadow.
|
3836
|
-
const scopeToken = isScopedCss ||
|
4030
|
+
const scopeToken = isScopedCss || shadowMode === 1 /* ShadowMode.Synthetic */ && renderMode === 1 /* RenderMode.Shadow */ ? stylesheetToken : undefined;
|
3837
4031
|
// Use the actual `:host` selector if we're rendering global CSS for light DOM, or if we're rendering
|
3838
4032
|
// native shadow DOM. Synthetic shadow DOM never uses `:host`.
|
3839
|
-
const useActualHostSelector =
|
4033
|
+
const useActualHostSelector = renderMode === 0 /* RenderMode.Light */ ? !isScopedCss : shadowMode === 0 /* ShadowMode.Native */;
|
3840
4034
|
// Use the native :dir() pseudoclass only in native shadow DOM. Otherwise, in synthetic shadow,
|
3841
4035
|
// we use an attribute selector on the host to simulate :dir().
|
3842
4036
|
let useNativeDirPseudoclass;
|
3843
|
-
if (
|
3844
|
-
useNativeDirPseudoclass =
|
4037
|
+
if (renderMode === 1 /* RenderMode.Shadow */) {
|
4038
|
+
useNativeDirPseudoclass = shadowMode === 0 /* ShadowMode.Native */;
|
3845
4039
|
} else {
|
3846
4040
|
// Light DOM components should only render `[dir]` if they're inside of a synthetic shadow root.
|
3847
4041
|
// At the top level (root is null) or inside of a native shadow root, they should use `:dir()`.
|
@@ -3851,7 +4045,15 @@ LWR.define('lwc/v/7_2_1', ['exports'], (function (exports) { 'use strict';
|
|
3851
4045
|
}
|
3852
4046
|
useNativeDirPseudoclass = isNull(root) || root.shadowMode === 0 /* ShadowMode.Native */;
|
3853
4047
|
}
|
3854
|
-
|
4048
|
+
let cssContent;
|
4049
|
+
if (isNativeOnlyCss && renderMode === 1 /* RenderMode.Shadow */ && shadowMode === 1 /* ShadowMode.Synthetic */) {
|
4050
|
+
// Native-only (i.e. disableSyntheticShadowSupport) CSS should be ignored entirely
|
4051
|
+
// in synthetic shadow. It's fine to use in either native shadow or light DOM, but in
|
4052
|
+
// synthetic shadow it wouldn't be scoped properly and so should be ignored.
|
4053
|
+
cssContent = '/* ignored native-only CSS */';
|
4054
|
+
} else {
|
4055
|
+
cssContent = stylesheet(scopeToken, useActualHostSelector, useNativeDirPseudoclass);
|
4056
|
+
}
|
3855
4057
|
if (process.env.NODE_ENV !== 'production') {
|
3856
4058
|
linkStylesheetToCssContentInDevMode(stylesheet, cssContent);
|
3857
4059
|
}
|
@@ -3913,25 +4115,6 @@ LWR.define('lwc/v/7_2_1', ['exports'], (function (exports) { 'use strict';
|
|
3913
4115
|
} = owner;
|
3914
4116
|
return context.hasScopedStyles && (legacy ? cmpTemplate?.legacyStylesheetToken : cmpTemplate?.stylesheetToken) || null;
|
3915
4117
|
}
|
3916
|
-
/**
|
3917
|
-
* This function returns the host style token for a custom element if it
|
3918
|
-
* exists. Otherwise it returns null.
|
3919
|
-
*
|
3920
|
-
* A host style token is applied to the component if scoped styles are used.
|
3921
|
-
* @param vnode
|
3922
|
-
*/
|
3923
|
-
function getStylesheetTokenHost(vnode) {
|
3924
|
-
const {
|
3925
|
-
template
|
3926
|
-
} = getComponentInternalDef(vnode.ctor);
|
3927
|
-
const {
|
3928
|
-
vm
|
3929
|
-
} = vnode;
|
3930
|
-
const {
|
3931
|
-
stylesheetToken
|
3932
|
-
} = template;
|
3933
|
-
return !isUndefined$1(stylesheetToken) && computeHasScopedStyles(template, vm) ? makeHostToken(stylesheetToken) : null;
|
3934
|
-
}
|
3935
4118
|
function getNearestNativeShadowComponent(vm) {
|
3936
4119
|
const owner = getNearestShadowComponent(vm);
|
3937
4120
|
if (!isNull(owner) && owner.shadowMode === 1 /* ShadowMode.Synthetic */) {
|
@@ -4483,7 +4666,6 @@ LWR.define('lwc/v/7_2_1', ['exports'], (function (exports) { 'use strict';
|
|
4483
4666
|
return def.bridge;
|
4484
4667
|
}
|
4485
4668
|
const lightingElementDef = {
|
4486
|
-
ctor: LightningElement,
|
4487
4669
|
name: LightningElement.name,
|
4488
4670
|
props: lightningBasedDescriptors,
|
4489
4671
|
propsConfig: EmptyObject,
|
@@ -4572,6 +4754,69 @@ LWR.define('lwc/v/7_2_1', ['exports'], (function (exports) { 'use strict';
|
|
4572
4754
|
return vnode.type === 0 /* VStaticPartType.Text */;
|
4573
4755
|
}
|
4574
4756
|
|
4757
|
+
/*
|
4758
|
+
* Copyright (c) 2024, Salesforce, Inc.
|
4759
|
+
* All rights reserved.
|
4760
|
+
* SPDX-License-Identifier: MIT
|
4761
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
4762
|
+
*/
|
4763
|
+
const sanitizedHtmlContentSymbol = Symbol('lwc-get-sanitized-html-content');
|
4764
|
+
function isSanitizedHtmlContent(object) {
|
4765
|
+
return isObject(object) && !isNull(object) && sanitizedHtmlContentSymbol in object;
|
4766
|
+
}
|
4767
|
+
function unwrapIfNecessary(object) {
|
4768
|
+
return isSanitizedHtmlContent(object) ? object[sanitizedHtmlContentSymbol] : object;
|
4769
|
+
}
|
4770
|
+
/**
|
4771
|
+
* Wrap a pre-sanitized string designated for `.innerHTML` via `lwc:inner-html`
|
4772
|
+
* as an object with a Symbol that only we have access to.
|
4773
|
+
* @param sanitizedString
|
4774
|
+
* @returns SanitizedHtmlContent
|
4775
|
+
*/
|
4776
|
+
function createSanitizedHtmlContent(sanitizedString) {
|
4777
|
+
return create(null, {
|
4778
|
+
[sanitizedHtmlContentSymbol]: {
|
4779
|
+
value: sanitizedString,
|
4780
|
+
configurable: false,
|
4781
|
+
writable: false
|
4782
|
+
}
|
4783
|
+
});
|
4784
|
+
}
|
4785
|
+
/**
|
4786
|
+
* Safely call setProperty on an Element while handling any SanitizedHtmlContent objects correctly
|
4787
|
+
*
|
4788
|
+
* @param setProperty - renderer.setProperty
|
4789
|
+
* @param elm - Element
|
4790
|
+
* @param key - key to set
|
4791
|
+
* @param value - value to set
|
4792
|
+
*/
|
4793
|
+
function safelySetProperty(setProperty, elm, key, value) {
|
4794
|
+
// See W-16614337
|
4795
|
+
// we support setting innerHTML to `undefined` because it's inherently safe
|
4796
|
+
if ((key === 'innerHTML' || key === 'outerHTML') && !isUndefined$1(value)) {
|
4797
|
+
if (isSanitizedHtmlContent(value)) {
|
4798
|
+
// it's a SanitizedHtmlContent object
|
4799
|
+
setProperty(elm, key, value[sanitizedHtmlContentSymbol]);
|
4800
|
+
} else {
|
4801
|
+
// not a SanitizedHtmlContent object
|
4802
|
+
if (process.env.NODE_ENV !== 'production') {
|
4803
|
+
logWarn(`Cannot set property "${key}". Instead, use lwc:inner-html or lwc:dom-manual.`);
|
4804
|
+
}
|
4805
|
+
}
|
4806
|
+
} else {
|
4807
|
+
setProperty(elm, key, value);
|
4808
|
+
}
|
4809
|
+
}
|
4810
|
+
/**
|
4811
|
+
* Given two objects (likely either a string or a SanitizedHtmlContent object), return true if their
|
4812
|
+
* string values are equivalent.
|
4813
|
+
* @param first
|
4814
|
+
* @param second
|
4815
|
+
*/
|
4816
|
+
function isSanitizedHtmlContentEqual(first, second) {
|
4817
|
+
return unwrapIfNecessary(first) === unwrapIfNecessary(second);
|
4818
|
+
}
|
4819
|
+
|
4575
4820
|
/*
|
4576
4821
|
* Copyright (c) 2018, salesforce.com, inc.
|
4577
4822
|
* All rights reserved.
|
@@ -4611,7 +4856,7 @@ LWR.define('lwc/v/7_2_1', ['exports'], (function (exports) { 'use strict';
|
|
4611
4856
|
// Use kebabCaseToCamelCase directly because we don't want to set props like `ariaLabel` or `tabIndex`
|
4612
4857
|
// on a custom element versus just using the more reliable attribute format.
|
4613
4858
|
if (external && (propName = kebabCaseToCamelCase(key)) in elm) {
|
4614
|
-
setProperty
|
4859
|
+
safelySetProperty(setProperty, elm, propName, cur);
|
4615
4860
|
} else if (StringCharCodeAt.call(key, 3) === ColonCharCode) {
|
4616
4861
|
// Assume xml namespace
|
4617
4862
|
setAttribute(elm, key, cur, XML_NAMESPACE);
|
@@ -4699,7 +4944,7 @@ LWR.define('lwc/v/7_2_1', ['exports'], (function (exports) { 'use strict';
|
|
4699
4944
|
logWarn(`Unknown public property "${key}" of element <${elm.tagName.toLowerCase()}>. This is either a typo on the corresponding attribute "${htmlPropertyToAttribute(key)}", or the attribute does not exist in this browser or DOM implementation.`);
|
4700
4945
|
}
|
4701
4946
|
}
|
4702
|
-
setProperty
|
4947
|
+
safelySetProperty(setProperty, elm, key, cur);
|
4703
4948
|
}
|
4704
4949
|
}
|
4705
4950
|
}
|
@@ -6133,25 +6378,33 @@ LWR.define('lwc/v/7_2_1', ['exports'], (function (exports) { 'use strict';
|
|
6133
6378
|
} else {
|
6134
6379
|
// This block is for standard slots (non-scoped slots)
|
6135
6380
|
let clonedVNode;
|
6136
|
-
if (renderMode === 0 /* RenderMode.Light */ && isAPIFeatureEnabled(6 /* APIFeature.USE_LIGHT_DOM_SLOT_FORWARDING */, apiVersion) && (isVBaseElement(vnode) || isVStatic(vnode)) &&
|
6137
|
-
|
6138
|
-
|
6139
|
-
|
6140
|
-
//
|
6141
|
-
//
|
6142
|
-
|
6143
|
-
|
6144
|
-
|
6145
|
-
|
6146
|
-
|
6147
|
-
|
6148
|
-
|
6149
|
-
|
6150
|
-
|
6151
|
-
|
6152
|
-
|
6153
|
-
|
6154
|
-
|
6381
|
+
if (renderMode === 0 /* RenderMode.Light */ && isAPIFeatureEnabled(6 /* APIFeature.USE_LIGHT_DOM_SLOT_FORWARDING */, apiVersion) && (isVBaseElement(vnode) || isVStatic(vnode)) && vnode.slotAssignment !== data.slotAssignment) {
|
6382
|
+
// When the light DOM slot assignment (slot attribute) changes, we can't use the same reference
|
6383
|
+
// to the vnode because the current way the diffing algo works, it will replace the original
|
6384
|
+
// reference to the host element with a new one. This means the new element will be mounted and
|
6385
|
+
// immediately unmounted. Creating a copy of the vnode preserves a reference to the previous
|
6386
|
+
// host element.
|
6387
|
+
clonedVNode = {
|
6388
|
+
...vnode,
|
6389
|
+
slotAssignment: data.slotAssignment
|
6390
|
+
};
|
6391
|
+
// For disconnectedCallback to work correctly in synthetic lifecycle mode, we need to link the
|
6392
|
+
// current VM's velements to the clone, so that when the VM unmounts, the clone also unmounts.
|
6393
|
+
// Note this only applies to VCustomElements, since those are the elements that we manually need
|
6394
|
+
// to call disconnectedCallback for, when running in synthetic lifecycle mode.
|
6395
|
+
//
|
6396
|
+
// You might think it would make more sense to add the clonedVNode to the same velements array
|
6397
|
+
// as the original vnode's VM (i.e. `vnode.owner.velements`) rather than the current VM (i.e.
|
6398
|
+
// `vmBeingRendered.velements`), but this actually might not trigger disconnectedCallback
|
6399
|
+
// in synthetic lifecycle mode. The reason for this is that a reactivity change may cause
|
6400
|
+
// the slottable component to unmount, but _not_ the slotter component (see issue #4446).
|
6401
|
+
//
|
6402
|
+
// If this occurs, then the slottable component (i.e .this component we are rendering right
|
6403
|
+
// now) is the one that needs to own the clone. Whereas if a reactivity change higher in the
|
6404
|
+
// tree causes the slotter to unmount, then the slottable will also unmount. So using the
|
6405
|
+
// current VM works either way.
|
6406
|
+
if (isVCustomElement(vnode)) {
|
6407
|
+
addVNodeToChildLWC(clonedVNode);
|
6155
6408
|
}
|
6156
6409
|
}
|
6157
6410
|
// If the slot content is standard type, the content is static, no additional
|
@@ -6455,7 +6708,7 @@ LWR.define('lwc/v/7_2_1', ['exports'], (function (exports) { 'use strict';
|
|
6455
6708
|
return null;
|
6456
6709
|
}
|
6457
6710
|
if (!isComponentConstructor(Ctor)) {
|
6458
|
-
throw new Error(`Invalid constructor ${toString$1(Ctor)} is not a LightningElement constructor.`);
|
6711
|
+
throw new Error(`Invalid constructor: "${toString$1(Ctor)}" is not a LightningElement constructor.`);
|
6459
6712
|
}
|
6460
6713
|
// Look up the dynamic component's name at runtime once the constructor is available.
|
6461
6714
|
// This information is only known at runtime and is stored as part of registerComponent.
|
@@ -6488,26 +6741,10 @@ LWR.define('lwc/v/7_2_1', ['exports'], (function (exports) { 'use strict';
|
|
6488
6741
|
markAsDynamicChildren(vnodes);
|
6489
6742
|
return vnodes;
|
6490
6743
|
}
|
6491
|
-
/**
|
6492
|
-
* EXPERIMENTAL: This function acts like a hook for Lightning Locker Service and other similar
|
6493
|
-
* libraries to sanitize HTML content. This hook process the content passed via the template to
|
6494
|
-
* lwc:inner-html directive.
|
6495
|
-
* It is meant to be overridden with setSanitizeHtmlContentHook, it throws an error by default.
|
6496
|
-
*/
|
6497
|
-
let sanitizeHtmlContentHook = () => {
|
6498
|
-
// locker-service patches this function during runtime to sanitize HTML content.
|
6499
|
-
throw new Error('sanitizeHtmlContent hook must be implemented.');
|
6500
|
-
};
|
6501
|
-
/**
|
6502
|
-
* Sets the sanitizeHtmlContentHook.
|
6503
|
-
* @param newHookImpl
|
6504
|
-
*/
|
6505
|
-
function setSanitizeHtmlContentHook(newHookImpl) {
|
6506
|
-
sanitizeHtmlContentHook = newHookImpl;
|
6507
|
-
}
|
6508
6744
|
// [s]anitize [h]tml [c]ontent
|
6509
6745
|
function shc(content) {
|
6510
|
-
|
6746
|
+
const sanitizedString = sanitizeHtmlContent(content);
|
6747
|
+
return createSanitizedHtmlContent(sanitizedString);
|
6511
6748
|
}
|
6512
6749
|
/**
|
6513
6750
|
* [ncls] - Normalize class name attribute.
|
@@ -6571,20 +6808,48 @@ LWR.define('lwc/v/7_2_1', ['exports'], (function (exports) { 'use strict';
|
|
6571
6808
|
});
|
6572
6809
|
|
6573
6810
|
/*
|
6574
|
-
* Copyright (c)
|
6811
|
+
* Copyright (c) 2024, Salesforce, Inc.
|
6575
6812
|
* All rights reserved.
|
6576
6813
|
* SPDX-License-Identifier: MIT
|
6577
6814
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
6578
6815
|
*/
|
6579
6816
|
const operationIdNameMapping = ['constructor', 'render', 'patch', 'connectedCallback', 'renderedCallback', 'disconnectedCallback', 'errorCallback', 'lwc-hydrate', 'lwc-rehydrate'];
|
6817
|
+
const operationTooltipMapping = [
|
6818
|
+
// constructor
|
6819
|
+
'component constructor()',
|
6820
|
+
// render
|
6821
|
+
'component render() and virtual DOM rendered',
|
6822
|
+
// patch
|
6823
|
+
'component DOM rendered',
|
6824
|
+
// connectedCallback
|
6825
|
+
'component connectedCallback()',
|
6826
|
+
// renderedCallback
|
6827
|
+
'component renderedCallback()',
|
6828
|
+
// disconnectedCallback
|
6829
|
+
'component disconnectedCallback()',
|
6830
|
+
// errorCallback
|
6831
|
+
'component errorCallback()',
|
6832
|
+
// lwc-hydrate
|
6833
|
+
'component first rendered',
|
6834
|
+
// lwc-rehydrate
|
6835
|
+
'component re-rendered'];
|
6580
6836
|
// Even if all the browser the engine supports implements the UserTiming API, we need to guard the measure APIs.
|
6581
6837
|
// JSDom (used in Jest) for example doesn't implement the UserTiming APIs.
|
6582
6838
|
const isUserTimingSupported = typeof performance !== 'undefined' && typeof performance.mark === 'function' && typeof performance.clearMarks === 'function' && typeof performance.measure === 'function' && typeof performance.clearMeasures === 'function';
|
6583
6839
|
const start = !isUserTimingSupported ? noop : markName => {
|
6584
6840
|
performance.mark(markName);
|
6585
6841
|
};
|
6586
|
-
const end = !isUserTimingSupported ? noop : (measureName, markName) => {
|
6587
|
-
performance.measure(measureName,
|
6842
|
+
const end = !isUserTimingSupported ? noop : (measureName, markName, devtools) => {
|
6843
|
+
performance.measure(measureName, {
|
6844
|
+
start: markName,
|
6845
|
+
detail: {
|
6846
|
+
devtools: {
|
6847
|
+
dataType: 'track-entry',
|
6848
|
+
track: '⚡️ Lightning Web Components',
|
6849
|
+
...devtools
|
6850
|
+
}
|
6851
|
+
}
|
6852
|
+
});
|
6588
6853
|
// Clear the created marks and measure to avoid filling the performance entries buffer.
|
6589
6854
|
// Note: Even if the entries get deleted, existing PerformanceObservers preserve a copy of those entries.
|
6590
6855
|
performance.clearMarks(markName);
|
@@ -6601,6 +6866,85 @@ LWR.define('lwc/v/7_2_1', ['exports'], (function (exports) { 'use strict';
|
|
6601
6866
|
// the right measures for components that are recursive.
|
6602
6867
|
return `${getMeasureName(opId, vm)} - ${vm.idx}`;
|
6603
6868
|
}
|
6869
|
+
function getProperties(vm) {
|
6870
|
+
return [['Tag Name', vm.tagName], ['Component ID', String(vm.idx)], ['Render Mode', vm.renderMode === 0 /* RenderMode.Light */ ? 'light DOM' : 'shadow DOM'], ['Shadow Mode', vm.shadowMode === 0 /* ShadowMode.Native */ ? 'native' : 'synthetic']];
|
6871
|
+
}
|
6872
|
+
function getColor(opId) {
|
6873
|
+
// As of Sept 2024: primary (dark blue), secondary (light blue), tertiary (green)
|
6874
|
+
switch (opId) {
|
6875
|
+
// GlobalHydrate and Constructor tend to occur at the top level
|
6876
|
+
case 7 /* OperationId.GlobalHydrate */:
|
6877
|
+
case 0 /* OperationId.Constructor */:
|
6878
|
+
return 'primary';
|
6879
|
+
// GlobalRehydrate also occurs at the top level, but we want to use tertiary (green) because it's easier to
|
6880
|
+
// distinguish from primary, and at a glance you should be able to easily tell re-renders from first renders.
|
6881
|
+
case 8 /* OperationId.GlobalRehydrate */:
|
6882
|
+
return 'tertiary';
|
6883
|
+
// Everything else (patch/render/callbacks)
|
6884
|
+
default:
|
6885
|
+
return 'secondary';
|
6886
|
+
}
|
6887
|
+
}
|
6888
|
+
// Create a list of tag names to the properties that were mutated, to help answer the question of
|
6889
|
+
// "why did this component re-render?"
|
6890
|
+
function getMutationProperties(mutationLogs) {
|
6891
|
+
// `mutationLogs` should never have length 0, but bail out if it does for whatever reason
|
6892
|
+
if (isUndefined$1(mutationLogs)) {
|
6893
|
+
return EmptyArray;
|
6894
|
+
}
|
6895
|
+
if (!mutationLogs.length) {
|
6896
|
+
// Currently this only occurs for experimental signals, because those mutations are not triggered by accessors
|
6897
|
+
// TODO [#4546]: support signals in mutation logging
|
6898
|
+
return EmptyArray;
|
6899
|
+
}
|
6900
|
+
// Keep track of unique IDs per tag name so we can just report a raw count at the end, e.g.
|
6901
|
+
// `<x-foo> (x2)` to indicate that two instances of `<x-foo>` were rendered.
|
6902
|
+
const tagNamesToIdsAndProps = new Map();
|
6903
|
+
for (const {
|
6904
|
+
vm: {
|
6905
|
+
tagName,
|
6906
|
+
idx
|
6907
|
+
},
|
6908
|
+
prop
|
6909
|
+
} of mutationLogs) {
|
6910
|
+
let idsAndProps = tagNamesToIdsAndProps.get(tagName);
|
6911
|
+
if (isUndefined$1(idsAndProps)) {
|
6912
|
+
idsAndProps = {
|
6913
|
+
ids: new Set(),
|
6914
|
+
keys: new Set()
|
6915
|
+
};
|
6916
|
+
tagNamesToIdsAndProps.set(tagName, idsAndProps);
|
6917
|
+
}
|
6918
|
+
idsAndProps.ids.add(idx);
|
6919
|
+
idsAndProps.keys.add(prop);
|
6920
|
+
}
|
6921
|
+
// Sort by tag name
|
6922
|
+
const entries = ArraySort.call([...tagNamesToIdsAndProps], (a, b) => a[0].localeCompare(b[0]));
|
6923
|
+
const tagNames = ArrayMap.call(entries, item => item[0]);
|
6924
|
+
// Show e.g. `<x-foo>` for one instance, or `<x-foo> (x2)` for two instances. (\u00D7 is multiplication symbol)
|
6925
|
+
const tagNamesToDisplayTagNames = new Map();
|
6926
|
+
for (const tagName of tagNames) {
|
6927
|
+
const {
|
6928
|
+
ids
|
6929
|
+
} = tagNamesToIdsAndProps.get(tagName);
|
6930
|
+
const displayTagName = `<${tagName}>${ids.size > 1 ? ` (\u00D7${ids.size})` : ''}`;
|
6931
|
+
tagNamesToDisplayTagNames.set(tagName, displayTagName);
|
6932
|
+
}
|
6933
|
+
// Summary row
|
6934
|
+
const usePlural = tagNames.length > 1 || tagNamesToIdsAndProps.get(tagNames[0]).ids.size > 1;
|
6935
|
+
const result = [[`Component${usePlural ? 's' : ''}`, ArrayJoin.call(ArrayMap.call(tagNames, _ => tagNamesToDisplayTagNames.get(_)), ', ')]];
|
6936
|
+
// Detail rows
|
6937
|
+
for (const [prettyTagName, {
|
6938
|
+
keys
|
6939
|
+
}] of entries) {
|
6940
|
+
const displayTagName = tagNamesToDisplayTagNames.get(prettyTagName);
|
6941
|
+
ArrayPush$1.call(result, [displayTagName, ArrayJoin.call(ArraySort.call([...keys]), ', ')]);
|
6942
|
+
}
|
6943
|
+
return result;
|
6944
|
+
}
|
6945
|
+
function getTooltipText(measureName, opId) {
|
6946
|
+
return `${measureName} - ${operationTooltipMapping[opId]}`;
|
6947
|
+
}
|
6604
6948
|
/** Indicates if operations should be logged via the User Timing API. */
|
6605
6949
|
const isMeasureEnabled = process.env.NODE_ENV !== 'production';
|
6606
6950
|
/** Indicates if operations should be logged by the profiler. */
|
@@ -6638,33 +6982,94 @@ LWR.define('lwc/v/7_2_1', ['exports'], (function (exports) { 'use strict';
|
|
6638
6982
|
if (isMeasureEnabled) {
|
6639
6983
|
const markName = getMarkName(opId, vm);
|
6640
6984
|
const measureName = getMeasureName(opId, vm);
|
6641
|
-
end(measureName, markName
|
6985
|
+
end(measureName, markName, {
|
6986
|
+
color: getColor(opId),
|
6987
|
+
tooltipText: getTooltipText(measureName, opId),
|
6988
|
+
properties: getProperties(vm)
|
6989
|
+
});
|
6642
6990
|
}
|
6643
6991
|
if (isProfilerEnabled) {
|
6644
6992
|
currentDispatcher(opId, 1 /* Phase.Stop */, vm.tagName, vm.idx, vm.renderMode, vm.shadowMode);
|
6645
6993
|
}
|
6646
6994
|
}
|
6647
|
-
function logGlobalOperationStart(opId
|
6995
|
+
function logGlobalOperationStart(opId) {
|
6648
6996
|
if (isMeasureEnabled) {
|
6649
|
-
const
|
6650
|
-
const markName = isUndefined$1(vm) ? opName : getMarkName(opId, vm);
|
6997
|
+
const markName = getOperationName(opId);
|
6651
6998
|
start(markName);
|
6652
6999
|
}
|
6653
7000
|
if (isProfilerEnabled) {
|
6654
|
-
currentDispatcher(opId, 0 /* Phase.Start
|
7001
|
+
currentDispatcher(opId, 0 /* Phase.Start */);
|
6655
7002
|
}
|
6656
7003
|
}
|
6657
|
-
function
|
7004
|
+
function logGlobalOperationStartWithVM(opId, vm) {
|
7005
|
+
if (isMeasureEnabled) {
|
7006
|
+
const markName = getMarkName(opId, vm);
|
7007
|
+
start(markName);
|
7008
|
+
}
|
7009
|
+
if (isProfilerEnabled) {
|
7010
|
+
currentDispatcher(opId, 0 /* Phase.Start */, vm.tagName, vm.idx, vm.renderMode, vm.shadowMode);
|
7011
|
+
}
|
7012
|
+
}
|
7013
|
+
function logGlobalOperationEnd(opId, mutationLogs) {
|
6658
7014
|
if (isMeasureEnabled) {
|
6659
7015
|
const opName = getOperationName(opId);
|
6660
|
-
const markName =
|
6661
|
-
end(opName, markName
|
7016
|
+
const markName = opName;
|
7017
|
+
end(opName, markName, {
|
7018
|
+
color: getColor(opId),
|
7019
|
+
tooltipText: getTooltipText(opName, opId),
|
7020
|
+
properties: getMutationProperties(mutationLogs)
|
7021
|
+
});
|
6662
7022
|
}
|
6663
7023
|
if (isProfilerEnabled) {
|
6664
|
-
currentDispatcher(opId, 1 /* Phase.Stop
|
7024
|
+
currentDispatcher(opId, 1 /* Phase.Stop */);
|
7025
|
+
}
|
7026
|
+
}
|
7027
|
+
function logGlobalOperationEndWithVM(opId, vm) {
|
7028
|
+
if (isMeasureEnabled) {
|
7029
|
+
const opName = getOperationName(opId);
|
7030
|
+
const markName = getMarkName(opId, vm);
|
7031
|
+
end(opName, markName, {
|
7032
|
+
color: getColor(opId),
|
7033
|
+
tooltipText: getTooltipText(opName, opId),
|
7034
|
+
properties: getProperties(vm)
|
7035
|
+
});
|
7036
|
+
}
|
7037
|
+
if (isProfilerEnabled) {
|
7038
|
+
currentDispatcher(opId, 1 /* Phase.Stop */, vm.tagName, vm.idx, vm.renderMode, vm.shadowMode);
|
6665
7039
|
}
|
6666
7040
|
}
|
6667
7041
|
|
7042
|
+
/*
|
7043
|
+
* Copyright (c) 2024, Salesforce, Inc.
|
7044
|
+
* All rights reserved.
|
7045
|
+
* SPDX-License-Identifier: MIT
|
7046
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
7047
|
+
*/
|
7048
|
+
// HAS_SCOPED_STYLE | SHADOW_MODE_SYNTHETIC = 3
|
7049
|
+
const MAX_CACHE_KEY = 3;
|
7050
|
+
// Mapping of cacheKeys to `string[]` (assumed to come from a tagged template literal) to an Element.
|
7051
|
+
// Note that every unique tagged template literal will have a unique `string[]`. So by using `string[]`
|
7052
|
+
// as the WeakMap key, we effectively associate each Element with a unique tagged template literal.
|
7053
|
+
// See: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals#tagged_templates
|
7054
|
+
// Also note that this array only needs to be large enough to account for the maximum possible cache key
|
7055
|
+
const fragmentCache = ArrayFrom({
|
7056
|
+
length: MAX_CACHE_KEY + 1
|
7057
|
+
}, () => new WeakMap());
|
7058
|
+
// Only used in LWC's Karma tests
|
7059
|
+
if (process.env.NODE_ENV === 'test-karma-lwc') {
|
7060
|
+
window.__lwcResetFragmentCache = () => {
|
7061
|
+
for (let i = 0; i < fragmentCache.length; i++) {
|
7062
|
+
fragmentCache[i] = new WeakMap();
|
7063
|
+
}
|
7064
|
+
};
|
7065
|
+
}
|
7066
|
+
function getFromFragmentCache(cacheKey, strings) {
|
7067
|
+
return fragmentCache[cacheKey].get(strings);
|
7068
|
+
}
|
7069
|
+
function setInFragmentCache(cacheKey, strings, element) {
|
7070
|
+
fragmentCache[cacheKey].set(strings, element);
|
7071
|
+
}
|
7072
|
+
|
6668
7073
|
/*
|
6669
7074
|
* Copyright (c) 2024, Salesforce, Inc.
|
6670
7075
|
* All rights reserved.
|
@@ -6679,6 +7084,12 @@ LWR.define('lwc/v/7_2_1', ['exports'], (function (exports) { 'use strict';
|
|
6679
7084
|
function setVMBeingRendered(vm) {
|
6680
7085
|
vmBeingRendered = vm;
|
6681
7086
|
}
|
7087
|
+
const VALID_SCOPE_TOKEN_REGEX = /^[a-zA-Z0-9\-_.]+$/;
|
7088
|
+
// See W-16614556
|
7089
|
+
// TODO [#2826]: freeze the template object
|
7090
|
+
function isValidScopeToken(token) {
|
7091
|
+
return isString(token) && VALID_SCOPE_TOKEN_REGEX.test(token);
|
7092
|
+
}
|
6682
7093
|
function validateSlots(vm) {
|
6683
7094
|
assertNotProd(); // this method should never leak to prod
|
6684
7095
|
const {
|
@@ -6688,18 +7099,28 @@ LWR.define('lwc/v/7_2_1', ['exports'], (function (exports) { 'use strict';
|
|
6688
7099
|
assert.isTrue(isArray$1(cmpSlots.slotAssignments[slotName]), `Slots can only be set to an array, instead received ${toString$1(cmpSlots.slotAssignments[slotName])} for slot "${slotName}" in ${vm}.`);
|
6689
7100
|
}
|
6690
7101
|
}
|
6691
|
-
function
|
6692
|
-
|
7102
|
+
function checkHasMatchingRenderMode(template, vm) {
|
7103
|
+
// don't validate in prod environments where reporting is disabled
|
7104
|
+
if (process.env.NODE_ENV === 'production' && !isReportingEnabled()) {
|
7105
|
+
return;
|
7106
|
+
}
|
7107
|
+
// don't validate the default empty template - it is not inherently light or shadow
|
6693
7108
|
if (template === defaultEmptyTemplate) {
|
6694
7109
|
return;
|
6695
7110
|
}
|
6696
|
-
|
6697
|
-
|
6698
|
-
|
6699
|
-
|
6700
|
-
|
6701
|
-
|
6702
|
-
|
7111
|
+
// TODO [#4663]: `renderMode` mismatch between template and component causes `console.error` but no error
|
7112
|
+
// Note that `undefined` means shadow in this case, because shadow is the default.
|
7113
|
+
const vmIsLight = vm.renderMode === 0 /* RenderMode.Light */;
|
7114
|
+
const templateIsLight = template.renderMode === 'light';
|
7115
|
+
if (vmIsLight !== templateIsLight) {
|
7116
|
+
report("RenderModeMismatch" /* ReportingEventId.RenderModeMismatch */, {
|
7117
|
+
tagName: vm.tagName,
|
7118
|
+
mode: vm.renderMode
|
7119
|
+
});
|
7120
|
+
if (process.env.NODE_ENV !== 'production') {
|
7121
|
+
const tagName = getComponentTag(vm);
|
7122
|
+
const message = vmIsLight ? `Light DOM components can't render shadow DOM templates. Add an 'lwc:render-mode="light"' directive to the root template tag of ${tagName}.` : `Shadow DOM components template can't render light DOM templates. Either remove the 'lwc:render-mode' directive from ${tagName} or set it to 'lwc:render-mode="shadow"`;
|
7123
|
+
logError(message);
|
6703
7124
|
}
|
6704
7125
|
}
|
6705
7126
|
}
|
@@ -6725,28 +7146,9 @@ LWR.define('lwc/v/7_2_1', ['exports'], (function (exports) { 'use strict';
|
|
6725
7146
|
return browserExpressionSerializer;
|
6726
7147
|
}
|
6727
7148
|
}
|
6728
|
-
// This should be a no-op outside of LWC's Karma tests, where it's not needed
|
6729
|
-
let registerFragmentCache = noop;
|
6730
|
-
// Only used in LWC's Karma tests
|
6731
|
-
if (process.env.NODE_ENV === 'test-karma-lwc') {
|
6732
|
-
// Keep track of fragmentCaches, so we can clear them in LWC's Karma tests
|
6733
|
-
const fragmentCaches = [];
|
6734
|
-
registerFragmentCache = fragmentCache => {
|
6735
|
-
fragmentCaches.push(fragmentCache);
|
6736
|
-
};
|
6737
|
-
window.__lwcResetFragmentCaches = () => {
|
6738
|
-
for (const fragmentCache of fragmentCaches) {
|
6739
|
-
for (const key of keys(fragmentCache)) {
|
6740
|
-
delete fragmentCache[key];
|
6741
|
-
}
|
6742
|
-
}
|
6743
|
-
};
|
6744
|
-
}
|
6745
7149
|
function buildParseFragmentFn(createFragmentFn) {
|
6746
|
-
return (strings, ...keys)
|
6747
|
-
|
6748
|
-
registerFragmentCache(cache);
|
6749
|
-
return function (parts) {
|
7150
|
+
return function parseFragment(strings, ...keys) {
|
7151
|
+
return function applyFragmentParts(parts) {
|
6750
7152
|
const {
|
6751
7153
|
context: {
|
6752
7154
|
hasScopedStyles,
|
@@ -6761,19 +7163,23 @@ LWR.define('lwc/v/7_2_1', ['exports'], (function (exports) { 'use strict';
|
|
6761
7163
|
const hasLegacyToken = lwcRuntimeFlags.ENABLE_LEGACY_SCOPE_TOKENS && !isUndefined$1(legacyStylesheetToken);
|
6762
7164
|
let cacheKey = 0;
|
6763
7165
|
if (hasStyleToken && hasScopedStyles) {
|
6764
|
-
cacheKey |= 1 /*
|
7166
|
+
cacheKey |= 1 /* FragmentCacheKey.HAS_SCOPED_STYLE */;
|
6765
7167
|
}
|
6766
7168
|
if (hasStyleToken && isSyntheticShadow) {
|
6767
|
-
cacheKey |= 2 /*
|
7169
|
+
cacheKey |= 2 /* FragmentCacheKey.SHADOW_MODE_SYNTHETIC */;
|
6768
7170
|
}
|
6769
7171
|
// Cache is only here to prevent calling innerHTML multiple times which doesn't happen on the server.
|
6770
7172
|
{
|
6771
7173
|
// Disable this on the server to prevent cache poisoning when expressions are used.
|
6772
|
-
const cached =
|
7174
|
+
const cached = getFromFragmentCache(cacheKey, strings);
|
6773
7175
|
if (!isUndefined$1(cached)) {
|
6774
7176
|
return cached;
|
6775
7177
|
}
|
6776
7178
|
}
|
7179
|
+
// See W-16614556
|
7180
|
+
if (hasStyleToken && !isValidScopeToken(stylesheetToken) || hasLegacyToken && !isValidScopeToken(legacyStylesheetToken)) {
|
7181
|
+
throw new Error('stylesheet token must be a valid string');
|
7182
|
+
}
|
6777
7183
|
// If legacy stylesheet tokens are required, then add them to the rendered string
|
6778
7184
|
const stylesheetTokenToRender = stylesheetToken + (hasLegacyToken ? ` ${legacyStylesheetToken}` : '');
|
6779
7185
|
const classToken = hasScopedStyles && hasStyleToken ? ' ' + stylesheetTokenToRender : '';
|
@@ -6813,8 +7219,12 @@ LWR.define('lwc/v/7_2_1', ['exports'], (function (exports) { 'use strict';
|
|
6813
7219
|
}
|
6814
7220
|
}
|
6815
7221
|
htmlFragment += strings[strings.length - 1];
|
6816
|
-
|
6817
|
-
|
7222
|
+
const element = createFragmentFn(htmlFragment, renderer);
|
7223
|
+
// Cache is only here to prevent calling innerHTML multiple times which doesn't happen on the server.
|
7224
|
+
{
|
7225
|
+
setInFragmentCache(cacheKey, strings, element);
|
7226
|
+
}
|
7227
|
+
return element;
|
6818
7228
|
};
|
6819
7229
|
};
|
6820
7230
|
}
|
@@ -6863,9 +7273,7 @@ LWR.define('lwc/v/7_2_1', ['exports'], (function (exports) { 'use strict';
|
|
6863
7273
|
if (!isTemplateRegistered(html)) {
|
6864
7274
|
throw new TypeError(`Invalid template returned by the render() method on ${vm.tagName}. It must return an imported template (e.g.: \`import html from "./${vm.def.name}.html"\`), instead, it has returned: ${toString$1(html)}.`);
|
6865
7275
|
}
|
6866
|
-
|
6867
|
-
validateLightDomTemplate(html, vm);
|
6868
|
-
}
|
7276
|
+
checkHasMatchingRenderMode(html, vm);
|
6869
7277
|
// Perf opt: do not reset the shadow root during the first rendering (there is
|
6870
7278
|
// nothing to reset).
|
6871
7279
|
if (!isNull(cmpTemplate)) {
|
@@ -6905,7 +7313,13 @@ LWR.define('lwc/v/7_2_1', ['exports'], (function (exports) { 'use strict';
|
|
6905
7313
|
styleVNodes
|
6906
7314
|
} = context;
|
6907
7315
|
if (!isNull(styleVNodes)) {
|
6908
|
-
|
7316
|
+
// It's important here not to mutate the underlying `vnodes` returned from `html.call()`.
|
7317
|
+
// The reason for this is because, due to the static content optimization, the vnodes array
|
7318
|
+
// may be a static array shared across multiple component instances. E.g. this occurs in the
|
7319
|
+
// case of an empty `<template></template>` in a `component.html` file, due to the underlying
|
7320
|
+
// children being `[]` (no children). If we append the `<style>` vnode to this array, then the same
|
7321
|
+
// array will be reused for every component instance, i.e. whenever `tmpl()` is called.
|
7322
|
+
vnodes = [...styleVNodes, ...vnodes];
|
6909
7323
|
}
|
6910
7324
|
});
|
6911
7325
|
}, () => {
|
@@ -7087,7 +7501,7 @@ LWR.define('lwc/v/7_2_1', ['exports'], (function (exports) { 'use strict';
|
|
7087
7501
|
return apiVersion;
|
7088
7502
|
}
|
7089
7503
|
function getTemplateReactiveObserver(vm) {
|
7090
|
-
|
7504
|
+
const reactiveObserver = createReactiveObserver(() => {
|
7091
7505
|
const {
|
7092
7506
|
isDirty
|
7093
7507
|
} = vm;
|
@@ -7096,6 +7510,10 @@ LWR.define('lwc/v/7_2_1', ['exports'], (function (exports) { 'use strict';
|
|
7096
7510
|
scheduleRehydration(vm);
|
7097
7511
|
}
|
7098
7512
|
});
|
7513
|
+
if (process.env.NODE_ENV !== 'production') {
|
7514
|
+
associateReactiveObserverWithVM(reactiveObserver, vm);
|
7515
|
+
}
|
7516
|
+
return reactiveObserver;
|
7099
7517
|
}
|
7100
7518
|
function resetTemplateObserverAndUnsubscribe(vm) {
|
7101
7519
|
const {
|
@@ -7173,7 +7591,12 @@ LWR.define('lwc/v/7_2_1', ['exports'], (function (exports) { 'use strict';
|
|
7173
7591
|
}
|
7174
7592
|
function connectRootElement(elm) {
|
7175
7593
|
const vm = getAssociatedVM(elm);
|
7176
|
-
|
7594
|
+
if (process.env.NODE_ENV !== 'production') {
|
7595
|
+
// Flush any logs for this VM so that the initial properties from the constructor don't "count"
|
7596
|
+
// in subsequent re-renders (lwc-rehydrate). Right now we're at the first render (lwc-hydrate).
|
7597
|
+
flushMutationLogsForVM(vm);
|
7598
|
+
}
|
7599
|
+
logGlobalOperationStartWithVM(7 /* OperationId.GlobalHydrate */, vm);
|
7177
7600
|
// Usually means moving the element from one place to another, which is observable via
|
7178
7601
|
// life-cycle hooks.
|
7179
7602
|
if (vm.state === 1 /* VMState.connected */) {
|
@@ -7181,7 +7604,7 @@ LWR.define('lwc/v/7_2_1', ['exports'], (function (exports) { 'use strict';
|
|
7181
7604
|
}
|
7182
7605
|
runConnectedCallback(vm);
|
7183
7606
|
rehydrate(vm);
|
7184
|
-
|
7607
|
+
logGlobalOperationEndWithVM(7 /* OperationId.GlobalHydrate */, vm);
|
7185
7608
|
}
|
7186
7609
|
function disconnectRootElement(elm) {
|
7187
7610
|
const vm = getAssociatedVM(elm);
|
@@ -7502,6 +7925,9 @@ LWR.define('lwc/v/7_2_1', ['exports'], (function (exports) { 'use strict';
|
|
7502
7925
|
}
|
7503
7926
|
let rehydrateQueue = [];
|
7504
7927
|
function flushRehydrationQueue() {
|
7928
|
+
// Gather the logs before rehydration starts so they can be reported at the end of rehydration.
|
7929
|
+
// Note that we also clear all existing logs at this point so that subsequent re-renders start from a clean slate.
|
7930
|
+
const mutationLogs = process.env.NODE_ENV === 'production' ? undefined : getAndFlushMutationLogs();
|
7505
7931
|
logGlobalOperationStart(8 /* OperationId.GlobalRehydrate */);
|
7506
7932
|
if (process.env.NODE_ENV !== 'production') {
|
7507
7933
|
assert.invariant(rehydrateQueue.length, `If rehydrateQueue was scheduled, it is because there must be at least one VM on this pending queue instead of ${rehydrateQueue}.`);
|
@@ -7521,13 +7947,13 @@ LWR.define('lwc/v/7_2_1', ['exports'], (function (exports) { 'use strict';
|
|
7521
7947
|
ArrayUnshift.apply(rehydrateQueue, ArraySlice.call(vms, i + 1));
|
7522
7948
|
}
|
7523
7949
|
// we need to end the measure before throwing.
|
7524
|
-
logGlobalOperationEnd(8 /* OperationId.GlobalRehydrate
|
7950
|
+
logGlobalOperationEnd(8 /* OperationId.GlobalRehydrate */, mutationLogs);
|
7525
7951
|
// re-throwing the original error will break the current tick, but since the next tick is
|
7526
7952
|
// already scheduled, it should continue patching the rest.
|
7527
7953
|
throw error;
|
7528
7954
|
}
|
7529
7955
|
}
|
7530
|
-
logGlobalOperationEnd(8 /* OperationId.GlobalRehydrate
|
7956
|
+
logGlobalOperationEnd(8 /* OperationId.GlobalRehydrate */, mutationLogs);
|
7531
7957
|
}
|
7532
7958
|
function runConnectedCallback(vm) {
|
7533
7959
|
const {
|
@@ -8070,7 +8496,7 @@ LWR.define('lwc/v/7_2_1', ['exports'], (function (exports) { 'use strict';
|
|
8070
8496
|
runConnectedCallback(vm);
|
8071
8497
|
hydrateVM(vm);
|
8072
8498
|
if (hasMismatch && process.env.NODE_ENV !== 'production') {
|
8073
|
-
|
8499
|
+
logWarn('Hydration completed with errors.', vm);
|
8074
8500
|
}
|
8075
8501
|
}
|
8076
8502
|
function hydrateVM(vm) {
|
@@ -8135,31 +8561,36 @@ LWR.define('lwc/v/7_2_1', ['exports'], (function (exports) { 'use strict';
|
|
8135
8561
|
// Any attribute names specified in that array will not be validated, and the
|
8136
8562
|
// LWC runtime will assume that VDOM attrs and DOM attrs are in sync.
|
8137
8563
|
function getValidationPredicate(elm, renderer, optOutStaticProp) {
|
8138
|
-
// `data-lwc-host-mutated` is a special attribute added by the SSR engine itself,
|
8139
|
-
//
|
8564
|
+
// `data-lwc-host-mutated` is a special attribute added by the SSR engine itself, which automatically detects
|
8565
|
+
// host mutations during `connectedCallback`.
|
8140
8566
|
const hostMutatedValue = renderer.getAttribute(elm, 'data-lwc-host-mutated');
|
8141
|
-
|
8142
|
-
const mutatedAttrValues = new Set(StringSplit.call(hostMutatedValue, / /));
|
8143
|
-
return attrName => !mutatedAttrValues.has(attrName);
|
8144
|
-
}
|
8145
|
-
if (isUndefined$1(optOutStaticProp)) {
|
8146
|
-
return _attrName => true;
|
8147
|
-
}
|
8567
|
+
const detectedHostMutations = isString(hostMutatedValue) ? new Set(StringSplit.call(hostMutatedValue, / /)) : undefined;
|
8148
8568
|
// If validationOptOut is true, no attributes will be checked for correctness
|
8149
8569
|
// and the runtime will assume VDOM attrs and DOM attrs are in sync.
|
8150
|
-
|
8151
|
-
|
8152
|
-
|
8153
|
-
|
8154
|
-
|
8155
|
-
|
8156
|
-
|
8157
|
-
|
8158
|
-
|
8159
|
-
|
8160
|
-
|
8161
|
-
|
8162
|
-
|
8570
|
+
const fullOptOut = isTrue(optOutStaticProp);
|
8571
|
+
// If validationOptOut is an array of strings, attributes specified in the array will be "opted out". Attributes
|
8572
|
+
// not specified in the array will still be validated.
|
8573
|
+
const isValidArray = isArray$1(optOutStaticProp) && arrayEvery(optOutStaticProp, isString);
|
8574
|
+
const conditionalOptOut = isValidArray ? new Set(optOutStaticProp) : undefined;
|
8575
|
+
if (process.env.NODE_ENV !== 'production' && !isUndefined$1(optOutStaticProp) && !isTrue(optOutStaticProp) && !isValidArray) {
|
8576
|
+
logWarn('`validationOptOut` must be `true` or an array of attributes that should not be validated.');
|
8577
|
+
}
|
8578
|
+
return attrName => {
|
8579
|
+
// Component wants to opt out of all validation
|
8580
|
+
if (fullOptOut) {
|
8581
|
+
return false;
|
8582
|
+
}
|
8583
|
+
// Mutations were automatically detected and should be ignored
|
8584
|
+
if (!isUndefined$1(detectedHostMutations) && detectedHostMutations.has(attrName)) {
|
8585
|
+
return false;
|
8586
|
+
}
|
8587
|
+
// Component explicitly wants to opt out of certain validations, regardless of auto-detection
|
8588
|
+
if (!isUndefined$1(conditionalOptOut) && conditionalOptOut.has(attrName)) {
|
8589
|
+
return false;
|
8590
|
+
}
|
8591
|
+
// Attribute must be validated
|
8592
|
+
return true;
|
8593
|
+
};
|
8163
8594
|
}
|
8164
8595
|
function hydrateText(node, vnode, renderer) {
|
8165
8596
|
if (!hasCorrectNodeType(vnode, node, 3 /* EnvNodeTypes.TEXT */, renderer)) {
|
@@ -8196,6 +8627,8 @@ LWR.define('lwc/v/7_2_1', ['exports'], (function (exports) { 'use strict';
|
|
8196
8627
|
const {
|
8197
8628
|
setProperty
|
8198
8629
|
} = renderer;
|
8630
|
+
// We only set the `nodeValue` property here (on a comment), so we don't need
|
8631
|
+
// to sanitize the content as HTML using `safelySetProperty`
|
8199
8632
|
setProperty(node, NODE_VALUE_PROP, vnode.text ?? null);
|
8200
8633
|
vnode.elm = node;
|
8201
8634
|
return node;
|
@@ -8255,7 +8688,7 @@ LWR.define('lwc/v/7_2_1', ['exports'], (function (exports) { 'use strict';
|
|
8255
8688
|
getProperty
|
8256
8689
|
} = renderer;
|
8257
8690
|
if (!isUndefined$1(props) && !isUndefined$1(props.innerHTML)) {
|
8258
|
-
if (getProperty(elm, 'innerHTML')
|
8691
|
+
if (isSanitizedHtmlContentEqual(getProperty(elm, 'innerHTML'), props.innerHTML)) {
|
8259
8692
|
// Do a shallow clone since VNodeData may be shared across VNodes due to hoist optimization
|
8260
8693
|
vnode.data = {
|
8261
8694
|
...vnode.data,
|
@@ -8352,11 +8785,11 @@ LWR.define('lwc/v/7_2_1', ['exports'], (function (exports) { 'use strict';
|
|
8352
8785
|
if (process.env.NODE_ENV !== 'production') {
|
8353
8786
|
if (!hasWarned) {
|
8354
8787
|
hasWarned = true;
|
8355
|
-
|
8788
|
+
logWarn(`Hydration mismatch: incorrect number of rendered nodes. Client produced more nodes than the server.`, owner);
|
8356
8789
|
}
|
8357
8790
|
}
|
8358
8791
|
mount(childVnode, parentNode, renderer, nextNode);
|
8359
|
-
nextNode = renderer.nextSibling(childVnode.elm);
|
8792
|
+
nextNode = renderer.nextSibling(childVnode.type === 5 /* VNodeType.Fragment */ ? childVnode.trailing : childVnode.elm);
|
8360
8793
|
}
|
8361
8794
|
}
|
8362
8795
|
}
|
@@ -8373,7 +8806,7 @@ LWR.define('lwc/v/7_2_1', ['exports'], (function (exports) { 'use strict';
|
|
8373
8806
|
hasMismatch = true;
|
8374
8807
|
if (process.env.NODE_ENV !== 'production') {
|
8375
8808
|
if (!hasWarned) {
|
8376
|
-
|
8809
|
+
logWarn(`Hydration mismatch: incorrect number of rendered nodes. Server rendered more nodes than the client.`, owner);
|
8377
8810
|
}
|
8378
8811
|
}
|
8379
8812
|
// nextSibling is mostly harmless, and since we don't have
|
@@ -8412,7 +8845,7 @@ LWR.define('lwc/v/7_2_1', ['exports'], (function (exports) { 'use strict';
|
|
8412
8845
|
} = renderer;
|
8413
8846
|
if (getProperty(node, 'nodeType') !== nodeType) {
|
8414
8847
|
if (process.env.NODE_ENV !== 'production') {
|
8415
|
-
|
8848
|
+
logWarn('Hydration mismatch: incorrect node type received', vnode.owner);
|
8416
8849
|
}
|
8417
8850
|
return false;
|
8418
8851
|
}
|
@@ -8424,7 +8857,7 @@ LWR.define('lwc/v/7_2_1', ['exports'], (function (exports) { 'use strict';
|
|
8424
8857
|
} = renderer;
|
8425
8858
|
if (vnode.sel.toLowerCase() !== getProperty(elm, 'tagName').toLowerCase()) {
|
8426
8859
|
if (process.env.NODE_ENV !== 'production') {
|
8427
|
-
|
8860
|
+
logWarn(`Hydration mismatch: expecting element with tag "${vnode.sel.toLowerCase()}" but found "${getProperty(elm, 'tagName').toLowerCase()}".`, vnode.owner);
|
8428
8861
|
}
|
8429
8862
|
return false;
|
8430
8863
|
}
|
@@ -8469,7 +8902,7 @@ LWR.define('lwc/v/7_2_1', ['exports'], (function (exports) { 'use strict';
|
|
8469
8902
|
const {
|
8470
8903
|
getProperty
|
8471
8904
|
} = renderer;
|
8472
|
-
|
8905
|
+
logWarn(`Mismatch hydrating element <${getProperty(elm, 'tagName').toLowerCase()}>: attribute "${attrName}" has different values, expected "${attrValue}" but found ${isNull(elmAttrValue) ? 'null' : `"${elmAttrValue}"`}`, vnode.owner);
|
8473
8906
|
}
|
8474
8907
|
nodesAreCompatible = false;
|
8475
8908
|
}
|
@@ -8482,82 +8915,65 @@ LWR.define('lwc/v/7_2_1', ['exports'], (function (exports) { 'use strict';
|
|
8482
8915
|
} = vnode;
|
8483
8916
|
// classMap is never available on VStaticPartData so it can default to undefined
|
8484
8917
|
// casting to prevent TS error.
|
8485
|
-
|
8918
|
+
const {
|
8486
8919
|
className,
|
8487
8920
|
classMap
|
8488
8921
|
} = data;
|
8489
8922
|
const {
|
8490
|
-
getProperty
|
8491
|
-
getClassList,
|
8492
|
-
getAttribute
|
8923
|
+
getProperty
|
8493
8924
|
} = renderer;
|
8925
|
+
// ---------- Step 1: get the classes from the element and the vnode
|
8926
|
+
// Use a Set because we don't care to validate mismatches for 1) different ordering in SSR vs CSR, or 2)
|
8927
|
+
// duplicated class names. These don't have an effect on rendered styles.
|
8928
|
+
const elmClasses = new Set(ArrayFrom(elm.classList));
|
8929
|
+
let vnodeClasses;
|
8930
|
+
if (!isUndefined$1(className)) {
|
8931
|
+
// ignore empty spaces entirely, filter them out using `filter(..., Boolean)`
|
8932
|
+
vnodeClasses = new Set(ArrayFilter.call(StringSplit.call(className, /\s+/), Boolean));
|
8933
|
+
} else if (!isUndefined$1(classMap)) {
|
8934
|
+
vnodeClasses = new Set(keys(classMap));
|
8935
|
+
} else {
|
8936
|
+
vnodeClasses = new Set();
|
8937
|
+
}
|
8938
|
+
// ---------- Step 2: handle the scope tokens
|
8494
8939
|
// we don't care about legacy for hydration. it's a new use case
|
8495
|
-
const
|
8496
|
-
const stylesheetTokenHost = isVCustomElement(vnode) ? getStylesheetTokenHost(vnode) : null;
|
8940
|
+
const scopeToken = getScopeTokenClass(owner, /* legacy */false);
|
8497
8941
|
// Classnames for scoped CSS are added directly to the DOM during rendering,
|
8498
8942
|
// or to the VDOM on the server in the case of SSR. As such, these classnames
|
8499
8943
|
// are never present in VDOM nodes in the browser.
|
8500
8944
|
//
|
8501
8945
|
// Consequently, hydration mismatches will occur if scoped CSS token classnames
|
8502
8946
|
// are rendered during SSR. This needs to be accounted for when validating.
|
8503
|
-
if (!isNull(
|
8504
|
-
|
8505
|
-
|
8506
|
-
|
8507
|
-
|
8508
|
-
|
8509
|
-
|
8510
|
-
|
8511
|
-
|
8512
|
-
|
8513
|
-
[scopedToken]: true
|
8514
|
-
} : {}),
|
8515
|
-
...(!isNull(stylesheetTokenHost) ? {
|
8516
|
-
[stylesheetTokenHost]: true
|
8517
|
-
} : {})
|
8518
|
-
};
|
8519
|
-
} else {
|
8520
|
-
// The order of the className should be scopedToken stylesheetTokenHost
|
8521
|
-
const classTokens = [scopedToken, stylesheetTokenHost];
|
8522
|
-
const classNames = ArrayFilter.call(classTokens, token => !isNull(token));
|
8523
|
-
if (classNames.length) {
|
8524
|
-
className = ArrayJoin.call(classNames, ' ');
|
8525
|
-
}
|
8526
|
-
}
|
8947
|
+
if (!isNull(scopeToken)) {
|
8948
|
+
vnodeClasses.add(scopeToken);
|
8949
|
+
}
|
8950
|
+
// This tells us which `*-host` scope token was rendered to the element's class.
|
8951
|
+
// For now we just ignore any mismatches involving this class.
|
8952
|
+
// TODO [#4866]: correctly validate the host scope token class
|
8953
|
+
const elmHostScopeToken = renderer.getAttribute(elm, 'data-lwc-host-scope-token');
|
8954
|
+
if (!isNull(elmHostScopeToken)) {
|
8955
|
+
elmClasses.delete(elmHostScopeToken);
|
8956
|
+
vnodeClasses.delete(elmHostScopeToken);
|
8527
8957
|
}
|
8958
|
+
// ---------- Step 3: check for compatibility
|
8528
8959
|
let nodesAreCompatible = true;
|
8529
|
-
|
8530
|
-
const elmClassName = getAttribute(elm, 'class');
|
8531
|
-
if (!isUndefined$1(className) && String(className) !== elmClassName) {
|
8532
|
-
// className is used when class is bound to an expr.
|
8960
|
+
if (vnodeClasses.size !== elmClasses.size) {
|
8533
8961
|
nodesAreCompatible = false;
|
8534
|
-
|
8535
|
-
|
8536
|
-
|
8537
|
-
// classMap is used when class is set to static value.
|
8538
|
-
const classList = getClassList(elm);
|
8539
|
-
let computedClassName = '';
|
8540
|
-
// all classes from the vnode should be in the element.classList
|
8541
|
-
for (const name in classMap) {
|
8542
|
-
computedClassName += ' ' + name;
|
8543
|
-
if (!classList.contains(name)) {
|
8962
|
+
} else {
|
8963
|
+
for (const vnodeClass of vnodeClasses) {
|
8964
|
+
if (!elmClasses.has(vnodeClass)) {
|
8544
8965
|
nodesAreCompatible = false;
|
8545
8966
|
}
|
8546
8967
|
}
|
8547
|
-
|
8548
|
-
|
8549
|
-
|
8550
|
-
|
8968
|
+
for (const elmClass of elmClasses) {
|
8969
|
+
if (!vnodeClasses.has(elmClass)) {
|
8970
|
+
nodesAreCompatible = false;
|
8971
|
+
}
|
8551
8972
|
}
|
8552
|
-
} else if (isUndefined$1(className) && !isNull(elmClassName)) {
|
8553
|
-
// SSR contains a className but client-side VDOM does not
|
8554
|
-
nodesAreCompatible = false;
|
8555
|
-
readableVnodeClassname = '""';
|
8556
8973
|
}
|
8557
|
-
if (!nodesAreCompatible) {
|
8558
|
-
|
8559
|
-
|
8560
|
-
}
|
8974
|
+
if (process.env.NODE_ENV !== 'production' && !nodesAreCompatible) {
|
8975
|
+
const prettyPrint = set => JSON.stringify(ArrayJoin.call(ArraySort.call(ArrayFrom(set)), ' '));
|
8976
|
+
logWarn(`Mismatch hydrating element <${getProperty(elm, 'tagName').toLowerCase()}>: attribute "class" has different values, expected ${prettyPrint(vnodeClasses)} but found ${prettyPrint(elmClasses)}`, vnode.owner);
|
8561
8977
|
}
|
8562
8978
|
return nodesAreCompatible;
|
8563
8979
|
}
|
@@ -8582,7 +8998,7 @@ LWR.define('lwc/v/7_2_1', ['exports'], (function (exports) { 'use strict';
|
|
8582
8998
|
// styleMap is used when style is set to static value.
|
8583
8999
|
for (let i = 0, n = styleDecls.length; i < n; i++) {
|
8584
9000
|
const [prop, value, important] = styleDecls[i];
|
8585
|
-
expectedStyle.push(`${prop}: ${value + (important ? ' important
|
9001
|
+
expectedStyle.push(`${prop}: ${value + (important ? ' !important' : '')};`);
|
8586
9002
|
const parsedPropValue = parsedVnodeStyle[prop];
|
8587
9003
|
if (isUndefined$1(parsedPropValue)) {
|
8588
9004
|
nodesAreCompatible = false;
|
@@ -8595,14 +9011,14 @@ LWR.define('lwc/v/7_2_1', ['exports'], (function (exports) { 'use strict';
|
|
8595
9011
|
if (keys(parsedVnodeStyle).length > styleDecls.length) {
|
8596
9012
|
nodesAreCompatible = false;
|
8597
9013
|
}
|
8598
|
-
vnodeStyle = ArrayJoin.call(expectedStyle, '
|
9014
|
+
vnodeStyle = ArrayJoin.call(expectedStyle, ' ');
|
8599
9015
|
}
|
8600
9016
|
if (!nodesAreCompatible) {
|
8601
9017
|
if (process.env.NODE_ENV !== 'production') {
|
8602
9018
|
const {
|
8603
9019
|
getProperty
|
8604
9020
|
} = renderer;
|
8605
|
-
|
9021
|
+
logWarn(`Mismatch hydrating element <${getProperty(elm, 'tagName').toLowerCase()}>: attribute "style" has different values, expected "${vnodeStyle}" but found "${elmStyle}".`, vnode.owner);
|
8606
9022
|
}
|
8607
9023
|
}
|
8608
9024
|
return nodesAreCompatible;
|
@@ -8634,7 +9050,7 @@ LWR.define('lwc/v/7_2_1', ['exports'], (function (exports) { 'use strict';
|
|
8634
9050
|
let isCompatibleElements = true;
|
8635
9051
|
if (getProperty(client, 'tagName') !== getProperty(ssr, 'tagName')) {
|
8636
9052
|
if (process.env.NODE_ENV !== 'production') {
|
8637
|
-
|
9053
|
+
logWarn(`Hydration mismatch: expecting element with tag "${getProperty(client, 'tagName').toLowerCase()}" but found "${getProperty(ssr, 'tagName').toLowerCase()}".`, owner);
|
8638
9054
|
}
|
8639
9055
|
return false;
|
8640
9056
|
}
|
@@ -8647,7 +9063,7 @@ LWR.define('lwc/v/7_2_1', ['exports'], (function (exports) { 'use strict';
|
|
8647
9063
|
// partId === 0 will always refer to the root element, this is guaranteed by the compiler.
|
8648
9064
|
if (parts?.[0].partId !== 0) {
|
8649
9065
|
if (process.env.NODE_ENV !== 'production') {
|
8650
|
-
|
9066
|
+
logWarn(`Mismatch hydrating element <${getProperty(client, 'tagName').toLowerCase()}>: attribute "${attrName}" has different values, expected "${getAttribute(client, attrName)}" but found "${getAttribute(ssr, attrName)}"`, owner);
|
8651
9067
|
}
|
8652
9068
|
isCompatibleElements = false;
|
8653
9069
|
}
|
@@ -8682,9 +9098,11 @@ LWR.define('lwc/v/7_2_1', ['exports'], (function (exports) { 'use strict';
|
|
8682
9098
|
// Explicitly skip hydration validation when static parts don't contain `style` or `className`.
|
8683
9099
|
// This means the style/class attributes are either static or don't exist on the element and
|
8684
9100
|
// cannot be affected by hydration.
|
8685
|
-
|
9101
|
+
// We need to do class first, style second to match the ordering of non-static-optimized nodes,
|
9102
|
+
// otherwise the ordering of console errors is different between the two.
|
8686
9103
|
const hasMatchingClass = shouldValidateAttr(data, 'className') ? validateClassAttr(vnode, elm, data, renderer) : true;
|
8687
|
-
|
9104
|
+
const hasMatchingStyleAttr = shouldValidateAttr(data, 'style') ? validateStyleAttr(vnode, elm, data, renderer) : true;
|
9105
|
+
if (isFalse(hasMatchingAttrs && hasMatchingClass && hasMatchingStyleAttr)) {
|
8688
9106
|
return false;
|
8689
9107
|
}
|
8690
9108
|
} else {
|
@@ -8698,19 +9116,6 @@ LWR.define('lwc/v/7_2_1', ['exports'], (function (exports) { 'use strict';
|
|
8698
9116
|
return true;
|
8699
9117
|
}
|
8700
9118
|
|
8701
|
-
/*
|
8702
|
-
* Copyright (c) 2018, salesforce.com, inc.
|
8703
|
-
* All rights reserved.
|
8704
|
-
* SPDX-License-Identifier: MIT
|
8705
|
-
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
8706
|
-
*/
|
8707
|
-
let hooksAreSet = false;
|
8708
|
-
function setHooks(hooks) {
|
8709
|
-
assert.isFalse(hooksAreSet, 'Hooks are already overridden, only one definition is allowed.');
|
8710
|
-
hooksAreSet = true;
|
8711
|
-
setSanitizeHtmlContentHook(hooks.sanitizeHtmlContent);
|
8712
|
-
}
|
8713
|
-
|
8714
9119
|
/*
|
8715
9120
|
* Copyright (c) 2024, Salesforce, Inc.
|
8716
9121
|
* All rights reserved.
|
@@ -8718,11 +9123,9 @@ LWR.define('lwc/v/7_2_1', ['exports'], (function (exports) { 'use strict';
|
|
8718
9123
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
8719
9124
|
*/
|
8720
9125
|
// See @lwc/engine-core/src/framework/template.ts
|
8721
|
-
const TEMPLATE_PROPS = ['slots', 'stylesheetToken', 'stylesheets', 'renderMode'];
|
9126
|
+
const TEMPLATE_PROPS = ['slots', 'stylesheetToken', 'stylesheets', 'renderMode', 'legacyStylesheetToken'];
|
8722
9127
|
// Expandos that may be placed on a stylesheet factory function, and which are meaningful to LWC at runtime
|
8723
|
-
const STYLESHEET_PROPS = [
|
8724
|
-
// SEE `KEY__SCOPED_CSS` in @lwc/style-compiler
|
8725
|
-
'$scoped$'];
|
9128
|
+
const STYLESHEET_PROPS = [KEY__SCOPED_CSS, KEY__NATIVE_ONLY_CSS];
|
8726
9129
|
// Via https://www.npmjs.com/package/object-observer
|
8727
9130
|
const ARRAY_MUTATION_METHODS = ['pop', 'push', 'shift', 'unshift', 'reverse', 'sort', 'fill', 'splice', 'copyWithin'];
|
8728
9131
|
let mutationTrackingDisabled = false;
|
@@ -8953,7 +9356,7 @@ LWR.define('lwc/v/7_2_1', ['exports'], (function (exports) { 'use strict';
|
|
8953
9356
|
}
|
8954
9357
|
return getReadOnlyProxy(obj);
|
8955
9358
|
}
|
8956
|
-
/** version:
|
9359
|
+
/** version: 8.9.0 */
|
8957
9360
|
|
8958
9361
|
/*
|
8959
9362
|
* Copyright (c) 2018, salesforce.com, inc.
|
@@ -9247,7 +9650,7 @@ LWR.define('lwc/v/7_2_1', ['exports'], (function (exports) { 'use strict';
|
|
9247
9650
|
formStateRestoreCallback(state, reason) {
|
9248
9651
|
runFormStateRestoreCallback(this, state, reason);
|
9249
9652
|
}
|
9250
|
-
/*LWC compiler
|
9653
|
+
/*LWC compiler v8.9.0*/
|
9251
9654
|
};
|
9252
9655
|
BaseHTMLElement = HTMLElement; // cache to track if it changes
|
9253
9656
|
}
|
@@ -9262,7 +9665,7 @@ LWR.define('lwc/v/7_2_1', ['exports'], (function (exports) { 'use strict';
|
|
9262
9665
|
// Using a BaseUpgradableConstructor superclass here is a perf optimization to avoid
|
9263
9666
|
// re-defining the same logic (connectedCallback, disconnectedCallback, etc.) over and over.
|
9264
9667
|
class UpgradableConstructor extends BaseUpgradableConstructor {
|
9265
|
-
/*LWC compiler
|
9668
|
+
/*LWC compiler v8.9.0*/
|
9266
9669
|
}
|
9267
9670
|
if (isFormAssociated) {
|
9268
9671
|
// Perf optimization - the vast majority of components have formAssociated=false,
|
@@ -9385,7 +9788,7 @@ LWR.define('lwc/v/7_2_1', ['exports'], (function (exports) { 'use strict';
|
|
9385
9788
|
function isNull(obj) {
|
9386
9789
|
return obj === null;
|
9387
9790
|
}
|
9388
|
-
/** version:
|
9791
|
+
/** version: 8.9.0 */
|
9389
9792
|
|
9390
9793
|
/*
|
9391
9794
|
* Copyright (c) 2023, salesforce.com, inc.
|
@@ -9405,7 +9808,7 @@ LWR.define('lwc/v/7_2_1', ['exports'], (function (exports) { 'use strict';
|
|
9405
9808
|
this.setNewContext = setNewContext;
|
9406
9809
|
this.setDisconnectedCallback = setDisconnectedCallback;
|
9407
9810
|
}
|
9408
|
-
/*LWC compiler
|
9811
|
+
/*LWC compiler v8.9.0*/
|
9409
9812
|
}
|
9410
9813
|
function registerContextConsumer(elm, adapterContextToken, subscriptionPayload) {
|
9411
9814
|
dispatchEvent(elm, new WireContextSubscriptionEvent(adapterContextToken, subscriptionPayload));
|
@@ -9828,7 +10231,7 @@ LWR.define('lwc/v/7_2_1', ['exports'], (function (exports) { 'use strict';
|
|
9828
10231
|
formStateRestoreCallback(state, reason) {
|
9829
10232
|
runFormStateRestoreCallback(this, state, reason);
|
9830
10233
|
}
|
9831
|
-
/*LWC compiler
|
10234
|
+
/*LWC compiler v8.9.0*/
|
9832
10235
|
}, _a.observedAttributes = observedAttributes,
|
9833
10236
|
// Note CustomElementConstructor is not upgraded by LWC and inherits directly from HTMLElement which means it calls the native
|
9834
10237
|
// attachInternals API.
|
@@ -10074,7 +10477,7 @@ LWR.define('lwc/v/7_2_1', ['exports'], (function (exports) { 'use strict';
|
|
10074
10477
|
});
|
10075
10478
|
});
|
10076
10479
|
}
|
10077
|
-
/** version:
|
10480
|
+
/** version: 8.9.0 */
|
10078
10481
|
|
10079
10482
|
exports.LightningElement = LightningElement;
|
10080
10483
|
exports.__unstable__ProfilerControl = profilerControl;
|
@@ -10101,6 +10504,7 @@ LWR.define('lwc/v/7_2_1', ['exports'], (function (exports) { 'use strict';
|
|
10101
10504
|
exports.setFeatureFlag = setFeatureFlag;
|
10102
10505
|
exports.setFeatureFlagForTest = setFeatureFlagForTest;
|
10103
10506
|
exports.setHooks = setHooks;
|
10507
|
+
exports.setTrustedSignalSet = setTrustedSignalSet;
|
10104
10508
|
exports.swapComponent = swapComponent;
|
10105
10509
|
exports.swapStyle = swapStyle;
|
10106
10510
|
exports.swapTemplate = swapTemplate;
|