@lwc/ssr-runtime 8.5.0 → 8.7.0
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/clone-and-deep-freeze.d.ts +1 -0
- package/dist/index.cjs.js +892 -714
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +5 -3
- package/dist/index.js +891 -715
- package/dist/index.js.map +1 -1
- package/dist/lightning-element.d.ts +52 -0
- package/dist/reflection.d.ts +7 -2
- package/dist/stubs.d.ts +0 -1
- package/package.json +2 -2
package/dist/index.cjs.js
CHANGED
@@ -11,110 +11,217 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
11
11
|
* SPDX-License-Identifier: MIT
|
12
12
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
13
13
|
*/
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
this.el = el;
|
18
|
-
}
|
19
|
-
add(...newClassNames) {
|
20
|
-
const className = this.el.className;
|
21
|
-
const set = new Set(className.split(MULTI_SPACE).filter(Boolean));
|
22
|
-
for (const newClassName of newClassNames) {
|
23
|
-
set.add(newClassName);
|
24
|
-
}
|
25
|
-
this.el.className = Array.from(set).join(' ');
|
26
|
-
}
|
27
|
-
contains(className) {
|
28
|
-
const currentClassNameStr = this.el.className;
|
29
|
-
return currentClassNameStr.split(MULTI_SPACE).includes(className);
|
30
|
-
}
|
31
|
-
remove(...classNamesToRemove) {
|
32
|
-
const className = this.el.className;
|
33
|
-
const set = new Set(className.split(MULTI_SPACE).filter(Boolean));
|
34
|
-
for (const newClassName of classNamesToRemove) {
|
35
|
-
set.delete(newClassName);
|
36
|
-
}
|
37
|
-
this.el.className = Array.from(set).join(' ');
|
38
|
-
}
|
39
|
-
replace(oldClassName, newClassName) {
|
40
|
-
let classWasReplaced = false;
|
41
|
-
const className = this.el.className;
|
42
|
-
const listOfClasses = className.split(MULTI_SPACE).filter(Boolean);
|
43
|
-
listOfClasses.forEach((value, idx) => {
|
44
|
-
if (value === oldClassName) {
|
45
|
-
classWasReplaced = true;
|
46
|
-
listOfClasses[idx] = newClassName;
|
47
|
-
}
|
48
|
-
});
|
49
|
-
this.el.className = listOfClasses.join(' ');
|
50
|
-
return classWasReplaced;
|
51
|
-
}
|
52
|
-
toggle(classNameToToggle, force) {
|
53
|
-
const classNameStr = this.el.className;
|
54
|
-
const set = new Set(classNameStr.split(MULTI_SPACE).filter(Boolean));
|
55
|
-
if (!set.has(classNameToToggle) && force !== false) {
|
56
|
-
set.add(classNameToToggle);
|
57
|
-
}
|
58
|
-
else if (set.has(classNameToToggle) && force !== true) {
|
59
|
-
set.delete(classNameToToggle);
|
60
|
-
}
|
61
|
-
this.el.className = Array.from(set).join(' ');
|
62
|
-
return set.has(classNameToToggle);
|
63
|
-
}
|
64
|
-
get value() {
|
65
|
-
return this.el.className;
|
66
|
-
}
|
67
|
-
toString() {
|
68
|
-
return this.el.className;
|
69
|
-
}
|
70
|
-
item(_index) {
|
71
|
-
throw new Error('Method "item" not implemented.');
|
72
|
-
}
|
73
|
-
supports(_token) {
|
74
|
-
throw new Error('Method "supports" not implemented.');
|
75
|
-
}
|
76
|
-
forEach(_callbackfn, _thisArg) {
|
77
|
-
throw new Error('Method "forEach" not implemented.');
|
78
|
-
}
|
79
|
-
get length() {
|
80
|
-
throw new Error('Property "length" not implemented.');
|
81
|
-
}
|
14
|
+
// Stubs for all the un-implemented exports from @lwc/engine-server
|
15
|
+
function api(..._) {
|
16
|
+
throw new Error('@api cannot be used in SSR context.');
|
82
17
|
}
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
function
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
function
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
}
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
18
|
+
function createContextProvider(..._) {
|
19
|
+
throw new Error('createContextProvider cannot be used in SSR context.');
|
20
|
+
}
|
21
|
+
function createElement(..._) {
|
22
|
+
throw new Error('createElement cannot be used in SSR context.');
|
23
|
+
}
|
24
|
+
function freezeTemplate(..._) {
|
25
|
+
throw new Error('freezeTemplate cannot be used in SSR context.');
|
26
|
+
}
|
27
|
+
function getComponentDef(..._) {
|
28
|
+
throw new Error('getComponentDef cannot be used in SSR context.');
|
29
|
+
}
|
30
|
+
function isComponentConstructor(..._) {
|
31
|
+
throw new Error('isComponentConstructor cannot be used in SSR context.');
|
32
|
+
}
|
33
|
+
function parseFragment(..._) {
|
34
|
+
throw new Error('parseFragment cannot be used in SSR context.');
|
35
|
+
}
|
36
|
+
function parseSVGFragment(..._) {
|
37
|
+
throw new Error('parseSVGFragment cannot be used in SSR context.');
|
38
|
+
}
|
39
|
+
function readonly(..._) {
|
40
|
+
throw new Error('readonly cannot be used in SSR context.');
|
41
|
+
}
|
42
|
+
function registerComponent(..._) {
|
43
|
+
throw new Error('registerComponent cannot be used in SSR context.');
|
44
|
+
}
|
45
|
+
function registerDecorators(..._) {
|
46
|
+
throw new Error('registerDecorators cannot be used in SSR context.');
|
47
|
+
}
|
48
|
+
function registerTemplate(..._) {
|
49
|
+
throw new Error('registerTemplate cannot be used in SSR context.');
|
50
|
+
}
|
51
|
+
function sanitizeAttribute(..._) {
|
52
|
+
throw new Error('sanitizeAttribute cannot be used in SSR context.');
|
53
|
+
}
|
54
|
+
function setFeatureFlag(..._) {
|
55
|
+
throw new Error('setFeatureFlag cannot be used in SSR context.');
|
56
|
+
}
|
57
|
+
function setFeatureFlagForTest(..._) {
|
58
|
+
throw new Error('setFeatureFlagForTest cannot be used in SSR context.');
|
59
|
+
}
|
60
|
+
function swapComponent(..._) {
|
61
|
+
throw new Error('swapComponent cannot be used in SSR context.');
|
62
|
+
}
|
63
|
+
function swapStyle(..._) {
|
64
|
+
throw new Error('swapStyle cannot be used in SSR context.');
|
65
|
+
}
|
66
|
+
function swapTemplate(..._) {
|
67
|
+
throw new Error('swapTemplate cannot be used in SSR context.');
|
68
|
+
}
|
69
|
+
function track(..._) {
|
70
|
+
throw new Error('@track cannot be used in SSR context.');
|
71
|
+
}
|
72
|
+
function unwrap(..._) {
|
73
|
+
throw new Error('unwrap cannot be used in SSR context.');
|
74
|
+
}
|
75
|
+
function wire(..._) {
|
76
|
+
throw new Error('@wire cannot be used in SSR context.');
|
77
|
+
}
|
78
|
+
const renderer = {
|
79
|
+
isSyntheticShadowDefined: false,
|
80
|
+
insert(..._) {
|
81
|
+
throw new Error('renderer.insert cannot be used in SSR context.');
|
82
|
+
},
|
83
|
+
remove(..._) {
|
84
|
+
throw new Error('renderer.remove cannot be used in SSR context.');
|
85
|
+
},
|
86
|
+
cloneNode(..._) {
|
87
|
+
throw new Error('renderer.cloneNode cannot be used in SSR context.');
|
88
|
+
},
|
89
|
+
createFragment(..._) {
|
90
|
+
throw new Error('renderer.createFragment cannot be used in SSR context.');
|
91
|
+
},
|
92
|
+
createElement(..._) {
|
93
|
+
throw new Error('renderer.createElement cannot be used in SSR context.');
|
94
|
+
},
|
95
|
+
createText(..._) {
|
96
|
+
throw new Error('renderer.createText cannot be used in SSR context.');
|
97
|
+
},
|
98
|
+
createComment(..._) {
|
99
|
+
throw new Error('renderer.createComment cannot be used in SSR context.');
|
100
|
+
},
|
101
|
+
createCustomElement(..._) {
|
102
|
+
throw new Error('renderer.createCustomElement cannot be used in SSR context.');
|
103
|
+
},
|
104
|
+
nextSibling(..._) {
|
105
|
+
throw new Error('renderer.nextSibling cannot be used in SSR context.');
|
106
|
+
},
|
107
|
+
previousSibling(..._) {
|
108
|
+
throw new Error('renderer.previousSibling cannot be used in SSR context.');
|
109
|
+
},
|
110
|
+
attachShadow(..._) {
|
111
|
+
throw new Error('renderer.attachShadow cannot be used in SSR context.');
|
112
|
+
},
|
113
|
+
getProperty(..._) {
|
114
|
+
throw new Error('renderer.getProperty cannot be used in SSR context.');
|
115
|
+
},
|
116
|
+
setProperty(..._) {
|
117
|
+
throw new Error('renderer.setProperty cannot be used in SSR context.');
|
118
|
+
},
|
119
|
+
setText(..._) {
|
120
|
+
throw new Error('renderer.setText cannot be used in SSR context.');
|
121
|
+
},
|
122
|
+
getAttribute(..._) {
|
123
|
+
throw new Error('renderer.getAttribute cannot be used in SSR context.');
|
124
|
+
},
|
125
|
+
setAttribute(..._) {
|
126
|
+
throw new Error('renderer.setAttribute cannot be used in SSR context.');
|
127
|
+
},
|
128
|
+
removeAttribute(..._) {
|
129
|
+
throw new Error('renderer.removeAttribute cannot be used in SSR context.');
|
130
|
+
},
|
131
|
+
addEventListener(..._) {
|
132
|
+
throw new Error('renderer.addEventListener cannot be used in SSR context.');
|
133
|
+
},
|
134
|
+
removeEventListener(..._) {
|
135
|
+
throw new Error('renderer.removeEventListener cannot be used in SSR context.');
|
136
|
+
},
|
137
|
+
dispatchEvent(..._) {
|
138
|
+
throw new Error('renderer.dispatchEvent cannot be used in SSR context.');
|
139
|
+
},
|
140
|
+
getClassList(..._) {
|
141
|
+
throw new Error('renderer.getClassList cannot be used in SSR context.');
|
142
|
+
},
|
143
|
+
setCSSStyleProperty(..._) {
|
144
|
+
throw new Error('renderer.setCSSStyleProperty cannot be used in SSR context.');
|
145
|
+
},
|
146
|
+
getBoundingClientRect(..._) {
|
147
|
+
throw new Error('renderer.getBoundingClientRect cannot be used in SSR context.');
|
148
|
+
},
|
149
|
+
querySelector(..._) {
|
150
|
+
throw new Error('renderer.querySelector cannot be used in SSR context.');
|
151
|
+
},
|
152
|
+
querySelectorAll(..._) {
|
153
|
+
throw new Error('renderer.querySelectorAll cannot be used in SSR context.');
|
154
|
+
},
|
155
|
+
getElementsByTagName(..._) {
|
156
|
+
throw new Error('renderer.getElementsByTagName cannot be used in SSR context.');
|
157
|
+
},
|
158
|
+
getElementsByClassName(..._) {
|
159
|
+
throw new Error('renderer.getElementsByClassName cannot be used in SSR context.');
|
160
|
+
},
|
161
|
+
getChildren(..._) {
|
162
|
+
throw new Error('renderer.getChildren cannot be used in SSR context.');
|
163
|
+
},
|
164
|
+
getChildNodes(..._) {
|
165
|
+
throw new Error('renderer.getChildNodes cannot be used in SSR context.');
|
166
|
+
},
|
167
|
+
getFirstChild(..._) {
|
168
|
+
throw new Error('renderer.getFirstChild cannot be used in SSR context.');
|
169
|
+
},
|
170
|
+
getFirstElementChild(..._) {
|
171
|
+
throw new Error('renderer.getFirstElementChild cannot be used in SSR context.');
|
172
|
+
},
|
173
|
+
getLastChild(..._) {
|
174
|
+
throw new Error('renderer.getLastChild cannot be used in SSR context.');
|
175
|
+
},
|
176
|
+
getLastElementChild(..._) {
|
177
|
+
throw new Error('renderer.getLastElementChild cannot be used in SSR context.');
|
178
|
+
},
|
179
|
+
getTagName(..._) {
|
180
|
+
throw new Error('renderer.getTagName cannot be used in SSR context.');
|
181
|
+
},
|
182
|
+
getStyle(..._) {
|
183
|
+
throw new Error('renderer.getStyle cannot be used in SSR context.');
|
184
|
+
},
|
185
|
+
isConnected(..._) {
|
186
|
+
throw new Error('renderer.isConnected cannot be used in SSR context.');
|
187
|
+
},
|
188
|
+
insertStylesheet(..._) {
|
189
|
+
throw new Error('renderer.insertStylesheet cannot be used in SSR context.');
|
190
|
+
},
|
191
|
+
assertInstanceOfHTMLElement(..._) {
|
192
|
+
throw new Error('renderer.assertInstanceOfHTMLElement cannot be used in SSR context.');
|
193
|
+
},
|
194
|
+
ownerDocument(..._) {
|
195
|
+
throw new Error('renderer.ownerDocument cannot be used in SSR context.');
|
196
|
+
},
|
197
|
+
registerContextConsumer(..._) {
|
198
|
+
throw new Error('renderer.registerContextConsumer cannot be used in SSR context.');
|
199
|
+
},
|
200
|
+
attachInternals(..._) {
|
201
|
+
throw new Error('renderer.attachInternals cannot be used in SSR context.');
|
202
|
+
},
|
203
|
+
defineCustomElement(..._) {
|
204
|
+
throw new Error('renderer.defineCustomElement cannot be used in SSR context.');
|
205
|
+
},
|
206
|
+
getParentNode(..._) {
|
207
|
+
throw new Error('renderer.getParentNode cannot be used in SSR context.');
|
208
|
+
},
|
209
|
+
startTrackingMutations(..._) {
|
210
|
+
throw new Error('renderer.startTrackingMutations cannot be used in SSR context.');
|
211
|
+
},
|
212
|
+
stopTrackingMutations(..._) {
|
213
|
+
throw new Error('renderer.stopTrackingMutations cannot be used in SSR context.');
|
214
|
+
},
|
117
215
|
};
|
216
|
+
/**
|
217
|
+
* The hot API is used to orchestrate hot swapping in client rendered components.
|
218
|
+
* It doesn't do anything on the server side, however, you may import it.
|
219
|
+
*
|
220
|
+
* The whole point of defining this and exporting it is so that you can import it in isomorphic code without
|
221
|
+
* an error being thrown by the import itself.
|
222
|
+
*/
|
223
|
+
// A real stub, not a "not implemented" one! 😯
|
224
|
+
const hot = undefined;
|
118
225
|
|
119
226
|
/**
|
120
227
|
* Copyright (c) 2024 Salesforce, Inc.
|
@@ -130,6 +237,16 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
|
|
130
237
|
* @param value
|
131
238
|
* @param msg
|
132
239
|
*/
|
240
|
+
/**
|
241
|
+
*
|
242
|
+
* @param value
|
243
|
+
* @param msg
|
244
|
+
*/
|
245
|
+
function isFalse$1(value, msg) {
|
246
|
+
if (value) {
|
247
|
+
throw new Error(`Assert Violation: ${msg}`);
|
248
|
+
}
|
249
|
+
}
|
133
250
|
|
134
251
|
/*
|
135
252
|
* Copyright (c) 2024, Salesforce, Inc.
|
@@ -182,8 +299,18 @@ from: ArrayFrom, } = Array;
|
|
182
299
|
// statement, rather than this declaration.
|
183
300
|
const { concat: ArrayConcat, copyWithin: ArrayCopyWithin, every: ArrayEvery, fill: ArrayFill, filter: ArrayFilter, find: ArrayFind, findIndex: ArrayFindIndex, includes: ArrayIncludes, indexOf: ArrayIndexOf, join: ArrayJoin, map: ArrayMap, pop: ArrayPop, push: ArrayPush, reduce: ArrayReduce, reverse: ArrayReverse, shift: ArrayShift, slice: ArraySlice, some: ArraySome, sort: ArraySort, splice: ArraySplice, unshift: ArrayUnshift, forEach, // Weird anomaly!
|
184
301
|
} = Array.prototype;
|
302
|
+
/** Detached {@linkcode String.fromCharCode}; see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/fromCharCode MDN Reference}. */
|
303
|
+
const { fromCharCode: StringFromCharCode } = String;
|
185
304
|
// No JSDocs here - see comment for Array.prototype
|
186
305
|
const { charAt: StringCharAt, charCodeAt: StringCharCodeAt, replace: StringReplace, split: StringSplit, slice: StringSlice, toLowerCase: StringToLowerCase, trim: StringTrim, } = String.prototype;
|
306
|
+
/**
|
307
|
+
* Determines whether the argument is `undefined`.
|
308
|
+
* @param obj Value to test
|
309
|
+
* @returns `true` if the value is `undefined`.
|
310
|
+
*/
|
311
|
+
function isUndefined(obj) {
|
312
|
+
return obj === undefined;
|
313
|
+
}
|
187
314
|
/**
|
188
315
|
* Determines whether the argument is `null`.
|
189
316
|
* @param obj Value to test
|
@@ -192,6 +319,14 @@ const { charAt: StringCharAt, charCodeAt: StringCharCodeAt, replace: StringRepla
|
|
192
319
|
function isNull(obj) {
|
193
320
|
return obj === null;
|
194
321
|
}
|
322
|
+
/**
|
323
|
+
* Determines whether the argument is an object or null.
|
324
|
+
* @param obj Value to test
|
325
|
+
* @returns `true` if the value is an object or null.
|
326
|
+
*/
|
327
|
+
function isObject(obj) {
|
328
|
+
return typeof obj === 'object';
|
329
|
+
}
|
195
330
|
const OtS = {}.toString;
|
196
331
|
/**
|
197
332
|
* Converts the argument to a string, safely accounting for objects with "null" prototype.
|
@@ -306,442 +441,325 @@ const { AriaAttrNameToPropNameMap, AriaPropNameToAttrNameMap } = /*@__PURE__*/ (
|
|
306
441
|
// Synthetic creation of all AOM property descriptors for Custom Elements
|
307
442
|
forEach.call(AriaPropertyNames, (propName) => {
|
308
443
|
const attrName = StringToLowerCase.call(StringReplace.call(propName, /^aria/, () => 'aria-'));
|
444
|
+
// These type assertions are because the map types are a 1:1 mapping of ariaX to aria-x.
|
445
|
+
// TypeScript knows we have one of ariaX | ariaY and one of aria-x | aria-y, and tries to
|
446
|
+
// prevent us from doing ariaX: aria-y, but we that it's safe.
|
309
447
|
AriaAttrNameToPropNameMap[attrName] = propName;
|
310
448
|
AriaPropNameToAttrNameMap[propName] = attrName;
|
311
449
|
});
|
312
450
|
return { AriaAttrNameToPropNameMap, AriaPropNameToAttrNameMap };
|
313
451
|
})();
|
314
|
-
|
315
|
-
/*
|
316
|
-
* Copyright (c) 2020, salesforce.com, inc.
|
317
|
-
* All rights reserved.
|
318
|
-
* SPDX-License-Identifier: MIT
|
319
|
-
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
320
|
-
*/
|
321
|
-
const ESCAPED_CHARS = {
|
322
|
-
'"': '"',
|
323
|
-
"'": ''',
|
324
|
-
'<': '<',
|
325
|
-
'>': '>',
|
326
|
-
'&': '&',
|
327
|
-
};
|
328
452
|
/**
|
329
453
|
*
|
330
|
-
* @param
|
331
|
-
* @param attrMode
|
332
|
-
*/
|
333
|
-
function htmlEscape(str, attrMode = false) {
|
334
|
-
const searchValue = attrMode ? /["&]/g : /["'<>&]/g;
|
335
|
-
return str.replace(searchValue, (char) => ESCAPED_CHARS[char]);
|
336
|
-
}
|
337
|
-
function flattenStylesheets(stylesheets) {
|
338
|
-
const list = [];
|
339
|
-
for (const stylesheet of stylesheets) {
|
340
|
-
if (!isArray(stylesheet)) {
|
341
|
-
list.push(stylesheet);
|
342
|
-
}
|
343
|
-
else {
|
344
|
-
list.push(...flattenStylesheets(stylesheet));
|
345
|
-
}
|
346
|
-
}
|
347
|
-
return list;
|
348
|
-
}
|
349
|
-
/** version: 8.5.0 */
|
350
|
-
|
351
|
-
/*
|
352
|
-
* Copyright (c) 2024, Salesforce, Inc.
|
353
|
-
* All rights reserved.
|
354
|
-
* SPDX-License-Identifier: MIT
|
355
|
-
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
454
|
+
* @param attrName
|
356
455
|
*/
|
357
|
-
|
358
|
-
|
359
|
-
constructor() {
|
360
|
-
_MutationTracker_enabledSet.set(this, new WeakSet());
|
361
|
-
_MutationTracker_mutationMap.set(this, new WeakMap());
|
362
|
-
}
|
363
|
-
add(instance, attrName) {
|
364
|
-
if (__classPrivateFieldGet(this, _MutationTracker_enabledSet, "f").has(instance)) {
|
365
|
-
let mutatedAttrs = __classPrivateFieldGet(this, _MutationTracker_mutationMap, "f").get(instance);
|
366
|
-
if (!mutatedAttrs) {
|
367
|
-
mutatedAttrs = new Set();
|
368
|
-
__classPrivateFieldGet(this, _MutationTracker_mutationMap, "f").set(instance, mutatedAttrs);
|
369
|
-
}
|
370
|
-
mutatedAttrs.add(attrName.toLowerCase());
|
371
|
-
}
|
372
|
-
}
|
373
|
-
enable(instance) {
|
374
|
-
__classPrivateFieldGet(this, _MutationTracker_enabledSet, "f").add(instance);
|
375
|
-
}
|
376
|
-
disable(instance) {
|
377
|
-
__classPrivateFieldGet(this, _MutationTracker_enabledSet, "f").delete(instance);
|
378
|
-
}
|
379
|
-
renderMutatedAttrs(instance) {
|
380
|
-
const mutatedAttrs = __classPrivateFieldGet(this, _MutationTracker_mutationMap, "f").get(instance);
|
381
|
-
if (mutatedAttrs) {
|
382
|
-
return ` data-lwc-host-mutated="${[...mutatedAttrs].sort().join(' ')}"`;
|
383
|
-
}
|
384
|
-
else {
|
385
|
-
return '';
|
386
|
-
}
|
387
|
-
}
|
456
|
+
function isAriaAttribute(attrName) {
|
457
|
+
return attrName in AriaAttrNameToPropNameMap;
|
388
458
|
}
|
389
|
-
|
390
|
-
const
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
459
|
+
// This list is based on https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes
|
460
|
+
const GLOBAL_ATTRIBUTE = /*@__PURE__*/ new Set([
|
461
|
+
'accesskey',
|
462
|
+
'autocapitalize',
|
463
|
+
'autofocus',
|
464
|
+
'class',
|
465
|
+
'contenteditable',
|
466
|
+
'contextmenu',
|
467
|
+
'dir',
|
468
|
+
'draggable',
|
469
|
+
'enterkeyhint',
|
470
|
+
'exportparts',
|
471
|
+
'hidden',
|
472
|
+
'id',
|
473
|
+
'inputmode',
|
474
|
+
'is',
|
475
|
+
'itemid',
|
476
|
+
'itemprop',
|
477
|
+
'itemref',
|
478
|
+
'itemscope',
|
479
|
+
'itemtype',
|
480
|
+
'lang',
|
481
|
+
'nonce',
|
482
|
+
'part',
|
483
|
+
'slot',
|
484
|
+
'spellcheck',
|
485
|
+
'style',
|
486
|
+
'tabindex',
|
487
|
+
'title',
|
488
|
+
'translate',
|
489
|
+
]);
|
414
490
|
/**
|
415
|
-
*
|
491
|
+
*
|
492
|
+
* @param attrName
|
416
493
|
*/
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
set(newValue) {
|
440
|
-
const currentValue = this.getAttribute(attrName);
|
441
|
-
const normalizedValue = String(Boolean(newValue));
|
442
|
-
if (normalizedValue !== currentValue) {
|
443
|
-
this.setAttribute(attrName, normalizedValue);
|
444
|
-
}
|
445
|
-
},
|
446
|
-
});
|
494
|
+
function isGlobalHtmlAttribute(attrName) {
|
495
|
+
return GLOBAL_ATTRIBUTE.has(attrName);
|
496
|
+
}
|
497
|
+
// These are HTML standard prop/attribute IDL mappings, but are not predictable based on camel/kebab-case conversion
|
498
|
+
const SPECIAL_PROPERTY_ATTRIBUTE_MAPPING = /*@__PURE__@*/ new Map([
|
499
|
+
['accessKey', 'accesskey'],
|
500
|
+
['readOnly', 'readonly'],
|
501
|
+
['tabIndex', 'tabindex'],
|
502
|
+
['bgColor', 'bgcolor'],
|
503
|
+
['colSpan', 'colspan'],
|
504
|
+
['rowSpan', 'rowspan'],
|
505
|
+
['contentEditable', 'contenteditable'],
|
506
|
+
['crossOrigin', 'crossorigin'],
|
507
|
+
['dateTime', 'datetime'],
|
508
|
+
['formAction', 'formaction'],
|
509
|
+
['isMap', 'ismap'],
|
510
|
+
['maxLength', 'maxlength'],
|
511
|
+
['minLength', 'minlength'],
|
512
|
+
['noValidate', 'novalidate'],
|
513
|
+
['useMap', 'usemap'],
|
514
|
+
['htmlFor', 'for'],
|
515
|
+
]);
|
447
516
|
/**
|
448
|
-
*
|
517
|
+
* Map associating previously transformed HTML property into HTML attribute.
|
449
518
|
*/
|
450
|
-
const
|
451
|
-
configurable: true,
|
452
|
-
enumerable: true,
|
453
|
-
get() {
|
454
|
-
return this.hasAttribute(attrName);
|
455
|
-
},
|
456
|
-
set(newValue) {
|
457
|
-
const hasAttribute = this.hasAttribute(attrName);
|
458
|
-
if (newValue) {
|
459
|
-
if (!hasAttribute) {
|
460
|
-
this.setAttribute(attrName, '');
|
461
|
-
}
|
462
|
-
}
|
463
|
-
else {
|
464
|
-
if (hasAttribute) {
|
465
|
-
this.removeAttribute(attrName);
|
466
|
-
}
|
467
|
-
}
|
468
|
-
},
|
469
|
-
});
|
519
|
+
const CACHED_PROPERTY_ATTRIBUTE_MAPPING = /*@__PURE__@*/ new Map();
|
470
520
|
/**
|
471
|
-
*
|
521
|
+
*
|
522
|
+
* @param propName
|
472
523
|
*/
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
|
524
|
+
function htmlPropertyToAttribute(propName) {
|
525
|
+
const ariaAttributeName = AriaPropNameToAttrNameMap[propName];
|
526
|
+
if (!isUndefined(ariaAttributeName)) {
|
527
|
+
return ariaAttributeName;
|
528
|
+
}
|
529
|
+
const specialAttributeName = SPECIAL_PROPERTY_ATTRIBUTE_MAPPING.get(propName);
|
530
|
+
if (!isUndefined(specialAttributeName)) {
|
531
|
+
return specialAttributeName;
|
532
|
+
}
|
533
|
+
const cachedAttributeName = CACHED_PROPERTY_ATTRIBUTE_MAPPING.get(propName);
|
534
|
+
if (!isUndefined(cachedAttributeName)) {
|
535
|
+
return cachedAttributeName;
|
536
|
+
}
|
537
|
+
let attributeName = '';
|
538
|
+
for (let i = 0, len = propName.length; i < len; i++) {
|
539
|
+
const code = StringCharCodeAt.call(propName, i);
|
540
|
+
if (code >= 65 && // "A"
|
541
|
+
code <= 90 // "Z"
|
542
|
+
) {
|
543
|
+
attributeName += '-' + StringFromCharCode(code + 32);
|
491
544
|
}
|
492
|
-
|
493
|
-
|
494
|
-
function reflectAttrToProp(instance, attrName, attrValue) {
|
495
|
-
const reflectedPropName = attrsToProps[attrName];
|
496
|
-
// If it is a reflected property and it was not overridden by the instance
|
497
|
-
if (reflectedPropName && !hasOwnProperty.call(instance, reflectedPropName)) {
|
498
|
-
const currentValue = instance[reflectedPropName];
|
499
|
-
if (currentValue !== attrValue) {
|
500
|
-
instance[reflectedPropName] = attrValue;
|
545
|
+
else {
|
546
|
+
attributeName += StringFromCharCode(code);
|
501
547
|
}
|
502
548
|
}
|
549
|
+
CACHED_PROPERTY_ATTRIBUTE_MAPPING.set(propName, attributeName);
|
550
|
+
return attributeName;
|
503
551
|
}
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
|
509
|
-
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
|
514
|
-
|
515
|
-
|
516
|
-
|
517
|
-
},
|
518
|
-
set(newValue) {
|
519
|
-
const currentValue = this.getAttribute('tabindex');
|
520
|
-
const num = Number(newValue);
|
521
|
-
const normalizedValue = isFinite(num) ? String(Math.trunc(num)) : '0';
|
522
|
-
if (normalizedValue !== currentValue) {
|
523
|
-
this.setAttribute('tabindex', toString(newValue));
|
524
|
-
}
|
525
|
-
},
|
526
|
-
},
|
527
|
-
title: stringDescriptor('title'),
|
552
|
+
|
553
|
+
/*
|
554
|
+
* Copyright (c) 2020, salesforce.com, inc.
|
555
|
+
* All rights reserved.
|
556
|
+
* SPDX-License-Identifier: MIT
|
557
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
558
|
+
*/
|
559
|
+
const ESCAPED_CHARS = {
|
560
|
+
'"': '"',
|
561
|
+
"'": ''',
|
562
|
+
'<': '<',
|
563
|
+
'>': '>',
|
564
|
+
'&': '&',
|
528
565
|
};
|
529
|
-
|
530
|
-
|
531
|
-
|
566
|
+
/**
|
567
|
+
*
|
568
|
+
* @param str
|
569
|
+
* @param attrMode
|
570
|
+
*/
|
571
|
+
function htmlEscape(str, attrMode = false) {
|
572
|
+
const searchValue = attrMode ? /["&]/g : /["'<>&]/g;
|
573
|
+
return str.replace(searchValue, (char) => ESCAPED_CHARS[char]);
|
532
574
|
}
|
533
575
|
|
534
576
|
/*
|
535
|
-
* Copyright (c) 2024,
|
577
|
+
* Copyright (c) 2024, Salesforce, Inc.
|
536
578
|
* All rights reserved.
|
537
579
|
* SPDX-License-Identifier: MIT
|
538
580
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
539
581
|
*/
|
540
|
-
|
541
|
-
|
542
|
-
|
543
|
-
|
544
|
-
|
545
|
-
|
546
|
-
|
547
|
-
|
548
|
-
|
549
|
-
|
550
|
-
|
551
|
-
|
552
|
-
|
553
|
-
|
554
|
-
|
555
|
-
|
556
|
-
|
557
|
-
|
558
|
-
|
559
|
-
|
560
|
-
|
561
|
-
|
562
|
-
|
563
|
-
|
564
|
-
|
565
|
-
get classList() {
|
566
|
-
if (__classPrivateFieldGet(this, _LightningElement_classList, "f")) {
|
567
|
-
return __classPrivateFieldGet(this, _LightningElement_classList, "f");
|
568
|
-
}
|
569
|
-
return (__classPrivateFieldSet(this, _LightningElement_classList, new ClassList(this), "f"));
|
570
|
-
}
|
571
|
-
setAttribute(attrName, attrValue) {
|
572
|
-
const normalizedName = StringToLowerCase.call(toString(attrName));
|
573
|
-
const normalizedValue = String(attrValue);
|
574
|
-
__classPrivateFieldGet(this, _LightningElement_attrs, "f")[normalizedName] = normalizedValue;
|
575
|
-
reflectAttrToProp(this, normalizedName, normalizedValue);
|
576
|
-
mutationTracker.add(this, normalizedName);
|
577
|
-
}
|
578
|
-
getAttribute(attrName) {
|
579
|
-
const normalizedName = StringToLowerCase.call(toString(attrName));
|
580
|
-
if (hasOwnProperty.call(__classPrivateFieldGet(this, _LightningElement_attrs, "f"), normalizedName)) {
|
581
|
-
return __classPrivateFieldGet(this, _LightningElement_attrs, "f")[normalizedName];
|
582
|
-
}
|
583
|
-
return null;
|
584
|
-
}
|
585
|
-
hasAttribute(attrName) {
|
586
|
-
const normalizedName = StringToLowerCase.call(toString(attrName));
|
587
|
-
return hasOwnProperty.call(__classPrivateFieldGet(this, _LightningElement_attrs, "f"), normalizedName);
|
588
|
-
}
|
589
|
-
removeAttribute(attrName) {
|
590
|
-
const normalizedName = StringToLowerCase.call(toString(attrName));
|
591
|
-
delete __classPrivateFieldGet(this, _LightningElement_attrs, "f")[normalizedName];
|
592
|
-
reflectAttrToProp(this, normalizedName, null);
|
593
|
-
// Track mutations for removal of non-existing attributes
|
594
|
-
mutationTracker.add(this, normalizedName);
|
595
|
-
}
|
596
|
-
addEventListener(_type, _listener, _options) {
|
597
|
-
// noop
|
598
|
-
}
|
599
|
-
removeEventListener(_type, _listener, _options) {
|
600
|
-
// noop
|
601
|
-
}
|
602
|
-
// ----------------------------------------------------------- //
|
603
|
-
// Props/methods explicitly not available in this environment //
|
604
|
-
// Getters are named "get*" for parity with @lwc/engine-server //
|
605
|
-
// ----------------------------------------------------------- //
|
606
|
-
get children() {
|
607
|
-
throw new TypeError('"getChildren" is not supported in this environment');
|
608
|
-
}
|
609
|
-
get childNodes() {
|
610
|
-
throw new TypeError('"getChildNodes" is not supported in this environment');
|
611
|
-
}
|
612
|
-
get firstChild() {
|
613
|
-
throw new TypeError('"getFirstChild" is not supported in this environment');
|
614
|
-
}
|
615
|
-
get firstElementChild() {
|
616
|
-
throw new TypeError('"getFirstElementChild" is not supported in this environment');
|
617
|
-
}
|
618
|
-
get hostElement() {
|
619
|
-
// Intentionally different to match @lwc/engine-*core*
|
620
|
-
throw new TypeError('this.hostElement is not supported in this environment');
|
621
|
-
}
|
622
|
-
get lastChild() {
|
623
|
-
throw new TypeError('"getLastChild" is not supported in this environment');
|
624
|
-
}
|
625
|
-
get lastElementChild() {
|
626
|
-
throw new TypeError('"getLastElementChild" is not supported in this environment');
|
627
|
-
}
|
628
|
-
get ownerDocument() {
|
629
|
-
// Intentionally not "get*" to match @lwc/engine-server
|
630
|
-
throw new TypeError('"ownerDocument" is not supported in this environment');
|
631
|
-
}
|
632
|
-
get style() {
|
633
|
-
// Intentionally not "get*" to match @lwc/engine-server
|
634
|
-
throw new TypeError('"style" is not supported in this environment');
|
635
|
-
}
|
636
|
-
attachInternals() {
|
637
|
-
throw new TypeError('"attachInternals" is not supported in this environment');
|
638
|
-
}
|
639
|
-
dispatchEvent(_event) {
|
640
|
-
throw new TypeError('"dispatchEvent" is not supported in this environment');
|
641
|
-
}
|
642
|
-
getBoundingClientRect() {
|
643
|
-
throw new TypeError('"getBoundingClientRect" is not supported in this environment');
|
644
|
-
}
|
645
|
-
getElementsByClassName(_classNames) {
|
646
|
-
throw new TypeError('"getElementsByClassName" is not supported in this environment');
|
647
|
-
}
|
648
|
-
getElementsByTagName(_qualifiedName) {
|
649
|
-
throw new TypeError('"getElementsByTagName" is not supported in this environment');
|
650
|
-
}
|
651
|
-
querySelector(_selectors) {
|
652
|
-
throw new TypeError('"querySelector" is not supported in this environment');
|
653
|
-
}
|
654
|
-
querySelectorAll(_selectors) {
|
655
|
-
throw new TypeError('"querySelectorAll" is not supported in this environment');
|
656
|
-
}
|
657
|
-
getAttributeNS(_namespace, _localName) {
|
658
|
-
throw new Error('Method "getAttributeNS" not implemented.');
|
659
|
-
}
|
660
|
-
hasAttributeNS(_namespace, _localName) {
|
661
|
-
throw new Error('Method "hasAttributeNS" not implemented.');
|
662
|
-
}
|
663
|
-
removeAttributeNS(_namespace, _localName) {
|
664
|
-
throw new Error('Method "removeAttributeNS" not implemented.');
|
665
|
-
}
|
666
|
-
setAttributeNS(_namespace, _qualifiedName, _value) {
|
667
|
-
throw new Error('Method "setAttributeNS" not implemented.');
|
582
|
+
let hooksAreSet = false;
|
583
|
+
/**
|
584
|
+
* EXPERIMENTAL: This function acts like a hook for Lightning Locker Service and other similar
|
585
|
+
* libraries to sanitize HTML content. This hook process the content passed via the template to
|
586
|
+
* lwc:inner-html directive.
|
587
|
+
* It is meant to be overridden via `setHooks`; it throws an error by default.
|
588
|
+
*/
|
589
|
+
exports.sanitizeHtmlContent = () => {
|
590
|
+
// locker-service patches this function during runtime to sanitize HTML content.
|
591
|
+
throw new Error('sanitizeHtmlContent hook must be implemented.');
|
592
|
+
};
|
593
|
+
function setHooks(hooks) {
|
594
|
+
isFalse$1(hooksAreSet, 'Hooks are already overridden, only one definition is allowed.');
|
595
|
+
hooksAreSet = true;
|
596
|
+
exports.sanitizeHtmlContent = hooks.sanitizeHtmlContent;
|
597
|
+
}
|
598
|
+
function flattenStylesheets(stylesheets) {
|
599
|
+
const list = [];
|
600
|
+
for (const stylesheet of stylesheets) {
|
601
|
+
if (!isArray(stylesheet)) {
|
602
|
+
list.push(stylesheet);
|
603
|
+
}
|
604
|
+
else {
|
605
|
+
list.push(...flattenStylesheets(stylesheet));
|
606
|
+
}
|
668
607
|
}
|
608
|
+
return list;
|
669
609
|
}
|
670
|
-
|
610
|
+
/** version: 8.7.0 */
|
671
611
|
|
672
612
|
/*
|
673
|
-
* Copyright (c) 2024,
|
613
|
+
* Copyright (c) 2024, Salesforce, Inc.
|
674
614
|
* All rights reserved.
|
675
615
|
* SPDX-License-Identifier: MIT
|
676
616
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
677
617
|
*/
|
678
|
-
const
|
679
|
-
|
680
|
-
|
681
|
-
|
618
|
+
const MULTI_SPACE = /\s+/g;
|
619
|
+
class ClassList {
|
620
|
+
constructor(el) {
|
621
|
+
this.el = el;
|
682
622
|
}
|
683
|
-
|
684
|
-
const
|
685
|
-
|
686
|
-
|
623
|
+
add(...newClassNames) {
|
624
|
+
const className = this.el.className;
|
625
|
+
const set = new Set(className.split(MULTI_SPACE).filter(Boolean));
|
626
|
+
for (const newClassName of newClassNames) {
|
627
|
+
set.add(newClassName);
|
687
628
|
}
|
688
|
-
|
689
|
-
|
629
|
+
this.el.className = Array.from(set).join(' ');
|
630
|
+
}
|
631
|
+
contains(className) {
|
632
|
+
const currentClassNameStr = this.el.className;
|
633
|
+
return currentClassNameStr.split(MULTI_SPACE).includes(className);
|
634
|
+
}
|
635
|
+
remove(...classNamesToRemove) {
|
636
|
+
const className = this.el.className;
|
637
|
+
const set = new Set(className.split(MULTI_SPACE).filter(Boolean));
|
638
|
+
for (const newClassName of classNamesToRemove) {
|
639
|
+
set.delete(newClassName);
|
690
640
|
}
|
641
|
+
this.el.className = Array.from(set).join(' ');
|
691
642
|
}
|
692
|
-
|
693
|
-
|
694
|
-
|
695
|
-
|
696
|
-
|
643
|
+
replace(oldClassName, newClassName) {
|
644
|
+
let classWasReplaced = false;
|
645
|
+
const className = this.el.className;
|
646
|
+
const listOfClasses = className.split(MULTI_SPACE).filter(Boolean);
|
647
|
+
listOfClasses.forEach((value, idx) => {
|
648
|
+
if (value === oldClassName) {
|
649
|
+
classWasReplaced = true;
|
650
|
+
listOfClasses[idx] = newClassName;
|
651
|
+
}
|
652
|
+
});
|
653
|
+
this.el.className = listOfClasses.join(' ');
|
654
|
+
return classWasReplaced;
|
697
655
|
}
|
698
|
-
|
699
|
-
const
|
700
|
-
|
701
|
-
|
656
|
+
toggle(classNameToToggle, force) {
|
657
|
+
const classNameStr = this.el.className;
|
658
|
+
const set = new Set(classNameStr.split(MULTI_SPACE).filter(Boolean));
|
659
|
+
if (!set.has(classNameToToggle) && force !== false) {
|
660
|
+
set.add(classNameToToggle);
|
702
661
|
}
|
703
|
-
else if (
|
704
|
-
|
662
|
+
else if (set.has(classNameToToggle) && force !== true) {
|
663
|
+
set.delete(classNameToToggle);
|
705
664
|
}
|
665
|
+
this.el.className = Array.from(set).join(' ');
|
666
|
+
return set.has(classNameToToggle);
|
706
667
|
}
|
707
|
-
|
708
|
-
|
709
|
-
function* fallbackTmpl(_props, _attrs, _slotted, Cmp, _instance) {
|
710
|
-
if (Cmp.renderMode !== 'light') {
|
711
|
-
yield '<template shadowrootmode="open"></template>';
|
668
|
+
get value() {
|
669
|
+
return this.el.className;
|
712
670
|
}
|
713
|
-
|
714
|
-
|
715
|
-
|
716
|
-
|
671
|
+
toString() {
|
672
|
+
return this.el.className;
|
673
|
+
}
|
674
|
+
item(_index) {
|
675
|
+
throw new Error('Method "item" not implemented.');
|
676
|
+
}
|
677
|
+
supports(_token) {
|
678
|
+
throw new Error('Method "supports" not implemented.');
|
679
|
+
}
|
680
|
+
forEach(_callbackfn, _thisArg) {
|
681
|
+
throw new Error('Method "forEach" not implemented.');
|
682
|
+
}
|
683
|
+
get length() {
|
684
|
+
throw new Error('Property "length" not implemented.');
|
717
685
|
}
|
718
686
|
}
|
719
|
-
|
720
|
-
|
721
|
-
|
687
|
+
|
688
|
+
/******************************************************************************
|
689
|
+
Copyright (c) Microsoft Corporation.
|
690
|
+
|
691
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
692
|
+
purpose with or without fee is hereby granted.
|
693
|
+
|
694
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
695
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
696
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
697
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
698
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
699
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
700
|
+
PERFORMANCE OF THIS SOFTWARE.
|
701
|
+
***************************************************************************** */
|
702
|
+
/* global Reflect, Promise, SuppressedError, Symbol, Iterator */
|
703
|
+
|
704
|
+
|
705
|
+
function __classPrivateFieldGet(receiver, state, kind, f) {
|
706
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
707
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
708
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
709
|
+
}
|
710
|
+
|
711
|
+
function __classPrivateFieldSet(receiver, state, value, kind, f) {
|
712
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
713
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
714
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
715
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
716
|
+
}
|
717
|
+
|
718
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
719
|
+
var e = new Error(message);
|
720
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
721
|
+
};
|
722
|
+
|
723
|
+
/*
|
724
|
+
* Copyright (c) 2024, Salesforce, Inc.
|
725
|
+
* All rights reserved.
|
726
|
+
* SPDX-License-Identifier: MIT
|
727
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
728
|
+
*/
|
729
|
+
var _MutationTracker_enabledSet, _MutationTracker_mutationMap;
|
730
|
+
class MutationTracker {
|
731
|
+
constructor() {
|
732
|
+
_MutationTracker_enabledSet.set(this, new WeakSet());
|
733
|
+
_MutationTracker_mutationMap.set(this, new WeakMap());
|
722
734
|
}
|
723
|
-
|
724
|
-
|
725
|
-
|
726
|
-
|
727
|
-
|
728
|
-
|
729
|
-
|
730
|
-
|
731
|
-
markup += segment;
|
735
|
+
add(instance, attrName) {
|
736
|
+
if (__classPrivateFieldGet(this, _MutationTracker_enabledSet, "f").has(instance)) {
|
737
|
+
let mutatedAttrs = __classPrivateFieldGet(this, _MutationTracker_mutationMap, "f").get(instance);
|
738
|
+
if (!mutatedAttrs) {
|
739
|
+
mutatedAttrs = new Set();
|
740
|
+
__classPrivateFieldGet(this, _MutationTracker_mutationMap, "f").set(instance, mutatedAttrs);
|
741
|
+
}
|
742
|
+
mutatedAttrs.add(attrName.toLowerCase());
|
732
743
|
}
|
733
744
|
}
|
734
|
-
|
735
|
-
|
745
|
+
enable(instance) {
|
746
|
+
__classPrivateFieldGet(this, _MutationTracker_enabledSet, "f").add(instance);
|
736
747
|
}
|
737
|
-
|
738
|
-
|
748
|
+
disable(instance) {
|
749
|
+
__classPrivateFieldGet(this, _MutationTracker_enabledSet, "f").delete(instance);
|
739
750
|
}
|
740
|
-
|
741
|
-
|
751
|
+
renderMutatedAttrs(instance) {
|
752
|
+
const mutatedAttrs = __classPrivateFieldGet(this, _MutationTracker_mutationMap, "f").get(instance);
|
753
|
+
if (mutatedAttrs) {
|
754
|
+
return ` data-lwc-host-mutated="${[...mutatedAttrs].sort().join(' ')}"`;
|
755
|
+
}
|
756
|
+
else {
|
757
|
+
return '';
|
758
|
+
}
|
742
759
|
}
|
743
|
-
return markup;
|
744
760
|
}
|
761
|
+
_MutationTracker_enabledSet = new WeakMap(), _MutationTracker_mutationMap = new WeakMap();
|
762
|
+
const mutationTracker = new MutationTracker();
|
745
763
|
|
746
764
|
/*
|
747
765
|
* Copyright (c) 2024, Salesforce, Inc.
|
@@ -749,220 +767,271 @@ async function serverSideRenderComponent(tagName, Component, props = {}, mode =
|
|
749
767
|
* SPDX-License-Identifier: MIT
|
750
768
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
751
769
|
*/
|
752
|
-
|
753
|
-
|
754
|
-
|
755
|
-
|
756
|
-
|
757
|
-
|
758
|
-
|
759
|
-
|
760
|
-
|
761
|
-
|
762
|
-
|
763
|
-
|
764
|
-
|
765
|
-
|
766
|
-
|
767
|
-
|
768
|
-
|
769
|
-
|
770
|
-
|
771
|
-
function parseFragment(..._) {
|
772
|
-
throw new Error('parseFragment cannot be used in SSR context.');
|
773
|
-
}
|
774
|
-
function parseSVGFragment(..._) {
|
775
|
-
throw new Error('parseSVGFragment cannot be used in SSR context.');
|
776
|
-
}
|
777
|
-
function readonly(..._) {
|
778
|
-
throw new Error('readonly cannot be used in SSR context.');
|
779
|
-
}
|
780
|
-
function registerComponent(..._) {
|
781
|
-
throw new Error('registerComponent cannot be used in SSR context.');
|
782
|
-
}
|
783
|
-
function registerDecorators(..._) {
|
784
|
-
throw new Error('registerDecorators cannot be used in SSR context.');
|
785
|
-
}
|
786
|
-
function registerTemplate(..._) {
|
787
|
-
throw new Error('registerTemplate cannot be used in SSR context.');
|
788
|
-
}
|
789
|
-
function sanitizeAttribute(..._) {
|
790
|
-
throw new Error('sanitizeAttribute cannot be used in SSR context.');
|
791
|
-
}
|
792
|
-
function setFeatureFlag(..._) {
|
793
|
-
throw new Error('setFeatureFlag cannot be used in SSR context.');
|
794
|
-
}
|
795
|
-
function setFeatureFlagForTest(..._) {
|
796
|
-
throw new Error('setFeatureFlagForTest cannot be used in SSR context.');
|
797
|
-
}
|
798
|
-
function setHooks(..._) {
|
799
|
-
throw new Error('setHooks cannot be used in SSR context.');
|
800
|
-
}
|
801
|
-
function swapComponent(..._) {
|
802
|
-
throw new Error('swapComponent cannot be used in SSR context.');
|
803
|
-
}
|
804
|
-
function swapStyle(..._) {
|
805
|
-
throw new Error('swapStyle cannot be used in SSR context.');
|
806
|
-
}
|
807
|
-
function swapTemplate(..._) {
|
808
|
-
throw new Error('swapTemplate cannot be used in SSR context.');
|
809
|
-
}
|
810
|
-
function track(..._) {
|
811
|
-
throw new Error('@track cannot be used in SSR context.');
|
812
|
-
}
|
813
|
-
function unwrap(..._) {
|
814
|
-
throw new Error('unwrap cannot be used in SSR context.');
|
815
|
-
}
|
816
|
-
function wire(..._) {
|
817
|
-
throw new Error('@wire cannot be used in SSR context.');
|
770
|
+
/**
|
771
|
+
* Filters out the following types of properties that should not be set.
|
772
|
+
* - Properties that are not public.
|
773
|
+
* - Properties that are not global.
|
774
|
+
* - Properties that are global but are internally overridden.
|
775
|
+
*/
|
776
|
+
function filterProperties(props, publicFields, privateFields) {
|
777
|
+
const propsToAssign = create(null);
|
778
|
+
const publicFieldSet = new Set(publicFields);
|
779
|
+
const privateFieldSet = new Set(privateFields);
|
780
|
+
keys(props).forEach((propName) => {
|
781
|
+
const attrName = htmlPropertyToAttribute(propName);
|
782
|
+
if (publicFieldSet.has(propName) ||
|
783
|
+
((isGlobalHtmlAttribute(attrName) || isAriaAttribute(attrName)) &&
|
784
|
+
!privateFieldSet.has(propName))) {
|
785
|
+
propsToAssign[propName] = props[propName];
|
786
|
+
}
|
787
|
+
});
|
788
|
+
return propsToAssign;
|
818
789
|
}
|
819
|
-
|
820
|
-
|
821
|
-
|
822
|
-
|
823
|
-
|
824
|
-
|
825
|
-
|
826
|
-
|
827
|
-
cloneNode(..._) {
|
828
|
-
throw new Error('renderer.cloneNode cannot be used in SSR context.');
|
829
|
-
},
|
830
|
-
createFragment(..._) {
|
831
|
-
throw new Error('renderer.createFragment cannot be used in SSR context.');
|
832
|
-
},
|
833
|
-
createElement(..._) {
|
834
|
-
throw new Error('renderer.createElement cannot be used in SSR context.');
|
835
|
-
},
|
836
|
-
createText(..._) {
|
837
|
-
throw new Error('renderer.createText cannot be used in SSR context.');
|
838
|
-
},
|
839
|
-
createComment(..._) {
|
840
|
-
throw new Error('renderer.createComment cannot be used in SSR context.');
|
841
|
-
},
|
842
|
-
createCustomElement(..._) {
|
843
|
-
throw new Error('renderer.createCustomElement cannot be used in SSR context.');
|
844
|
-
},
|
845
|
-
nextSibling(..._) {
|
846
|
-
throw new Error('renderer.nextSibling cannot be used in SSR context.');
|
847
|
-
},
|
848
|
-
previousSibling(..._) {
|
849
|
-
throw new Error('renderer.previousSibling cannot be used in SSR context.');
|
850
|
-
},
|
851
|
-
attachShadow(..._) {
|
852
|
-
throw new Error('renderer.attachShadow cannot be used in SSR context.');
|
853
|
-
},
|
854
|
-
getProperty(..._) {
|
855
|
-
throw new Error('renderer.getProperty cannot be used in SSR context.');
|
856
|
-
},
|
857
|
-
setProperty(..._) {
|
858
|
-
throw new Error('renderer.setProperty cannot be used in SSR context.');
|
859
|
-
},
|
860
|
-
setText(..._) {
|
861
|
-
throw new Error('renderer.setText cannot be used in SSR context.');
|
862
|
-
},
|
863
|
-
getAttribute(..._) {
|
864
|
-
throw new Error('renderer.getAttribute cannot be used in SSR context.');
|
865
|
-
},
|
866
|
-
setAttribute(..._) {
|
867
|
-
throw new Error('renderer.setAttribute cannot be used in SSR context.');
|
868
|
-
},
|
869
|
-
removeAttribute(..._) {
|
870
|
-
throw new Error('renderer.removeAttribute cannot be used in SSR context.');
|
871
|
-
},
|
872
|
-
addEventListener(..._) {
|
873
|
-
throw new Error('renderer.addEventListener cannot be used in SSR context.');
|
874
|
-
},
|
875
|
-
removeEventListener(..._) {
|
876
|
-
throw new Error('renderer.removeEventListener cannot be used in SSR context.');
|
877
|
-
},
|
878
|
-
dispatchEvent(..._) {
|
879
|
-
throw new Error('renderer.dispatchEvent cannot be used in SSR context.');
|
880
|
-
},
|
881
|
-
getClassList(..._) {
|
882
|
-
throw new Error('renderer.getClassList cannot be used in SSR context.');
|
883
|
-
},
|
884
|
-
setCSSStyleProperty(..._) {
|
885
|
-
throw new Error('renderer.setCSSStyleProperty cannot be used in SSR context.');
|
886
|
-
},
|
887
|
-
getBoundingClientRect(..._) {
|
888
|
-
throw new Error('renderer.getBoundingClientRect cannot be used in SSR context.');
|
889
|
-
},
|
890
|
-
querySelector(..._) {
|
891
|
-
throw new Error('renderer.querySelector cannot be used in SSR context.');
|
892
|
-
},
|
893
|
-
querySelectorAll(..._) {
|
894
|
-
throw new Error('renderer.querySelectorAll cannot be used in SSR context.');
|
895
|
-
},
|
896
|
-
getElementsByTagName(..._) {
|
897
|
-
throw new Error('renderer.getElementsByTagName cannot be used in SSR context.');
|
898
|
-
},
|
899
|
-
getElementsByClassName(..._) {
|
900
|
-
throw new Error('renderer.getElementsByClassName cannot be used in SSR context.');
|
901
|
-
},
|
902
|
-
getChildren(..._) {
|
903
|
-
throw new Error('renderer.getChildren cannot be used in SSR context.');
|
904
|
-
},
|
905
|
-
getChildNodes(..._) {
|
906
|
-
throw new Error('renderer.getChildNodes cannot be used in SSR context.');
|
907
|
-
},
|
908
|
-
getFirstChild(..._) {
|
909
|
-
throw new Error('renderer.getFirstChild cannot be used in SSR context.');
|
910
|
-
},
|
911
|
-
getFirstElementChild(..._) {
|
912
|
-
throw new Error('renderer.getFirstElementChild cannot be used in SSR context.');
|
913
|
-
},
|
914
|
-
getLastChild(..._) {
|
915
|
-
throw new Error('renderer.getLastChild cannot be used in SSR context.');
|
916
|
-
},
|
917
|
-
getLastElementChild(..._) {
|
918
|
-
throw new Error('renderer.getLastElementChild cannot be used in SSR context.');
|
919
|
-
},
|
920
|
-
getTagName(..._) {
|
921
|
-
throw new Error('renderer.getTagName cannot be used in SSR context.');
|
922
|
-
},
|
923
|
-
getStyle(..._) {
|
924
|
-
throw new Error('renderer.getStyle cannot be used in SSR context.');
|
925
|
-
},
|
926
|
-
isConnected(..._) {
|
927
|
-
throw new Error('renderer.isConnected cannot be used in SSR context.');
|
928
|
-
},
|
929
|
-
insertStylesheet(..._) {
|
930
|
-
throw new Error('renderer.insertStylesheet cannot be used in SSR context.');
|
790
|
+
/**
|
791
|
+
* Descriptor for IDL attribute reflections that merely reflect the string, e.g. `title`.
|
792
|
+
*/
|
793
|
+
const stringDescriptor = (attrName) => ({
|
794
|
+
configurable: true,
|
795
|
+
enumerable: true,
|
796
|
+
get() {
|
797
|
+
return this.getAttribute(attrName);
|
931
798
|
},
|
932
|
-
|
933
|
-
|
799
|
+
set(newValue) {
|
800
|
+
const currentValue = this.getAttribute(attrName);
|
801
|
+
const normalizedValue = String(newValue);
|
802
|
+
if (normalizedValue !== currentValue) {
|
803
|
+
this.setAttribute(attrName, normalizedValue);
|
804
|
+
}
|
934
805
|
},
|
935
|
-
|
936
|
-
|
806
|
+
});
|
807
|
+
/** Descriptor for a boolean that checks for `attr="true"` or `attr="false"`, e.g. `spellcheck` and `draggable`. */
|
808
|
+
const explicitBooleanDescriptor = (attrName, defaultValue) => ({
|
809
|
+
configurable: true,
|
810
|
+
enumerable: true,
|
811
|
+
get() {
|
812
|
+
const value = this.getAttribute(attrName);
|
813
|
+
return value === null ? defaultValue : value === String(defaultValue);
|
937
814
|
},
|
938
|
-
|
939
|
-
|
815
|
+
set(newValue) {
|
816
|
+
const currentValue = this.getAttribute(attrName);
|
817
|
+
const normalizedValue = String(Boolean(newValue));
|
818
|
+
if (normalizedValue !== currentValue) {
|
819
|
+
this.setAttribute(attrName, normalizedValue);
|
820
|
+
}
|
940
821
|
},
|
941
|
-
|
942
|
-
|
822
|
+
});
|
823
|
+
/**
|
824
|
+
* Descriptor for a "true" boolean attribute that checks solely for presence, e.g. `hidden`.
|
825
|
+
*/
|
826
|
+
const booleanAttributeDescriptor = (attrName) => ({
|
827
|
+
configurable: true,
|
828
|
+
enumerable: true,
|
829
|
+
get() {
|
830
|
+
return this.hasAttribute(attrName);
|
943
831
|
},
|
944
|
-
|
945
|
-
|
832
|
+
set(newValue) {
|
833
|
+
const hasAttribute = this.hasAttribute(attrName);
|
834
|
+
if (newValue) {
|
835
|
+
if (!hasAttribute) {
|
836
|
+
this.setAttribute(attrName, '');
|
837
|
+
}
|
838
|
+
}
|
839
|
+
else {
|
840
|
+
if (hasAttribute) {
|
841
|
+
this.removeAttribute(attrName);
|
842
|
+
}
|
843
|
+
}
|
946
844
|
},
|
947
|
-
|
948
|
-
|
845
|
+
});
|
846
|
+
/**
|
847
|
+
* Descriptor for ARIA reflections, e.g. `ariaLabel` and `role`.
|
848
|
+
*/
|
849
|
+
const ariaDescriptor = (attrName) => ({
|
850
|
+
configurable: true,
|
851
|
+
enumerable: true,
|
852
|
+
get() {
|
853
|
+
return this.getAttribute(attrName);
|
949
854
|
},
|
950
|
-
|
951
|
-
|
855
|
+
set(newValue) {
|
856
|
+
const currentValue = this.getAttribute(attrName);
|
857
|
+
if (newValue !== currentValue) {
|
858
|
+
// TODO [#3284]: According to the spec, IDL nullable type values
|
859
|
+
// (null and undefined) should remove the attribute; however, we
|
860
|
+
// only do so in the case of null for historical reasons.
|
861
|
+
if (isNull(newValue)) {
|
862
|
+
this.removeAttribute(attrName);
|
863
|
+
}
|
864
|
+
else {
|
865
|
+
this.setAttribute(attrName, toString(newValue));
|
866
|
+
}
|
867
|
+
}
|
952
868
|
},
|
953
|
-
|
954
|
-
|
869
|
+
});
|
870
|
+
const descriptors = {
|
871
|
+
accessKey: stringDescriptor('accesskey'),
|
872
|
+
dir: stringDescriptor('dir'),
|
873
|
+
draggable: explicitBooleanDescriptor('draggable', true),
|
874
|
+
hidden: booleanAttributeDescriptor('hidden'),
|
875
|
+
id: stringDescriptor('id'),
|
876
|
+
lang: stringDescriptor('lang'),
|
877
|
+
spellcheck: explicitBooleanDescriptor('spellcheck', false),
|
878
|
+
tabIndex: {
|
879
|
+
get() {
|
880
|
+
const str = this.getAttribute('tabindex');
|
881
|
+
const num = Number(str);
|
882
|
+
return isFinite(num) ? Math.trunc(num) : -1;
|
883
|
+
},
|
884
|
+
set(newValue) {
|
885
|
+
const currentValue = this.getAttribute('tabindex');
|
886
|
+
const num = Number(newValue);
|
887
|
+
const normalizedValue = isFinite(num) ? String(Math.trunc(num)) : '0';
|
888
|
+
if (normalizedValue !== currentValue) {
|
889
|
+
this.setAttribute('tabindex', toString(newValue));
|
890
|
+
}
|
891
|
+
},
|
955
892
|
},
|
893
|
+
title: stringDescriptor('title'),
|
956
894
|
};
|
957
|
-
|
958
|
-
|
959
|
-
|
960
|
-
|
961
|
-
|
962
|
-
|
895
|
+
// Add descriptors for ARIA attributes
|
896
|
+
for (const [attrName, propName] of entries(AriaAttrNameToPropNameMap)) {
|
897
|
+
descriptors[propName] = ariaDescriptor(attrName);
|
898
|
+
}
|
899
|
+
|
900
|
+
/*
|
901
|
+
* Copyright (c) 2024, salesforce.com, inc.
|
902
|
+
* All rights reserved.
|
903
|
+
* SPDX-License-Identifier: MIT
|
904
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
963
905
|
*/
|
964
|
-
|
965
|
-
const
|
906
|
+
var _LightningElement_attrs, _LightningElement_classList;
|
907
|
+
const SYMBOL__SET_INTERNALS = Symbol('set-internals');
|
908
|
+
const SYMBOL__GENERATE_MARKUP = Symbol('generate-markup');
|
909
|
+
class LightningElement {
|
910
|
+
constructor(propsAvailableAtConstruction) {
|
911
|
+
this.isConnected = false;
|
912
|
+
this.className = '';
|
913
|
+
_LightningElement_attrs.set(this, void 0);
|
914
|
+
_LightningElement_classList.set(this, null);
|
915
|
+
assign(this, propsAvailableAtConstruction);
|
916
|
+
}
|
917
|
+
[(_LightningElement_attrs = new WeakMap(), _LightningElement_classList = new WeakMap(), SYMBOL__SET_INTERNALS)](props, attrs) {
|
918
|
+
__classPrivateFieldSet(this, _LightningElement_attrs, attrs, "f");
|
919
|
+
assign(this, props);
|
920
|
+
defineProperty(this, 'className', {
|
921
|
+
get() {
|
922
|
+
return props.class ?? '';
|
923
|
+
},
|
924
|
+
set(newVal) {
|
925
|
+
props.class = newVal;
|
926
|
+
attrs.class = newVal;
|
927
|
+
mutationTracker.add(this, 'class');
|
928
|
+
},
|
929
|
+
});
|
930
|
+
}
|
931
|
+
get classList() {
|
932
|
+
if (__classPrivateFieldGet(this, _LightningElement_classList, "f")) {
|
933
|
+
return __classPrivateFieldGet(this, _LightningElement_classList, "f");
|
934
|
+
}
|
935
|
+
return (__classPrivateFieldSet(this, _LightningElement_classList, new ClassList(this), "f"));
|
936
|
+
}
|
937
|
+
setAttribute(attrName, attrValue) {
|
938
|
+
const normalizedName = StringToLowerCase.call(toString(attrName));
|
939
|
+
const normalizedValue = String(attrValue);
|
940
|
+
__classPrivateFieldGet(this, _LightningElement_attrs, "f")[normalizedName] = normalizedValue;
|
941
|
+
mutationTracker.add(this, normalizedName);
|
942
|
+
}
|
943
|
+
getAttribute(attrName) {
|
944
|
+
const normalizedName = StringToLowerCase.call(toString(attrName));
|
945
|
+
if (hasOwnProperty.call(__classPrivateFieldGet(this, _LightningElement_attrs, "f"), normalizedName)) {
|
946
|
+
return __classPrivateFieldGet(this, _LightningElement_attrs, "f")[normalizedName];
|
947
|
+
}
|
948
|
+
return null;
|
949
|
+
}
|
950
|
+
hasAttribute(attrName) {
|
951
|
+
const normalizedName = StringToLowerCase.call(toString(attrName));
|
952
|
+
return hasOwnProperty.call(__classPrivateFieldGet(this, _LightningElement_attrs, "f"), normalizedName);
|
953
|
+
}
|
954
|
+
removeAttribute(attrName) {
|
955
|
+
const normalizedName = StringToLowerCase.call(toString(attrName));
|
956
|
+
delete __classPrivateFieldGet(this, _LightningElement_attrs, "f")[normalizedName];
|
957
|
+
// Track mutations for removal of non-existing attributes
|
958
|
+
mutationTracker.add(this, normalizedName);
|
959
|
+
}
|
960
|
+
addEventListener(_type, _listener, _options) {
|
961
|
+
// noop
|
962
|
+
}
|
963
|
+
removeEventListener(_type, _listener, _options) {
|
964
|
+
// noop
|
965
|
+
}
|
966
|
+
// ----------------------------------------------------------- //
|
967
|
+
// Props/methods explicitly not available in this environment //
|
968
|
+
// Getters are named "get*" for parity with @lwc/engine-server //
|
969
|
+
// ----------------------------------------------------------- //
|
970
|
+
get children() {
|
971
|
+
throw new TypeError('"getChildren" is not supported in this environment');
|
972
|
+
}
|
973
|
+
get childNodes() {
|
974
|
+
throw new TypeError('"getChildNodes" is not supported in this environment');
|
975
|
+
}
|
976
|
+
get firstChild() {
|
977
|
+
throw new TypeError('"getFirstChild" is not supported in this environment');
|
978
|
+
}
|
979
|
+
get firstElementChild() {
|
980
|
+
throw new TypeError('"getFirstElementChild" is not supported in this environment');
|
981
|
+
}
|
982
|
+
get hostElement() {
|
983
|
+
// Intentionally different to match @lwc/engine-*core*
|
984
|
+
throw new TypeError('this.hostElement is not supported in this environment');
|
985
|
+
}
|
986
|
+
get lastChild() {
|
987
|
+
throw new TypeError('"getLastChild" is not supported in this environment');
|
988
|
+
}
|
989
|
+
get lastElementChild() {
|
990
|
+
throw new TypeError('"getLastElementChild" is not supported in this environment');
|
991
|
+
}
|
992
|
+
get ownerDocument() {
|
993
|
+
// Intentionally not "get*" to match @lwc/engine-server
|
994
|
+
throw new TypeError('"ownerDocument" is not supported in this environment');
|
995
|
+
}
|
996
|
+
get style() {
|
997
|
+
// Intentionally not "get*" to match @lwc/engine-server
|
998
|
+
throw new TypeError('"style" is not supported in this environment');
|
999
|
+
}
|
1000
|
+
attachInternals() {
|
1001
|
+
throw new TypeError('"attachInternals" is not supported in this environment');
|
1002
|
+
}
|
1003
|
+
dispatchEvent(_event) {
|
1004
|
+
throw new TypeError('"dispatchEvent" is not supported in this environment');
|
1005
|
+
}
|
1006
|
+
getBoundingClientRect() {
|
1007
|
+
throw new TypeError('"getBoundingClientRect" is not supported in this environment');
|
1008
|
+
}
|
1009
|
+
getElementsByClassName(_classNames) {
|
1010
|
+
throw new TypeError('"getElementsByClassName" is not supported in this environment');
|
1011
|
+
}
|
1012
|
+
getElementsByTagName(_qualifiedName) {
|
1013
|
+
throw new TypeError('"getElementsByTagName" is not supported in this environment');
|
1014
|
+
}
|
1015
|
+
querySelector(_selectors) {
|
1016
|
+
throw new TypeError('"querySelector" is not supported in this environment');
|
1017
|
+
}
|
1018
|
+
querySelectorAll(_selectors) {
|
1019
|
+
throw new TypeError('"querySelectorAll" is not supported in this environment');
|
1020
|
+
}
|
1021
|
+
getAttributeNS(_namespace, _localName) {
|
1022
|
+
throw new Error('Method "getAttributeNS" not implemented.');
|
1023
|
+
}
|
1024
|
+
hasAttributeNS(_namespace, _localName) {
|
1025
|
+
throw new Error('Method "hasAttributeNS" not implemented.');
|
1026
|
+
}
|
1027
|
+
removeAttributeNS(_namespace, _localName) {
|
1028
|
+
throw new Error('Method "removeAttributeNS" not implemented.');
|
1029
|
+
}
|
1030
|
+
setAttributeNS(_namespace, _qualifiedName, _value) {
|
1031
|
+
throw new Error('Method "setAttributeNS" not implemented.');
|
1032
|
+
}
|
1033
|
+
}
|
1034
|
+
defineProperties(LightningElement.prototype, descriptors);
|
966
1035
|
|
967
1036
|
/*
|
968
1037
|
* Copyright (c) 2024, salesforce.com, inc.
|
@@ -970,35 +1039,72 @@ const hot = undefined;
|
|
970
1039
|
* SPDX-License-Identifier: MIT
|
971
1040
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
972
1041
|
*/
|
973
|
-
|
974
|
-
|
975
|
-
|
976
|
-
*/
|
977
|
-
function* toIteratorDirective(iterable) {
|
978
|
-
if (iterable === undefined || iterable === null)
|
1042
|
+
const escapeAttrVal = (attrVal) => attrVal.replaceAll('&', '&').replaceAll('"', '"');
|
1043
|
+
function* renderAttrs(instance, attrs) {
|
1044
|
+
if (!attrs) {
|
979
1045
|
return;
|
980
|
-
if (!iterable[Symbol.iterator]) {
|
981
|
-
throw new Error(
|
982
|
-
// Mimic error message from "[i]terable node" in engine-core's api.ts
|
983
|
-
`Invalid template iteration for value \`${iterable}\`. It must be an array-like object.`);
|
984
1046
|
}
|
985
|
-
const
|
986
|
-
|
987
|
-
|
988
|
-
|
989
|
-
|
990
|
-
|
991
|
-
|
992
|
-
|
993
|
-
|
994
|
-
|
995
|
-
|
996
|
-
|
997
|
-
|
998
|
-
|
999
|
-
|
1000
|
-
|
1047
|
+
for (const attrName of Object.getOwnPropertyNames(attrs)) {
|
1048
|
+
const attrVal = attrs[attrName];
|
1049
|
+
if (typeof attrVal === 'string') {
|
1050
|
+
yield attrVal === '' ? ` ${attrName}` : ` ${attrName}="${escapeAttrVal(attrVal)}"`;
|
1051
|
+
}
|
1052
|
+
else if (attrVal === null) {
|
1053
|
+
yield '';
|
1054
|
+
}
|
1055
|
+
}
|
1056
|
+
yield mutationTracker.renderMutatedAttrs(instance);
|
1057
|
+
}
|
1058
|
+
function renderAttrsNoYield(emit, instance, attrs) {
|
1059
|
+
if (!attrs) {
|
1060
|
+
return;
|
1061
|
+
}
|
1062
|
+
for (const attrName of Object.getOwnPropertyNames(attrs)) {
|
1063
|
+
const attrVal = attrs[attrName];
|
1064
|
+
if (typeof attrVal === 'string') {
|
1065
|
+
emit(attrVal === '' ? ` ${attrName}` : ` ${attrName}="${escapeAttrVal(attrVal)}"`);
|
1066
|
+
}
|
1067
|
+
else if (attrVal === null) {
|
1068
|
+
emit('');
|
1069
|
+
}
|
1070
|
+
}
|
1071
|
+
emit(mutationTracker.renderMutatedAttrs(instance));
|
1072
|
+
}
|
1073
|
+
function* fallbackTmpl(_props, _attrs, _slotted, Cmp, _instance) {
|
1074
|
+
if (Cmp.renderMode !== 'light') {
|
1075
|
+
yield '<template shadowrootmode="open"></template>';
|
1076
|
+
}
|
1077
|
+
}
|
1078
|
+
function fallbackTmplNoYield(emit, _props, _attrs, _slotted, Cmp, _instance) {
|
1079
|
+
if (Cmp.renderMode !== 'light') {
|
1080
|
+
emit('<template shadowrootmode="open"></template>');
|
1081
|
+
}
|
1082
|
+
}
|
1083
|
+
async function serverSideRenderComponent(tagName, Component, props = {}, mode = 'asyncYield') {
|
1084
|
+
if (typeof tagName !== 'string') {
|
1085
|
+
throw new Error(`tagName must be a string, found: ${tagName}`);
|
1086
|
+
}
|
1087
|
+
// TODO [#4726]: remove `generateMarkup` export
|
1088
|
+
const generateMarkup = SYMBOL__GENERATE_MARKUP in Component ? Component[SYMBOL__GENERATE_MARKUP] : Component;
|
1089
|
+
let markup = '';
|
1090
|
+
const emit = (segment) => {
|
1091
|
+
markup += segment;
|
1092
|
+
};
|
1093
|
+
if (mode === 'asyncYield') {
|
1094
|
+
for await (const segment of generateMarkup(tagName, props, null, null)) {
|
1095
|
+
markup += segment;
|
1096
|
+
}
|
1097
|
+
}
|
1098
|
+
else if (mode === 'async') {
|
1099
|
+
await generateMarkup(emit, tagName, props, null, null);
|
1100
|
+
}
|
1101
|
+
else if (mode === 'sync') {
|
1102
|
+
generateMarkup(emit, tagName, props, null, null);
|
1103
|
+
}
|
1104
|
+
else {
|
1105
|
+
throw new Error(`Invalid mode: ${mode}`);
|
1001
1106
|
}
|
1107
|
+
return markup;
|
1002
1108
|
}
|
1003
1109
|
|
1004
1110
|
/*
|
@@ -1079,15 +1185,87 @@ function renderStylesheets(stylesheets, scopeToken, Component, hasScopedTemplate
|
|
1079
1185
|
return result;
|
1080
1186
|
}
|
1081
1187
|
|
1188
|
+
/*
|
1189
|
+
* Copyright (c) 2024, salesforce.com, inc.
|
1190
|
+
* All rights reserved.
|
1191
|
+
* SPDX-License-Identifier: MIT
|
1192
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
1193
|
+
*/
|
1194
|
+
/**
|
1195
|
+
* Converts an iterable into one that emits the object used by the [`iterator` directive](
|
1196
|
+
* https://lwc.dev/guide/html_templates#iterator).
|
1197
|
+
*/
|
1198
|
+
function* toIteratorDirective(iterable) {
|
1199
|
+
if (iterable === undefined || iterable === null)
|
1200
|
+
return;
|
1201
|
+
if (!iterable[Symbol.iterator]) {
|
1202
|
+
throw new Error(
|
1203
|
+
// Mimic error message from "[i]terable node" in engine-core's api.ts
|
1204
|
+
`Invalid template iteration for value \`${iterable}\`. It must be an array-like object.`);
|
1205
|
+
}
|
1206
|
+
const iterator = iterable[Symbol.iterator]();
|
1207
|
+
let next = iterator.next();
|
1208
|
+
let index = 0;
|
1209
|
+
let { value, done: last = false } = next;
|
1210
|
+
while (last === false) {
|
1211
|
+
// using a look-back approach because we need to know if the element is the last
|
1212
|
+
next = iterator.next();
|
1213
|
+
last = next.done ?? false;
|
1214
|
+
yield {
|
1215
|
+
value,
|
1216
|
+
index,
|
1217
|
+
first: index === 0,
|
1218
|
+
last,
|
1219
|
+
};
|
1220
|
+
index += 1;
|
1221
|
+
value = next.value;
|
1222
|
+
}
|
1223
|
+
}
|
1224
|
+
|
1225
|
+
/*
|
1226
|
+
* Copyright (c) 2024, Salesforce, Inc.
|
1227
|
+
* All rights reserved.
|
1228
|
+
* SPDX-License-Identifier: MIT
|
1229
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
1230
|
+
*/
|
1231
|
+
// Deep freeze and clone an object. Designed for cloning/freezing child props when passed from a parent to a child so
|
1232
|
+
// that they are immutable. This is one of the normal guarantees of both engine-dom and engine-server that we want to
|
1233
|
+
// emulate in ssr-runtime. The goal here is that a child cannot mutate the props of its parent and thus affect
|
1234
|
+
// the parent's rendering, which would lead to bidirectional reactivity and mischief.
|
1235
|
+
function cloneAndDeepFreeze(obj) {
|
1236
|
+
if (isArray(obj)) {
|
1237
|
+
const res = [];
|
1238
|
+
for (const item of obj) {
|
1239
|
+
ArrayPush.call(res, cloneAndDeepFreeze(item));
|
1240
|
+
}
|
1241
|
+
freeze(res);
|
1242
|
+
return res;
|
1243
|
+
}
|
1244
|
+
else if (isObject(obj) && !isNull(obj)) {
|
1245
|
+
const res = create(null);
|
1246
|
+
for (const [key, value] of entries(obj)) {
|
1247
|
+
res[key] = cloneAndDeepFreeze(value);
|
1248
|
+
}
|
1249
|
+
freeze(res);
|
1250
|
+
return res;
|
1251
|
+
}
|
1252
|
+
else {
|
1253
|
+
// primitive
|
1254
|
+
return obj;
|
1255
|
+
}
|
1256
|
+
}
|
1257
|
+
|
1082
1258
|
exports.ClassList = ClassList;
|
1083
1259
|
exports.LightningElement = LightningElement;
|
1084
1260
|
exports.SYMBOL__GENERATE_MARKUP = SYMBOL__GENERATE_MARKUP;
|
1085
1261
|
exports.SYMBOL__SET_INTERNALS = SYMBOL__SET_INTERNALS;
|
1086
1262
|
exports.api = api;
|
1263
|
+
exports.cloneAndDeepFreeze = cloneAndDeepFreeze;
|
1087
1264
|
exports.createContextProvider = createContextProvider;
|
1088
1265
|
exports.createElement = createElement;
|
1089
1266
|
exports.fallbackTmpl = fallbackTmpl;
|
1090
1267
|
exports.fallbackTmplNoYield = fallbackTmplNoYield;
|
1268
|
+
exports.filterProperties = filterProperties;
|
1091
1269
|
exports.freezeTemplate = freezeTemplate;
|
1092
1270
|
exports.getComponentDef = getComponentDef;
|
1093
1271
|
exports.hasScopedStaticStylesheets = hasScopedStaticStylesheets;
|
@@ -1119,5 +1297,5 @@ exports.track = track;
|
|
1119
1297
|
exports.unwrap = unwrap;
|
1120
1298
|
exports.validateStyleTextContents = validateStyleTextContents;
|
1121
1299
|
exports.wire = wire;
|
1122
|
-
/** version: 8.
|
1300
|
+
/** version: 8.7.0 */
|
1123
1301
|
//# sourceMappingURL=index.cjs.js.map
|