@lwc/ssr-runtime 8.12.0 → 8.12.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs.js +34 -182
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.js +34 -182
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.cjs.js
CHANGED
@@ -332,14 +332,14 @@ function isObject(obj) {
|
|
332
332
|
function isString(obj) {
|
333
333
|
return typeof obj === 'string';
|
334
334
|
}
|
335
|
-
const OtS
|
335
|
+
const OtS = {}.toString;
|
336
336
|
/**
|
337
337
|
* Converts the argument to a string, safely accounting for objects with "null" prototype.
|
338
338
|
* Note that `toString(null)` returns `"[object Null]"` rather than `"null"`.
|
339
339
|
* @param obj Value to convert to a string.
|
340
340
|
* @returns String representation of the value.
|
341
341
|
*/
|
342
|
-
function toString
|
342
|
+
function toString(obj) {
|
343
343
|
if (obj?.toString) {
|
344
344
|
// Arrays might hold objects with "null" prototype So using
|
345
345
|
// Array.prototype.toString directly will cause an error Iterate through
|
@@ -355,13 +355,13 @@ function toString$1(obj) {
|
|
355
355
|
// 4. Array#toString converts recursive references to arrays to ''
|
356
356
|
// Ex: arr = [1]; arr.push(arr, 2); arr.toString() === '1,,2'; toString(arr) throws
|
357
357
|
// Ref: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/toString
|
358
|
-
return ArrayJoin.call(ArrayMap.call(obj, toString
|
358
|
+
return ArrayJoin.call(ArrayMap.call(obj, toString), ',');
|
359
359
|
}
|
360
360
|
return obj.toString();
|
361
361
|
}
|
362
362
|
else if (typeof obj === 'object') {
|
363
363
|
// This catches null and returns "[object Null]". Weird, but kept for backwards compatibility.
|
364
|
-
return OtS
|
364
|
+
return OtS.call(obj);
|
365
365
|
}
|
366
366
|
else {
|
367
367
|
return String(obj);
|
@@ -461,43 +461,6 @@ const { AriaAttrNameToPropNameMap, AriaPropNameToAttrNameMap } = /*@__PURE__*/ (
|
|
461
461
|
function isAriaAttribute(attrName) {
|
462
462
|
return attrName in AriaAttrNameToPropNameMap;
|
463
463
|
}
|
464
|
-
// This list is based on https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes
|
465
|
-
const GLOBAL_ATTRIBUTE = /*@__PURE__*/ new Set([
|
466
|
-
'accesskey',
|
467
|
-
'autocapitalize',
|
468
|
-
'autofocus',
|
469
|
-
'class',
|
470
|
-
'contenteditable',
|
471
|
-
'dir',
|
472
|
-
'draggable',
|
473
|
-
'enterkeyhint',
|
474
|
-
'exportparts',
|
475
|
-
'hidden',
|
476
|
-
'id',
|
477
|
-
'inputmode',
|
478
|
-
'is',
|
479
|
-
'itemid',
|
480
|
-
'itemprop',
|
481
|
-
'itemref',
|
482
|
-
'itemscope',
|
483
|
-
'itemtype',
|
484
|
-
'lang',
|
485
|
-
'nonce',
|
486
|
-
'part',
|
487
|
-
'slot',
|
488
|
-
'spellcheck',
|
489
|
-
'style',
|
490
|
-
'tabindex',
|
491
|
-
'title',
|
492
|
-
'translate',
|
493
|
-
]);
|
494
|
-
/**
|
495
|
-
*
|
496
|
-
* @param attrName
|
497
|
-
*/
|
498
|
-
function isGlobalHtmlAttribute(attrName) {
|
499
|
-
return GLOBAL_ATTRIBUTE.has(attrName);
|
500
|
-
}
|
501
464
|
// These are HTML standard prop/attribute IDL mappings, but are not predictable based on camel/kebab-case conversion
|
502
465
|
const SPECIAL_PROPERTY_ATTRIBUTE_MAPPING = /*@__PURE__@*/ new Map([
|
503
466
|
['accessKey', 'accesskey'],
|
@@ -517,6 +480,21 @@ const SPECIAL_PROPERTY_ATTRIBUTE_MAPPING = /*@__PURE__@*/ new Map([
|
|
517
480
|
['useMap', 'usemap'],
|
518
481
|
['htmlFor', 'for'],
|
519
482
|
]);
|
483
|
+
// Global properties that this framework currently reflects. For CSR, the native
|
484
|
+
// descriptors for these properties are added from HTMLElement.prototype to
|
485
|
+
// LightningElement.prototype. For SSR, in order to match CSR behavior, this
|
486
|
+
// list is used to determine which attributes to reflect.
|
487
|
+
const REFLECTIVE_GLOBAL_PROPERTY_SET = /*@__PURE__@*/ new Set([
|
488
|
+
'accessKey',
|
489
|
+
'dir',
|
490
|
+
'draggable',
|
491
|
+
'hidden',
|
492
|
+
'id',
|
493
|
+
'lang',
|
494
|
+
'spellcheck',
|
495
|
+
'tabIndex',
|
496
|
+
'title',
|
497
|
+
]);
|
520
498
|
/**
|
521
499
|
* Map associating previously transformed HTML property into HTML attribute.
|
522
500
|
*/
|
@@ -653,7 +631,7 @@ function setHooks(hooks) {
|
|
653
631
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
654
632
|
*/
|
655
633
|
const DEFAULT_SSR_MODE = 'sync';
|
656
|
-
/** version: 8.12.
|
634
|
+
/** version: 8.12.2 */
|
657
635
|
|
658
636
|
/*
|
659
637
|
* Copyright (c) 2024, Salesforce, Inc.
|
@@ -737,18 +715,6 @@ class ClassList {
|
|
737
715
|
const { isArray } = Array;
|
738
716
|
const { prototype: ObjectDotPrototype, getPrototypeOf, create: ObjectCreate, defineProperty: ObjectDefineProperty, isExtensible, getOwnPropertyDescriptor, getOwnPropertyNames, getOwnPropertySymbols, preventExtensions, hasOwnProperty, } = Object;
|
739
717
|
const { push: ArrayPush, concat: ArrayConcat } = Array.prototype;
|
740
|
-
const OtS = {}.toString;
|
741
|
-
function toString(obj) {
|
742
|
-
if (obj && obj.toString) {
|
743
|
-
return obj.toString();
|
744
|
-
}
|
745
|
-
else if (typeof obj === 'object') {
|
746
|
-
return OtS.call(obj);
|
747
|
-
}
|
748
|
-
else {
|
749
|
-
return obj + '';
|
750
|
-
}
|
751
|
-
}
|
752
718
|
function isUndefined(obj) {
|
753
719
|
return obj === undefined;
|
754
720
|
}
|
@@ -986,10 +952,6 @@ class ReactiveProxyHandler extends BaseProxyHandler {
|
|
986
952
|
return true;
|
987
953
|
}
|
988
954
|
setPrototypeOf(shadowTarget, prototype) {
|
989
|
-
/* istanbul ignore else */
|
990
|
-
if (process.env.NODE_ENV !== 'production') {
|
991
|
-
throw new Error(`Invalid setPrototypeOf invocation for reactive proxy ${toString(this.originalTarget)}. Prototype of reactive objects cannot be changed.`);
|
992
|
-
}
|
993
955
|
}
|
994
956
|
preventExtensions(shadowTarget) {
|
995
957
|
if (isExtensible(shadowTarget)) {
|
@@ -1053,147 +1015,31 @@ class ReadOnlyHandler extends BaseProxyHandler {
|
|
1053
1015
|
if (!isUndefined(wrappedSetter)) {
|
1054
1016
|
return wrappedSetter;
|
1055
1017
|
}
|
1056
|
-
const handler = this;
|
1057
1018
|
const set = function (v) {
|
1058
|
-
/* istanbul ignore else */
|
1059
|
-
if (process.env.NODE_ENV !== 'production') {
|
1060
|
-
const { originalTarget } = handler;
|
1061
|
-
throw new Error(`Invalid mutation: Cannot invoke a setter on "${originalTarget}". "${originalTarget}" is read-only.`);
|
1062
|
-
}
|
1063
1019
|
};
|
1064
1020
|
setterMap.set(originalSet, set);
|
1065
1021
|
return set;
|
1066
1022
|
}
|
1067
1023
|
set(shadowTarget, key, value) {
|
1068
|
-
/* istanbul ignore else */
|
1069
|
-
if (process.env.NODE_ENV !== 'production') {
|
1070
|
-
const { originalTarget } = this;
|
1071
|
-
const msg = isArray(originalTarget)
|
1072
|
-
? `Invalid mutation: Cannot mutate array at index ${key.toString()}. Array is read-only.`
|
1073
|
-
: `Invalid mutation: Cannot set "${key.toString()}" on "${originalTarget}". "${originalTarget}" is read-only.`;
|
1074
|
-
throw new Error(msg);
|
1075
|
-
}
|
1076
1024
|
/* istanbul ignore next */
|
1077
1025
|
return false;
|
1078
1026
|
}
|
1079
1027
|
deleteProperty(shadowTarget, key) {
|
1080
|
-
/* istanbul ignore else */
|
1081
|
-
if (process.env.NODE_ENV !== 'production') {
|
1082
|
-
const { originalTarget } = this;
|
1083
|
-
throw new Error(`Invalid mutation: Cannot delete "${key.toString()}" on "${originalTarget}". "${originalTarget}" is read-only.`);
|
1084
|
-
}
|
1085
1028
|
/* istanbul ignore next */
|
1086
1029
|
return false;
|
1087
1030
|
}
|
1088
1031
|
setPrototypeOf(shadowTarget, prototype) {
|
1089
|
-
/* istanbul ignore else */
|
1090
|
-
if (process.env.NODE_ENV !== 'production') {
|
1091
|
-
const { originalTarget } = this;
|
1092
|
-
throw new Error(`Invalid prototype mutation: Cannot set prototype on "${originalTarget}". "${originalTarget}" prototype is read-only.`);
|
1093
|
-
}
|
1094
1032
|
}
|
1095
1033
|
preventExtensions(shadowTarget) {
|
1096
|
-
/* istanbul ignore else */
|
1097
|
-
if (process.env.NODE_ENV !== 'production') {
|
1098
|
-
const { originalTarget } = this;
|
1099
|
-
throw new Error(`Invalid mutation: Cannot preventExtensions on ${originalTarget}". "${originalTarget} is read-only.`);
|
1100
|
-
}
|
1101
1034
|
/* istanbul ignore next */
|
1102
1035
|
return false;
|
1103
1036
|
}
|
1104
1037
|
defineProperty(shadowTarget, key, descriptor) {
|
1105
|
-
/* istanbul ignore else */
|
1106
|
-
if (process.env.NODE_ENV !== 'production') {
|
1107
|
-
const { originalTarget } = this;
|
1108
|
-
throw new Error(`Invalid mutation: Cannot defineProperty "${key.toString()}" on "${originalTarget}". "${originalTarget}" is read-only.`);
|
1109
|
-
}
|
1110
1038
|
/* istanbul ignore next */
|
1111
1039
|
return false;
|
1112
1040
|
}
|
1113
1041
|
}
|
1114
1042
|
|
1115
|
-
function extract(objectOrArray) {
|
1116
|
-
if (isArray(objectOrArray)) {
|
1117
|
-
return objectOrArray.map((item) => {
|
1118
|
-
const original = unwrap(item);
|
1119
|
-
if (original !== item) {
|
1120
|
-
return extract(original);
|
1121
|
-
}
|
1122
|
-
return item;
|
1123
|
-
});
|
1124
|
-
}
|
1125
|
-
const obj = ObjectCreate(getPrototypeOf(objectOrArray));
|
1126
|
-
const names = getOwnPropertyNames(objectOrArray);
|
1127
|
-
return ArrayConcat.call(names, getOwnPropertySymbols(objectOrArray)).reduce((seed, key) => {
|
1128
|
-
const item = objectOrArray[key];
|
1129
|
-
const original = unwrap(item);
|
1130
|
-
if (original !== item) {
|
1131
|
-
seed[key] = extract(original);
|
1132
|
-
}
|
1133
|
-
else {
|
1134
|
-
seed[key] = item;
|
1135
|
-
}
|
1136
|
-
return seed;
|
1137
|
-
}, obj);
|
1138
|
-
}
|
1139
|
-
const formatter = {
|
1140
|
-
header: (plainOrProxy) => {
|
1141
|
-
const originalTarget = unwrap(plainOrProxy);
|
1142
|
-
// if originalTarget is falsy or not unwrappable, exit
|
1143
|
-
if (!originalTarget || originalTarget === plainOrProxy) {
|
1144
|
-
return null;
|
1145
|
-
}
|
1146
|
-
const obj = extract(plainOrProxy);
|
1147
|
-
return ['object', { object: obj }];
|
1148
|
-
},
|
1149
|
-
hasBody: () => {
|
1150
|
-
return false;
|
1151
|
-
},
|
1152
|
-
body: () => {
|
1153
|
-
return null;
|
1154
|
-
},
|
1155
|
-
};
|
1156
|
-
// Inspired from paulmillr/es6-shim
|
1157
|
-
// https://github.com/paulmillr/es6-shim/blob/master/es6-shim.js#L176-L185
|
1158
|
-
/* istanbul ignore next */
|
1159
|
-
function getGlobal() {
|
1160
|
-
// the only reliable means to get the global object is `Function('return this')()`
|
1161
|
-
// However, this causes CSP violations in Chrome apps.
|
1162
|
-
if (typeof globalThis !== 'undefined') {
|
1163
|
-
return globalThis;
|
1164
|
-
}
|
1165
|
-
if (typeof self !== 'undefined') {
|
1166
|
-
return self;
|
1167
|
-
}
|
1168
|
-
if (typeof window !== 'undefined') {
|
1169
|
-
return window;
|
1170
|
-
}
|
1171
|
-
if (typeof global !== 'undefined') {
|
1172
|
-
return global;
|
1173
|
-
}
|
1174
|
-
// Gracefully degrade if not able to locate the global object
|
1175
|
-
return {};
|
1176
|
-
}
|
1177
|
-
function init() {
|
1178
|
-
/* istanbul ignore if */
|
1179
|
-
if (process.env.NODE_ENV === 'production') {
|
1180
|
-
// this method should never leak to prod
|
1181
|
-
throw new ReferenceError();
|
1182
|
-
}
|
1183
|
-
const global = getGlobal();
|
1184
|
-
// Custom Formatter for Dev Tools. To enable this, open Chrome Dev Tools
|
1185
|
-
// - Go to Settings,
|
1186
|
-
// - Under console, select "Enable custom formatters"
|
1187
|
-
// For more information, https://docs.google.com/document/d/1FTascZXT9cxfetuPRT2eXPQKXui4nWFivUnS_335T3U/preview
|
1188
|
-
const devtoolsFormatters = global.devtoolsFormatters || [];
|
1189
|
-
ArrayPush.call(devtoolsFormatters, formatter);
|
1190
|
-
global.devtoolsFormatters = devtoolsFormatters;
|
1191
|
-
}
|
1192
|
-
|
1193
|
-
/* istanbul ignore else */
|
1194
|
-
if (process.env.NODE_ENV !== 'production') {
|
1195
|
-
init();
|
1196
|
-
}
|
1197
1043
|
function defaultValueIsObservable(value) {
|
1198
1044
|
// intentionally checking for null
|
1199
1045
|
if (value === null) {
|
@@ -1385,7 +1231,7 @@ function filterProperties(props, publicFields, privateFields) {
|
|
1385
1231
|
keys(props).forEach((propName) => {
|
1386
1232
|
const attrName = htmlPropertyToAttribute(propName);
|
1387
1233
|
if (publicFieldSet.has(propName) ||
|
1388
|
-
((
|
1234
|
+
((REFLECTIVE_GLOBAL_PROPERTY_SET.has(propName) || isAriaAttribute(attrName)) &&
|
1389
1235
|
!privateFieldSet.has(propName))) {
|
1390
1236
|
propsToAssign[propName] = props[propName];
|
1391
1237
|
}
|
@@ -1471,7 +1317,7 @@ const ariaDescriptor = (attrName) => ({
|
|
1471
1317
|
this.removeAttribute(attrName);
|
1472
1318
|
}
|
1473
1319
|
else {
|
1474
|
-
this.setAttribute(attrName, toString
|
1320
|
+
this.setAttribute(attrName, toString(newValue));
|
1475
1321
|
}
|
1476
1322
|
}
|
1477
1323
|
},
|
@@ -1489,7 +1335,7 @@ const tabIndexDescriptor = () => ({
|
|
1489
1335
|
const num = Number(newValue);
|
1490
1336
|
const normalizedValue = isFinite(num) ? String(Math.trunc(num)) : '0';
|
1491
1337
|
if (normalizedValue !== currentValue) {
|
1492
|
-
this.setAttribute('tabindex', toString
|
1338
|
+
this.setAttribute('tabindex', toString(newValue));
|
1493
1339
|
}
|
1494
1340
|
},
|
1495
1341
|
});
|
@@ -1548,24 +1394,24 @@ class LightningElement {
|
|
1548
1394
|
return (__classPrivateFieldSet(this, _LightningElement_classList, new ClassList(this), "f"));
|
1549
1395
|
}
|
1550
1396
|
setAttribute(attrName, attrValue) {
|
1551
|
-
const normalizedName = StringToLowerCase.call(toString
|
1397
|
+
const normalizedName = StringToLowerCase.call(toString(attrName));
|
1552
1398
|
const normalizedValue = String(attrValue);
|
1553
1399
|
__classPrivateFieldGet(this, _LightningElement_attrs, "f")[normalizedName] = normalizedValue;
|
1554
1400
|
mutationTracker.add(this, normalizedName);
|
1555
1401
|
}
|
1556
1402
|
getAttribute(attrName) {
|
1557
|
-
const normalizedName = StringToLowerCase.call(toString
|
1403
|
+
const normalizedName = StringToLowerCase.call(toString(attrName));
|
1558
1404
|
if (hasOwnProperty$1.call(__classPrivateFieldGet(this, _LightningElement_attrs, "f"), normalizedName)) {
|
1559
1405
|
return __classPrivateFieldGet(this, _LightningElement_attrs, "f")[normalizedName];
|
1560
1406
|
}
|
1561
1407
|
return null;
|
1562
1408
|
}
|
1563
1409
|
hasAttribute(attrName) {
|
1564
|
-
const normalizedName = StringToLowerCase.call(toString
|
1410
|
+
const normalizedName = StringToLowerCase.call(toString(attrName));
|
1565
1411
|
return hasOwnProperty$1.call(__classPrivateFieldGet(this, _LightningElement_attrs, "f"), normalizedName);
|
1566
1412
|
}
|
1567
1413
|
removeAttribute(attrName) {
|
1568
|
-
const normalizedName = StringToLowerCase.call(toString
|
1414
|
+
const normalizedName = StringToLowerCase.call(toString(attrName));
|
1569
1415
|
delete __classPrivateFieldGet(this, _LightningElement_attrs, "f")[normalizedName];
|
1570
1416
|
// Track mutations for removal of non-existing attributes
|
1571
1417
|
mutationTracker.add(this, normalizedName);
|
@@ -1664,6 +1510,12 @@ function renderAttrsPrivate(instance, attrs, hostScopeToken, scopeToken) {
|
|
1664
1510
|
let hasClassAttribute = false;
|
1665
1511
|
for (const attrName of getOwnPropertyNames$1(attrs)) {
|
1666
1512
|
let attrValue = attrs[attrName];
|
1513
|
+
// Backwards compatibility with historical patchStyleAttribute() behavior:
|
1514
|
+
// https://github.com/salesforce/lwc/blob/59e2c6c/packages/%40lwc/engine-core/src/framework/modules/computed-style-attr.ts#L40
|
1515
|
+
if (attrName === 'style' && (!isString(attrValue) || attrValue === '')) {
|
1516
|
+
// If the style attribute is invalid, we don't render it.
|
1517
|
+
continue;
|
1518
|
+
}
|
1667
1519
|
if (isNull(attrValue) || isUndefined$1(attrValue)) {
|
1668
1520
|
attrValue = '';
|
1669
1521
|
}
|
@@ -1984,5 +1836,5 @@ exports.track = track;
|
|
1984
1836
|
exports.unwrap = unwrap$1;
|
1985
1837
|
exports.validateStyleTextContents = validateStyleTextContents;
|
1986
1838
|
exports.wire = wire;
|
1987
|
-
/** version: 8.12.
|
1839
|
+
/** version: 8.12.2 */
|
1988
1840
|
//# sourceMappingURL=index.cjs.js.map
|