lwc 2.5.5-canary1 → 2.5.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/engine-dom/esm/es2017/engine-dom.js +672 -214
- package/dist/engine-dom/iife/es2017/engine-dom.js +673 -215
- package/dist/engine-dom/iife/es2017/engine-dom.min.js +2 -2
- package/dist/engine-dom/iife/es2017/engine-dom_debug.js +473 -202
- package/dist/engine-dom/iife/es5/engine-dom.js +741 -265
- package/dist/engine-dom/iife/es5/engine-dom.min.js +2 -2
- package/dist/engine-dom/iife/es5/engine-dom_debug.js +522 -243
- package/dist/engine-dom/umd/es2017/engine-dom.js +674 -216
- package/dist/engine-dom/umd/es2017/engine-dom.min.js +2 -2
- package/dist/engine-dom/umd/es2017/engine-dom_debug.js +474 -203
- package/dist/engine-dom/umd/es5/engine-dom.js +742 -266
- package/dist/engine-dom/umd/es5/engine-dom.min.js +2 -2
- package/dist/engine-dom/umd/es5/engine-dom_debug.js +523 -244
- package/dist/engine-server/commonjs/es2017/engine-server.js +551 -166
- package/dist/engine-server/commonjs/es2017/engine-server.min.js +2 -2
- package/dist/engine-server/esm/es2017/engine-server.js +552 -166
- package/dist/synthetic-shadow/esm/es2017/synthetic-shadow.js +9 -39
- package/dist/synthetic-shadow/iife/es2017/synthetic-shadow.js +10 -40
- package/dist/synthetic-shadow/iife/es2017/synthetic-shadow.min.js +2 -2
- package/dist/synthetic-shadow/iife/es2017/synthetic-shadow_debug.js +10 -40
- package/dist/synthetic-shadow/iife/es5/synthetic-shadow.js +10 -40
- package/dist/synthetic-shadow/iife/es5/synthetic-shadow.min.js +2 -2
- package/dist/synthetic-shadow/iife/es5/synthetic-shadow_debug.js +10 -40
- package/dist/synthetic-shadow/umd/es2017/synthetic-shadow.js +11 -41
- package/dist/synthetic-shadow/umd/es2017/synthetic-shadow.min.js +2 -2
- package/dist/synthetic-shadow/umd/es2017/synthetic-shadow_debug.js +11 -41
- package/dist/synthetic-shadow/umd/es5/synthetic-shadow.js +11 -41
- package/dist/synthetic-shadow/umd/es5/synthetic-shadow.min.js +2 -2
- package/dist/synthetic-shadow/umd/es5/synthetic-shadow_debug.js +11 -41
- package/dist/wire-service/esm/es2017/wire-service.js +2 -2
- package/dist/wire-service/iife/es2017/wire-service.js +3 -3
- package/dist/wire-service/iife/es2017/wire-service_debug.js +3 -3
- package/dist/wire-service/iife/es5/wire-service.js +3 -3
- package/dist/wire-service/iife/es5/wire-service.min.js +1 -1
- package/dist/wire-service/iife/es5/wire-service_debug.js +3 -3
- package/dist/wire-service/umd/es2017/wire-service.js +4 -4
- package/dist/wire-service/umd/es2017/wire-service_debug.js +4 -4
- package/dist/wire-service/umd/es5/wire-service.js +4 -4
- package/dist/wire-service/umd/es5/wire-service.min.js +1 -1
- package/dist/wire-service/umd/es5/wire-service_debug.js +4 -4
- package/package.json +8 -8
|
@@ -69,7 +69,7 @@ const {
|
|
|
69
69
|
find: ArrayFind,
|
|
70
70
|
indexOf: ArrayIndexOf,
|
|
71
71
|
join: ArrayJoin,
|
|
72
|
-
map: ArrayMap
|
|
72
|
+
map: ArrayMap,
|
|
73
73
|
push: ArrayPush$1,
|
|
74
74
|
reduce: ArrayReduce,
|
|
75
75
|
reverse: ArrayReverse,
|
|
@@ -136,7 +136,7 @@ function toString$1(obj) {
|
|
|
136
136
|
// Array.prototype.toString directly will cause an error Iterate through
|
|
137
137
|
// all the items and handle individually.
|
|
138
138
|
if (isArray$1(obj)) {
|
|
139
|
-
return ArrayJoin.call(ArrayMap
|
|
139
|
+
return ArrayJoin.call(ArrayMap.call(obj, toString$1), ',');
|
|
140
140
|
}
|
|
141
141
|
|
|
142
142
|
return obj.toString();
|
|
@@ -299,7 +299,7 @@ function htmlPropertyToAttribute(propName) {
|
|
|
299
299
|
CACHED_PROPERTY_ATTRIBUTE_MAPPING.set(propName, attributeName);
|
|
300
300
|
return attributeName;
|
|
301
301
|
}
|
|
302
|
-
/** version: 2.5.
|
|
302
|
+
/** version: 2.5.9 */
|
|
303
303
|
|
|
304
304
|
/*
|
|
305
305
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
@@ -479,7 +479,7 @@ function setFeatureFlagForTest(name, value) {
|
|
|
479
479
|
setFeatureFlag(name, value);
|
|
480
480
|
}
|
|
481
481
|
}
|
|
482
|
-
/** version: 2.5.
|
|
482
|
+
/** version: 2.5.9 */
|
|
483
483
|
|
|
484
484
|
/* proxy-compat-disable */
|
|
485
485
|
|
|
@@ -531,6 +531,28 @@ function guid() {
|
|
|
531
531
|
}
|
|
532
532
|
|
|
533
533
|
return s4() + s4() + '-' + s4() + '-' + s4() + '-' + s4() + '-' + s4() + s4() + s4();
|
|
534
|
+
} // Borrowed from Vue template compiler.
|
|
535
|
+
// https://github.com/vuejs/vue/blob/531371b818b0e31a989a06df43789728f23dc4e8/src/platforms/web/util/style.js#L5-L16
|
|
536
|
+
|
|
537
|
+
|
|
538
|
+
const DECLARATION_DELIMITER = /;(?![^(]*\))/g;
|
|
539
|
+
const PROPERTY_DELIMITER = /:(.+)/;
|
|
540
|
+
|
|
541
|
+
function parseStyleText(cssText) {
|
|
542
|
+
const styleMap = {};
|
|
543
|
+
const declarations = cssText.split(DECLARATION_DELIMITER);
|
|
544
|
+
|
|
545
|
+
for (const declaration of declarations) {
|
|
546
|
+
if (declaration) {
|
|
547
|
+
const [prop, value] = declaration.split(PROPERTY_DELIMITER);
|
|
548
|
+
|
|
549
|
+
if (prop !== undefined && value !== undefined) {
|
|
550
|
+
styleMap[prop.trim()] = value.trim();
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
return styleMap;
|
|
534
556
|
}
|
|
535
557
|
/*
|
|
536
558
|
* Copyright (c) 2019, salesforce.com, inc.
|
|
@@ -712,8 +734,8 @@ function getErrorComponentStack(vm) {
|
|
|
712
734
|
*/
|
|
713
735
|
|
|
714
736
|
|
|
715
|
-
function
|
|
716
|
-
let msg = `[LWC
|
|
737
|
+
function log(method, message, vm) {
|
|
738
|
+
let msg = `[LWC ${method}]: ${message}`;
|
|
717
739
|
|
|
718
740
|
if (!isUndefined$1(vm)) {
|
|
719
741
|
msg = `${msg}\n${getComponentStack(vm)}`;
|
|
@@ -721,7 +743,7 @@ function logError(message, vm) {
|
|
|
721
743
|
|
|
722
744
|
if (process.env.NODE_ENV === 'test') {
|
|
723
745
|
/* eslint-disable-next-line no-console */
|
|
724
|
-
console
|
|
746
|
+
console[method](msg);
|
|
725
747
|
return;
|
|
726
748
|
}
|
|
727
749
|
|
|
@@ -729,9 +751,17 @@ function logError(message, vm) {
|
|
|
729
751
|
throw new Error(msg);
|
|
730
752
|
} catch (e) {
|
|
731
753
|
/* eslint-disable-next-line no-console */
|
|
732
|
-
console
|
|
754
|
+
console[method](e);
|
|
733
755
|
}
|
|
734
756
|
}
|
|
757
|
+
|
|
758
|
+
function logError(message, vm) {
|
|
759
|
+
log('error', message, vm);
|
|
760
|
+
}
|
|
761
|
+
|
|
762
|
+
function logWarn(message, vm) {
|
|
763
|
+
log('warn', message, vm);
|
|
764
|
+
}
|
|
735
765
|
/*
|
|
736
766
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
737
767
|
* All rights reserved.
|
|
@@ -1899,7 +1929,6 @@ const {
|
|
|
1899
1929
|
getPrototypeOf,
|
|
1900
1930
|
create: ObjectCreate,
|
|
1901
1931
|
defineProperty: ObjectDefineProperty,
|
|
1902
|
-
defineProperties: ObjectDefineProperties,
|
|
1903
1932
|
isExtensible,
|
|
1904
1933
|
getOwnPropertyDescriptor,
|
|
1905
1934
|
getOwnPropertyNames,
|
|
@@ -1909,8 +1938,7 @@ const {
|
|
|
1909
1938
|
} = Object;
|
|
1910
1939
|
const {
|
|
1911
1940
|
push: ArrayPush,
|
|
1912
|
-
concat: ArrayConcat
|
|
1913
|
-
map: ArrayMap
|
|
1941
|
+
concat: ArrayConcat
|
|
1914
1942
|
} = Array.prototype;
|
|
1915
1943
|
const OtS = {}.toString;
|
|
1916
1944
|
|
|
@@ -1975,7 +2003,9 @@ class BaseProxyHandler {
|
|
|
1975
2003
|
// but it will always be compatible with the previous descriptor
|
|
1976
2004
|
// to preserve the object invariants, which makes these lines safe.
|
|
1977
2005
|
|
|
1978
|
-
const originalDescriptor = getOwnPropertyDescriptor(originalTarget, key);
|
|
2006
|
+
const originalDescriptor = getOwnPropertyDescriptor(originalTarget, key); // TODO: it should be impossible for the originalDescriptor to ever be undefined, this `if` can be removed
|
|
2007
|
+
|
|
2008
|
+
/* istanbul ignore else */
|
|
1979
2009
|
|
|
1980
2010
|
if (!isUndefined(originalDescriptor)) {
|
|
1981
2011
|
const wrappedDesc = this.wrapDescriptor(originalDescriptor);
|
|
@@ -2003,11 +2033,17 @@ class BaseProxyHandler {
|
|
|
2003
2033
|
|
|
2004
2034
|
preventExtensions(shadowTarget);
|
|
2005
2035
|
} // Shared Traps
|
|
2036
|
+
// TODO: apply() is never called
|
|
2037
|
+
|
|
2038
|
+
/* istanbul ignore next */
|
|
2006
2039
|
|
|
2007
2040
|
|
|
2008
2041
|
apply(shadowTarget, thisArg, argArray) {
|
|
2009
2042
|
/* No op */
|
|
2010
|
-
}
|
|
2043
|
+
} // TODO: construct() is never called
|
|
2044
|
+
|
|
2045
|
+
/* istanbul ignore next */
|
|
2046
|
+
|
|
2011
2047
|
|
|
2012
2048
|
construct(shadowTarget, argArray, newTarget) {
|
|
2013
2049
|
/* No op */
|
|
@@ -2120,8 +2156,8 @@ class BaseProxyHandler {
|
|
|
2120
2156
|
|
|
2121
2157
|
}
|
|
2122
2158
|
|
|
2123
|
-
const getterMap = new WeakMap();
|
|
2124
|
-
const setterMap = new WeakMap();
|
|
2159
|
+
const getterMap$1 = new WeakMap();
|
|
2160
|
+
const setterMap$1 = new WeakMap();
|
|
2125
2161
|
const reverseGetterMap = new WeakMap();
|
|
2126
2162
|
const reverseSetterMap = new WeakMap();
|
|
2127
2163
|
|
|
@@ -2131,7 +2167,7 @@ class ReactiveProxyHandler extends BaseProxyHandler {
|
|
|
2131
2167
|
}
|
|
2132
2168
|
|
|
2133
2169
|
wrapGetter(originalGet) {
|
|
2134
|
-
const wrappedGetter = getterMap.get(originalGet);
|
|
2170
|
+
const wrappedGetter = getterMap$1.get(originalGet);
|
|
2135
2171
|
|
|
2136
2172
|
if (!isUndefined(wrappedGetter)) {
|
|
2137
2173
|
return wrappedGetter;
|
|
@@ -2144,13 +2180,13 @@ class ReactiveProxyHandler extends BaseProxyHandler {
|
|
|
2144
2180
|
return handler.wrapValue(originalGet.call(unwrap$1(this)));
|
|
2145
2181
|
};
|
|
2146
2182
|
|
|
2147
|
-
getterMap.set(originalGet, get);
|
|
2183
|
+
getterMap$1.set(originalGet, get);
|
|
2148
2184
|
reverseGetterMap.set(get, originalGet);
|
|
2149
2185
|
return get;
|
|
2150
2186
|
}
|
|
2151
2187
|
|
|
2152
2188
|
wrapSetter(originalSet) {
|
|
2153
|
-
const wrappedSetter = setterMap.get(originalSet);
|
|
2189
|
+
const wrappedSetter = setterMap$1.get(originalSet);
|
|
2154
2190
|
|
|
2155
2191
|
if (!isUndefined(wrappedSetter)) {
|
|
2156
2192
|
return wrappedSetter;
|
|
@@ -2161,7 +2197,7 @@ class ReactiveProxyHandler extends BaseProxyHandler {
|
|
|
2161
2197
|
originalSet.call(unwrap$1(this), unwrap$1(v));
|
|
2162
2198
|
};
|
|
2163
2199
|
|
|
2164
|
-
setterMap.set(originalSet, set);
|
|
2200
|
+
setterMap$1.set(originalSet, set);
|
|
2165
2201
|
reverseSetterMap.set(set, originalSet);
|
|
2166
2202
|
return set;
|
|
2167
2203
|
}
|
|
@@ -2202,7 +2238,7 @@ class ReactiveProxyHandler extends BaseProxyHandler {
|
|
|
2202
2238
|
return unwrap$1(redGet.call(handler.wrapValue(this)));
|
|
2203
2239
|
};
|
|
2204
2240
|
|
|
2205
|
-
getterMap.set(get, redGet);
|
|
2241
|
+
getterMap$1.set(get, redGet);
|
|
2206
2242
|
reverseGetterMap.set(redGet, get);
|
|
2207
2243
|
return get;
|
|
2208
2244
|
}
|
|
@@ -2221,7 +2257,7 @@ class ReactiveProxyHandler extends BaseProxyHandler {
|
|
|
2221
2257
|
redSet.call(handler.wrapValue(this), handler.wrapValue(v));
|
|
2222
2258
|
};
|
|
2223
2259
|
|
|
2224
|
-
setterMap.set(set, redSet);
|
|
2260
|
+
setterMap$1.set(set, redSet);
|
|
2225
2261
|
reverseSetterMap.set(redSet, set);
|
|
2226
2262
|
return set;
|
|
2227
2263
|
}
|
|
@@ -2262,6 +2298,7 @@ class ReactiveProxyHandler extends BaseProxyHandler {
|
|
|
2262
2298
|
}
|
|
2263
2299
|
|
|
2264
2300
|
setPrototypeOf(shadowTarget, prototype) {
|
|
2301
|
+
/* istanbul ignore else */
|
|
2265
2302
|
if (process.env.NODE_ENV !== 'production') {
|
|
2266
2303
|
throw new Error(`Invalid setPrototypeOf invocation for reactive proxy ${toString(this.originalTarget)}. Prototype of reactive objects cannot be changed.`);
|
|
2267
2304
|
}
|
|
@@ -2275,6 +2312,11 @@ class ReactiveProxyHandler extends BaseProxyHandler {
|
|
|
2275
2312
|
preventExtensions(originalTarget); // if the originalTarget is a proxy itself, it might reject
|
|
2276
2313
|
// the preventExtension call, in which case we should not attempt to lock down
|
|
2277
2314
|
// the shadow target.
|
|
2315
|
+
// TODO: It should not actually be possible to reach this `if` statement.
|
|
2316
|
+
// If a proxy rejects extensions, then calling preventExtensions will throw an error:
|
|
2317
|
+
// https://codepen.io/nolanlawson-the-selector/pen/QWMOjbY
|
|
2318
|
+
|
|
2319
|
+
/* istanbul ignore if */
|
|
2278
2320
|
|
|
2279
2321
|
if (isExtensible(originalTarget)) {
|
|
2280
2322
|
return false;
|
|
@@ -2316,8 +2358,8 @@ class ReactiveProxyHandler extends BaseProxyHandler {
|
|
|
2316
2358
|
|
|
2317
2359
|
}
|
|
2318
2360
|
|
|
2319
|
-
const getterMap
|
|
2320
|
-
const setterMap
|
|
2361
|
+
const getterMap = new WeakMap();
|
|
2362
|
+
const setterMap = new WeakMap();
|
|
2321
2363
|
|
|
2322
2364
|
class ReadOnlyHandler extends BaseProxyHandler {
|
|
2323
2365
|
wrapValue(value) {
|
|
@@ -2325,7 +2367,7 @@ class ReadOnlyHandler extends BaseProxyHandler {
|
|
|
2325
2367
|
}
|
|
2326
2368
|
|
|
2327
2369
|
wrapGetter(originalGet) {
|
|
2328
|
-
const wrappedGetter = getterMap
|
|
2370
|
+
const wrappedGetter = getterMap.get(originalGet);
|
|
2329
2371
|
|
|
2330
2372
|
if (!isUndefined(wrappedGetter)) {
|
|
2331
2373
|
return wrappedGetter;
|
|
@@ -2338,12 +2380,12 @@ class ReadOnlyHandler extends BaseProxyHandler {
|
|
|
2338
2380
|
return handler.wrapValue(originalGet.call(unwrap$1(this)));
|
|
2339
2381
|
};
|
|
2340
2382
|
|
|
2341
|
-
getterMap
|
|
2383
|
+
getterMap.set(originalGet, get);
|
|
2342
2384
|
return get;
|
|
2343
2385
|
}
|
|
2344
2386
|
|
|
2345
2387
|
wrapSetter(originalSet) {
|
|
2346
|
-
const wrappedSetter = setterMap
|
|
2388
|
+
const wrappedSetter = setterMap.get(originalSet);
|
|
2347
2389
|
|
|
2348
2390
|
if (!isUndefined(wrappedSetter)) {
|
|
2349
2391
|
return wrappedSetter;
|
|
@@ -2352,6 +2394,7 @@ class ReadOnlyHandler extends BaseProxyHandler {
|
|
|
2352
2394
|
const handler = this;
|
|
2353
2395
|
|
|
2354
2396
|
const set = function (v) {
|
|
2397
|
+
/* istanbul ignore else */
|
|
2355
2398
|
if (process.env.NODE_ENV !== 'production') {
|
|
2356
2399
|
const {
|
|
2357
2400
|
originalTarget
|
|
@@ -2360,33 +2403,41 @@ class ReadOnlyHandler extends BaseProxyHandler {
|
|
|
2360
2403
|
}
|
|
2361
2404
|
};
|
|
2362
2405
|
|
|
2363
|
-
setterMap
|
|
2406
|
+
setterMap.set(originalSet, set);
|
|
2364
2407
|
return set;
|
|
2365
2408
|
}
|
|
2366
2409
|
|
|
2367
2410
|
set(shadowTarget, key, value) {
|
|
2411
|
+
/* istanbul ignore else */
|
|
2368
2412
|
if (process.env.NODE_ENV !== 'production') {
|
|
2369
2413
|
const {
|
|
2370
2414
|
originalTarget
|
|
2371
2415
|
} = this;
|
|
2372
|
-
|
|
2416
|
+
const msg = isArray(originalTarget) ? `Invalid mutation: Cannot mutate array at index ${key.toString()}. Array is read-only.` : `Invalid mutation: Cannot set "${key.toString()}" on "${originalTarget}". "${originalTarget}" is read-only.`;
|
|
2417
|
+
throw new Error(msg);
|
|
2373
2418
|
}
|
|
2419
|
+
/* istanbul ignore next */
|
|
2420
|
+
|
|
2374
2421
|
|
|
2375
2422
|
return false;
|
|
2376
2423
|
}
|
|
2377
2424
|
|
|
2378
2425
|
deleteProperty(shadowTarget, key) {
|
|
2426
|
+
/* istanbul ignore else */
|
|
2379
2427
|
if (process.env.NODE_ENV !== 'production') {
|
|
2380
2428
|
const {
|
|
2381
2429
|
originalTarget
|
|
2382
2430
|
} = this;
|
|
2383
2431
|
throw new Error(`Invalid mutation: Cannot delete "${key.toString()}" on "${originalTarget}". "${originalTarget}" is read-only.`);
|
|
2384
2432
|
}
|
|
2433
|
+
/* istanbul ignore next */
|
|
2434
|
+
|
|
2385
2435
|
|
|
2386
2436
|
return false;
|
|
2387
2437
|
}
|
|
2388
2438
|
|
|
2389
2439
|
setPrototypeOf(shadowTarget, prototype) {
|
|
2440
|
+
/* istanbul ignore else */
|
|
2390
2441
|
if (process.env.NODE_ENV !== 'production') {
|
|
2391
2442
|
const {
|
|
2392
2443
|
originalTarget
|
|
@@ -2396,23 +2447,29 @@ class ReadOnlyHandler extends BaseProxyHandler {
|
|
|
2396
2447
|
}
|
|
2397
2448
|
|
|
2398
2449
|
preventExtensions(shadowTarget) {
|
|
2450
|
+
/* istanbul ignore else */
|
|
2399
2451
|
if (process.env.NODE_ENV !== 'production') {
|
|
2400
2452
|
const {
|
|
2401
2453
|
originalTarget
|
|
2402
2454
|
} = this;
|
|
2403
2455
|
throw new Error(`Invalid mutation: Cannot preventExtensions on ${originalTarget}". "${originalTarget} is read-only.`);
|
|
2404
2456
|
}
|
|
2457
|
+
/* istanbul ignore next */
|
|
2458
|
+
|
|
2405
2459
|
|
|
2406
2460
|
return false;
|
|
2407
2461
|
}
|
|
2408
2462
|
|
|
2409
2463
|
defineProperty(shadowTarget, key, descriptor) {
|
|
2464
|
+
/* istanbul ignore else */
|
|
2410
2465
|
if (process.env.NODE_ENV !== 'production') {
|
|
2411
2466
|
const {
|
|
2412
2467
|
originalTarget
|
|
2413
2468
|
} = this;
|
|
2414
2469
|
throw new Error(`Invalid mutation: Cannot defineProperty "${key.toString()}" on "${originalTarget}". "${originalTarget}" is read-only.`);
|
|
2415
2470
|
}
|
|
2471
|
+
/* istanbul ignore next */
|
|
2472
|
+
|
|
2416
2473
|
|
|
2417
2474
|
return false;
|
|
2418
2475
|
}
|
|
@@ -2470,6 +2527,8 @@ const formatter = {
|
|
|
2470
2527
|
}; // Inspired from paulmillr/es6-shim
|
|
2471
2528
|
// https://github.com/paulmillr/es6-shim/blob/master/es6-shim.js#L176-L185
|
|
2472
2529
|
|
|
2530
|
+
/* istanbul ignore next */
|
|
2531
|
+
|
|
2473
2532
|
function getGlobal() {
|
|
2474
2533
|
// the only reliable means to get the global object is `Function('return this')()`
|
|
2475
2534
|
// However, this causes CSP violations in Chrome apps.
|
|
@@ -2494,6 +2553,7 @@ function getGlobal() {
|
|
|
2494
2553
|
}
|
|
2495
2554
|
|
|
2496
2555
|
function init() {
|
|
2556
|
+
/* istanbul ignore if */
|
|
2497
2557
|
if (process.env.NODE_ENV === 'production') {
|
|
2498
2558
|
// this method should never leak to prod
|
|
2499
2559
|
throw new ReferenceError();
|
|
@@ -2508,6 +2568,8 @@ function init() {
|
|
|
2508
2568
|
ArrayPush.call(devtoolsFormatters, formatter);
|
|
2509
2569
|
global.devtoolsFormatters = devtoolsFormatters;
|
|
2510
2570
|
}
|
|
2571
|
+
/* istanbul ignore else */
|
|
2572
|
+
|
|
2511
2573
|
|
|
2512
2574
|
if (process.env.NODE_ENV !== 'production') {
|
|
2513
2575
|
init();
|
|
@@ -2554,7 +2616,8 @@ class ReactiveMembrane {
|
|
|
2554
2616
|
this.valueMutated = defaultValueMutated;
|
|
2555
2617
|
this.valueObserved = defaultValueObserved;
|
|
2556
2618
|
this.valueIsObservable = defaultValueIsObservable;
|
|
2557
|
-
this.
|
|
2619
|
+
this.readOnlyObjectGraph = new WeakMap();
|
|
2620
|
+
this.reactiveObjectGraph = new WeakMap();
|
|
2558
2621
|
|
|
2559
2622
|
if (!isUndefined(options)) {
|
|
2560
2623
|
const {
|
|
@@ -2577,10 +2640,13 @@ class ReactiveMembrane {
|
|
|
2577
2640
|
const distorted = this.valueDistortion(unwrappedValue);
|
|
2578
2641
|
|
|
2579
2642
|
if (this.valueIsObservable(distorted)) {
|
|
2580
|
-
|
|
2581
|
-
|
|
2643
|
+
if (this.readOnlyObjectGraph.get(distorted) === value) {
|
|
2644
|
+
// when trying to extract the writable version of a readonly
|
|
2645
|
+
// we return the readonly.
|
|
2646
|
+
return value;
|
|
2647
|
+
}
|
|
2582
2648
|
|
|
2583
|
-
return
|
|
2649
|
+
return this.getReactiveHandler(unwrappedValue, distorted);
|
|
2584
2650
|
}
|
|
2585
2651
|
|
|
2586
2652
|
return distorted;
|
|
@@ -2591,7 +2657,7 @@ class ReactiveMembrane {
|
|
|
2591
2657
|
const distorted = this.valueDistortion(value);
|
|
2592
2658
|
|
|
2593
2659
|
if (this.valueIsObservable(distorted)) {
|
|
2594
|
-
return this.
|
|
2660
|
+
return this.getReadOnlyHandler(value, distorted);
|
|
2595
2661
|
}
|
|
2596
2662
|
|
|
2597
2663
|
return distorted;
|
|
@@ -2601,47 +2667,36 @@ class ReactiveMembrane {
|
|
|
2601
2667
|
return unwrap$1(p);
|
|
2602
2668
|
}
|
|
2603
2669
|
|
|
2604
|
-
|
|
2605
|
-
|
|
2606
|
-
objectGraph
|
|
2607
|
-
} = this;
|
|
2608
|
-
let reactiveState = objectGraph.get(distortedValue);
|
|
2670
|
+
getReactiveHandler(value, distortedValue) {
|
|
2671
|
+
let proxy = this.reactiveObjectGraph.get(distortedValue);
|
|
2609
2672
|
|
|
2610
|
-
if (
|
|
2611
|
-
|
|
2673
|
+
if (isUndefined(proxy)) {
|
|
2674
|
+
// caching the proxy after the first time it is accessed
|
|
2675
|
+
const handler = new ReactiveProxyHandler(this, distortedValue);
|
|
2676
|
+
proxy = new Proxy(createShadowTarget(distortedValue), handler);
|
|
2677
|
+
registerProxy(proxy, value);
|
|
2678
|
+
this.reactiveObjectGraph.set(distortedValue, proxy);
|
|
2612
2679
|
}
|
|
2613
2680
|
|
|
2614
|
-
|
|
2615
|
-
|
|
2616
|
-
get reactive() {
|
|
2617
|
-
const reactiveHandler = new ReactiveProxyHandler(membrane, distortedValue); // caching the reactive proxy after the first time it is accessed
|
|
2618
|
-
|
|
2619
|
-
const proxy = new Proxy(createShadowTarget(distortedValue), reactiveHandler);
|
|
2620
|
-
registerProxy(proxy, value);
|
|
2621
|
-
ObjectDefineProperty(this, 'reactive', {
|
|
2622
|
-
value: proxy
|
|
2623
|
-
});
|
|
2624
|
-
return proxy;
|
|
2625
|
-
},
|
|
2681
|
+
return proxy;
|
|
2682
|
+
}
|
|
2626
2683
|
|
|
2627
|
-
|
|
2628
|
-
|
|
2684
|
+
getReadOnlyHandler(value, distortedValue) {
|
|
2685
|
+
let proxy = this.readOnlyObjectGraph.get(distortedValue);
|
|
2629
2686
|
|
|
2630
|
-
|
|
2631
|
-
|
|
2632
|
-
|
|
2633
|
-
|
|
2634
|
-
|
|
2635
|
-
|
|
2636
|
-
|
|
2687
|
+
if (isUndefined(proxy)) {
|
|
2688
|
+
// caching the proxy after the first time it is accessed
|
|
2689
|
+
const handler = new ReadOnlyHandler(this, distortedValue);
|
|
2690
|
+
proxy = new Proxy(createShadowTarget(distortedValue), handler);
|
|
2691
|
+
registerProxy(proxy, value);
|
|
2692
|
+
this.readOnlyObjectGraph.set(distortedValue, proxy);
|
|
2693
|
+
}
|
|
2637
2694
|
|
|
2638
|
-
|
|
2639
|
-
objectGraph.set(distortedValue, reactiveState);
|
|
2640
|
-
return reactiveState;
|
|
2695
|
+
return proxy;
|
|
2641
2696
|
}
|
|
2642
2697
|
|
|
2643
2698
|
}
|
|
2644
|
-
/** version: 1.
|
|
2699
|
+
/** version: 1.1.5 */
|
|
2645
2700
|
|
|
2646
2701
|
/*
|
|
2647
2702
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
@@ -3095,8 +3150,10 @@ for (const [elementProp, rendererMethod] of childGetters) {
|
|
|
3095
3150
|
}
|
|
3096
3151
|
|
|
3097
3152
|
return renderer[rendererMethod](elm);
|
|
3098
|
-
}
|
|
3153
|
+
},
|
|
3099
3154
|
|
|
3155
|
+
configurable: true,
|
|
3156
|
+
enumerable: true
|
|
3100
3157
|
};
|
|
3101
3158
|
}
|
|
3102
3159
|
|
|
@@ -3116,8 +3173,11 @@ for (const queryMethod of queryMethods) {
|
|
|
3116
3173
|
}
|
|
3117
3174
|
|
|
3118
3175
|
return renderer[queryMethod](elm, arg);
|
|
3119
|
-
}
|
|
3176
|
+
},
|
|
3120
3177
|
|
|
3178
|
+
configurable: true,
|
|
3179
|
+
enumerable: true,
|
|
3180
|
+
writable: true
|
|
3121
3181
|
};
|
|
3122
3182
|
}
|
|
3123
3183
|
|
|
@@ -4275,7 +4335,7 @@ function createComponentDef(Ctor) {
|
|
|
4275
4335
|
if (!isUndefined$1(ctorShadowSupportMode)) {
|
|
4276
4336
|
assert.invariant(ctorShadowSupportMode === "any"
|
|
4277
4337
|
/* Any */
|
|
4278
|
-
|| ctorShadowSupportMode === "
|
|
4338
|
+
|| ctorShadowSupportMode === "reset"
|
|
4279
4339
|
/* Default */
|
|
4280
4340
|
, `Invalid value for static property shadowSupportMode: '${ctorShadowSupportMode}'`);
|
|
4281
4341
|
}
|
|
@@ -4437,7 +4497,7 @@ const lightingElementDef = {
|
|
|
4437
4497
|
renderMode: 1
|
|
4438
4498
|
/* Shadow */
|
|
4439
4499
|
,
|
|
4440
|
-
shadowSupportMode: "
|
|
4500
|
+
shadowSupportMode: "reset"
|
|
4441
4501
|
/* Default */
|
|
4442
4502
|
,
|
|
4443
4503
|
wire: EmptyObject,
|
|
@@ -4586,6 +4646,17 @@ function createElmHook(vnode) {
|
|
|
4586
4646
|
modComputedStyle.create(vnode);
|
|
4587
4647
|
}
|
|
4588
4648
|
|
|
4649
|
+
function hydrateElmHook(vnode) {
|
|
4650
|
+
modEvents.create(vnode); // Attrs are already on the element.
|
|
4651
|
+
// modAttrs.create(vnode);
|
|
4652
|
+
|
|
4653
|
+
modProps.create(vnode); // Already set.
|
|
4654
|
+
// modStaticClassName.create(vnode);
|
|
4655
|
+
// modStaticStyle.create(vnode);
|
|
4656
|
+
// modComputedClassName.create(vnode);
|
|
4657
|
+
// modComputedStyle.create(vnode);
|
|
4658
|
+
}
|
|
4659
|
+
|
|
4589
4660
|
function fallbackElmHook(elm, vnode) {
|
|
4590
4661
|
const {
|
|
4591
4662
|
owner
|
|
@@ -4757,6 +4828,179 @@ function createChildrenHook(vnode) {
|
|
|
4757
4828
|
}
|
|
4758
4829
|
}
|
|
4759
4830
|
|
|
4831
|
+
function isElementNode(node) {
|
|
4832
|
+
// eslint-disable-next-line lwc-internal/no-global-node
|
|
4833
|
+
return node.nodeType === Node.ELEMENT_NODE;
|
|
4834
|
+
}
|
|
4835
|
+
|
|
4836
|
+
function vnodesAndElementHaveCompatibleAttrs(vnode, elm) {
|
|
4837
|
+
const {
|
|
4838
|
+
data: {
|
|
4839
|
+
attrs = {}
|
|
4840
|
+
},
|
|
4841
|
+
owner: {
|
|
4842
|
+
renderer
|
|
4843
|
+
}
|
|
4844
|
+
} = vnode;
|
|
4845
|
+
let nodesAreCompatible = true; // Validate attributes, though we could always recovery from those by running the update mods.
|
|
4846
|
+
// Note: intentionally ONLY matching vnodes.attrs to elm.attrs, in case SSR is adding extra attributes.
|
|
4847
|
+
|
|
4848
|
+
for (const [attrName, attrValue] of Object.entries(attrs)) {
|
|
4849
|
+
const elmAttrValue = renderer.getAttribute(elm, attrName);
|
|
4850
|
+
|
|
4851
|
+
if (String(attrValue) !== elmAttrValue) {
|
|
4852
|
+
logError(`Mismatch hydrating element <${elm.tagName.toLowerCase()}>: attribute "${attrName}" has different values, expected "${attrValue}" but found "${elmAttrValue}"`, vnode.owner);
|
|
4853
|
+
nodesAreCompatible = false;
|
|
4854
|
+
}
|
|
4855
|
+
}
|
|
4856
|
+
|
|
4857
|
+
return nodesAreCompatible;
|
|
4858
|
+
}
|
|
4859
|
+
|
|
4860
|
+
function vnodesAndElementHaveCompatibleClass(vnode, elm) {
|
|
4861
|
+
const {
|
|
4862
|
+
data: {
|
|
4863
|
+
className,
|
|
4864
|
+
classMap
|
|
4865
|
+
},
|
|
4866
|
+
owner: {
|
|
4867
|
+
renderer
|
|
4868
|
+
}
|
|
4869
|
+
} = vnode;
|
|
4870
|
+
let nodesAreCompatible = true;
|
|
4871
|
+
let vnodeClassName;
|
|
4872
|
+
|
|
4873
|
+
if (!isUndefined$1(className) && String(className) !== elm.className) {
|
|
4874
|
+
// className is used when class is bound to an expr.
|
|
4875
|
+
nodesAreCompatible = false;
|
|
4876
|
+
vnodeClassName = className;
|
|
4877
|
+
} else if (!isUndefined$1(classMap)) {
|
|
4878
|
+
// classMap is used when class is set to static value.
|
|
4879
|
+
const classList = renderer.getClassList(elm);
|
|
4880
|
+
let computedClassName = ''; // all classes from the vnode should be in the element.classList
|
|
4881
|
+
|
|
4882
|
+
for (const name in classMap) {
|
|
4883
|
+
computedClassName += ' ' + name;
|
|
4884
|
+
|
|
4885
|
+
if (!classList.contains(name)) {
|
|
4886
|
+
nodesAreCompatible = false;
|
|
4887
|
+
}
|
|
4888
|
+
}
|
|
4889
|
+
|
|
4890
|
+
vnodeClassName = computedClassName.trim();
|
|
4891
|
+
|
|
4892
|
+
if (classList.length > keys(classMap).length) {
|
|
4893
|
+
nodesAreCompatible = false;
|
|
4894
|
+
}
|
|
4895
|
+
}
|
|
4896
|
+
|
|
4897
|
+
if (!nodesAreCompatible) {
|
|
4898
|
+
logError(`Mismatch hydrating element <${elm.tagName.toLowerCase()}>: attribute "class" has different values, expected "${vnodeClassName}" but found "${elm.className}"`, vnode.owner);
|
|
4899
|
+
}
|
|
4900
|
+
|
|
4901
|
+
return nodesAreCompatible;
|
|
4902
|
+
}
|
|
4903
|
+
|
|
4904
|
+
function vnodesAndElementHaveCompatibleStyle(vnode, elm) {
|
|
4905
|
+
const {
|
|
4906
|
+
data: {
|
|
4907
|
+
style,
|
|
4908
|
+
styleDecls
|
|
4909
|
+
},
|
|
4910
|
+
owner: {
|
|
4911
|
+
renderer
|
|
4912
|
+
}
|
|
4913
|
+
} = vnode;
|
|
4914
|
+
const elmStyle = renderer.getAttribute(elm, 'style') || '';
|
|
4915
|
+
let vnodeStyle;
|
|
4916
|
+
let nodesAreCompatible = true;
|
|
4917
|
+
|
|
4918
|
+
if (!isUndefined$1(style) && style !== elmStyle) {
|
|
4919
|
+
nodesAreCompatible = false;
|
|
4920
|
+
vnodeStyle = style;
|
|
4921
|
+
} else if (!isUndefined$1(styleDecls)) {
|
|
4922
|
+
const parsedVnodeStyle = parseStyleText(elmStyle);
|
|
4923
|
+
const expectedStyle = []; // styleMap is used when style is set to static value.
|
|
4924
|
+
|
|
4925
|
+
for (let i = 0, n = styleDecls.length; i < n; i++) {
|
|
4926
|
+
const [prop, value, important] = styleDecls[i];
|
|
4927
|
+
expectedStyle.push(`${prop}: ${value + (important ? ' important!' : '')}`);
|
|
4928
|
+
const parsedPropValue = parsedVnodeStyle[prop];
|
|
4929
|
+
|
|
4930
|
+
if (isUndefined$1(parsedPropValue)) {
|
|
4931
|
+
nodesAreCompatible = false;
|
|
4932
|
+
} else if (!parsedPropValue.startsWith(value)) {
|
|
4933
|
+
nodesAreCompatible = false;
|
|
4934
|
+
} else if (important && !parsedPropValue.endsWith('!important')) {
|
|
4935
|
+
nodesAreCompatible = false;
|
|
4936
|
+
}
|
|
4937
|
+
}
|
|
4938
|
+
|
|
4939
|
+
if (keys(parsedVnodeStyle).length > styleDecls.length) {
|
|
4940
|
+
nodesAreCompatible = false;
|
|
4941
|
+
}
|
|
4942
|
+
|
|
4943
|
+
vnodeStyle = ArrayJoin.call(expectedStyle, ';');
|
|
4944
|
+
}
|
|
4945
|
+
|
|
4946
|
+
if (!nodesAreCompatible) {
|
|
4947
|
+
// style is used when class is bound to an expr.
|
|
4948
|
+
logError(`Mismatch hydrating element <${elm.tagName.toLowerCase()}>: attribute "style" has different values, expected "${vnodeStyle}" but found "${elmStyle}".`, vnode.owner);
|
|
4949
|
+
}
|
|
4950
|
+
|
|
4951
|
+
return nodesAreCompatible;
|
|
4952
|
+
}
|
|
4953
|
+
|
|
4954
|
+
function throwHydrationError() {
|
|
4955
|
+
assert.fail('Server rendered elements do not match client side generated elements');
|
|
4956
|
+
}
|
|
4957
|
+
|
|
4958
|
+
function hydrateChildrenHook(elmChildren, children, vm) {
|
|
4959
|
+
var _a, _b;
|
|
4960
|
+
|
|
4961
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
4962
|
+
const filteredVNodes = ArrayFilter.call(children, vnode => !!vnode);
|
|
4963
|
+
|
|
4964
|
+
if (elmChildren.length !== filteredVNodes.length) {
|
|
4965
|
+
logError(`Hydration mismatch: incorrect number of rendered nodes, expected ${filteredVNodes.length} but found ${elmChildren.length}.`, vm);
|
|
4966
|
+
throwHydrationError();
|
|
4967
|
+
}
|
|
4968
|
+
}
|
|
4969
|
+
|
|
4970
|
+
let elmCurrentChildIdx = 0;
|
|
4971
|
+
|
|
4972
|
+
for (let j = 0, n = children.length; j < n; j++) {
|
|
4973
|
+
const ch = children[j];
|
|
4974
|
+
|
|
4975
|
+
if (ch != null) {
|
|
4976
|
+
const childNode = elmChildren[elmCurrentChildIdx];
|
|
4977
|
+
|
|
4978
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
4979
|
+
// VComments and VTexts validation is handled in their hooks
|
|
4980
|
+
if (isElementNode(childNode)) {
|
|
4981
|
+
if (((_a = ch.sel) === null || _a === void 0 ? void 0 : _a.toLowerCase()) !== childNode.tagName.toLowerCase()) {
|
|
4982
|
+
logError(`Hydration mismatch: expecting element with tag "${(_b = ch.sel) === null || _b === void 0 ? void 0 : _b.toLowerCase()}" but found "${childNode.tagName.toLowerCase()}".`, vm);
|
|
4983
|
+
throwHydrationError();
|
|
4984
|
+
} // Note: props are not yet set
|
|
4985
|
+
|
|
4986
|
+
|
|
4987
|
+
const hasIncompatibleAttrs = vnodesAndElementHaveCompatibleAttrs(ch, childNode);
|
|
4988
|
+
const hasIncompatibleClass = vnodesAndElementHaveCompatibleClass(ch, childNode);
|
|
4989
|
+
const hasIncompatibleStyle = vnodesAndElementHaveCompatibleStyle(ch, childNode);
|
|
4990
|
+
const isVNodeAndElementCompatible = hasIncompatibleAttrs && hasIncompatibleClass && hasIncompatibleStyle;
|
|
4991
|
+
|
|
4992
|
+
if (!isVNodeAndElementCompatible) {
|
|
4993
|
+
throwHydrationError();
|
|
4994
|
+
}
|
|
4995
|
+
}
|
|
4996
|
+
}
|
|
4997
|
+
|
|
4998
|
+
ch.hook.hydrate(ch, childNode);
|
|
4999
|
+
elmCurrentChildIdx++;
|
|
5000
|
+
}
|
|
5001
|
+
}
|
|
5002
|
+
}
|
|
5003
|
+
|
|
4760
5004
|
function updateCustomElmHook(oldVnode, vnode) {
|
|
4761
5005
|
// Attrs need to be applied to element before props
|
|
4762
5006
|
// IE11 will wipe out value on radio inputs if value
|
|
@@ -4840,38 +5084,6 @@ function getUpgradableConstructor(tagName, renderer) {
|
|
|
4840
5084
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
4841
5085
|
*/
|
|
4842
5086
|
|
|
4843
|
-
/**
|
|
4844
|
-
* EXPERIMENTAL: This function acts like a hook for Lightning Locker Service and other similar
|
|
4845
|
-
* libraries to sanitize HTML content. This hook process the content passed via the template to
|
|
4846
|
-
* lwc:inner-html directive.
|
|
4847
|
-
* It is meant to be overridden with setSanitizeHtmlContentHook
|
|
4848
|
-
*/
|
|
4849
|
-
|
|
4850
|
-
|
|
4851
|
-
let sanitizeHtmlContentHook = () => {
|
|
4852
|
-
// locker-service patches this function during runtime to sanitize HTML content.
|
|
4853
|
-
throw new Error('sanitizeHtmlContent hook must be implemented.');
|
|
4854
|
-
};
|
|
4855
|
-
/**
|
|
4856
|
-
* Sets the sanitizeHtmlContentHook.
|
|
4857
|
-
*
|
|
4858
|
-
* @param newHookImpl
|
|
4859
|
-
* @returns oldHookImplementation.
|
|
4860
|
-
*/
|
|
4861
|
-
|
|
4862
|
-
|
|
4863
|
-
function setSanitizeHtmlContentHook(newHookImpl) {
|
|
4864
|
-
const currentHook = sanitizeHtmlContentHook;
|
|
4865
|
-
sanitizeHtmlContentHook = newHookImpl;
|
|
4866
|
-
return currentHook;
|
|
4867
|
-
}
|
|
4868
|
-
/*
|
|
4869
|
-
* Copyright (c) 2018, salesforce.com, inc.
|
|
4870
|
-
* All rights reserved.
|
|
4871
|
-
* SPDX-License-Identifier: MIT
|
|
4872
|
-
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
4873
|
-
*/
|
|
4874
|
-
|
|
4875
5087
|
|
|
4876
5088
|
const SVG_NAMESPACE = 'http://www.w3.org/2000/svg';
|
|
4877
5089
|
const SymbolIterator = Symbol.iterator;
|
|
@@ -4890,7 +5102,26 @@ const TextHook = {
|
|
|
4890
5102
|
update: updateNodeHook,
|
|
4891
5103
|
insert: insertNodeHook,
|
|
4892
5104
|
move: insertNodeHook,
|
|
4893
|
-
remove: removeNodeHook
|
|
5105
|
+
remove: removeNodeHook,
|
|
5106
|
+
hydrate: (vNode, node) => {
|
|
5107
|
+
var _a;
|
|
5108
|
+
|
|
5109
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
5110
|
+
// eslint-disable-next-line lwc-internal/no-global-node
|
|
5111
|
+
if (node.nodeType !== Node.TEXT_NODE) {
|
|
5112
|
+
logError('Hydration mismatch: incorrect node type received', vNode.owner);
|
|
5113
|
+
assert.fail('Hydration mismatch: incorrect node type received.');
|
|
5114
|
+
}
|
|
5115
|
+
|
|
5116
|
+
if (node.nodeValue !== vNode.text) {
|
|
5117
|
+
logWarn('Hydration mismatch: text values do not match, will recover from the difference', vNode.owner);
|
|
5118
|
+
}
|
|
5119
|
+
} // always set the text value to the one from the vnode.
|
|
5120
|
+
|
|
5121
|
+
|
|
5122
|
+
node.nodeValue = (_a = vNode.text) !== null && _a !== void 0 ? _a : null;
|
|
5123
|
+
vNode.elm = node;
|
|
5124
|
+
}
|
|
4894
5125
|
};
|
|
4895
5126
|
const CommentHook = {
|
|
4896
5127
|
create: vnode => {
|
|
@@ -4908,7 +5139,26 @@ const CommentHook = {
|
|
|
4908
5139
|
update: updateNodeHook,
|
|
4909
5140
|
insert: insertNodeHook,
|
|
4910
5141
|
move: insertNodeHook,
|
|
4911
|
-
remove: removeNodeHook
|
|
5142
|
+
remove: removeNodeHook,
|
|
5143
|
+
hydrate: (vNode, node) => {
|
|
5144
|
+
var _a;
|
|
5145
|
+
|
|
5146
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
5147
|
+
// eslint-disable-next-line lwc-internal/no-global-node
|
|
5148
|
+
if (node.nodeType !== Node.COMMENT_NODE) {
|
|
5149
|
+
logError('Hydration mismatch: incorrect node type received', vNode.owner);
|
|
5150
|
+
assert.fail('Hydration mismatch: incorrect node type received.');
|
|
5151
|
+
}
|
|
5152
|
+
|
|
5153
|
+
if (node.nodeValue !== vNode.text) {
|
|
5154
|
+
logWarn('Hydration mismatch: comment values do not match, will recover from the difference', vNode.owner);
|
|
5155
|
+
}
|
|
5156
|
+
} // always set the text value to the one from the vnode.
|
|
5157
|
+
|
|
5158
|
+
|
|
5159
|
+
node.nodeValue = (_a = vNode.text) !== null && _a !== void 0 ? _a : null;
|
|
5160
|
+
vNode.elm = node;
|
|
5161
|
+
}
|
|
4912
5162
|
}; // insert is called after update, which is used somewhere else (via a module)
|
|
4913
5163
|
// to mark the vm as inserted, that means we cannot use update as the main channel
|
|
4914
5164
|
// to rehydrate when dirty, because sometimes the element is not inserted just yet,
|
|
@@ -4948,6 +5198,38 @@ const ElementHook = {
|
|
|
4948
5198
|
remove: (vnode, parentNode) => {
|
|
4949
5199
|
removeNodeHook(vnode, parentNode);
|
|
4950
5200
|
removeElmHook(vnode);
|
|
5201
|
+
},
|
|
5202
|
+
hydrate: (vnode, node) => {
|
|
5203
|
+
const elm = node;
|
|
5204
|
+
vnode.elm = elm;
|
|
5205
|
+
const {
|
|
5206
|
+
context
|
|
5207
|
+
} = vnode.data;
|
|
5208
|
+
const isDomManual = Boolean(!isUndefined$1(context) && !isUndefined$1(context.lwc) && context.lwc.dom === "manual"
|
|
5209
|
+
/* manual */
|
|
5210
|
+
);
|
|
5211
|
+
|
|
5212
|
+
if (isDomManual) {
|
|
5213
|
+
// it may be that this element has lwc:inner-html, we need to diff and in case are the same,
|
|
5214
|
+
// remove the innerHTML from props so it reuses the existing dom elements.
|
|
5215
|
+
const {
|
|
5216
|
+
props
|
|
5217
|
+
} = vnode.data;
|
|
5218
|
+
|
|
5219
|
+
if (!isUndefined$1(props) && !isUndefined$1(props.innerHTML)) {
|
|
5220
|
+
if (elm.innerHTML === props.innerHTML) {
|
|
5221
|
+
delete props.innerHTML;
|
|
5222
|
+
} else {
|
|
5223
|
+
logWarn(`Mismatch hydrating element <${elm.tagName.toLowerCase()}>: innerHTML values do not match for element, will recover from the difference`, vnode.owner);
|
|
5224
|
+
}
|
|
5225
|
+
}
|
|
5226
|
+
}
|
|
5227
|
+
|
|
5228
|
+
hydrateElmHook(vnode);
|
|
5229
|
+
|
|
5230
|
+
if (!isDomManual) {
|
|
5231
|
+
hydrateChildrenHook(vnode.elm.childNodes, vnode.children, vnode.owner);
|
|
5232
|
+
}
|
|
4951
5233
|
}
|
|
4952
5234
|
};
|
|
4953
5235
|
const CustomElementHook = {
|
|
@@ -5039,6 +5321,44 @@ const CustomElementHook = {
|
|
|
5039
5321
|
// will take care of disconnecting any child VM attached to its shadow as well.
|
|
5040
5322
|
removeVM(vm);
|
|
5041
5323
|
}
|
|
5324
|
+
},
|
|
5325
|
+
hydrate: (vnode, elm) => {
|
|
5326
|
+
// the element is created, but the vm is not
|
|
5327
|
+
const {
|
|
5328
|
+
sel,
|
|
5329
|
+
mode,
|
|
5330
|
+
ctor,
|
|
5331
|
+
owner
|
|
5332
|
+
} = vnode;
|
|
5333
|
+
const def = getComponentInternalDef(ctor);
|
|
5334
|
+
createVM(elm, def, {
|
|
5335
|
+
mode,
|
|
5336
|
+
owner,
|
|
5337
|
+
tagName: sel,
|
|
5338
|
+
renderer: owner.renderer
|
|
5339
|
+
});
|
|
5340
|
+
vnode.elm = elm;
|
|
5341
|
+
const vm = getAssociatedVM(elm);
|
|
5342
|
+
allocateChildrenHook(vnode, vm);
|
|
5343
|
+
hydrateElmHook(vnode); // Insert hook section:
|
|
5344
|
+
|
|
5345
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
5346
|
+
assert.isTrue(vm.state === 0
|
|
5347
|
+
/* created */
|
|
5348
|
+
, `${vm} cannot be recycled.`);
|
|
5349
|
+
}
|
|
5350
|
+
|
|
5351
|
+
runConnectedCallback(vm);
|
|
5352
|
+
|
|
5353
|
+
if (vm.renderMode !== 0
|
|
5354
|
+
/* Light */
|
|
5355
|
+
) {
|
|
5356
|
+
// VM is not rendering in Light DOM, we can proceed and hydrate the slotted content.
|
|
5357
|
+
// Note: for Light DOM, this is handled while hydrating the VM
|
|
5358
|
+
hydrateChildrenHook(vnode.elm.childNodes, vnode.children, vm);
|
|
5359
|
+
}
|
|
5360
|
+
|
|
5361
|
+
hydrateVM(vm);
|
|
5042
5362
|
}
|
|
5043
5363
|
};
|
|
5044
5364
|
|
|
@@ -5247,7 +5567,7 @@ function i(iterable, factory) {
|
|
|
5247
5567
|
next = iterator.next();
|
|
5248
5568
|
last = next.done; // template factory logic based on the previous collected value
|
|
5249
5569
|
|
|
5250
|
-
const vnode = factory(value, j, j === 0, last);
|
|
5570
|
+
const vnode = factory(value, j, j === 0, last === true);
|
|
5251
5571
|
|
|
5252
5572
|
if (isArray$1(vnode)) {
|
|
5253
5573
|
ArrayPush$1.apply(list, vnode);
|
|
@@ -5351,7 +5671,7 @@ function co(text) {
|
|
|
5351
5671
|
|
|
5352
5672
|
|
|
5353
5673
|
function d(value) {
|
|
5354
|
-
return value == null ? '' : value;
|
|
5674
|
+
return value == null ? '' : String(value);
|
|
5355
5675
|
} // [b]ind function
|
|
5356
5676
|
|
|
5357
5677
|
|
|
@@ -5513,6 +5833,26 @@ function sc(vnodes) {
|
|
|
5513
5833
|
|
|
5514
5834
|
markAsDynamicChildren(vnodes);
|
|
5515
5835
|
return vnodes;
|
|
5836
|
+
}
|
|
5837
|
+
/**
|
|
5838
|
+
* EXPERIMENTAL: This function acts like a hook for Lightning Locker Service and other similar
|
|
5839
|
+
* libraries to sanitize HTML content. This hook process the content passed via the template to
|
|
5840
|
+
* lwc:inner-html directive.
|
|
5841
|
+
* It is meant to be overridden with setSanitizeHtmlContentHook, it throws an error by default.
|
|
5842
|
+
*/
|
|
5843
|
+
|
|
5844
|
+
|
|
5845
|
+
let sanitizeHtmlContentHook = () => {
|
|
5846
|
+
// locker-service patches this function during runtime to sanitize HTML content.
|
|
5847
|
+
throw new Error('sanitizeHtmlContent hook must be implemented.');
|
|
5848
|
+
};
|
|
5849
|
+
/**
|
|
5850
|
+
* Sets the sanitizeHtmlContentHook.
|
|
5851
|
+
*/
|
|
5852
|
+
|
|
5853
|
+
|
|
5854
|
+
function setSanitizeHtmlContentHook(newHookImpl) {
|
|
5855
|
+
sanitizeHtmlContentHook = newHookImpl;
|
|
5516
5856
|
} // [s]anitize [h]tml [c]ontent
|
|
5517
5857
|
|
|
5518
5858
|
|
|
@@ -5520,24 +5860,22 @@ function shc(content) {
|
|
|
5520
5860
|
return sanitizeHtmlContentHook(content);
|
|
5521
5861
|
}
|
|
5522
5862
|
|
|
5523
|
-
|
|
5524
|
-
|
|
5525
|
-
h
|
|
5526
|
-
|
|
5527
|
-
|
|
5528
|
-
|
|
5529
|
-
|
|
5530
|
-
|
|
5531
|
-
|
|
5532
|
-
|
|
5533
|
-
|
|
5534
|
-
|
|
5535
|
-
|
|
5536
|
-
gid
|
|
5537
|
-
fid
|
|
5538
|
-
|
|
5539
|
-
sc: sc,
|
|
5540
|
-
shc: shc
|
|
5863
|
+
const api = freeze({
|
|
5864
|
+
s,
|
|
5865
|
+
h,
|
|
5866
|
+
c,
|
|
5867
|
+
i,
|
|
5868
|
+
f,
|
|
5869
|
+
t,
|
|
5870
|
+
d,
|
|
5871
|
+
b,
|
|
5872
|
+
k,
|
|
5873
|
+
co,
|
|
5874
|
+
dc,
|
|
5875
|
+
ti,
|
|
5876
|
+
gid,
|
|
5877
|
+
fid,
|
|
5878
|
+
shc
|
|
5541
5879
|
});
|
|
5542
5880
|
/*
|
|
5543
5881
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
@@ -5551,12 +5889,12 @@ function makeHostToken(token) {
|
|
|
5551
5889
|
}
|
|
5552
5890
|
|
|
5553
5891
|
function createInlineStyleVNode(content) {
|
|
5554
|
-
return h('style', {
|
|
5892
|
+
return api.h('style', {
|
|
5555
5893
|
key: 'style',
|
|
5556
5894
|
attrs: {
|
|
5557
5895
|
type: 'text/css'
|
|
5558
5896
|
}
|
|
5559
|
-
}, [t(content)]);
|
|
5897
|
+
}, [api.t(content)]);
|
|
5560
5898
|
}
|
|
5561
5899
|
|
|
5562
5900
|
function updateStylesheetToken(vm, template) {
|
|
@@ -5624,6 +5962,7 @@ function updateStylesheetToken(vm, template) {
|
|
|
5624
5962
|
|
|
5625
5963
|
function evaluateStylesheetsContent(stylesheets, stylesheetToken, vm) {
|
|
5626
5964
|
const content = [];
|
|
5965
|
+
let root;
|
|
5627
5966
|
|
|
5628
5967
|
for (let i = 0; i < stylesheets.length; i++) {
|
|
5629
5968
|
let stylesheet = stylesheets[i];
|
|
@@ -5636,23 +5975,46 @@ function evaluateStylesheetsContent(stylesheets, stylesheetToken, vm) {
|
|
|
5636
5975
|
// the component instance might be attempting to use an old version of
|
|
5637
5976
|
// the stylesheet, while internally, we have a replacement for it.
|
|
5638
5977
|
stylesheet = getStyleOrSwappedStyle(stylesheet);
|
|
5639
|
-
}
|
|
5640
|
-
|
|
5978
|
+
}
|
|
5979
|
+
|
|
5980
|
+
const isScopedCss = stylesheet[KEY__SCOPED_CSS]; // Apply the scope token only if the stylesheet itself is scoped, or if we're rendering synthetic shadow.
|
|
5641
5981
|
|
|
5982
|
+
const scopeToken = isScopedCss || vm.shadowMode === 1
|
|
5983
|
+
/* Synthetic */
|
|
5984
|
+
&& vm.renderMode === 1
|
|
5985
|
+
/* Shadow */
|
|
5986
|
+
? stylesheetToken : undefined; // Use the actual `:host` selector if we're rendering global CSS for light DOM, or if we're rendering
|
|
5987
|
+
// native shadow DOM. Synthetic shadow DOM never uses `:host`.
|
|
5642
5988
|
|
|
5643
|
-
const isScopedCss = stylesheet[KEY__SCOPED_CSS];
|
|
5644
5989
|
const useActualHostSelector = vm.renderMode === 0
|
|
5645
5990
|
/* Light */
|
|
5646
5991
|
? !isScopedCss : vm.shadowMode === 0
|
|
5647
5992
|
/* Native */
|
|
5648
|
-
; //
|
|
5993
|
+
; // Use the native :dir() pseudoclass only in native shadow DOM. Otherwise, in synthetic shadow,
|
|
5994
|
+
// we use an attribute selector on the host to simulate :dir().
|
|
5649
5995
|
|
|
5650
|
-
|
|
5651
|
-
|
|
5652
|
-
|
|
5996
|
+
let useNativeDirPseudoclass;
|
|
5997
|
+
|
|
5998
|
+
if (vm.renderMode === 1
|
|
5653
5999
|
/* Shadow */
|
|
5654
|
-
|
|
5655
|
-
|
|
6000
|
+
) {
|
|
6001
|
+
useNativeDirPseudoclass = vm.shadowMode === 0
|
|
6002
|
+
/* Native */
|
|
6003
|
+
;
|
|
6004
|
+
} else {
|
|
6005
|
+
// Light DOM components should only render `[dir]` if they're inside of a synthetic shadow root.
|
|
6006
|
+
// At the top level (root is null) or inside of a native shadow root, they should use `:dir()`.
|
|
6007
|
+
if (isUndefined$1(root)) {
|
|
6008
|
+
// Only calculate the root once as necessary
|
|
6009
|
+
root = getNearestShadowComponent(vm);
|
|
6010
|
+
}
|
|
6011
|
+
|
|
6012
|
+
useNativeDirPseudoclass = isNull(root) || root.shadowMode === 0
|
|
6013
|
+
/* Native */
|
|
6014
|
+
;
|
|
6015
|
+
}
|
|
6016
|
+
|
|
6017
|
+
ArrayPush$1.call(content, stylesheet(scopeToken, useActualHostSelector, useNativeDirPseudoclass));
|
|
5656
6018
|
}
|
|
5657
6019
|
}
|
|
5658
6020
|
|
|
@@ -5676,14 +6038,12 @@ function getStylesheetsContent(vm, template) {
|
|
|
5676
6038
|
// https://github.com/salesforce/lwc/pull/2460#discussion_r691208892
|
|
5677
6039
|
|
|
5678
6040
|
|
|
5679
|
-
function
|
|
6041
|
+
function getNearestShadowComponent(vm) {
|
|
5680
6042
|
let owner = vm;
|
|
5681
6043
|
|
|
5682
6044
|
while (!isNull(owner)) {
|
|
5683
6045
|
if (owner.renderMode === 1
|
|
5684
6046
|
/* Shadow */
|
|
5685
|
-
&& owner.shadowMode === 0
|
|
5686
|
-
/* Native */
|
|
5687
6047
|
) {
|
|
5688
6048
|
return owner;
|
|
5689
6049
|
}
|
|
@@ -5694,6 +6054,20 @@ function getNearestNativeShadowComponent(vm) {
|
|
|
5694
6054
|
return owner;
|
|
5695
6055
|
}
|
|
5696
6056
|
|
|
6057
|
+
function getNearestNativeShadowComponent(vm) {
|
|
6058
|
+
const owner = getNearestShadowComponent(vm);
|
|
6059
|
+
|
|
6060
|
+
if (!isNull(owner) && owner.shadowMode === 1
|
|
6061
|
+
/* Synthetic */
|
|
6062
|
+
) {
|
|
6063
|
+
// Synthetic-within-native is impossible. So if the nearest shadow component is
|
|
6064
|
+
// synthetic, we know we won't find a native component if we go any further.
|
|
6065
|
+
return null;
|
|
6066
|
+
}
|
|
6067
|
+
|
|
6068
|
+
return owner;
|
|
6069
|
+
}
|
|
6070
|
+
|
|
5697
6071
|
function createStylesheet(vm, stylesheets) {
|
|
5698
6072
|
const {
|
|
5699
6073
|
renderer,
|
|
@@ -5709,7 +6083,10 @@ function createStylesheet(vm, stylesheets) {
|
|
|
5709
6083
|
for (let i = 0; i < stylesheets.length; i++) {
|
|
5710
6084
|
renderer.insertGlobalStylesheet(stylesheets[i]);
|
|
5711
6085
|
}
|
|
5712
|
-
} else if (renderer.ssr) {
|
|
6086
|
+
} else if (renderer.ssr || renderer.isHydrating()) {
|
|
6087
|
+
// Note: We need to ensure that during hydration, the stylesheets method is the same as those in ssr.
|
|
6088
|
+
// This works in the client, because the stylesheets are created, and cached in the VM
|
|
6089
|
+
// the first time the VM renders.
|
|
5713
6090
|
// native shadow or light DOM, SSR
|
|
5714
6091
|
const combinedStylesheetContent = ArrayJoin.call(stylesheets, '\n');
|
|
5715
6092
|
return createInlineStyleVNode(combinedStylesheetContent);
|
|
@@ -6334,6 +6711,12 @@ function connectRootElement(elm) {
|
|
|
6334
6711
|
, vm);
|
|
6335
6712
|
}
|
|
6336
6713
|
|
|
6714
|
+
function hydrateRootElement(elm) {
|
|
6715
|
+
const vm = getAssociatedVM(elm);
|
|
6716
|
+
runConnectedCallback(vm);
|
|
6717
|
+
hydrateVM(vm);
|
|
6718
|
+
}
|
|
6719
|
+
|
|
6337
6720
|
function disconnectRootElement(elm) {
|
|
6338
6721
|
const vm = getAssociatedVM(elm);
|
|
6339
6722
|
resetComponentStateWhenRemoved(vm);
|
|
@@ -6341,6 +6724,10 @@ function disconnectRootElement(elm) {
|
|
|
6341
6724
|
|
|
6342
6725
|
function appendVM(vm) {
|
|
6343
6726
|
rehydrate(vm);
|
|
6727
|
+
}
|
|
6728
|
+
|
|
6729
|
+
function hydrateVM(vm) {
|
|
6730
|
+
hydrate(vm);
|
|
6344
6731
|
} // just in case the component comes back, with this we guarantee re-rendering it
|
|
6345
6732
|
// while preventing any attempt to rehydration until after reinsertion.
|
|
6346
6733
|
|
|
@@ -6574,6 +6961,22 @@ function rehydrate(vm) {
|
|
|
6574
6961
|
}
|
|
6575
6962
|
}
|
|
6576
6963
|
|
|
6964
|
+
function hydrate(vm) {
|
|
6965
|
+
if (isTrue(vm.isDirty)) {
|
|
6966
|
+
// manually diffing/patching here.
|
|
6967
|
+
// This routine is:
|
|
6968
|
+
// patchShadowRoot(vm, children);
|
|
6969
|
+
// -> addVnodes.
|
|
6970
|
+
const children = renderComponent(vm);
|
|
6971
|
+
vm.children = children;
|
|
6972
|
+
const vmChildren = vm.renderMode === 0
|
|
6973
|
+
/* Light */
|
|
6974
|
+
? vm.elm.childNodes : vm.elm.shadowRoot.childNodes;
|
|
6975
|
+
hydrateChildrenHook(vmChildren, children, vm);
|
|
6976
|
+
runRenderedCallback(vm);
|
|
6977
|
+
}
|
|
6978
|
+
}
|
|
6979
|
+
|
|
6577
6980
|
function patchShadowRoot(vm, newCh) {
|
|
6578
6981
|
const {
|
|
6579
6982
|
children: oldCh
|
|
@@ -7400,28 +7803,12 @@ function readonly(obj) {
|
|
|
7400
7803
|
|
|
7401
7804
|
let hooksAreSet = false;
|
|
7402
7805
|
|
|
7403
|
-
function overrideHooks(hooks) {
|
|
7404
|
-
const oldHooks = {};
|
|
7405
|
-
|
|
7406
|
-
if (!isUndefined$1(hooks.sanitizeHtmlContent)) {
|
|
7407
|
-
oldHooks.sanitizeHtmlContent = setSanitizeHtmlContentHook(hooks.sanitizeHtmlContent);
|
|
7408
|
-
}
|
|
7409
|
-
|
|
7410
|
-
return oldHooks;
|
|
7411
|
-
}
|
|
7412
|
-
|
|
7413
7806
|
function setHooks(hooks) {
|
|
7414
7807
|
assert.isFalse(hooksAreSet, 'Hooks are already overridden, only one definition is allowed.');
|
|
7415
|
-
overrideHooks(hooks);
|
|
7416
7808
|
hooksAreSet = true;
|
|
7809
|
+
setSanitizeHtmlContentHook(hooks.sanitizeHtmlContent);
|
|
7417
7810
|
}
|
|
7418
|
-
|
|
7419
|
-
function setHooksForTest(hooks) {
|
|
7420
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
7421
|
-
return overrideHooks(hooks);
|
|
7422
|
-
}
|
|
7423
|
-
}
|
|
7424
|
-
/* version: 2.5.5-canary1 */
|
|
7811
|
+
/* version: 2.5.9 */
|
|
7425
7812
|
|
|
7426
7813
|
/*
|
|
7427
7814
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
@@ -7565,8 +7952,19 @@ if (isCustomElementRegistryAvailable()) {
|
|
|
7565
7952
|
HTMLElementConstructor.prototype = HTMLElement.prototype;
|
|
7566
7953
|
}
|
|
7567
7954
|
|
|
7955
|
+
let isHydrating = false;
|
|
7956
|
+
|
|
7957
|
+
function setIsHydrating(v) {
|
|
7958
|
+
isHydrating = v;
|
|
7959
|
+
}
|
|
7960
|
+
|
|
7568
7961
|
const renderer = {
|
|
7569
7962
|
ssr: false,
|
|
7963
|
+
|
|
7964
|
+
isHydrating() {
|
|
7965
|
+
return isHydrating;
|
|
7966
|
+
},
|
|
7967
|
+
|
|
7570
7968
|
isNativeShadowDefined: _globalThis[KEY__IS_NATIVE_SHADOW_ROOT_DEFINED],
|
|
7571
7969
|
isSyntheticShadowDefined: hasOwnProperty$1.call(Element.prototype, KEY__SHADOW_TOKEN),
|
|
7572
7970
|
|
|
@@ -7595,6 +7993,10 @@ const renderer = {
|
|
|
7595
7993
|
},
|
|
7596
7994
|
|
|
7597
7995
|
attachShadow(element, options) {
|
|
7996
|
+
if (isHydrating) {
|
|
7997
|
+
return element.shadowRoot;
|
|
7998
|
+
}
|
|
7999
|
+
|
|
7598
8000
|
return element.attachShadow(options);
|
|
7599
8001
|
},
|
|
7600
8002
|
|
|
@@ -7732,61 +8134,6 @@ const renderer = {
|
|
|
7732
8134
|
getCustomElement,
|
|
7733
8135
|
HTMLElement: HTMLElementConstructor
|
|
7734
8136
|
};
|
|
7735
|
-
/*
|
|
7736
|
-
* Copyright (c) 2018, salesforce.com, inc.
|
|
7737
|
-
* All rights reserved.
|
|
7738
|
-
* SPDX-License-Identifier: MIT
|
|
7739
|
-
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
7740
|
-
*/
|
|
7741
|
-
|
|
7742
|
-
/**
|
|
7743
|
-
* This function builds a Web Component class from a LWC constructor so it can be
|
|
7744
|
-
* registered as a new element via customElements.define() at any given time.
|
|
7745
|
-
*
|
|
7746
|
-
* @deprecated since version 1.3.11
|
|
7747
|
-
*
|
|
7748
|
-
* @example
|
|
7749
|
-
* ```
|
|
7750
|
-
* import { buildCustomElementConstructor } from 'lwc';
|
|
7751
|
-
* import Foo from 'ns/foo';
|
|
7752
|
-
* const WC = buildCustomElementConstructor(Foo);
|
|
7753
|
-
* customElements.define('x-foo', WC);
|
|
7754
|
-
* const elm = document.createElement('x-foo');
|
|
7755
|
-
* ```
|
|
7756
|
-
*/
|
|
7757
|
-
|
|
7758
|
-
function deprecatedBuildCustomElementConstructor(Ctor) {
|
|
7759
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
7760
|
-
/* eslint-disable-next-line no-console */
|
|
7761
|
-
console.warn('Deprecated function called: "buildCustomElementConstructor" function is deprecated and it will be removed.' + `Use "${Ctor.name}.CustomElementConstructor" static property of the component constructor to access the corresponding custom element constructor instead.`);
|
|
7762
|
-
}
|
|
7763
|
-
|
|
7764
|
-
return Ctor.CustomElementConstructor;
|
|
7765
|
-
}
|
|
7766
|
-
|
|
7767
|
-
function buildCustomElementConstructor(Ctor) {
|
|
7768
|
-
const def = getComponentInternalDef(Ctor);
|
|
7769
|
-
return class extends def.bridge {
|
|
7770
|
-
constructor() {
|
|
7771
|
-
super();
|
|
7772
|
-
createVM(this, def, {
|
|
7773
|
-
mode: 'open',
|
|
7774
|
-
owner: null,
|
|
7775
|
-
tagName: this.tagName,
|
|
7776
|
-
renderer
|
|
7777
|
-
});
|
|
7778
|
-
}
|
|
7779
|
-
|
|
7780
|
-
connectedCallback() {
|
|
7781
|
-
connectRootElement(this);
|
|
7782
|
-
}
|
|
7783
|
-
|
|
7784
|
-
disconnectedCallback() {
|
|
7785
|
-
disconnectRootElement(this);
|
|
7786
|
-
}
|
|
7787
|
-
|
|
7788
|
-
};
|
|
7789
|
-
}
|
|
7790
8137
|
/*
|
|
7791
8138
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
7792
8139
|
* All rights reserved.
|
|
@@ -7796,7 +8143,6 @@ function buildCustomElementConstructor(Ctor) {
|
|
|
7796
8143
|
// TODO [#2472]: Remove this workaround when appropriate.
|
|
7797
8144
|
// eslint-disable-next-line lwc-internal/no-global-node
|
|
7798
8145
|
|
|
7799
|
-
|
|
7800
8146
|
const _Node$1 = Node;
|
|
7801
8147
|
const ConnectingSlot = new WeakMap();
|
|
7802
8148
|
const DisconnectingSlot = new WeakMap();
|
|
@@ -7907,6 +8253,118 @@ function createElement(sel, options) {
|
|
|
7907
8253
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
7908
8254
|
*/
|
|
7909
8255
|
|
|
8256
|
+
|
|
8257
|
+
function hydrateComponent(element, Ctor, props = {}) {
|
|
8258
|
+
if (!isFunction$1(Ctor)) {
|
|
8259
|
+
throw new TypeError(`"hydrateComponent" expects a valid component constructor as the second parameter but instead received ${Ctor}.`);
|
|
8260
|
+
}
|
|
8261
|
+
|
|
8262
|
+
if (!isObject(props) || isNull(props)) {
|
|
8263
|
+
throw new TypeError(`"hydrateComponent" expects an object as the third parameter but instead received ${props}.`);
|
|
8264
|
+
}
|
|
8265
|
+
|
|
8266
|
+
const def = getComponentInternalDef(Ctor);
|
|
8267
|
+
|
|
8268
|
+
try {
|
|
8269
|
+
// Let the renderer know we are hydrating, so it does not replace the existing shadowRoot
|
|
8270
|
+
// and uses the same algo to create the stylesheets as in SSR.
|
|
8271
|
+
setIsHydrating(true);
|
|
8272
|
+
createVM(element, def, {
|
|
8273
|
+
mode: 'open',
|
|
8274
|
+
owner: null,
|
|
8275
|
+
renderer,
|
|
8276
|
+
tagName: element.tagName.toLowerCase()
|
|
8277
|
+
});
|
|
8278
|
+
|
|
8279
|
+
for (const [key, value] of Object.entries(props)) {
|
|
8280
|
+
element[key] = value;
|
|
8281
|
+
}
|
|
8282
|
+
|
|
8283
|
+
hydrateRootElement(element); // set it back since now we finished hydration.
|
|
8284
|
+
|
|
8285
|
+
setIsHydrating(false);
|
|
8286
|
+
} catch (e) {
|
|
8287
|
+
// Fallback: In case there's an error while hydrating, let's log the error, and replace the element with
|
|
8288
|
+
// the client generated DOM.
|
|
8289
|
+
|
|
8290
|
+
/* eslint-disable-next-line no-console */
|
|
8291
|
+
console.error('Recovering from error while hydrating: ', e);
|
|
8292
|
+
setIsHydrating(false);
|
|
8293
|
+
const newElem = createElement(element.tagName, {
|
|
8294
|
+
is: Ctor,
|
|
8295
|
+
mode: 'open'
|
|
8296
|
+
});
|
|
8297
|
+
|
|
8298
|
+
for (const [key, value] of Object.entries(props)) {
|
|
8299
|
+
newElem[key] = value;
|
|
8300
|
+
}
|
|
8301
|
+
|
|
8302
|
+
element.parentNode.replaceChild(newElem, element);
|
|
8303
|
+
}
|
|
8304
|
+
}
|
|
8305
|
+
/*
|
|
8306
|
+
* Copyright (c) 2018, salesforce.com, inc.
|
|
8307
|
+
* All rights reserved.
|
|
8308
|
+
* SPDX-License-Identifier: MIT
|
|
8309
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
8310
|
+
*/
|
|
8311
|
+
|
|
8312
|
+
/**
|
|
8313
|
+
* This function builds a Web Component class from a LWC constructor so it can be
|
|
8314
|
+
* registered as a new element via customElements.define() at any given time.
|
|
8315
|
+
*
|
|
8316
|
+
* @deprecated since version 1.3.11
|
|
8317
|
+
*
|
|
8318
|
+
* @example
|
|
8319
|
+
* ```
|
|
8320
|
+
* import { buildCustomElementConstructor } from 'lwc';
|
|
8321
|
+
* import Foo from 'ns/foo';
|
|
8322
|
+
* const WC = buildCustomElementConstructor(Foo);
|
|
8323
|
+
* customElements.define('x-foo', WC);
|
|
8324
|
+
* const elm = document.createElement('x-foo');
|
|
8325
|
+
* ```
|
|
8326
|
+
*/
|
|
8327
|
+
|
|
8328
|
+
|
|
8329
|
+
function deprecatedBuildCustomElementConstructor(Ctor) {
|
|
8330
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
8331
|
+
/* eslint-disable-next-line no-console */
|
|
8332
|
+
console.warn('Deprecated function called: "buildCustomElementConstructor" function is deprecated and it will be removed.' + `Use "${Ctor.name}.CustomElementConstructor" static property of the component constructor to access the corresponding custom element constructor instead.`);
|
|
8333
|
+
}
|
|
8334
|
+
|
|
8335
|
+
return Ctor.CustomElementConstructor;
|
|
8336
|
+
}
|
|
8337
|
+
|
|
8338
|
+
function buildCustomElementConstructor(Ctor) {
|
|
8339
|
+
const def = getComponentInternalDef(Ctor);
|
|
8340
|
+
return class extends def.bridge {
|
|
8341
|
+
constructor() {
|
|
8342
|
+
super();
|
|
8343
|
+
createVM(this, def, {
|
|
8344
|
+
mode: 'open',
|
|
8345
|
+
owner: null,
|
|
8346
|
+
tagName: this.tagName,
|
|
8347
|
+
renderer
|
|
8348
|
+
});
|
|
8349
|
+
}
|
|
8350
|
+
|
|
8351
|
+
connectedCallback() {
|
|
8352
|
+
connectRootElement(this);
|
|
8353
|
+
}
|
|
8354
|
+
|
|
8355
|
+
disconnectedCallback() {
|
|
8356
|
+
disconnectRootElement(this);
|
|
8357
|
+
}
|
|
8358
|
+
|
|
8359
|
+
};
|
|
8360
|
+
}
|
|
8361
|
+
/*
|
|
8362
|
+
* Copyright (c) 2018, salesforce.com, inc.
|
|
8363
|
+
* All rights reserved.
|
|
8364
|
+
* SPDX-License-Identifier: MIT
|
|
8365
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
8366
|
+
*/
|
|
8367
|
+
|
|
7910
8368
|
/**
|
|
7911
8369
|
* EXPERIMENTAL: This function provides access to the component constructor, given an HTMLElement.
|
|
7912
8370
|
* This API is subject to change or being removed.
|
|
@@ -8006,6 +8464,6 @@ defineProperty(LightningElement, 'CustomElementConstructor', {
|
|
|
8006
8464
|
});
|
|
8007
8465
|
freeze(LightningElement);
|
|
8008
8466
|
seal(LightningElement.prototype);
|
|
8009
|
-
/* version: 2.5.
|
|
8467
|
+
/* version: 2.5.9 */
|
|
8010
8468
|
|
|
8011
|
-
export { LightningElement, profilerControl as __unstable__ProfilerControl, api$1 as api, deprecatedBuildCustomElementConstructor as buildCustomElementConstructor, createContextProvider, createElement, getComponentConstructor, getComponentDef, isComponentConstructor, isNodeFromTemplate, readonly, register, registerComponent, registerDecorators, registerTemplate, sanitizeAttribute, setFeatureFlag, setFeatureFlagForTest, setHooks,
|
|
8469
|
+
export { LightningElement, profilerControl as __unstable__ProfilerControl, api$1 as api, deprecatedBuildCustomElementConstructor as buildCustomElementConstructor, createContextProvider, createElement, getComponentConstructor, getComponentDef, hydrateComponent, isComponentConstructor, isNodeFromTemplate, readonly, register, registerComponent, registerDecorators, registerTemplate, sanitizeAttribute, setFeatureFlag, setFeatureFlagForTest, setHooks, swapComponent, swapStyle, swapTemplate, track, unwrap, wire };
|