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
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
|
|
3
3
|
typeof define === 'function' && define.amd ? define(['exports'], factory) :
|
|
4
4
|
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.LWC = {}));
|
|
5
|
-
}(this, (function (exports) { 'use strict';
|
|
5
|
+
})(this, (function (exports) { 'use strict';
|
|
6
6
|
|
|
7
7
|
/* proxy-compat-disable */
|
|
8
8
|
|
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
find: ArrayFind,
|
|
76
76
|
indexOf: ArrayIndexOf,
|
|
77
77
|
join: ArrayJoin,
|
|
78
|
-
map: ArrayMap
|
|
78
|
+
map: ArrayMap,
|
|
79
79
|
push: ArrayPush$1,
|
|
80
80
|
reduce: ArrayReduce,
|
|
81
81
|
reverse: ArrayReverse,
|
|
@@ -142,7 +142,7 @@
|
|
|
142
142
|
// Array.prototype.toString directly will cause an error Iterate through
|
|
143
143
|
// all the items and handle individually.
|
|
144
144
|
if (isArray$1(obj)) {
|
|
145
|
-
return ArrayJoin.call(ArrayMap
|
|
145
|
+
return ArrayJoin.call(ArrayMap.call(obj, toString$1), ',');
|
|
146
146
|
}
|
|
147
147
|
|
|
148
148
|
return obj.toString();
|
|
@@ -305,7 +305,7 @@
|
|
|
305
305
|
CACHED_PROPERTY_ATTRIBUTE_MAPPING.set(propName, attributeName);
|
|
306
306
|
return attributeName;
|
|
307
307
|
}
|
|
308
|
-
/** version: 2.5.
|
|
308
|
+
/** version: 2.5.9 */
|
|
309
309
|
|
|
310
310
|
/*
|
|
311
311
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
@@ -485,7 +485,7 @@
|
|
|
485
485
|
setFeatureFlag(name, value);
|
|
486
486
|
}
|
|
487
487
|
}
|
|
488
|
-
/** version: 2.5.
|
|
488
|
+
/** version: 2.5.9 */
|
|
489
489
|
|
|
490
490
|
/* proxy-compat-disable */
|
|
491
491
|
|
|
@@ -537,6 +537,28 @@
|
|
|
537
537
|
}
|
|
538
538
|
|
|
539
539
|
return s4() + s4() + '-' + s4() + '-' + s4() + '-' + s4() + '-' + s4() + s4() + s4();
|
|
540
|
+
} // Borrowed from Vue template compiler.
|
|
541
|
+
// https://github.com/vuejs/vue/blob/531371b818b0e31a989a06df43789728f23dc4e8/src/platforms/web/util/style.js#L5-L16
|
|
542
|
+
|
|
543
|
+
|
|
544
|
+
const DECLARATION_DELIMITER = /;(?![^(]*\))/g;
|
|
545
|
+
const PROPERTY_DELIMITER = /:(.+)/;
|
|
546
|
+
|
|
547
|
+
function parseStyleText(cssText) {
|
|
548
|
+
const styleMap = {};
|
|
549
|
+
const declarations = cssText.split(DECLARATION_DELIMITER);
|
|
550
|
+
|
|
551
|
+
for (const declaration of declarations) {
|
|
552
|
+
if (declaration) {
|
|
553
|
+
const [prop, value] = declaration.split(PROPERTY_DELIMITER);
|
|
554
|
+
|
|
555
|
+
if (prop !== undefined && value !== undefined) {
|
|
556
|
+
styleMap[prop.trim()] = value.trim();
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
return styleMap;
|
|
540
562
|
}
|
|
541
563
|
/*
|
|
542
564
|
* Copyright (c) 2019, salesforce.com, inc.
|
|
@@ -718,8 +740,8 @@
|
|
|
718
740
|
*/
|
|
719
741
|
|
|
720
742
|
|
|
721
|
-
function
|
|
722
|
-
let msg = `[LWC
|
|
743
|
+
function log(method, message, vm) {
|
|
744
|
+
let msg = `[LWC ${method}]: ${message}`;
|
|
723
745
|
|
|
724
746
|
if (!isUndefined$1(vm)) {
|
|
725
747
|
msg = `${msg}\n${getComponentStack(vm)}`;
|
|
@@ -727,7 +749,7 @@
|
|
|
727
749
|
|
|
728
750
|
if (process.env.NODE_ENV === 'test') {
|
|
729
751
|
/* eslint-disable-next-line no-console */
|
|
730
|
-
console
|
|
752
|
+
console[method](msg);
|
|
731
753
|
return;
|
|
732
754
|
}
|
|
733
755
|
|
|
@@ -735,9 +757,17 @@
|
|
|
735
757
|
throw new Error(msg);
|
|
736
758
|
} catch (e) {
|
|
737
759
|
/* eslint-disable-next-line no-console */
|
|
738
|
-
console
|
|
760
|
+
console[method](e);
|
|
739
761
|
}
|
|
740
762
|
}
|
|
763
|
+
|
|
764
|
+
function logError(message, vm) {
|
|
765
|
+
log('error', message, vm);
|
|
766
|
+
}
|
|
767
|
+
|
|
768
|
+
function logWarn(message, vm) {
|
|
769
|
+
log('warn', message, vm);
|
|
770
|
+
}
|
|
741
771
|
/*
|
|
742
772
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
743
773
|
* All rights reserved.
|
|
@@ -1905,7 +1935,6 @@
|
|
|
1905
1935
|
getPrototypeOf,
|
|
1906
1936
|
create: ObjectCreate,
|
|
1907
1937
|
defineProperty: ObjectDefineProperty,
|
|
1908
|
-
defineProperties: ObjectDefineProperties,
|
|
1909
1938
|
isExtensible,
|
|
1910
1939
|
getOwnPropertyDescriptor,
|
|
1911
1940
|
getOwnPropertyNames,
|
|
@@ -1915,8 +1944,7 @@
|
|
|
1915
1944
|
} = Object;
|
|
1916
1945
|
const {
|
|
1917
1946
|
push: ArrayPush,
|
|
1918
|
-
concat: ArrayConcat
|
|
1919
|
-
map: ArrayMap
|
|
1947
|
+
concat: ArrayConcat
|
|
1920
1948
|
} = Array.prototype;
|
|
1921
1949
|
const OtS = {}.toString;
|
|
1922
1950
|
|
|
@@ -1981,7 +2009,9 @@
|
|
|
1981
2009
|
// but it will always be compatible with the previous descriptor
|
|
1982
2010
|
// to preserve the object invariants, which makes these lines safe.
|
|
1983
2011
|
|
|
1984
|
-
const originalDescriptor = getOwnPropertyDescriptor(originalTarget, key);
|
|
2012
|
+
const originalDescriptor = getOwnPropertyDescriptor(originalTarget, key); // TODO: it should be impossible for the originalDescriptor to ever be undefined, this `if` can be removed
|
|
2013
|
+
|
|
2014
|
+
/* istanbul ignore else */
|
|
1985
2015
|
|
|
1986
2016
|
if (!isUndefined(originalDescriptor)) {
|
|
1987
2017
|
const wrappedDesc = this.wrapDescriptor(originalDescriptor);
|
|
@@ -2009,11 +2039,17 @@
|
|
|
2009
2039
|
|
|
2010
2040
|
preventExtensions(shadowTarget);
|
|
2011
2041
|
} // Shared Traps
|
|
2042
|
+
// TODO: apply() is never called
|
|
2043
|
+
|
|
2044
|
+
/* istanbul ignore next */
|
|
2012
2045
|
|
|
2013
2046
|
|
|
2014
2047
|
apply(shadowTarget, thisArg, argArray) {
|
|
2015
2048
|
/* No op */
|
|
2016
|
-
}
|
|
2049
|
+
} // TODO: construct() is never called
|
|
2050
|
+
|
|
2051
|
+
/* istanbul ignore next */
|
|
2052
|
+
|
|
2017
2053
|
|
|
2018
2054
|
construct(shadowTarget, argArray, newTarget) {
|
|
2019
2055
|
/* No op */
|
|
@@ -2126,8 +2162,8 @@
|
|
|
2126
2162
|
|
|
2127
2163
|
}
|
|
2128
2164
|
|
|
2129
|
-
const getterMap = new WeakMap();
|
|
2130
|
-
const setterMap = new WeakMap();
|
|
2165
|
+
const getterMap$1 = new WeakMap();
|
|
2166
|
+
const setterMap$1 = new WeakMap();
|
|
2131
2167
|
const reverseGetterMap = new WeakMap();
|
|
2132
2168
|
const reverseSetterMap = new WeakMap();
|
|
2133
2169
|
|
|
@@ -2137,7 +2173,7 @@
|
|
|
2137
2173
|
}
|
|
2138
2174
|
|
|
2139
2175
|
wrapGetter(originalGet) {
|
|
2140
|
-
const wrappedGetter = getterMap.get(originalGet);
|
|
2176
|
+
const wrappedGetter = getterMap$1.get(originalGet);
|
|
2141
2177
|
|
|
2142
2178
|
if (!isUndefined(wrappedGetter)) {
|
|
2143
2179
|
return wrappedGetter;
|
|
@@ -2150,13 +2186,13 @@
|
|
|
2150
2186
|
return handler.wrapValue(originalGet.call(unwrap$1(this)));
|
|
2151
2187
|
};
|
|
2152
2188
|
|
|
2153
|
-
getterMap.set(originalGet, get);
|
|
2189
|
+
getterMap$1.set(originalGet, get);
|
|
2154
2190
|
reverseGetterMap.set(get, originalGet);
|
|
2155
2191
|
return get;
|
|
2156
2192
|
}
|
|
2157
2193
|
|
|
2158
2194
|
wrapSetter(originalSet) {
|
|
2159
|
-
const wrappedSetter = setterMap.get(originalSet);
|
|
2195
|
+
const wrappedSetter = setterMap$1.get(originalSet);
|
|
2160
2196
|
|
|
2161
2197
|
if (!isUndefined(wrappedSetter)) {
|
|
2162
2198
|
return wrappedSetter;
|
|
@@ -2167,7 +2203,7 @@
|
|
|
2167
2203
|
originalSet.call(unwrap$1(this), unwrap$1(v));
|
|
2168
2204
|
};
|
|
2169
2205
|
|
|
2170
|
-
setterMap.set(originalSet, set);
|
|
2206
|
+
setterMap$1.set(originalSet, set);
|
|
2171
2207
|
reverseSetterMap.set(set, originalSet);
|
|
2172
2208
|
return set;
|
|
2173
2209
|
}
|
|
@@ -2208,7 +2244,7 @@
|
|
|
2208
2244
|
return unwrap$1(redGet.call(handler.wrapValue(this)));
|
|
2209
2245
|
};
|
|
2210
2246
|
|
|
2211
|
-
getterMap.set(get, redGet);
|
|
2247
|
+
getterMap$1.set(get, redGet);
|
|
2212
2248
|
reverseGetterMap.set(redGet, get);
|
|
2213
2249
|
return get;
|
|
2214
2250
|
}
|
|
@@ -2227,7 +2263,7 @@
|
|
|
2227
2263
|
redSet.call(handler.wrapValue(this), handler.wrapValue(v));
|
|
2228
2264
|
};
|
|
2229
2265
|
|
|
2230
|
-
setterMap.set(set, redSet);
|
|
2266
|
+
setterMap$1.set(set, redSet);
|
|
2231
2267
|
reverseSetterMap.set(redSet, set);
|
|
2232
2268
|
return set;
|
|
2233
2269
|
}
|
|
@@ -2268,6 +2304,7 @@
|
|
|
2268
2304
|
}
|
|
2269
2305
|
|
|
2270
2306
|
setPrototypeOf(shadowTarget, prototype) {
|
|
2307
|
+
/* istanbul ignore else */
|
|
2271
2308
|
if (process.env.NODE_ENV !== 'production') {
|
|
2272
2309
|
throw new Error(`Invalid setPrototypeOf invocation for reactive proxy ${toString(this.originalTarget)}. Prototype of reactive objects cannot be changed.`);
|
|
2273
2310
|
}
|
|
@@ -2281,6 +2318,11 @@
|
|
|
2281
2318
|
preventExtensions(originalTarget); // if the originalTarget is a proxy itself, it might reject
|
|
2282
2319
|
// the preventExtension call, in which case we should not attempt to lock down
|
|
2283
2320
|
// the shadow target.
|
|
2321
|
+
// TODO: It should not actually be possible to reach this `if` statement.
|
|
2322
|
+
// If a proxy rejects extensions, then calling preventExtensions will throw an error:
|
|
2323
|
+
// https://codepen.io/nolanlawson-the-selector/pen/QWMOjbY
|
|
2324
|
+
|
|
2325
|
+
/* istanbul ignore if */
|
|
2284
2326
|
|
|
2285
2327
|
if (isExtensible(originalTarget)) {
|
|
2286
2328
|
return false;
|
|
@@ -2322,8 +2364,8 @@
|
|
|
2322
2364
|
|
|
2323
2365
|
}
|
|
2324
2366
|
|
|
2325
|
-
const getterMap
|
|
2326
|
-
const setterMap
|
|
2367
|
+
const getterMap = new WeakMap();
|
|
2368
|
+
const setterMap = new WeakMap();
|
|
2327
2369
|
|
|
2328
2370
|
class ReadOnlyHandler extends BaseProxyHandler {
|
|
2329
2371
|
wrapValue(value) {
|
|
@@ -2331,7 +2373,7 @@
|
|
|
2331
2373
|
}
|
|
2332
2374
|
|
|
2333
2375
|
wrapGetter(originalGet) {
|
|
2334
|
-
const wrappedGetter = getterMap
|
|
2376
|
+
const wrappedGetter = getterMap.get(originalGet);
|
|
2335
2377
|
|
|
2336
2378
|
if (!isUndefined(wrappedGetter)) {
|
|
2337
2379
|
return wrappedGetter;
|
|
@@ -2344,12 +2386,12 @@
|
|
|
2344
2386
|
return handler.wrapValue(originalGet.call(unwrap$1(this)));
|
|
2345
2387
|
};
|
|
2346
2388
|
|
|
2347
|
-
getterMap
|
|
2389
|
+
getterMap.set(originalGet, get);
|
|
2348
2390
|
return get;
|
|
2349
2391
|
}
|
|
2350
2392
|
|
|
2351
2393
|
wrapSetter(originalSet) {
|
|
2352
|
-
const wrappedSetter = setterMap
|
|
2394
|
+
const wrappedSetter = setterMap.get(originalSet);
|
|
2353
2395
|
|
|
2354
2396
|
if (!isUndefined(wrappedSetter)) {
|
|
2355
2397
|
return wrappedSetter;
|
|
@@ -2358,6 +2400,7 @@
|
|
|
2358
2400
|
const handler = this;
|
|
2359
2401
|
|
|
2360
2402
|
const set = function (v) {
|
|
2403
|
+
/* istanbul ignore else */
|
|
2361
2404
|
if (process.env.NODE_ENV !== 'production') {
|
|
2362
2405
|
const {
|
|
2363
2406
|
originalTarget
|
|
@@ -2366,33 +2409,41 @@
|
|
|
2366
2409
|
}
|
|
2367
2410
|
};
|
|
2368
2411
|
|
|
2369
|
-
setterMap
|
|
2412
|
+
setterMap.set(originalSet, set);
|
|
2370
2413
|
return set;
|
|
2371
2414
|
}
|
|
2372
2415
|
|
|
2373
2416
|
set(shadowTarget, key, value) {
|
|
2417
|
+
/* istanbul ignore else */
|
|
2374
2418
|
if (process.env.NODE_ENV !== 'production') {
|
|
2375
2419
|
const {
|
|
2376
2420
|
originalTarget
|
|
2377
2421
|
} = this;
|
|
2378
|
-
|
|
2422
|
+
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.`;
|
|
2423
|
+
throw new Error(msg);
|
|
2379
2424
|
}
|
|
2425
|
+
/* istanbul ignore next */
|
|
2426
|
+
|
|
2380
2427
|
|
|
2381
2428
|
return false;
|
|
2382
2429
|
}
|
|
2383
2430
|
|
|
2384
2431
|
deleteProperty(shadowTarget, key) {
|
|
2432
|
+
/* istanbul ignore else */
|
|
2385
2433
|
if (process.env.NODE_ENV !== 'production') {
|
|
2386
2434
|
const {
|
|
2387
2435
|
originalTarget
|
|
2388
2436
|
} = this;
|
|
2389
2437
|
throw new Error(`Invalid mutation: Cannot delete "${key.toString()}" on "${originalTarget}". "${originalTarget}" is read-only.`);
|
|
2390
2438
|
}
|
|
2439
|
+
/* istanbul ignore next */
|
|
2440
|
+
|
|
2391
2441
|
|
|
2392
2442
|
return false;
|
|
2393
2443
|
}
|
|
2394
2444
|
|
|
2395
2445
|
setPrototypeOf(shadowTarget, prototype) {
|
|
2446
|
+
/* istanbul ignore else */
|
|
2396
2447
|
if (process.env.NODE_ENV !== 'production') {
|
|
2397
2448
|
const {
|
|
2398
2449
|
originalTarget
|
|
@@ -2402,23 +2453,29 @@
|
|
|
2402
2453
|
}
|
|
2403
2454
|
|
|
2404
2455
|
preventExtensions(shadowTarget) {
|
|
2456
|
+
/* istanbul ignore else */
|
|
2405
2457
|
if (process.env.NODE_ENV !== 'production') {
|
|
2406
2458
|
const {
|
|
2407
2459
|
originalTarget
|
|
2408
2460
|
} = this;
|
|
2409
2461
|
throw new Error(`Invalid mutation: Cannot preventExtensions on ${originalTarget}". "${originalTarget} is read-only.`);
|
|
2410
2462
|
}
|
|
2463
|
+
/* istanbul ignore next */
|
|
2464
|
+
|
|
2411
2465
|
|
|
2412
2466
|
return false;
|
|
2413
2467
|
}
|
|
2414
2468
|
|
|
2415
2469
|
defineProperty(shadowTarget, key, descriptor) {
|
|
2470
|
+
/* istanbul ignore else */
|
|
2416
2471
|
if (process.env.NODE_ENV !== 'production') {
|
|
2417
2472
|
const {
|
|
2418
2473
|
originalTarget
|
|
2419
2474
|
} = this;
|
|
2420
2475
|
throw new Error(`Invalid mutation: Cannot defineProperty "${key.toString()}" on "${originalTarget}". "${originalTarget}" is read-only.`);
|
|
2421
2476
|
}
|
|
2477
|
+
/* istanbul ignore next */
|
|
2478
|
+
|
|
2422
2479
|
|
|
2423
2480
|
return false;
|
|
2424
2481
|
}
|
|
@@ -2476,6 +2533,8 @@
|
|
|
2476
2533
|
}; // Inspired from paulmillr/es6-shim
|
|
2477
2534
|
// https://github.com/paulmillr/es6-shim/blob/master/es6-shim.js#L176-L185
|
|
2478
2535
|
|
|
2536
|
+
/* istanbul ignore next */
|
|
2537
|
+
|
|
2479
2538
|
function getGlobal() {
|
|
2480
2539
|
// the only reliable means to get the global object is `Function('return this')()`
|
|
2481
2540
|
// However, this causes CSP violations in Chrome apps.
|
|
@@ -2500,6 +2559,7 @@
|
|
|
2500
2559
|
}
|
|
2501
2560
|
|
|
2502
2561
|
function init() {
|
|
2562
|
+
/* istanbul ignore if */
|
|
2503
2563
|
if (process.env.NODE_ENV === 'production') {
|
|
2504
2564
|
// this method should never leak to prod
|
|
2505
2565
|
throw new ReferenceError();
|
|
@@ -2514,6 +2574,8 @@
|
|
|
2514
2574
|
ArrayPush.call(devtoolsFormatters, formatter);
|
|
2515
2575
|
global.devtoolsFormatters = devtoolsFormatters;
|
|
2516
2576
|
}
|
|
2577
|
+
/* istanbul ignore else */
|
|
2578
|
+
|
|
2517
2579
|
|
|
2518
2580
|
if (process.env.NODE_ENV !== 'production') {
|
|
2519
2581
|
init();
|
|
@@ -2560,7 +2622,8 @@
|
|
|
2560
2622
|
this.valueMutated = defaultValueMutated;
|
|
2561
2623
|
this.valueObserved = defaultValueObserved;
|
|
2562
2624
|
this.valueIsObservable = defaultValueIsObservable;
|
|
2563
|
-
this.
|
|
2625
|
+
this.readOnlyObjectGraph = new WeakMap();
|
|
2626
|
+
this.reactiveObjectGraph = new WeakMap();
|
|
2564
2627
|
|
|
2565
2628
|
if (!isUndefined(options)) {
|
|
2566
2629
|
const {
|
|
@@ -2583,10 +2646,13 @@
|
|
|
2583
2646
|
const distorted = this.valueDistortion(unwrappedValue);
|
|
2584
2647
|
|
|
2585
2648
|
if (this.valueIsObservable(distorted)) {
|
|
2586
|
-
|
|
2587
|
-
|
|
2649
|
+
if (this.readOnlyObjectGraph.get(distorted) === value) {
|
|
2650
|
+
// when trying to extract the writable version of a readonly
|
|
2651
|
+
// we return the readonly.
|
|
2652
|
+
return value;
|
|
2653
|
+
}
|
|
2588
2654
|
|
|
2589
|
-
return
|
|
2655
|
+
return this.getReactiveHandler(unwrappedValue, distorted);
|
|
2590
2656
|
}
|
|
2591
2657
|
|
|
2592
2658
|
return distorted;
|
|
@@ -2597,7 +2663,7 @@
|
|
|
2597
2663
|
const distorted = this.valueDistortion(value);
|
|
2598
2664
|
|
|
2599
2665
|
if (this.valueIsObservable(distorted)) {
|
|
2600
|
-
return this.
|
|
2666
|
+
return this.getReadOnlyHandler(value, distorted);
|
|
2601
2667
|
}
|
|
2602
2668
|
|
|
2603
2669
|
return distorted;
|
|
@@ -2607,47 +2673,36 @@
|
|
|
2607
2673
|
return unwrap$1(p);
|
|
2608
2674
|
}
|
|
2609
2675
|
|
|
2610
|
-
|
|
2611
|
-
|
|
2612
|
-
objectGraph
|
|
2613
|
-
} = this;
|
|
2614
|
-
let reactiveState = objectGraph.get(distortedValue);
|
|
2676
|
+
getReactiveHandler(value, distortedValue) {
|
|
2677
|
+
let proxy = this.reactiveObjectGraph.get(distortedValue);
|
|
2615
2678
|
|
|
2616
|
-
if (
|
|
2617
|
-
|
|
2679
|
+
if (isUndefined(proxy)) {
|
|
2680
|
+
// caching the proxy after the first time it is accessed
|
|
2681
|
+
const handler = new ReactiveProxyHandler(this, distortedValue);
|
|
2682
|
+
proxy = new Proxy(createShadowTarget(distortedValue), handler);
|
|
2683
|
+
registerProxy(proxy, value);
|
|
2684
|
+
this.reactiveObjectGraph.set(distortedValue, proxy);
|
|
2618
2685
|
}
|
|
2619
2686
|
|
|
2620
|
-
|
|
2621
|
-
|
|
2622
|
-
get reactive() {
|
|
2623
|
-
const reactiveHandler = new ReactiveProxyHandler(membrane, distortedValue); // caching the reactive proxy after the first time it is accessed
|
|
2624
|
-
|
|
2625
|
-
const proxy = new Proxy(createShadowTarget(distortedValue), reactiveHandler);
|
|
2626
|
-
registerProxy(proxy, value);
|
|
2627
|
-
ObjectDefineProperty(this, 'reactive', {
|
|
2628
|
-
value: proxy
|
|
2629
|
-
});
|
|
2630
|
-
return proxy;
|
|
2631
|
-
},
|
|
2687
|
+
return proxy;
|
|
2688
|
+
}
|
|
2632
2689
|
|
|
2633
|
-
|
|
2634
|
-
|
|
2690
|
+
getReadOnlyHandler(value, distortedValue) {
|
|
2691
|
+
let proxy = this.readOnlyObjectGraph.get(distortedValue);
|
|
2635
2692
|
|
|
2636
|
-
|
|
2637
|
-
|
|
2638
|
-
|
|
2639
|
-
|
|
2640
|
-
|
|
2641
|
-
|
|
2642
|
-
|
|
2693
|
+
if (isUndefined(proxy)) {
|
|
2694
|
+
// caching the proxy after the first time it is accessed
|
|
2695
|
+
const handler = new ReadOnlyHandler(this, distortedValue);
|
|
2696
|
+
proxy = new Proxy(createShadowTarget(distortedValue), handler);
|
|
2697
|
+
registerProxy(proxy, value);
|
|
2698
|
+
this.readOnlyObjectGraph.set(distortedValue, proxy);
|
|
2699
|
+
}
|
|
2643
2700
|
|
|
2644
|
-
|
|
2645
|
-
objectGraph.set(distortedValue, reactiveState);
|
|
2646
|
-
return reactiveState;
|
|
2701
|
+
return proxy;
|
|
2647
2702
|
}
|
|
2648
2703
|
|
|
2649
2704
|
}
|
|
2650
|
-
/** version: 1.
|
|
2705
|
+
/** version: 1.1.5 */
|
|
2651
2706
|
|
|
2652
2707
|
/*
|
|
2653
2708
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
@@ -3101,8 +3156,10 @@
|
|
|
3101
3156
|
}
|
|
3102
3157
|
|
|
3103
3158
|
return renderer[rendererMethod](elm);
|
|
3104
|
-
}
|
|
3159
|
+
},
|
|
3105
3160
|
|
|
3161
|
+
configurable: true,
|
|
3162
|
+
enumerable: true
|
|
3106
3163
|
};
|
|
3107
3164
|
}
|
|
3108
3165
|
|
|
@@ -3122,8 +3179,11 @@
|
|
|
3122
3179
|
}
|
|
3123
3180
|
|
|
3124
3181
|
return renderer[queryMethod](elm, arg);
|
|
3125
|
-
}
|
|
3182
|
+
},
|
|
3126
3183
|
|
|
3184
|
+
configurable: true,
|
|
3185
|
+
enumerable: true,
|
|
3186
|
+
writable: true
|
|
3127
3187
|
};
|
|
3128
3188
|
}
|
|
3129
3189
|
|
|
@@ -4281,7 +4341,7 @@
|
|
|
4281
4341
|
if (!isUndefined$1(ctorShadowSupportMode)) {
|
|
4282
4342
|
assert.invariant(ctorShadowSupportMode === "any"
|
|
4283
4343
|
/* Any */
|
|
4284
|
-
|| ctorShadowSupportMode === "
|
|
4344
|
+
|| ctorShadowSupportMode === "reset"
|
|
4285
4345
|
/* Default */
|
|
4286
4346
|
, `Invalid value for static property shadowSupportMode: '${ctorShadowSupportMode}'`);
|
|
4287
4347
|
}
|
|
@@ -4443,7 +4503,7 @@
|
|
|
4443
4503
|
renderMode: 1
|
|
4444
4504
|
/* Shadow */
|
|
4445
4505
|
,
|
|
4446
|
-
shadowSupportMode: "
|
|
4506
|
+
shadowSupportMode: "reset"
|
|
4447
4507
|
/* Default */
|
|
4448
4508
|
,
|
|
4449
4509
|
wire: EmptyObject,
|
|
@@ -4592,6 +4652,17 @@
|
|
|
4592
4652
|
modComputedStyle.create(vnode);
|
|
4593
4653
|
}
|
|
4594
4654
|
|
|
4655
|
+
function hydrateElmHook(vnode) {
|
|
4656
|
+
modEvents.create(vnode); // Attrs are already on the element.
|
|
4657
|
+
// modAttrs.create(vnode);
|
|
4658
|
+
|
|
4659
|
+
modProps.create(vnode); // Already set.
|
|
4660
|
+
// modStaticClassName.create(vnode);
|
|
4661
|
+
// modStaticStyle.create(vnode);
|
|
4662
|
+
// modComputedClassName.create(vnode);
|
|
4663
|
+
// modComputedStyle.create(vnode);
|
|
4664
|
+
}
|
|
4665
|
+
|
|
4595
4666
|
function fallbackElmHook(elm, vnode) {
|
|
4596
4667
|
const {
|
|
4597
4668
|
owner
|
|
@@ -4763,6 +4834,179 @@
|
|
|
4763
4834
|
}
|
|
4764
4835
|
}
|
|
4765
4836
|
|
|
4837
|
+
function isElementNode(node) {
|
|
4838
|
+
// eslint-disable-next-line lwc-internal/no-global-node
|
|
4839
|
+
return node.nodeType === Node.ELEMENT_NODE;
|
|
4840
|
+
}
|
|
4841
|
+
|
|
4842
|
+
function vnodesAndElementHaveCompatibleAttrs(vnode, elm) {
|
|
4843
|
+
const {
|
|
4844
|
+
data: {
|
|
4845
|
+
attrs = {}
|
|
4846
|
+
},
|
|
4847
|
+
owner: {
|
|
4848
|
+
renderer
|
|
4849
|
+
}
|
|
4850
|
+
} = vnode;
|
|
4851
|
+
let nodesAreCompatible = true; // Validate attributes, though we could always recovery from those by running the update mods.
|
|
4852
|
+
// Note: intentionally ONLY matching vnodes.attrs to elm.attrs, in case SSR is adding extra attributes.
|
|
4853
|
+
|
|
4854
|
+
for (const [attrName, attrValue] of Object.entries(attrs)) {
|
|
4855
|
+
const elmAttrValue = renderer.getAttribute(elm, attrName);
|
|
4856
|
+
|
|
4857
|
+
if (String(attrValue) !== elmAttrValue) {
|
|
4858
|
+
logError(`Mismatch hydrating element <${elm.tagName.toLowerCase()}>: attribute "${attrName}" has different values, expected "${attrValue}" but found "${elmAttrValue}"`, vnode.owner);
|
|
4859
|
+
nodesAreCompatible = false;
|
|
4860
|
+
}
|
|
4861
|
+
}
|
|
4862
|
+
|
|
4863
|
+
return nodesAreCompatible;
|
|
4864
|
+
}
|
|
4865
|
+
|
|
4866
|
+
function vnodesAndElementHaveCompatibleClass(vnode, elm) {
|
|
4867
|
+
const {
|
|
4868
|
+
data: {
|
|
4869
|
+
className,
|
|
4870
|
+
classMap
|
|
4871
|
+
},
|
|
4872
|
+
owner: {
|
|
4873
|
+
renderer
|
|
4874
|
+
}
|
|
4875
|
+
} = vnode;
|
|
4876
|
+
let nodesAreCompatible = true;
|
|
4877
|
+
let vnodeClassName;
|
|
4878
|
+
|
|
4879
|
+
if (!isUndefined$1(className) && String(className) !== elm.className) {
|
|
4880
|
+
// className is used when class is bound to an expr.
|
|
4881
|
+
nodesAreCompatible = false;
|
|
4882
|
+
vnodeClassName = className;
|
|
4883
|
+
} else if (!isUndefined$1(classMap)) {
|
|
4884
|
+
// classMap is used when class is set to static value.
|
|
4885
|
+
const classList = renderer.getClassList(elm);
|
|
4886
|
+
let computedClassName = ''; // all classes from the vnode should be in the element.classList
|
|
4887
|
+
|
|
4888
|
+
for (const name in classMap) {
|
|
4889
|
+
computedClassName += ' ' + name;
|
|
4890
|
+
|
|
4891
|
+
if (!classList.contains(name)) {
|
|
4892
|
+
nodesAreCompatible = false;
|
|
4893
|
+
}
|
|
4894
|
+
}
|
|
4895
|
+
|
|
4896
|
+
vnodeClassName = computedClassName.trim();
|
|
4897
|
+
|
|
4898
|
+
if (classList.length > keys(classMap).length) {
|
|
4899
|
+
nodesAreCompatible = false;
|
|
4900
|
+
}
|
|
4901
|
+
}
|
|
4902
|
+
|
|
4903
|
+
if (!nodesAreCompatible) {
|
|
4904
|
+
logError(`Mismatch hydrating element <${elm.tagName.toLowerCase()}>: attribute "class" has different values, expected "${vnodeClassName}" but found "${elm.className}"`, vnode.owner);
|
|
4905
|
+
}
|
|
4906
|
+
|
|
4907
|
+
return nodesAreCompatible;
|
|
4908
|
+
}
|
|
4909
|
+
|
|
4910
|
+
function vnodesAndElementHaveCompatibleStyle(vnode, elm) {
|
|
4911
|
+
const {
|
|
4912
|
+
data: {
|
|
4913
|
+
style,
|
|
4914
|
+
styleDecls
|
|
4915
|
+
},
|
|
4916
|
+
owner: {
|
|
4917
|
+
renderer
|
|
4918
|
+
}
|
|
4919
|
+
} = vnode;
|
|
4920
|
+
const elmStyle = renderer.getAttribute(elm, 'style') || '';
|
|
4921
|
+
let vnodeStyle;
|
|
4922
|
+
let nodesAreCompatible = true;
|
|
4923
|
+
|
|
4924
|
+
if (!isUndefined$1(style) && style !== elmStyle) {
|
|
4925
|
+
nodesAreCompatible = false;
|
|
4926
|
+
vnodeStyle = style;
|
|
4927
|
+
} else if (!isUndefined$1(styleDecls)) {
|
|
4928
|
+
const parsedVnodeStyle = parseStyleText(elmStyle);
|
|
4929
|
+
const expectedStyle = []; // styleMap is used when style is set to static value.
|
|
4930
|
+
|
|
4931
|
+
for (let i = 0, n = styleDecls.length; i < n; i++) {
|
|
4932
|
+
const [prop, value, important] = styleDecls[i];
|
|
4933
|
+
expectedStyle.push(`${prop}: ${value + (important ? ' important!' : '')}`);
|
|
4934
|
+
const parsedPropValue = parsedVnodeStyle[prop];
|
|
4935
|
+
|
|
4936
|
+
if (isUndefined$1(parsedPropValue)) {
|
|
4937
|
+
nodesAreCompatible = false;
|
|
4938
|
+
} else if (!parsedPropValue.startsWith(value)) {
|
|
4939
|
+
nodesAreCompatible = false;
|
|
4940
|
+
} else if (important && !parsedPropValue.endsWith('!important')) {
|
|
4941
|
+
nodesAreCompatible = false;
|
|
4942
|
+
}
|
|
4943
|
+
}
|
|
4944
|
+
|
|
4945
|
+
if (keys(parsedVnodeStyle).length > styleDecls.length) {
|
|
4946
|
+
nodesAreCompatible = false;
|
|
4947
|
+
}
|
|
4948
|
+
|
|
4949
|
+
vnodeStyle = ArrayJoin.call(expectedStyle, ';');
|
|
4950
|
+
}
|
|
4951
|
+
|
|
4952
|
+
if (!nodesAreCompatible) {
|
|
4953
|
+
// style is used when class is bound to an expr.
|
|
4954
|
+
logError(`Mismatch hydrating element <${elm.tagName.toLowerCase()}>: attribute "style" has different values, expected "${vnodeStyle}" but found "${elmStyle}".`, vnode.owner);
|
|
4955
|
+
}
|
|
4956
|
+
|
|
4957
|
+
return nodesAreCompatible;
|
|
4958
|
+
}
|
|
4959
|
+
|
|
4960
|
+
function throwHydrationError() {
|
|
4961
|
+
assert.fail('Server rendered elements do not match client side generated elements');
|
|
4962
|
+
}
|
|
4963
|
+
|
|
4964
|
+
function hydrateChildrenHook(elmChildren, children, vm) {
|
|
4965
|
+
var _a, _b;
|
|
4966
|
+
|
|
4967
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
4968
|
+
const filteredVNodes = ArrayFilter.call(children, vnode => !!vnode);
|
|
4969
|
+
|
|
4970
|
+
if (elmChildren.length !== filteredVNodes.length) {
|
|
4971
|
+
logError(`Hydration mismatch: incorrect number of rendered nodes, expected ${filteredVNodes.length} but found ${elmChildren.length}.`, vm);
|
|
4972
|
+
throwHydrationError();
|
|
4973
|
+
}
|
|
4974
|
+
}
|
|
4975
|
+
|
|
4976
|
+
let elmCurrentChildIdx = 0;
|
|
4977
|
+
|
|
4978
|
+
for (let j = 0, n = children.length; j < n; j++) {
|
|
4979
|
+
const ch = children[j];
|
|
4980
|
+
|
|
4981
|
+
if (ch != null) {
|
|
4982
|
+
const childNode = elmChildren[elmCurrentChildIdx];
|
|
4983
|
+
|
|
4984
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
4985
|
+
// VComments and VTexts validation is handled in their hooks
|
|
4986
|
+
if (isElementNode(childNode)) {
|
|
4987
|
+
if (((_a = ch.sel) === null || _a === void 0 ? void 0 : _a.toLowerCase()) !== childNode.tagName.toLowerCase()) {
|
|
4988
|
+
logError(`Hydration mismatch: expecting element with tag "${(_b = ch.sel) === null || _b === void 0 ? void 0 : _b.toLowerCase()}" but found "${childNode.tagName.toLowerCase()}".`, vm);
|
|
4989
|
+
throwHydrationError();
|
|
4990
|
+
} // Note: props are not yet set
|
|
4991
|
+
|
|
4992
|
+
|
|
4993
|
+
const hasIncompatibleAttrs = vnodesAndElementHaveCompatibleAttrs(ch, childNode);
|
|
4994
|
+
const hasIncompatibleClass = vnodesAndElementHaveCompatibleClass(ch, childNode);
|
|
4995
|
+
const hasIncompatibleStyle = vnodesAndElementHaveCompatibleStyle(ch, childNode);
|
|
4996
|
+
const isVNodeAndElementCompatible = hasIncompatibleAttrs && hasIncompatibleClass && hasIncompatibleStyle;
|
|
4997
|
+
|
|
4998
|
+
if (!isVNodeAndElementCompatible) {
|
|
4999
|
+
throwHydrationError();
|
|
5000
|
+
}
|
|
5001
|
+
}
|
|
5002
|
+
}
|
|
5003
|
+
|
|
5004
|
+
ch.hook.hydrate(ch, childNode);
|
|
5005
|
+
elmCurrentChildIdx++;
|
|
5006
|
+
}
|
|
5007
|
+
}
|
|
5008
|
+
}
|
|
5009
|
+
|
|
4766
5010
|
function updateCustomElmHook(oldVnode, vnode) {
|
|
4767
5011
|
// Attrs need to be applied to element before props
|
|
4768
5012
|
// IE11 will wipe out value on radio inputs if value
|
|
@@ -4846,38 +5090,6 @@
|
|
|
4846
5090
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
4847
5091
|
*/
|
|
4848
5092
|
|
|
4849
|
-
/**
|
|
4850
|
-
* EXPERIMENTAL: This function acts like a hook for Lightning Locker Service and other similar
|
|
4851
|
-
* libraries to sanitize HTML content. This hook process the content passed via the template to
|
|
4852
|
-
* lwc:inner-html directive.
|
|
4853
|
-
* It is meant to be overridden with setSanitizeHtmlContentHook
|
|
4854
|
-
*/
|
|
4855
|
-
|
|
4856
|
-
|
|
4857
|
-
let sanitizeHtmlContentHook = () => {
|
|
4858
|
-
// locker-service patches this function during runtime to sanitize HTML content.
|
|
4859
|
-
throw new Error('sanitizeHtmlContent hook must be implemented.');
|
|
4860
|
-
};
|
|
4861
|
-
/**
|
|
4862
|
-
* Sets the sanitizeHtmlContentHook.
|
|
4863
|
-
*
|
|
4864
|
-
* @param newHookImpl
|
|
4865
|
-
* @returns oldHookImplementation.
|
|
4866
|
-
*/
|
|
4867
|
-
|
|
4868
|
-
|
|
4869
|
-
function setSanitizeHtmlContentHook(newHookImpl) {
|
|
4870
|
-
const currentHook = sanitizeHtmlContentHook;
|
|
4871
|
-
sanitizeHtmlContentHook = newHookImpl;
|
|
4872
|
-
return currentHook;
|
|
4873
|
-
}
|
|
4874
|
-
/*
|
|
4875
|
-
* Copyright (c) 2018, salesforce.com, inc.
|
|
4876
|
-
* All rights reserved.
|
|
4877
|
-
* SPDX-License-Identifier: MIT
|
|
4878
|
-
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
4879
|
-
*/
|
|
4880
|
-
|
|
4881
5093
|
|
|
4882
5094
|
const SVG_NAMESPACE = 'http://www.w3.org/2000/svg';
|
|
4883
5095
|
const SymbolIterator = Symbol.iterator;
|
|
@@ -4896,7 +5108,26 @@
|
|
|
4896
5108
|
update: updateNodeHook,
|
|
4897
5109
|
insert: insertNodeHook,
|
|
4898
5110
|
move: insertNodeHook,
|
|
4899
|
-
remove: removeNodeHook
|
|
5111
|
+
remove: removeNodeHook,
|
|
5112
|
+
hydrate: (vNode, node) => {
|
|
5113
|
+
var _a;
|
|
5114
|
+
|
|
5115
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
5116
|
+
// eslint-disable-next-line lwc-internal/no-global-node
|
|
5117
|
+
if (node.nodeType !== Node.TEXT_NODE) {
|
|
5118
|
+
logError('Hydration mismatch: incorrect node type received', vNode.owner);
|
|
5119
|
+
assert.fail('Hydration mismatch: incorrect node type received.');
|
|
5120
|
+
}
|
|
5121
|
+
|
|
5122
|
+
if (node.nodeValue !== vNode.text) {
|
|
5123
|
+
logWarn('Hydration mismatch: text values do not match, will recover from the difference', vNode.owner);
|
|
5124
|
+
}
|
|
5125
|
+
} // always set the text value to the one from the vnode.
|
|
5126
|
+
|
|
5127
|
+
|
|
5128
|
+
node.nodeValue = (_a = vNode.text) !== null && _a !== void 0 ? _a : null;
|
|
5129
|
+
vNode.elm = node;
|
|
5130
|
+
}
|
|
4900
5131
|
};
|
|
4901
5132
|
const CommentHook = {
|
|
4902
5133
|
create: vnode => {
|
|
@@ -4914,7 +5145,26 @@
|
|
|
4914
5145
|
update: updateNodeHook,
|
|
4915
5146
|
insert: insertNodeHook,
|
|
4916
5147
|
move: insertNodeHook,
|
|
4917
|
-
remove: removeNodeHook
|
|
5148
|
+
remove: removeNodeHook,
|
|
5149
|
+
hydrate: (vNode, node) => {
|
|
5150
|
+
var _a;
|
|
5151
|
+
|
|
5152
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
5153
|
+
// eslint-disable-next-line lwc-internal/no-global-node
|
|
5154
|
+
if (node.nodeType !== Node.COMMENT_NODE) {
|
|
5155
|
+
logError('Hydration mismatch: incorrect node type received', vNode.owner);
|
|
5156
|
+
assert.fail('Hydration mismatch: incorrect node type received.');
|
|
5157
|
+
}
|
|
5158
|
+
|
|
5159
|
+
if (node.nodeValue !== vNode.text) {
|
|
5160
|
+
logWarn('Hydration mismatch: comment values do not match, will recover from the difference', vNode.owner);
|
|
5161
|
+
}
|
|
5162
|
+
} // always set the text value to the one from the vnode.
|
|
5163
|
+
|
|
5164
|
+
|
|
5165
|
+
node.nodeValue = (_a = vNode.text) !== null && _a !== void 0 ? _a : null;
|
|
5166
|
+
vNode.elm = node;
|
|
5167
|
+
}
|
|
4918
5168
|
}; // insert is called after update, which is used somewhere else (via a module)
|
|
4919
5169
|
// to mark the vm as inserted, that means we cannot use update as the main channel
|
|
4920
5170
|
// to rehydrate when dirty, because sometimes the element is not inserted just yet,
|
|
@@ -4954,6 +5204,38 @@
|
|
|
4954
5204
|
remove: (vnode, parentNode) => {
|
|
4955
5205
|
removeNodeHook(vnode, parentNode);
|
|
4956
5206
|
removeElmHook(vnode);
|
|
5207
|
+
},
|
|
5208
|
+
hydrate: (vnode, node) => {
|
|
5209
|
+
const elm = node;
|
|
5210
|
+
vnode.elm = elm;
|
|
5211
|
+
const {
|
|
5212
|
+
context
|
|
5213
|
+
} = vnode.data;
|
|
5214
|
+
const isDomManual = Boolean(!isUndefined$1(context) && !isUndefined$1(context.lwc) && context.lwc.dom === "manual"
|
|
5215
|
+
/* manual */
|
|
5216
|
+
);
|
|
5217
|
+
|
|
5218
|
+
if (isDomManual) {
|
|
5219
|
+
// it may be that this element has lwc:inner-html, we need to diff and in case are the same,
|
|
5220
|
+
// remove the innerHTML from props so it reuses the existing dom elements.
|
|
5221
|
+
const {
|
|
5222
|
+
props
|
|
5223
|
+
} = vnode.data;
|
|
5224
|
+
|
|
5225
|
+
if (!isUndefined$1(props) && !isUndefined$1(props.innerHTML)) {
|
|
5226
|
+
if (elm.innerHTML === props.innerHTML) {
|
|
5227
|
+
delete props.innerHTML;
|
|
5228
|
+
} else {
|
|
5229
|
+
logWarn(`Mismatch hydrating element <${elm.tagName.toLowerCase()}>: innerHTML values do not match for element, will recover from the difference`, vnode.owner);
|
|
5230
|
+
}
|
|
5231
|
+
}
|
|
5232
|
+
}
|
|
5233
|
+
|
|
5234
|
+
hydrateElmHook(vnode);
|
|
5235
|
+
|
|
5236
|
+
if (!isDomManual) {
|
|
5237
|
+
hydrateChildrenHook(vnode.elm.childNodes, vnode.children, vnode.owner);
|
|
5238
|
+
}
|
|
4957
5239
|
}
|
|
4958
5240
|
};
|
|
4959
5241
|
const CustomElementHook = {
|
|
@@ -5045,6 +5327,44 @@
|
|
|
5045
5327
|
// will take care of disconnecting any child VM attached to its shadow as well.
|
|
5046
5328
|
removeVM(vm);
|
|
5047
5329
|
}
|
|
5330
|
+
},
|
|
5331
|
+
hydrate: (vnode, elm) => {
|
|
5332
|
+
// the element is created, but the vm is not
|
|
5333
|
+
const {
|
|
5334
|
+
sel,
|
|
5335
|
+
mode,
|
|
5336
|
+
ctor,
|
|
5337
|
+
owner
|
|
5338
|
+
} = vnode;
|
|
5339
|
+
const def = getComponentInternalDef(ctor);
|
|
5340
|
+
createVM(elm, def, {
|
|
5341
|
+
mode,
|
|
5342
|
+
owner,
|
|
5343
|
+
tagName: sel,
|
|
5344
|
+
renderer: owner.renderer
|
|
5345
|
+
});
|
|
5346
|
+
vnode.elm = elm;
|
|
5347
|
+
const vm = getAssociatedVM(elm);
|
|
5348
|
+
allocateChildrenHook(vnode, vm);
|
|
5349
|
+
hydrateElmHook(vnode); // Insert hook section:
|
|
5350
|
+
|
|
5351
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
5352
|
+
assert.isTrue(vm.state === 0
|
|
5353
|
+
/* created */
|
|
5354
|
+
, `${vm} cannot be recycled.`);
|
|
5355
|
+
}
|
|
5356
|
+
|
|
5357
|
+
runConnectedCallback(vm);
|
|
5358
|
+
|
|
5359
|
+
if (vm.renderMode !== 0
|
|
5360
|
+
/* Light */
|
|
5361
|
+
) {
|
|
5362
|
+
// VM is not rendering in Light DOM, we can proceed and hydrate the slotted content.
|
|
5363
|
+
// Note: for Light DOM, this is handled while hydrating the VM
|
|
5364
|
+
hydrateChildrenHook(vnode.elm.childNodes, vnode.children, vm);
|
|
5365
|
+
}
|
|
5366
|
+
|
|
5367
|
+
hydrateVM(vm);
|
|
5048
5368
|
}
|
|
5049
5369
|
};
|
|
5050
5370
|
|
|
@@ -5253,7 +5573,7 @@
|
|
|
5253
5573
|
next = iterator.next();
|
|
5254
5574
|
last = next.done; // template factory logic based on the previous collected value
|
|
5255
5575
|
|
|
5256
|
-
const vnode = factory(value, j, j === 0, last);
|
|
5576
|
+
const vnode = factory(value, j, j === 0, last === true);
|
|
5257
5577
|
|
|
5258
5578
|
if (isArray$1(vnode)) {
|
|
5259
5579
|
ArrayPush$1.apply(list, vnode);
|
|
@@ -5357,7 +5677,7 @@
|
|
|
5357
5677
|
|
|
5358
5678
|
|
|
5359
5679
|
function d(value) {
|
|
5360
|
-
return value == null ? '' : value;
|
|
5680
|
+
return value == null ? '' : String(value);
|
|
5361
5681
|
} // [b]ind function
|
|
5362
5682
|
|
|
5363
5683
|
|
|
@@ -5519,6 +5839,26 @@
|
|
|
5519
5839
|
|
|
5520
5840
|
markAsDynamicChildren(vnodes);
|
|
5521
5841
|
return vnodes;
|
|
5842
|
+
}
|
|
5843
|
+
/**
|
|
5844
|
+
* EXPERIMENTAL: This function acts like a hook for Lightning Locker Service and other similar
|
|
5845
|
+
* libraries to sanitize HTML content. This hook process the content passed via the template to
|
|
5846
|
+
* lwc:inner-html directive.
|
|
5847
|
+
* It is meant to be overridden with setSanitizeHtmlContentHook, it throws an error by default.
|
|
5848
|
+
*/
|
|
5849
|
+
|
|
5850
|
+
|
|
5851
|
+
let sanitizeHtmlContentHook = () => {
|
|
5852
|
+
// locker-service patches this function during runtime to sanitize HTML content.
|
|
5853
|
+
throw new Error('sanitizeHtmlContent hook must be implemented.');
|
|
5854
|
+
};
|
|
5855
|
+
/**
|
|
5856
|
+
* Sets the sanitizeHtmlContentHook.
|
|
5857
|
+
*/
|
|
5858
|
+
|
|
5859
|
+
|
|
5860
|
+
function setSanitizeHtmlContentHook(newHookImpl) {
|
|
5861
|
+
sanitizeHtmlContentHook = newHookImpl;
|
|
5522
5862
|
} // [s]anitize [h]tml [c]ontent
|
|
5523
5863
|
|
|
5524
5864
|
|
|
@@ -5526,24 +5866,22 @@
|
|
|
5526
5866
|
return sanitizeHtmlContentHook(content);
|
|
5527
5867
|
}
|
|
5528
5868
|
|
|
5529
|
-
|
|
5530
|
-
|
|
5531
|
-
h
|
|
5532
|
-
|
|
5533
|
-
|
|
5534
|
-
|
|
5535
|
-
|
|
5536
|
-
|
|
5537
|
-
|
|
5538
|
-
|
|
5539
|
-
|
|
5540
|
-
|
|
5541
|
-
|
|
5542
|
-
gid
|
|
5543
|
-
fid
|
|
5544
|
-
|
|
5545
|
-
sc: sc,
|
|
5546
|
-
shc: shc
|
|
5869
|
+
const api = freeze({
|
|
5870
|
+
s,
|
|
5871
|
+
h,
|
|
5872
|
+
c,
|
|
5873
|
+
i,
|
|
5874
|
+
f,
|
|
5875
|
+
t,
|
|
5876
|
+
d,
|
|
5877
|
+
b,
|
|
5878
|
+
k,
|
|
5879
|
+
co,
|
|
5880
|
+
dc,
|
|
5881
|
+
ti,
|
|
5882
|
+
gid,
|
|
5883
|
+
fid,
|
|
5884
|
+
shc
|
|
5547
5885
|
});
|
|
5548
5886
|
/*
|
|
5549
5887
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
@@ -5557,12 +5895,12 @@
|
|
|
5557
5895
|
}
|
|
5558
5896
|
|
|
5559
5897
|
function createInlineStyleVNode(content) {
|
|
5560
|
-
return h('style', {
|
|
5898
|
+
return api.h('style', {
|
|
5561
5899
|
key: 'style',
|
|
5562
5900
|
attrs: {
|
|
5563
5901
|
type: 'text/css'
|
|
5564
5902
|
}
|
|
5565
|
-
}, [t(content)]);
|
|
5903
|
+
}, [api.t(content)]);
|
|
5566
5904
|
}
|
|
5567
5905
|
|
|
5568
5906
|
function updateStylesheetToken(vm, template) {
|
|
@@ -5630,6 +5968,7 @@
|
|
|
5630
5968
|
|
|
5631
5969
|
function evaluateStylesheetsContent(stylesheets, stylesheetToken, vm) {
|
|
5632
5970
|
const content = [];
|
|
5971
|
+
let root;
|
|
5633
5972
|
|
|
5634
5973
|
for (let i = 0; i < stylesheets.length; i++) {
|
|
5635
5974
|
let stylesheet = stylesheets[i];
|
|
@@ -5642,23 +5981,46 @@
|
|
|
5642
5981
|
// the component instance might be attempting to use an old version of
|
|
5643
5982
|
// the stylesheet, while internally, we have a replacement for it.
|
|
5644
5983
|
stylesheet = getStyleOrSwappedStyle(stylesheet);
|
|
5645
|
-
}
|
|
5646
|
-
|
|
5984
|
+
}
|
|
5985
|
+
|
|
5986
|
+
const isScopedCss = stylesheet[KEY__SCOPED_CSS]; // Apply the scope token only if the stylesheet itself is scoped, or if we're rendering synthetic shadow.
|
|
5647
5987
|
|
|
5988
|
+
const scopeToken = isScopedCss || vm.shadowMode === 1
|
|
5989
|
+
/* Synthetic */
|
|
5990
|
+
&& vm.renderMode === 1
|
|
5991
|
+
/* Shadow */
|
|
5992
|
+
? stylesheetToken : undefined; // Use the actual `:host` selector if we're rendering global CSS for light DOM, or if we're rendering
|
|
5993
|
+
// native shadow DOM. Synthetic shadow DOM never uses `:host`.
|
|
5648
5994
|
|
|
5649
|
-
const isScopedCss = stylesheet[KEY__SCOPED_CSS];
|
|
5650
5995
|
const useActualHostSelector = vm.renderMode === 0
|
|
5651
5996
|
/* Light */
|
|
5652
5997
|
? !isScopedCss : vm.shadowMode === 0
|
|
5653
5998
|
/* Native */
|
|
5654
|
-
; //
|
|
5999
|
+
; // Use the native :dir() pseudoclass only in native shadow DOM. Otherwise, in synthetic shadow,
|
|
6000
|
+
// we use an attribute selector on the host to simulate :dir().
|
|
5655
6001
|
|
|
5656
|
-
|
|
5657
|
-
|
|
5658
|
-
|
|
6002
|
+
let useNativeDirPseudoclass;
|
|
6003
|
+
|
|
6004
|
+
if (vm.renderMode === 1
|
|
5659
6005
|
/* Shadow */
|
|
5660
|
-
|
|
5661
|
-
|
|
6006
|
+
) {
|
|
6007
|
+
useNativeDirPseudoclass = vm.shadowMode === 0
|
|
6008
|
+
/* Native */
|
|
6009
|
+
;
|
|
6010
|
+
} else {
|
|
6011
|
+
// Light DOM components should only render `[dir]` if they're inside of a synthetic shadow root.
|
|
6012
|
+
// At the top level (root is null) or inside of a native shadow root, they should use `:dir()`.
|
|
6013
|
+
if (isUndefined$1(root)) {
|
|
6014
|
+
// Only calculate the root once as necessary
|
|
6015
|
+
root = getNearestShadowComponent(vm);
|
|
6016
|
+
}
|
|
6017
|
+
|
|
6018
|
+
useNativeDirPseudoclass = isNull(root) || root.shadowMode === 0
|
|
6019
|
+
/* Native */
|
|
6020
|
+
;
|
|
6021
|
+
}
|
|
6022
|
+
|
|
6023
|
+
ArrayPush$1.call(content, stylesheet(scopeToken, useActualHostSelector, useNativeDirPseudoclass));
|
|
5662
6024
|
}
|
|
5663
6025
|
}
|
|
5664
6026
|
|
|
@@ -5682,14 +6044,12 @@
|
|
|
5682
6044
|
// https://github.com/salesforce/lwc/pull/2460#discussion_r691208892
|
|
5683
6045
|
|
|
5684
6046
|
|
|
5685
|
-
function
|
|
6047
|
+
function getNearestShadowComponent(vm) {
|
|
5686
6048
|
let owner = vm;
|
|
5687
6049
|
|
|
5688
6050
|
while (!isNull(owner)) {
|
|
5689
6051
|
if (owner.renderMode === 1
|
|
5690
6052
|
/* Shadow */
|
|
5691
|
-
&& owner.shadowMode === 0
|
|
5692
|
-
/* Native */
|
|
5693
6053
|
) {
|
|
5694
6054
|
return owner;
|
|
5695
6055
|
}
|
|
@@ -5700,6 +6060,20 @@
|
|
|
5700
6060
|
return owner;
|
|
5701
6061
|
}
|
|
5702
6062
|
|
|
6063
|
+
function getNearestNativeShadowComponent(vm) {
|
|
6064
|
+
const owner = getNearestShadowComponent(vm);
|
|
6065
|
+
|
|
6066
|
+
if (!isNull(owner) && owner.shadowMode === 1
|
|
6067
|
+
/* Synthetic */
|
|
6068
|
+
) {
|
|
6069
|
+
// Synthetic-within-native is impossible. So if the nearest shadow component is
|
|
6070
|
+
// synthetic, we know we won't find a native component if we go any further.
|
|
6071
|
+
return null;
|
|
6072
|
+
}
|
|
6073
|
+
|
|
6074
|
+
return owner;
|
|
6075
|
+
}
|
|
6076
|
+
|
|
5703
6077
|
function createStylesheet(vm, stylesheets) {
|
|
5704
6078
|
const {
|
|
5705
6079
|
renderer,
|
|
@@ -5715,7 +6089,10 @@
|
|
|
5715
6089
|
for (let i = 0; i < stylesheets.length; i++) {
|
|
5716
6090
|
renderer.insertGlobalStylesheet(stylesheets[i]);
|
|
5717
6091
|
}
|
|
5718
|
-
} else if (renderer.ssr) {
|
|
6092
|
+
} else if (renderer.ssr || renderer.isHydrating()) {
|
|
6093
|
+
// Note: We need to ensure that during hydration, the stylesheets method is the same as those in ssr.
|
|
6094
|
+
// This works in the client, because the stylesheets are created, and cached in the VM
|
|
6095
|
+
// the first time the VM renders.
|
|
5719
6096
|
// native shadow or light DOM, SSR
|
|
5720
6097
|
const combinedStylesheetContent = ArrayJoin.call(stylesheets, '\n');
|
|
5721
6098
|
return createInlineStyleVNode(combinedStylesheetContent);
|
|
@@ -6340,6 +6717,12 @@
|
|
|
6340
6717
|
, vm);
|
|
6341
6718
|
}
|
|
6342
6719
|
|
|
6720
|
+
function hydrateRootElement(elm) {
|
|
6721
|
+
const vm = getAssociatedVM(elm);
|
|
6722
|
+
runConnectedCallback(vm);
|
|
6723
|
+
hydrateVM(vm);
|
|
6724
|
+
}
|
|
6725
|
+
|
|
6343
6726
|
function disconnectRootElement(elm) {
|
|
6344
6727
|
const vm = getAssociatedVM(elm);
|
|
6345
6728
|
resetComponentStateWhenRemoved(vm);
|
|
@@ -6347,6 +6730,10 @@
|
|
|
6347
6730
|
|
|
6348
6731
|
function appendVM(vm) {
|
|
6349
6732
|
rehydrate(vm);
|
|
6733
|
+
}
|
|
6734
|
+
|
|
6735
|
+
function hydrateVM(vm) {
|
|
6736
|
+
hydrate(vm);
|
|
6350
6737
|
} // just in case the component comes back, with this we guarantee re-rendering it
|
|
6351
6738
|
// while preventing any attempt to rehydration until after reinsertion.
|
|
6352
6739
|
|
|
@@ -6580,6 +6967,22 @@
|
|
|
6580
6967
|
}
|
|
6581
6968
|
}
|
|
6582
6969
|
|
|
6970
|
+
function hydrate(vm) {
|
|
6971
|
+
if (isTrue(vm.isDirty)) {
|
|
6972
|
+
// manually diffing/patching here.
|
|
6973
|
+
// This routine is:
|
|
6974
|
+
// patchShadowRoot(vm, children);
|
|
6975
|
+
// -> addVnodes.
|
|
6976
|
+
const children = renderComponent(vm);
|
|
6977
|
+
vm.children = children;
|
|
6978
|
+
const vmChildren = vm.renderMode === 0
|
|
6979
|
+
/* Light */
|
|
6980
|
+
? vm.elm.childNodes : vm.elm.shadowRoot.childNodes;
|
|
6981
|
+
hydrateChildrenHook(vmChildren, children, vm);
|
|
6982
|
+
runRenderedCallback(vm);
|
|
6983
|
+
}
|
|
6984
|
+
}
|
|
6985
|
+
|
|
6583
6986
|
function patchShadowRoot(vm, newCh) {
|
|
6584
6987
|
const {
|
|
6585
6988
|
children: oldCh
|
|
@@ -7406,28 +7809,12 @@
|
|
|
7406
7809
|
|
|
7407
7810
|
let hooksAreSet = false;
|
|
7408
7811
|
|
|
7409
|
-
function overrideHooks(hooks) {
|
|
7410
|
-
const oldHooks = {};
|
|
7411
|
-
|
|
7412
|
-
if (!isUndefined$1(hooks.sanitizeHtmlContent)) {
|
|
7413
|
-
oldHooks.sanitizeHtmlContent = setSanitizeHtmlContentHook(hooks.sanitizeHtmlContent);
|
|
7414
|
-
}
|
|
7415
|
-
|
|
7416
|
-
return oldHooks;
|
|
7417
|
-
}
|
|
7418
|
-
|
|
7419
7812
|
function setHooks(hooks) {
|
|
7420
7813
|
assert.isFalse(hooksAreSet, 'Hooks are already overridden, only one definition is allowed.');
|
|
7421
|
-
overrideHooks(hooks);
|
|
7422
7814
|
hooksAreSet = true;
|
|
7815
|
+
setSanitizeHtmlContentHook(hooks.sanitizeHtmlContent);
|
|
7423
7816
|
}
|
|
7424
|
-
|
|
7425
|
-
function setHooksForTest(hooks) {
|
|
7426
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
7427
|
-
return overrideHooks(hooks);
|
|
7428
|
-
}
|
|
7429
|
-
}
|
|
7430
|
-
/* version: 2.5.5-canary1 */
|
|
7817
|
+
/* version: 2.5.9 */
|
|
7431
7818
|
|
|
7432
7819
|
/*
|
|
7433
7820
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
@@ -7571,8 +7958,19 @@
|
|
|
7571
7958
|
HTMLElementConstructor.prototype = HTMLElement.prototype;
|
|
7572
7959
|
}
|
|
7573
7960
|
|
|
7961
|
+
let isHydrating = false;
|
|
7962
|
+
|
|
7963
|
+
function setIsHydrating(v) {
|
|
7964
|
+
isHydrating = v;
|
|
7965
|
+
}
|
|
7966
|
+
|
|
7574
7967
|
const renderer = {
|
|
7575
7968
|
ssr: false,
|
|
7969
|
+
|
|
7970
|
+
isHydrating() {
|
|
7971
|
+
return isHydrating;
|
|
7972
|
+
},
|
|
7973
|
+
|
|
7576
7974
|
isNativeShadowDefined: _globalThis[KEY__IS_NATIVE_SHADOW_ROOT_DEFINED],
|
|
7577
7975
|
isSyntheticShadowDefined: hasOwnProperty$1.call(Element.prototype, KEY__SHADOW_TOKEN),
|
|
7578
7976
|
|
|
@@ -7601,6 +7999,10 @@
|
|
|
7601
7999
|
},
|
|
7602
8000
|
|
|
7603
8001
|
attachShadow(element, options) {
|
|
8002
|
+
if (isHydrating) {
|
|
8003
|
+
return element.shadowRoot;
|
|
8004
|
+
}
|
|
8005
|
+
|
|
7604
8006
|
return element.attachShadow(options);
|
|
7605
8007
|
},
|
|
7606
8008
|
|
|
@@ -7738,61 +8140,6 @@
|
|
|
7738
8140
|
getCustomElement,
|
|
7739
8141
|
HTMLElement: HTMLElementConstructor
|
|
7740
8142
|
};
|
|
7741
|
-
/*
|
|
7742
|
-
* Copyright (c) 2018, salesforce.com, inc.
|
|
7743
|
-
* All rights reserved.
|
|
7744
|
-
* SPDX-License-Identifier: MIT
|
|
7745
|
-
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
7746
|
-
*/
|
|
7747
|
-
|
|
7748
|
-
/**
|
|
7749
|
-
* This function builds a Web Component class from a LWC constructor so it can be
|
|
7750
|
-
* registered as a new element via customElements.define() at any given time.
|
|
7751
|
-
*
|
|
7752
|
-
* @deprecated since version 1.3.11
|
|
7753
|
-
*
|
|
7754
|
-
* @example
|
|
7755
|
-
* ```
|
|
7756
|
-
* import { buildCustomElementConstructor } from 'lwc';
|
|
7757
|
-
* import Foo from 'ns/foo';
|
|
7758
|
-
* const WC = buildCustomElementConstructor(Foo);
|
|
7759
|
-
* customElements.define('x-foo', WC);
|
|
7760
|
-
* const elm = document.createElement('x-foo');
|
|
7761
|
-
* ```
|
|
7762
|
-
*/
|
|
7763
|
-
|
|
7764
|
-
function deprecatedBuildCustomElementConstructor(Ctor) {
|
|
7765
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
7766
|
-
/* eslint-disable-next-line no-console */
|
|
7767
|
-
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.`);
|
|
7768
|
-
}
|
|
7769
|
-
|
|
7770
|
-
return Ctor.CustomElementConstructor;
|
|
7771
|
-
}
|
|
7772
|
-
|
|
7773
|
-
function buildCustomElementConstructor(Ctor) {
|
|
7774
|
-
const def = getComponentInternalDef(Ctor);
|
|
7775
|
-
return class extends def.bridge {
|
|
7776
|
-
constructor() {
|
|
7777
|
-
super();
|
|
7778
|
-
createVM(this, def, {
|
|
7779
|
-
mode: 'open',
|
|
7780
|
-
owner: null,
|
|
7781
|
-
tagName: this.tagName,
|
|
7782
|
-
renderer
|
|
7783
|
-
});
|
|
7784
|
-
}
|
|
7785
|
-
|
|
7786
|
-
connectedCallback() {
|
|
7787
|
-
connectRootElement(this);
|
|
7788
|
-
}
|
|
7789
|
-
|
|
7790
|
-
disconnectedCallback() {
|
|
7791
|
-
disconnectRootElement(this);
|
|
7792
|
-
}
|
|
7793
|
-
|
|
7794
|
-
};
|
|
7795
|
-
}
|
|
7796
8143
|
/*
|
|
7797
8144
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
7798
8145
|
* All rights reserved.
|
|
@@ -7802,7 +8149,6 @@
|
|
|
7802
8149
|
// TODO [#2472]: Remove this workaround when appropriate.
|
|
7803
8150
|
// eslint-disable-next-line lwc-internal/no-global-node
|
|
7804
8151
|
|
|
7805
|
-
|
|
7806
8152
|
const _Node$1 = Node;
|
|
7807
8153
|
const ConnectingSlot = new WeakMap();
|
|
7808
8154
|
const DisconnectingSlot = new WeakMap();
|
|
@@ -7913,6 +8259,118 @@
|
|
|
7913
8259
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
7914
8260
|
*/
|
|
7915
8261
|
|
|
8262
|
+
|
|
8263
|
+
function hydrateComponent(element, Ctor, props = {}) {
|
|
8264
|
+
if (!isFunction$1(Ctor)) {
|
|
8265
|
+
throw new TypeError(`"hydrateComponent" expects a valid component constructor as the second parameter but instead received ${Ctor}.`);
|
|
8266
|
+
}
|
|
8267
|
+
|
|
8268
|
+
if (!isObject(props) || isNull(props)) {
|
|
8269
|
+
throw new TypeError(`"hydrateComponent" expects an object as the third parameter but instead received ${props}.`);
|
|
8270
|
+
}
|
|
8271
|
+
|
|
8272
|
+
const def = getComponentInternalDef(Ctor);
|
|
8273
|
+
|
|
8274
|
+
try {
|
|
8275
|
+
// Let the renderer know we are hydrating, so it does not replace the existing shadowRoot
|
|
8276
|
+
// and uses the same algo to create the stylesheets as in SSR.
|
|
8277
|
+
setIsHydrating(true);
|
|
8278
|
+
createVM(element, def, {
|
|
8279
|
+
mode: 'open',
|
|
8280
|
+
owner: null,
|
|
8281
|
+
renderer,
|
|
8282
|
+
tagName: element.tagName.toLowerCase()
|
|
8283
|
+
});
|
|
8284
|
+
|
|
8285
|
+
for (const [key, value] of Object.entries(props)) {
|
|
8286
|
+
element[key] = value;
|
|
8287
|
+
}
|
|
8288
|
+
|
|
8289
|
+
hydrateRootElement(element); // set it back since now we finished hydration.
|
|
8290
|
+
|
|
8291
|
+
setIsHydrating(false);
|
|
8292
|
+
} catch (e) {
|
|
8293
|
+
// Fallback: In case there's an error while hydrating, let's log the error, and replace the element with
|
|
8294
|
+
// the client generated DOM.
|
|
8295
|
+
|
|
8296
|
+
/* eslint-disable-next-line no-console */
|
|
8297
|
+
console.error('Recovering from error while hydrating: ', e);
|
|
8298
|
+
setIsHydrating(false);
|
|
8299
|
+
const newElem = createElement(element.tagName, {
|
|
8300
|
+
is: Ctor,
|
|
8301
|
+
mode: 'open'
|
|
8302
|
+
});
|
|
8303
|
+
|
|
8304
|
+
for (const [key, value] of Object.entries(props)) {
|
|
8305
|
+
newElem[key] = value;
|
|
8306
|
+
}
|
|
8307
|
+
|
|
8308
|
+
element.parentNode.replaceChild(newElem, element);
|
|
8309
|
+
}
|
|
8310
|
+
}
|
|
8311
|
+
/*
|
|
8312
|
+
* Copyright (c) 2018, salesforce.com, inc.
|
|
8313
|
+
* All rights reserved.
|
|
8314
|
+
* SPDX-License-Identifier: MIT
|
|
8315
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
8316
|
+
*/
|
|
8317
|
+
|
|
8318
|
+
/**
|
|
8319
|
+
* This function builds a Web Component class from a LWC constructor so it can be
|
|
8320
|
+
* registered as a new element via customElements.define() at any given time.
|
|
8321
|
+
*
|
|
8322
|
+
* @deprecated since version 1.3.11
|
|
8323
|
+
*
|
|
8324
|
+
* @example
|
|
8325
|
+
* ```
|
|
8326
|
+
* import { buildCustomElementConstructor } from 'lwc';
|
|
8327
|
+
* import Foo from 'ns/foo';
|
|
8328
|
+
* const WC = buildCustomElementConstructor(Foo);
|
|
8329
|
+
* customElements.define('x-foo', WC);
|
|
8330
|
+
* const elm = document.createElement('x-foo');
|
|
8331
|
+
* ```
|
|
8332
|
+
*/
|
|
8333
|
+
|
|
8334
|
+
|
|
8335
|
+
function deprecatedBuildCustomElementConstructor(Ctor) {
|
|
8336
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
8337
|
+
/* eslint-disable-next-line no-console */
|
|
8338
|
+
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.`);
|
|
8339
|
+
}
|
|
8340
|
+
|
|
8341
|
+
return Ctor.CustomElementConstructor;
|
|
8342
|
+
}
|
|
8343
|
+
|
|
8344
|
+
function buildCustomElementConstructor(Ctor) {
|
|
8345
|
+
const def = getComponentInternalDef(Ctor);
|
|
8346
|
+
return class extends def.bridge {
|
|
8347
|
+
constructor() {
|
|
8348
|
+
super();
|
|
8349
|
+
createVM(this, def, {
|
|
8350
|
+
mode: 'open',
|
|
8351
|
+
owner: null,
|
|
8352
|
+
tagName: this.tagName,
|
|
8353
|
+
renderer
|
|
8354
|
+
});
|
|
8355
|
+
}
|
|
8356
|
+
|
|
8357
|
+
connectedCallback() {
|
|
8358
|
+
connectRootElement(this);
|
|
8359
|
+
}
|
|
8360
|
+
|
|
8361
|
+
disconnectedCallback() {
|
|
8362
|
+
disconnectRootElement(this);
|
|
8363
|
+
}
|
|
8364
|
+
|
|
8365
|
+
};
|
|
8366
|
+
}
|
|
8367
|
+
/*
|
|
8368
|
+
* Copyright (c) 2018, salesforce.com, inc.
|
|
8369
|
+
* All rights reserved.
|
|
8370
|
+
* SPDX-License-Identifier: MIT
|
|
8371
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
8372
|
+
*/
|
|
8373
|
+
|
|
7916
8374
|
/**
|
|
7917
8375
|
* EXPERIMENTAL: This function provides access to the component constructor, given an HTMLElement.
|
|
7918
8376
|
* This API is subject to change or being removed.
|
|
@@ -8012,7 +8470,7 @@
|
|
|
8012
8470
|
});
|
|
8013
8471
|
freeze(LightningElement);
|
|
8014
8472
|
seal(LightningElement.prototype);
|
|
8015
|
-
/* version: 2.5.
|
|
8473
|
+
/* version: 2.5.9 */
|
|
8016
8474
|
|
|
8017
8475
|
exports.LightningElement = LightningElement;
|
|
8018
8476
|
exports.__unstable__ProfilerControl = profilerControl;
|
|
@@ -8022,6 +8480,7 @@
|
|
|
8022
8480
|
exports.createElement = createElement;
|
|
8023
8481
|
exports.getComponentConstructor = getComponentConstructor;
|
|
8024
8482
|
exports.getComponentDef = getComponentDef;
|
|
8483
|
+
exports.hydrateComponent = hydrateComponent;
|
|
8025
8484
|
exports.isComponentConstructor = isComponentConstructor;
|
|
8026
8485
|
exports.isNodeFromTemplate = isNodeFromTemplate;
|
|
8027
8486
|
exports.readonly = readonly;
|
|
@@ -8033,7 +8492,6 @@
|
|
|
8033
8492
|
exports.setFeatureFlag = setFeatureFlag;
|
|
8034
8493
|
exports.setFeatureFlagForTest = setFeatureFlagForTest;
|
|
8035
8494
|
exports.setHooks = setHooks;
|
|
8036
|
-
exports.setHooksForTest = setHooksForTest;
|
|
8037
8495
|
exports.swapComponent = swapComponent;
|
|
8038
8496
|
exports.swapStyle = swapStyle;
|
|
8039
8497
|
exports.swapTemplate = swapTemplate;
|
|
@@ -8043,4 +8501,4 @@
|
|
|
8043
8501
|
|
|
8044
8502
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
8045
8503
|
|
|
8046
|
-
}))
|
|
8504
|
+
}));
|