lwc 2.29.0 → 2.30.0
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 +319 -683
- package/dist/engine-dom/iife/es2017/engine-dom.js +319 -683
- package/dist/engine-dom/iife/es2017/engine-dom.min.js +1 -1
- package/dist/engine-dom/iife/es2017/engine-dom_debug.js +201 -624
- package/dist/engine-dom/iife/es5/engine-dom.js +1138 -2843
- package/dist/engine-dom/iife/es5/engine-dom.min.js +1 -1
- package/dist/engine-dom/iife/es5/engine-dom_debug.js +892 -2428
- package/dist/engine-dom/umd/es2017/engine-dom.js +319 -683
- package/dist/engine-dom/umd/es2017/engine-dom.min.js +1 -1
- package/dist/engine-dom/umd/es2017/engine-dom_debug.js +201 -624
- package/dist/engine-dom/umd/es5/engine-dom.js +1138 -2843
- package/dist/engine-dom/umd/es5/engine-dom.min.js +1 -1
- package/dist/engine-dom/umd/es5/engine-dom_debug.js +892 -2428
- package/dist/engine-server/commonjs/es2017/engine-server.js +204 -584
- package/dist/engine-server/commonjs/es2017/engine-server.min.js +1 -1
- package/dist/engine-server/esm/es2017/engine-server.js +204 -584
- package/dist/synthetic-shadow/esm/es2017/synthetic-shadow.js +99 -323
- package/dist/synthetic-shadow/iife/es2017/synthetic-shadow.js +99 -323
- package/dist/synthetic-shadow/iife/es2017/synthetic-shadow_debug.js +98 -316
- package/dist/synthetic-shadow/iife/es5/synthetic-shadow.js +483 -1220
- package/dist/synthetic-shadow/iife/es5/synthetic-shadow_debug.js +470 -1187
- package/dist/synthetic-shadow/umd/es2017/synthetic-shadow.js +99 -323
- package/dist/synthetic-shadow/umd/es2017/synthetic-shadow_debug.js +98 -316
- package/dist/synthetic-shadow/umd/es5/synthetic-shadow.js +483 -1220
- package/dist/synthetic-shadow/umd/es5/synthetic-shadow_debug.js +470 -1187
- package/dist/wire-service/esm/es2017/wire-service.js +2 -2
- package/dist/wire-service/iife/es2017/wire-service.js +2 -2
- package/dist/wire-service/iife/es2017/wire-service.min.js +1 -1
- package/dist/wire-service/iife/es2017/wire-service_debug.js +2 -2
- package/dist/wire-service/iife/es5/wire-service.js +13 -68
- package/dist/wire-service/iife/es5/wire-service_debug.js +13 -68
- package/dist/wire-service/umd/es2017/wire-service.js +2 -2
- package/dist/wire-service/umd/es2017/wire-service.min.js +1 -1
- package/dist/wire-service/umd/es2017/wire-service_debug.js +2 -2
- package/dist/wire-service/umd/es5/wire-service.js +13 -68
- package/dist/wire-service/umd/es5/wire-service_debug.js +13 -68
- package/package.json +7 -7
|
@@ -305,9 +305,9 @@
|
|
|
305
305
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
306
306
|
*/
|
|
307
307
|
// Increment whenever the LWC template compiler changes
|
|
308
|
-
const LWC_VERSION = "2.
|
|
308
|
+
const LWC_VERSION = "2.30.0";
|
|
309
309
|
const LWC_VERSION_COMMENT_REGEX = /\/\*LWC compiler v([\d.]+)\*\/\s*}/;
|
|
310
|
-
/** version: 2.
|
|
310
|
+
/** version: 2.30.0 */
|
|
311
311
|
|
|
312
312
|
/**
|
|
313
313
|
* Copyright (C) 2018 salesforce.com, inc.
|
|
@@ -389,7 +389,7 @@
|
|
|
389
389
|
patch$1(propName);
|
|
390
390
|
}
|
|
391
391
|
}
|
|
392
|
-
/** version: 2.
|
|
392
|
+
/** version: 2.30.0 */
|
|
393
393
|
|
|
394
394
|
/**
|
|
395
395
|
* Copyright (C) 2018 salesforce.com, inc.
|
|
@@ -469,7 +469,7 @@
|
|
|
469
469
|
setFeatureFlag(name, value);
|
|
470
470
|
}
|
|
471
471
|
}
|
|
472
|
-
/** version: 2.
|
|
472
|
+
/** version: 2.30.0 */
|
|
473
473
|
|
|
474
474
|
/*
|
|
475
475
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
@@ -477,16 +477,14 @@
|
|
|
477
477
|
* SPDX-License-Identifier: MIT
|
|
478
478
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
479
479
|
*/
|
|
480
|
+
// Only used in LWC's Karma tests
|
|
480
481
|
// @ts-ignore
|
|
481
|
-
|
|
482
482
|
if (process.env.NODE_ENV !== 'production' && typeof __karma__ !== 'undefined') {
|
|
483
483
|
window.addEventListener('test-dummy-flag', () => {
|
|
484
484
|
let hasFlag = false;
|
|
485
|
-
|
|
486
485
|
if (lwcRuntimeFlags.DUMMY_TEST_FLAG) {
|
|
487
486
|
hasFlag = true;
|
|
488
487
|
}
|
|
489
|
-
|
|
490
488
|
window.dispatchEvent(new CustomEvent('has-dummy-flag', {
|
|
491
489
|
detail: {
|
|
492
490
|
package: '@lwc/engine-dom',
|
|
@@ -504,16 +502,14 @@
|
|
|
504
502
|
* SPDX-License-Identifier: MIT
|
|
505
503
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
506
504
|
*/
|
|
505
|
+
// Only used in LWC's Karma tests
|
|
507
506
|
// @ts-ignore
|
|
508
|
-
|
|
509
507
|
if (process.env.NODE_ENV !== 'production' && typeof __karma__ !== 'undefined') {
|
|
510
508
|
window.addEventListener('test-dummy-flag', () => {
|
|
511
509
|
let hasFlag = false;
|
|
512
|
-
|
|
513
510
|
if (lwcRuntimeFlags.DUMMY_TEST_FLAG) {
|
|
514
511
|
hasFlag = true;
|
|
515
512
|
}
|
|
516
|
-
|
|
517
513
|
window.dispatchEvent(new CustomEvent('has-dummy-flag', {
|
|
518
514
|
detail: {
|
|
519
515
|
package: '@lwc/engine-core',
|
|
@@ -1739,7 +1735,7 @@
|
|
|
1739
1735
|
// Gracefully degrade if not able to locate the global object
|
|
1740
1736
|
return {};
|
|
1741
1737
|
}
|
|
1742
|
-
function init() {
|
|
1738
|
+
function init$1() {
|
|
1743
1739
|
/* istanbul ignore if */
|
|
1744
1740
|
if (process.env.NODE_ENV === 'production') {
|
|
1745
1741
|
// this method should never leak to prod
|
|
@@ -1757,7 +1753,7 @@
|
|
|
1757
1753
|
|
|
1758
1754
|
/* istanbul ignore else */
|
|
1759
1755
|
if (process.env.NODE_ENV !== 'production') {
|
|
1760
|
-
init();
|
|
1756
|
+
init$1();
|
|
1761
1757
|
}
|
|
1762
1758
|
function defaultValueIsObservable(value) {
|
|
1763
1759
|
// intentionally checking for null
|
|
@@ -2347,39 +2343,31 @@
|
|
|
2347
2343
|
if (process.env.NODE_ENV !== 'production') {
|
|
2348
2344
|
assert.fail(`@api decorator can only be used as a decorator function.`);
|
|
2349
2345
|
}
|
|
2350
|
-
|
|
2351
2346
|
throw new Error();
|
|
2352
2347
|
}
|
|
2353
2348
|
function createPublicPropertyDescriptor(key) {
|
|
2354
2349
|
return {
|
|
2355
2350
|
get() {
|
|
2356
2351
|
const vm = getAssociatedVM(this);
|
|
2357
|
-
|
|
2358
2352
|
if (isBeingConstructed(vm)) {
|
|
2359
2353
|
if (process.env.NODE_ENV !== 'production') {
|
|
2360
2354
|
logError(`Can’t read the value of property \`${toString$1(key)}\` from the constructor because the owner component hasn’t set the value yet. Instead, use the constructor to set a default value for the property.`, vm);
|
|
2361
2355
|
}
|
|
2362
|
-
|
|
2363
2356
|
return;
|
|
2364
2357
|
}
|
|
2365
|
-
|
|
2366
2358
|
componentValueObserved(vm, key);
|
|
2367
2359
|
return vm.cmpProps[key];
|
|
2368
2360
|
},
|
|
2369
|
-
|
|
2370
2361
|
set(newValue) {
|
|
2371
2362
|
const vm = getAssociatedVM(this);
|
|
2372
|
-
|
|
2373
2363
|
if (process.env.NODE_ENV !== 'production') {
|
|
2374
2364
|
const vmBeingRendered = getVMBeingRendered();
|
|
2375
2365
|
assert.invariant(!isInvokingRender, `${vmBeingRendered}.render() method has side effects on the state of ${vm}.${toString$1(key)}`);
|
|
2376
2366
|
assert.invariant(!isUpdatingTemplate, `Updating the template of ${vmBeingRendered} has side effects on the state of ${vm}.${toString$1(key)}`);
|
|
2377
2367
|
}
|
|
2378
|
-
|
|
2379
2368
|
vm.cmpProps[key] = newValue;
|
|
2380
2369
|
componentValueMutated(vm, key);
|
|
2381
2370
|
},
|
|
2382
|
-
|
|
2383
2371
|
enumerable: true,
|
|
2384
2372
|
configurable: true
|
|
2385
2373
|
};
|
|
@@ -2391,46 +2379,37 @@
|
|
|
2391
2379
|
enumerable,
|
|
2392
2380
|
configurable
|
|
2393
2381
|
} = descriptor;
|
|
2394
|
-
|
|
2395
2382
|
if (!isFunction$1(get)) {
|
|
2396
2383
|
if (process.env.NODE_ENV !== 'production') {
|
|
2397
2384
|
assert.invariant(isFunction$1(get), `Invalid compiler output for public accessor ${toString$1(key)} decorated with @api`);
|
|
2398
2385
|
}
|
|
2399
|
-
|
|
2400
2386
|
throw new Error();
|
|
2401
2387
|
}
|
|
2402
|
-
|
|
2403
2388
|
return {
|
|
2404
2389
|
get() {
|
|
2405
2390
|
if (process.env.NODE_ENV !== 'production') {
|
|
2406
2391
|
// Assert that the this value is an actual Component with an associated VM.
|
|
2407
2392
|
getAssociatedVM(this);
|
|
2408
2393
|
}
|
|
2409
|
-
|
|
2410
2394
|
return get.call(this);
|
|
2411
2395
|
},
|
|
2412
|
-
|
|
2413
2396
|
set(newValue) {
|
|
2414
2397
|
const vm = getAssociatedVM(this);
|
|
2415
|
-
|
|
2416
2398
|
if (process.env.NODE_ENV !== 'production') {
|
|
2417
2399
|
const vmBeingRendered = getVMBeingRendered();
|
|
2418
2400
|
assert.invariant(!isInvokingRender, `${vmBeingRendered}.render() method has side effects on the state of ${vm}.${toString$1(key)}`);
|
|
2419
2401
|
assert.invariant(!isUpdatingTemplate, `Updating the template of ${vmBeingRendered} has side effects on the state of ${vm}.${toString$1(key)}`);
|
|
2420
2402
|
}
|
|
2421
|
-
|
|
2422
2403
|
if (set) {
|
|
2423
2404
|
if (lwcRuntimeFlags.ENABLE_REACTIVE_SETTER) {
|
|
2424
2405
|
let ro = vm.oar[key];
|
|
2425
|
-
|
|
2426
2406
|
if (isUndefined$1(ro)) {
|
|
2427
2407
|
ro = vm.oar[key] = createAccessorReactiveObserver(vm, set);
|
|
2428
|
-
}
|
|
2408
|
+
}
|
|
2409
|
+
// every time we invoke this setter from outside (through this wrapper setter)
|
|
2429
2410
|
// we should reset the value and then debounce just in case there is a pending
|
|
2430
2411
|
// invocation the next tick that is not longer relevant since the value is changing
|
|
2431
2412
|
// from outside.
|
|
2432
|
-
|
|
2433
|
-
|
|
2434
2413
|
ro.reset(newValue);
|
|
2435
2414
|
ro.observe(() => {
|
|
2436
2415
|
set.call(this, newValue);
|
|
@@ -2442,7 +2421,6 @@
|
|
|
2442
2421
|
assert.fail(`Invalid attempt to set a new value for property ${toString$1(key)} of ${vm} that does not has a setter decorated with @api.`);
|
|
2443
2422
|
}
|
|
2444
2423
|
},
|
|
2445
|
-
|
|
2446
2424
|
enumerable,
|
|
2447
2425
|
configurable
|
|
2448
2426
|
};
|
|
@@ -3407,11 +3385,9 @@
|
|
|
3407
3385
|
* SPDX-License-Identifier: MIT
|
|
3408
3386
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
3409
3387
|
*/
|
|
3410
|
-
|
|
3411
3388
|
function makeHostToken(token) {
|
|
3412
3389
|
return `${token}-host`;
|
|
3413
3390
|
}
|
|
3414
|
-
|
|
3415
3391
|
function createInlineStyleVNode(content) {
|
|
3416
3392
|
return api.h('style', {
|
|
3417
3393
|
key: 'style',
|
|
@@ -3420,7 +3396,6 @@
|
|
|
3420
3396
|
}
|
|
3421
3397
|
}, [api.t(content)]);
|
|
3422
3398
|
}
|
|
3423
|
-
|
|
3424
3399
|
function updateStylesheetToken(vm, template) {
|
|
3425
3400
|
const {
|
|
3426
3401
|
elm,
|
|
@@ -3437,112 +3412,81 @@
|
|
|
3437
3412
|
stylesheets: newStylesheets,
|
|
3438
3413
|
stylesheetToken: newStylesheetToken
|
|
3439
3414
|
} = template;
|
|
3440
|
-
const isSyntheticShadow = renderMode === 1
|
|
3441
|
-
/* RenderMode.Shadow */
|
|
3442
|
-
&& shadowMode === 1
|
|
3443
|
-
/* ShadowMode.Synthetic */
|
|
3444
|
-
;
|
|
3415
|
+
const isSyntheticShadow = renderMode === 1 /* RenderMode.Shadow */ && shadowMode === 1 /* ShadowMode.Synthetic */;
|
|
3445
3416
|
const {
|
|
3446
3417
|
hasScopedStyles
|
|
3447
3418
|
} = context;
|
|
3448
3419
|
let newToken;
|
|
3449
3420
|
let newHasTokenInClass;
|
|
3450
|
-
let newHasTokenInAttribute;
|
|
3451
|
-
|
|
3421
|
+
let newHasTokenInAttribute;
|
|
3422
|
+
// Reset the styling token applied to the host element.
|
|
3452
3423
|
const {
|
|
3453
3424
|
stylesheetToken: oldToken,
|
|
3454
3425
|
hasTokenInClass: oldHasTokenInClass,
|
|
3455
3426
|
hasTokenInAttribute: oldHasTokenInAttribute
|
|
3456
3427
|
} = context;
|
|
3457
|
-
|
|
3458
3428
|
if (!isUndefined$1(oldToken)) {
|
|
3459
3429
|
if (oldHasTokenInClass) {
|
|
3460
3430
|
getClassList(elm).remove(makeHostToken(oldToken));
|
|
3461
3431
|
}
|
|
3462
|
-
|
|
3463
3432
|
if (oldHasTokenInAttribute) {
|
|
3464
3433
|
removeAttribute(elm, makeHostToken(oldToken));
|
|
3465
3434
|
}
|
|
3466
|
-
}
|
|
3435
|
+
}
|
|
3436
|
+
// Apply the new template styling token to the host element, if the new template has any
|
|
3467
3437
|
// associated stylesheets. In the case of light DOM, also ensure there is at least one scoped stylesheet.
|
|
3468
|
-
|
|
3469
|
-
|
|
3470
3438
|
if (!isUndefined$1(newStylesheets) && newStylesheets.length !== 0) {
|
|
3471
3439
|
newToken = newStylesheetToken;
|
|
3472
|
-
}
|
|
3473
|
-
|
|
3474
|
-
|
|
3440
|
+
}
|
|
3441
|
+
// Set the new styling token on the host element
|
|
3475
3442
|
if (!isUndefined$1(newToken)) {
|
|
3476
3443
|
if (hasScopedStyles) {
|
|
3477
3444
|
getClassList(elm).add(makeHostToken(newToken));
|
|
3478
3445
|
newHasTokenInClass = true;
|
|
3479
3446
|
}
|
|
3480
|
-
|
|
3481
3447
|
if (isSyntheticShadow) {
|
|
3482
3448
|
setAttribute(elm, makeHostToken(newToken), '');
|
|
3483
3449
|
newHasTokenInAttribute = true;
|
|
3484
3450
|
}
|
|
3485
|
-
}
|
|
3486
|
-
|
|
3487
|
-
|
|
3451
|
+
}
|
|
3452
|
+
// Update the styling tokens present on the context object.
|
|
3488
3453
|
context.stylesheetToken = newToken;
|
|
3489
3454
|
context.hasTokenInClass = newHasTokenInClass;
|
|
3490
3455
|
context.hasTokenInAttribute = newHasTokenInAttribute;
|
|
3491
3456
|
}
|
|
3492
|
-
|
|
3493
3457
|
function evaluateStylesheetsContent(stylesheets, stylesheetToken, vm) {
|
|
3494
3458
|
const content = [];
|
|
3495
3459
|
let root;
|
|
3496
|
-
|
|
3497
3460
|
for (let i = 0; i < stylesheets.length; i++) {
|
|
3498
3461
|
let stylesheet = stylesheets[i];
|
|
3499
|
-
|
|
3500
3462
|
if (isArray$1(stylesheet)) {
|
|
3501
3463
|
ArrayPush$1.apply(content, evaluateStylesheetsContent(stylesheet, stylesheetToken, vm));
|
|
3502
3464
|
} else {
|
|
3503
3465
|
if (process.env.NODE_ENV !== 'production') {
|
|
3504
3466
|
// Check for compiler version mismatch in dev mode only
|
|
3505
|
-
checkVersionMismatch(stylesheet, 'stylesheet');
|
|
3467
|
+
checkVersionMismatch(stylesheet, 'stylesheet');
|
|
3468
|
+
// in dev-mode, we support hot swapping of stylesheet, which means that
|
|
3506
3469
|
// the component instance might be attempting to use an old version of
|
|
3507
3470
|
// the stylesheet, while internally, we have a replacement for it.
|
|
3508
|
-
|
|
3509
3471
|
stylesheet = getStyleOrSwappedStyle(stylesheet);
|
|
3510
3472
|
}
|
|
3511
|
-
|
|
3512
3473
|
const isScopedCss = stylesheet[KEY__SCOPED_CSS];
|
|
3513
|
-
|
|
3514
3474
|
if (lwcRuntimeFlags.DISABLE_LIGHT_DOM_UNSCOPED_CSS) {
|
|
3515
|
-
if (!isScopedCss && vm.renderMode === 0
|
|
3516
|
-
/* RenderMode.Light */
|
|
3517
|
-
) {
|
|
3475
|
+
if (!isScopedCss && vm.renderMode === 0 /* RenderMode.Light */) {
|
|
3518
3476
|
logError('Unscoped CSS is not supported in Light DOM. Please use scoped CSS (*.scoped.css) instead of unscoped CSS (*.css).');
|
|
3519
3477
|
continue;
|
|
3520
3478
|
}
|
|
3521
|
-
}
|
|
3522
|
-
|
|
3523
|
-
|
|
3524
|
-
|
|
3525
|
-
/* ShadowMode.Synthetic */
|
|
3526
|
-
&& vm.renderMode === 1
|
|
3527
|
-
/* RenderMode.Shadow */
|
|
3528
|
-
? stylesheetToken : undefined; // Use the actual `:host` selector if we're rendering global CSS for light DOM, or if we're rendering
|
|
3479
|
+
}
|
|
3480
|
+
// Apply the scope token only if the stylesheet itself is scoped, or if we're rendering synthetic shadow.
|
|
3481
|
+
const scopeToken = isScopedCss || vm.shadowMode === 1 /* ShadowMode.Synthetic */ && vm.renderMode === 1 /* RenderMode.Shadow */ ? stylesheetToken : undefined;
|
|
3482
|
+
// Use the actual `:host` selector if we're rendering global CSS for light DOM, or if we're rendering
|
|
3529
3483
|
// native shadow DOM. Synthetic shadow DOM never uses `:host`.
|
|
3530
|
-
|
|
3531
|
-
|
|
3532
|
-
/* RenderMode.Light */
|
|
3533
|
-
? !isScopedCss : vm.shadowMode === 0
|
|
3534
|
-
/* ShadowMode.Native */
|
|
3535
|
-
; // Use the native :dir() pseudoclass only in native shadow DOM. Otherwise, in synthetic shadow,
|
|
3484
|
+
const useActualHostSelector = vm.renderMode === 0 /* RenderMode.Light */ ? !isScopedCss : vm.shadowMode === 0 /* ShadowMode.Native */;
|
|
3485
|
+
// Use the native :dir() pseudoclass only in native shadow DOM. Otherwise, in synthetic shadow,
|
|
3536
3486
|
// we use an attribute selector on the host to simulate :dir().
|
|
3537
|
-
|
|
3538
3487
|
let useNativeDirPseudoclass;
|
|
3539
|
-
|
|
3540
|
-
|
|
3541
|
-
/* RenderMode.Shadow */
|
|
3542
|
-
) {
|
|
3543
|
-
useNativeDirPseudoclass = vm.shadowMode === 0
|
|
3544
|
-
/* ShadowMode.Native */
|
|
3545
|
-
;
|
|
3488
|
+
if (vm.renderMode === 1 /* RenderMode.Shadow */) {
|
|
3489
|
+
useNativeDirPseudoclass = vm.shadowMode === 0 /* ShadowMode.Native */;
|
|
3546
3490
|
} else {
|
|
3547
3491
|
// Light DOM components should only render `[dir]` if they're inside of a synthetic shadow root.
|
|
3548
3492
|
// At the top level (root is null) or inside of a native shadow root, they should use `:dir()`.
|
|
@@ -3550,48 +3494,36 @@
|
|
|
3550
3494
|
// Only calculate the root once as necessary
|
|
3551
3495
|
root = getNearestShadowComponent(vm);
|
|
3552
3496
|
}
|
|
3553
|
-
|
|
3554
|
-
useNativeDirPseudoclass = isNull(root) || root.shadowMode === 0
|
|
3555
|
-
/* ShadowMode.Native */
|
|
3556
|
-
;
|
|
3497
|
+
useNativeDirPseudoclass = isNull(root) || root.shadowMode === 0 /* ShadowMode.Native */;
|
|
3557
3498
|
}
|
|
3558
3499
|
|
|
3559
3500
|
ArrayPush$1.call(content, stylesheet(scopeToken, useActualHostSelector, useNativeDirPseudoclass));
|
|
3560
3501
|
}
|
|
3561
3502
|
}
|
|
3562
|
-
|
|
3563
3503
|
return content;
|
|
3564
3504
|
}
|
|
3565
|
-
|
|
3566
3505
|
function getStylesheetsContent(vm, template) {
|
|
3567
3506
|
const {
|
|
3568
3507
|
stylesheets,
|
|
3569
3508
|
stylesheetToken
|
|
3570
3509
|
} = template;
|
|
3571
3510
|
let content = [];
|
|
3572
|
-
|
|
3573
3511
|
if (!isUndefined$1(stylesheets) && stylesheets.length !== 0) {
|
|
3574
3512
|
content = evaluateStylesheetsContent(stylesheets, stylesheetToken, vm);
|
|
3575
3513
|
}
|
|
3576
|
-
|
|
3577
3514
|
return content;
|
|
3578
|
-
}
|
|
3515
|
+
}
|
|
3516
|
+
// It might be worth caching this to avoid doing the lookup repeatedly, but
|
|
3579
3517
|
// perf testing has not shown it to be a huge improvement yet:
|
|
3580
3518
|
// https://github.com/salesforce/lwc/pull/2460#discussion_r691208892
|
|
3581
|
-
|
|
3582
3519
|
function getNearestShadowComponent(vm) {
|
|
3583
3520
|
let owner = vm;
|
|
3584
|
-
|
|
3585
3521
|
while (!isNull(owner)) {
|
|
3586
|
-
if (owner.renderMode === 1
|
|
3587
|
-
/* RenderMode.Shadow */
|
|
3588
|
-
) {
|
|
3522
|
+
if (owner.renderMode === 1 /* RenderMode.Shadow */) {
|
|
3589
3523
|
return owner;
|
|
3590
3524
|
}
|
|
3591
|
-
|
|
3592
3525
|
owner = owner.owner;
|
|
3593
3526
|
}
|
|
3594
|
-
|
|
3595
3527
|
return owner;
|
|
3596
3528
|
}
|
|
3597
3529
|
/**
|
|
@@ -3599,8 +3531,6 @@
|
|
|
3599
3531
|
* this returns the unique token for that scoped stylesheet. Otherwise
|
|
3600
3532
|
* it returns null.
|
|
3601
3533
|
*/
|
|
3602
|
-
|
|
3603
|
-
|
|
3604
3534
|
function getScopeTokenClass(owner) {
|
|
3605
3535
|
const {
|
|
3606
3536
|
cmpTemplate,
|
|
@@ -3614,7 +3544,6 @@
|
|
|
3614
3544
|
*
|
|
3615
3545
|
* A host style token is applied to the component if scoped styles are used.
|
|
3616
3546
|
*/
|
|
3617
|
-
|
|
3618
3547
|
function getStylesheetTokenHost(vnode) {
|
|
3619
3548
|
const {
|
|
3620
3549
|
template
|
|
@@ -3624,21 +3553,15 @@
|
|
|
3624
3553
|
} = template;
|
|
3625
3554
|
return !isUndefined$1(stylesheetToken) && computeHasScopedStyles(template) ? makeHostToken(stylesheetToken) : null;
|
|
3626
3555
|
}
|
|
3627
|
-
|
|
3628
3556
|
function getNearestNativeShadowComponent(vm) {
|
|
3629
3557
|
const owner = getNearestShadowComponent(vm);
|
|
3630
|
-
|
|
3631
|
-
if (!isNull(owner) && owner.shadowMode === 1
|
|
3632
|
-
/* ShadowMode.Synthetic */
|
|
3633
|
-
) {
|
|
3558
|
+
if (!isNull(owner) && owner.shadowMode === 1 /* ShadowMode.Synthetic */) {
|
|
3634
3559
|
// Synthetic-within-native is impossible. So if the nearest shadow component is
|
|
3635
3560
|
// synthetic, we know we won't find a native component if we go any further.
|
|
3636
3561
|
return null;
|
|
3637
3562
|
}
|
|
3638
|
-
|
|
3639
3563
|
return owner;
|
|
3640
3564
|
}
|
|
3641
|
-
|
|
3642
3565
|
function createStylesheet(vm, stylesheets) {
|
|
3643
3566
|
const {
|
|
3644
3567
|
renderMode,
|
|
@@ -3647,12 +3570,7 @@
|
|
|
3647
3570
|
insertStylesheet
|
|
3648
3571
|
}
|
|
3649
3572
|
} = vm;
|
|
3650
|
-
|
|
3651
|
-
if (renderMode === 1
|
|
3652
|
-
/* RenderMode.Shadow */
|
|
3653
|
-
&& shadowMode === 1
|
|
3654
|
-
/* ShadowMode.Synthetic */
|
|
3655
|
-
) {
|
|
3573
|
+
if (renderMode === 1 /* RenderMode.Shadow */ && shadowMode === 1 /* ShadowMode.Synthetic */) {
|
|
3656
3574
|
for (let i = 0; i < stylesheets.length; i++) {
|
|
3657
3575
|
insertStylesheet(stylesheets[i]);
|
|
3658
3576
|
}
|
|
@@ -3664,15 +3582,13 @@
|
|
|
3664
3582
|
return ArrayMap.call(stylesheets, createInlineStyleVNode);
|
|
3665
3583
|
} else {
|
|
3666
3584
|
// native shadow or light DOM, DOM renderer
|
|
3667
|
-
const root = getNearestNativeShadowComponent(vm);
|
|
3668
|
-
|
|
3585
|
+
const root = getNearestNativeShadowComponent(vm);
|
|
3586
|
+
// null root means a global style
|
|
3669
3587
|
const target = isNull(root) ? undefined : root.shadowRoot;
|
|
3670
|
-
|
|
3671
3588
|
for (let i = 0; i < stylesheets.length; i++) {
|
|
3672
3589
|
insertStylesheet(stylesheets[i], target);
|
|
3673
3590
|
}
|
|
3674
3591
|
}
|
|
3675
|
-
|
|
3676
3592
|
return null;
|
|
3677
3593
|
}
|
|
3678
3594
|
|
|
@@ -3958,14 +3874,11 @@
|
|
|
3958
3874
|
updateStaticChildren(c1, c2, parent, renderer);
|
|
3959
3875
|
}
|
|
3960
3876
|
}
|
|
3961
|
-
|
|
3962
3877
|
function patch(n1, n2, parent, renderer) {
|
|
3963
3878
|
var _a, _b;
|
|
3964
|
-
|
|
3965
3879
|
if (n1 === n2) {
|
|
3966
3880
|
return;
|
|
3967
3881
|
}
|
|
3968
|
-
|
|
3969
3882
|
if (process.env.NODE_ENV !== 'production') {
|
|
3970
3883
|
if (!isSameVnode(n1, n2)) {
|
|
3971
3884
|
throw new Error('Expected these VNodes to be the same: ' + JSON.stringify({
|
|
@@ -3977,103 +3890,63 @@
|
|
|
3977
3890
|
}));
|
|
3978
3891
|
}
|
|
3979
3892
|
}
|
|
3980
|
-
|
|
3981
3893
|
switch (n2.type) {
|
|
3982
|
-
case 0
|
|
3983
|
-
/* VNodeType.Text */
|
|
3984
|
-
:
|
|
3894
|
+
case 0 /* VNodeType.Text */:
|
|
3985
3895
|
// VText has no special capability, fallback to the owner's renderer
|
|
3986
3896
|
patchText(n1, n2, renderer);
|
|
3987
3897
|
break;
|
|
3988
|
-
|
|
3989
|
-
case 1
|
|
3990
|
-
/* VNodeType.Comment */
|
|
3991
|
-
:
|
|
3898
|
+
case 1 /* VNodeType.Comment */:
|
|
3992
3899
|
// VComment has no special capability, fallback to the owner's renderer
|
|
3993
3900
|
patchComment(n1, n2, renderer);
|
|
3994
3901
|
break;
|
|
3995
|
-
|
|
3996
|
-
case 4
|
|
3997
|
-
/* VNodeType.Static */
|
|
3998
|
-
:
|
|
3902
|
+
case 4 /* VNodeType.Static */:
|
|
3999
3903
|
n2.elm = n1.elm;
|
|
4000
3904
|
break;
|
|
4001
|
-
|
|
4002
|
-
case 5
|
|
4003
|
-
/* VNodeType.Fragment */
|
|
4004
|
-
:
|
|
3905
|
+
case 5 /* VNodeType.Fragment */:
|
|
4005
3906
|
patchFragment(n1, n2, parent, renderer);
|
|
4006
3907
|
break;
|
|
4007
|
-
|
|
4008
|
-
case 2
|
|
4009
|
-
/* VNodeType.Element */
|
|
4010
|
-
:
|
|
3908
|
+
case 2 /* VNodeType.Element */:
|
|
4011
3909
|
patchElement(n1, n2, (_a = n2.data.renderer) !== null && _a !== void 0 ? _a : renderer);
|
|
4012
3910
|
break;
|
|
4013
|
-
|
|
4014
|
-
case 3
|
|
4015
|
-
/* VNodeType.CustomElement */
|
|
4016
|
-
:
|
|
3911
|
+
case 3 /* VNodeType.CustomElement */:
|
|
4017
3912
|
patchCustomElement(n1, n2, parent, (_b = n2.data.renderer) !== null && _b !== void 0 ? _b : renderer);
|
|
4018
3913
|
break;
|
|
4019
3914
|
}
|
|
4020
3915
|
}
|
|
4021
|
-
|
|
4022
3916
|
function mount(node, parent, renderer, anchor) {
|
|
4023
3917
|
var _a, _b;
|
|
4024
|
-
|
|
4025
3918
|
switch (node.type) {
|
|
4026
|
-
case 0
|
|
4027
|
-
/* VNodeType.Text */
|
|
4028
|
-
:
|
|
3919
|
+
case 0 /* VNodeType.Text */:
|
|
4029
3920
|
// VText has no special capability, fallback to the owner's renderer
|
|
4030
3921
|
mountText(node, parent, anchor, renderer);
|
|
4031
3922
|
break;
|
|
4032
|
-
|
|
4033
|
-
case 1
|
|
4034
|
-
/* VNodeType.Comment */
|
|
4035
|
-
:
|
|
3923
|
+
case 1 /* VNodeType.Comment */:
|
|
4036
3924
|
// VComment has no special capability, fallback to the owner's renderer
|
|
4037
3925
|
mountComment(node, parent, anchor, renderer);
|
|
4038
3926
|
break;
|
|
4039
|
-
|
|
4040
|
-
case 4
|
|
4041
|
-
/* VNodeType.Static */
|
|
4042
|
-
:
|
|
3927
|
+
case 4 /* VNodeType.Static */:
|
|
4043
3928
|
// VStatic cannot have a custom renderer associated to them, using owner's renderer
|
|
4044
3929
|
mountStatic(node, parent, anchor, renderer);
|
|
4045
3930
|
break;
|
|
4046
|
-
|
|
4047
|
-
case 5
|
|
4048
|
-
/* VNodeType.Fragment */
|
|
4049
|
-
:
|
|
3931
|
+
case 5 /* VNodeType.Fragment */:
|
|
4050
3932
|
mountFragment(node, parent, anchor, renderer);
|
|
4051
3933
|
break;
|
|
4052
|
-
|
|
4053
|
-
case 2
|
|
4054
|
-
/* VNodeType.Element */
|
|
4055
|
-
:
|
|
3934
|
+
case 2 /* VNodeType.Element */:
|
|
4056
3935
|
// If the vnode data has a renderer override use it, else fallback to owner's renderer
|
|
4057
3936
|
mountElement(node, parent, anchor, (_a = node.data.renderer) !== null && _a !== void 0 ? _a : renderer);
|
|
4058
3937
|
break;
|
|
4059
|
-
|
|
4060
|
-
case 3
|
|
4061
|
-
/* VNodeType.CustomElement */
|
|
4062
|
-
:
|
|
3938
|
+
case 3 /* VNodeType.CustomElement */:
|
|
4063
3939
|
// If the vnode data has a renderer override use it, else fallback to owner's renderer
|
|
4064
3940
|
mountCustomElement(node, parent, anchor, (_b = node.data.renderer) !== null && _b !== void 0 ? _b : renderer);
|
|
4065
3941
|
break;
|
|
4066
3942
|
}
|
|
4067
3943
|
}
|
|
4068
|
-
|
|
4069
3944
|
function patchText(n1, n2, renderer) {
|
|
4070
3945
|
n2.elm = n1.elm;
|
|
4071
|
-
|
|
4072
3946
|
if (n2.text !== n1.text) {
|
|
4073
3947
|
updateTextContent(n2, renderer);
|
|
4074
3948
|
}
|
|
4075
3949
|
}
|
|
4076
|
-
|
|
4077
3950
|
function mountText(vnode, parent, anchor, renderer) {
|
|
4078
3951
|
const {
|
|
4079
3952
|
owner
|
|
@@ -4085,16 +3958,14 @@
|
|
|
4085
3958
|
linkNodeToShadow(textNode, owner, renderer);
|
|
4086
3959
|
insertNode(textNode, parent, anchor, renderer);
|
|
4087
3960
|
}
|
|
4088
|
-
|
|
4089
3961
|
function patchComment(n1, n2, renderer) {
|
|
4090
|
-
n2.elm = n1.elm;
|
|
3962
|
+
n2.elm = n1.elm;
|
|
3963
|
+
// FIXME: Comment nodes should be static, we shouldn't need to diff them together. However
|
|
4091
3964
|
// it is the case today.
|
|
4092
|
-
|
|
4093
3965
|
if (n2.text !== n1.text) {
|
|
4094
3966
|
updateTextContent(n2, renderer);
|
|
4095
3967
|
}
|
|
4096
3968
|
}
|
|
4097
|
-
|
|
4098
3969
|
function mountComment(vnode, parent, anchor, renderer) {
|
|
4099
3970
|
const {
|
|
4100
3971
|
owner
|
|
@@ -4106,32 +3977,27 @@
|
|
|
4106
3977
|
linkNodeToShadow(commentNode, owner, renderer);
|
|
4107
3978
|
insertNode(commentNode, parent, anchor, renderer);
|
|
4108
3979
|
}
|
|
4109
|
-
|
|
4110
3980
|
function mountFragment(vnode, parent, anchor, renderer) {
|
|
4111
3981
|
const {
|
|
4112
3982
|
children
|
|
4113
3983
|
} = vnode;
|
|
4114
|
-
mountVNodes(children, parent, renderer, anchor);
|
|
4115
|
-
|
|
3984
|
+
mountVNodes(children, parent, renderer, anchor);
|
|
3985
|
+
// children of a fragment will always have at least the two delimiters.
|
|
4116
3986
|
vnode.elm = children[children.length - 1].elm;
|
|
4117
3987
|
}
|
|
4118
|
-
|
|
4119
3988
|
function patchFragment(n1, n2, parent, renderer) {
|
|
4120
3989
|
const {
|
|
4121
3990
|
children,
|
|
4122
3991
|
stable
|
|
4123
3992
|
} = n2;
|
|
4124
|
-
|
|
4125
3993
|
if (stable) {
|
|
4126
3994
|
updateStaticChildren(n1.children, children, parent, renderer);
|
|
4127
3995
|
} else {
|
|
4128
3996
|
updateDynamicChildren(n1.children, children, parent, renderer);
|
|
4129
|
-
}
|
|
4130
|
-
|
|
4131
|
-
|
|
3997
|
+
}
|
|
3998
|
+
// Note: not reusing n1.elm, because during patching, it may be patched with another text node.
|
|
4132
3999
|
n2.elm = children[children.length - 1].elm;
|
|
4133
4000
|
}
|
|
4134
|
-
|
|
4135
4001
|
function mountElement(vnode, parent, anchor, renderer) {
|
|
4136
4002
|
const {
|
|
4137
4003
|
sel,
|
|
@@ -4153,13 +4019,11 @@
|
|
|
4153
4019
|
insertNode(elm, parent, anchor, renderer);
|
|
4154
4020
|
mountVNodes(vnode.children, elm, renderer, null);
|
|
4155
4021
|
}
|
|
4156
|
-
|
|
4157
4022
|
function patchElement(n1, n2, renderer) {
|
|
4158
4023
|
const elm = n2.elm = n1.elm;
|
|
4159
4024
|
patchElementPropsAndAttrs$1(n1, n2, renderer);
|
|
4160
4025
|
patchChildren(n1.children, n2.children, elm, renderer);
|
|
4161
4026
|
}
|
|
4162
|
-
|
|
4163
4027
|
function mountStatic(vnode, parent, anchor, renderer) {
|
|
4164
4028
|
const {
|
|
4165
4029
|
owner
|
|
@@ -4170,26 +4034,19 @@
|
|
|
4170
4034
|
} = renderer;
|
|
4171
4035
|
const elm = vnode.elm = cloneNode(vnode.fragment, true);
|
|
4172
4036
|
linkNodeToShadow(elm, owner, renderer);
|
|
4173
|
-
applyElementRestrictions(elm, vnode);
|
|
4174
|
-
|
|
4037
|
+
applyElementRestrictions(elm, vnode);
|
|
4038
|
+
// Marks this node as Static to propagate the shadow resolver. must happen after elm is assigned to the proper shadow
|
|
4175
4039
|
const {
|
|
4176
4040
|
renderMode,
|
|
4177
4041
|
shadowMode
|
|
4178
4042
|
} = owner;
|
|
4179
|
-
|
|
4180
4043
|
if (isSyntheticShadowDefined) {
|
|
4181
|
-
if (shadowMode === 1
|
|
4182
|
-
/* ShadowMode.Synthetic */
|
|
4183
|
-
|| renderMode === 0
|
|
4184
|
-
/* RenderMode.Light */
|
|
4185
|
-
) {
|
|
4044
|
+
if (shadowMode === 1 /* ShadowMode.Synthetic */ || renderMode === 0 /* RenderMode.Light */) {
|
|
4186
4045
|
elm[KEY__SHADOW_STATIC] = true;
|
|
4187
4046
|
}
|
|
4188
4047
|
}
|
|
4189
|
-
|
|
4190
4048
|
insertNode(elm, parent, anchor, renderer);
|
|
4191
4049
|
}
|
|
4192
|
-
|
|
4193
4050
|
function mountCustomElement(vnode, parent, anchor, renderer) {
|
|
4194
4051
|
const {
|
|
4195
4052
|
sel,
|
|
@@ -4204,67 +4061,53 @@
|
|
|
4204
4061
|
* mechanism that only passes that argument if the constructor is known to be
|
|
4205
4062
|
* an upgradable custom element.
|
|
4206
4063
|
*/
|
|
4207
|
-
|
|
4208
4064
|
let vm;
|
|
4209
|
-
|
|
4210
4065
|
const upgradeCallback = elm => {
|
|
4211
4066
|
// the custom element from the registry is expecting an upgrade callback
|
|
4212
4067
|
vm = createViewModelHook(elm, vnode, renderer);
|
|
4213
4068
|
};
|
|
4214
|
-
|
|
4215
4069
|
const connectedCallback = elm => {
|
|
4216
4070
|
if (lwcRuntimeFlags.ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE) {
|
|
4217
4071
|
connectRootElement(elm);
|
|
4218
4072
|
}
|
|
4219
4073
|
};
|
|
4220
|
-
|
|
4221
4074
|
const disconnectedCallback = elm => {
|
|
4222
4075
|
if (lwcRuntimeFlags.ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE) {
|
|
4223
4076
|
disconnectRootElement(elm);
|
|
4224
4077
|
}
|
|
4225
|
-
};
|
|
4078
|
+
};
|
|
4079
|
+
// Should never get a tag with upper case letter at this point; the compiler
|
|
4226
4080
|
// should produce only tags with lowercase letters. However, the Java
|
|
4227
4081
|
// compiler may generate tagnames with uppercase letters so - for backwards
|
|
4228
4082
|
// compatibility, we lower case the tagname here.
|
|
4229
|
-
|
|
4230
|
-
|
|
4231
4083
|
const normalizedTagname = sel.toLowerCase();
|
|
4232
4084
|
const elm = createCustomElement(normalizedTagname, upgradeCallback, connectedCallback, disconnectedCallback);
|
|
4233
4085
|
vnode.elm = elm;
|
|
4234
4086
|
vnode.vm = vm;
|
|
4235
4087
|
linkNodeToShadow(elm, owner, renderer);
|
|
4236
4088
|
applyStyleScoping(elm, owner, renderer);
|
|
4237
|
-
|
|
4238
4089
|
if (vm) {
|
|
4239
4090
|
allocateChildren(vnode, vm);
|
|
4240
4091
|
}
|
|
4241
|
-
|
|
4242
4092
|
patchElementPropsAndAttrs$1(null, vnode, renderer);
|
|
4243
4093
|
insertNode(elm, parent, anchor, renderer);
|
|
4244
|
-
|
|
4245
4094
|
if (vm) {
|
|
4246
4095
|
{
|
|
4247
4096
|
if (!lwcRuntimeFlags.ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE) {
|
|
4248
4097
|
if (process.env.NODE_ENV !== 'production') {
|
|
4249
4098
|
// With synthetic lifecycle callbacks, it's possible for elements to be removed without the engine
|
|
4250
4099
|
// noticing it (e.g. `appendChild` the same host element twice). This test ensures we don't regress.
|
|
4251
|
-
assert.isTrue(vm.state === 0
|
|
4252
|
-
/* VMState.created */
|
|
4253
|
-
, `${vm} cannot be recycled.`);
|
|
4100
|
+
assert.isTrue(vm.state === 0 /* VMState.created */, `${vm} cannot be recycled.`);
|
|
4254
4101
|
}
|
|
4255
|
-
|
|
4256
4102
|
runConnectedCallback(vm);
|
|
4257
4103
|
}
|
|
4258
4104
|
}
|
|
4259
4105
|
}
|
|
4260
|
-
|
|
4261
4106
|
mountVNodes(vnode.children, elm, renderer, null);
|
|
4262
|
-
|
|
4263
4107
|
if (vm) {
|
|
4264
4108
|
appendVM(vm);
|
|
4265
4109
|
}
|
|
4266
4110
|
}
|
|
4267
|
-
|
|
4268
4111
|
function patchCustomElement(n1, n2, parent, renderer) {
|
|
4269
4112
|
if (n1.ctor !== n2.ctor) {
|
|
4270
4113
|
// If the constructor, unmount the current component and mount a new one using the new
|
|
@@ -4277,17 +4120,14 @@
|
|
|
4277
4120
|
const elm = n2.elm = n1.elm;
|
|
4278
4121
|
const vm = n2.vm = n1.vm;
|
|
4279
4122
|
patchElementPropsAndAttrs$1(n1, n2, renderer);
|
|
4280
|
-
|
|
4281
4123
|
if (!isUndefined$1(vm)) {
|
|
4282
4124
|
// in fallback mode, the allocation will always set children to
|
|
4283
4125
|
// empty and delegate the real allocation to the slot elements
|
|
4284
4126
|
allocateChildren(n2, vm);
|
|
4285
|
-
}
|
|
4127
|
+
}
|
|
4128
|
+
// in fallback mode, the children will be always empty, so, nothing
|
|
4286
4129
|
// will happen, but in native, it does allocate the light dom
|
|
4287
|
-
|
|
4288
|
-
|
|
4289
4130
|
patchChildren(n1.children, n2.children, elm, renderer);
|
|
4290
|
-
|
|
4291
4131
|
if (!isUndefined$1(vm)) {
|
|
4292
4132
|
// this will probably update the shadowRoot, but only if the vm is in a dirty state
|
|
4293
4133
|
// this is important to preserve the top to bottom synchronous rendering phase.
|
|
@@ -4295,29 +4135,24 @@
|
|
|
4295
4135
|
}
|
|
4296
4136
|
}
|
|
4297
4137
|
}
|
|
4298
|
-
|
|
4299
4138
|
function mountVNodes(vnodes, parent, renderer, anchor, start = 0, end = vnodes.length) {
|
|
4300
4139
|
for (; start < end; ++start) {
|
|
4301
4140
|
const vnode = vnodes[start];
|
|
4302
|
-
|
|
4303
4141
|
if (isVNode(vnode)) {
|
|
4304
4142
|
mount(vnode, parent, renderer, anchor);
|
|
4305
4143
|
}
|
|
4306
4144
|
}
|
|
4307
4145
|
}
|
|
4308
|
-
|
|
4309
4146
|
function unmount(vnode, parent, renderer, doRemove = false) {
|
|
4310
4147
|
const {
|
|
4311
4148
|
type,
|
|
4312
4149
|
elm,
|
|
4313
4150
|
sel
|
|
4314
|
-
} = vnode;
|
|
4151
|
+
} = vnode;
|
|
4152
|
+
// When unmounting a VNode subtree not all the elements have to removed from the DOM. The
|
|
4315
4153
|
// subtree root, is the only element worth unmounting from the subtree.
|
|
4316
|
-
|
|
4317
4154
|
if (doRemove) {
|
|
4318
|
-
if (type === 5
|
|
4319
|
-
/* VNodeType.Fragment */
|
|
4320
|
-
) {
|
|
4155
|
+
if (type === 5 /* VNodeType.Fragment */) {
|
|
4321
4156
|
unmountVNodes(vnode.children, parent, renderer, doRemove);
|
|
4322
4157
|
} else {
|
|
4323
4158
|
// The vnode might or might not have a data.renderer associated to it
|
|
@@ -4325,51 +4160,39 @@
|
|
|
4325
4160
|
removeNode(elm, parent, renderer);
|
|
4326
4161
|
}
|
|
4327
4162
|
}
|
|
4328
|
-
|
|
4329
4163
|
switch (type) {
|
|
4330
|
-
case 2
|
|
4331
|
-
/* VNodeType.Element */
|
|
4332
|
-
:
|
|
4164
|
+
case 2 /* VNodeType.Element */:
|
|
4333
4165
|
{
|
|
4334
4166
|
// Slot content is removed to trigger slotchange event when removing slot.
|
|
4335
4167
|
// Only required for synthetic shadow.
|
|
4336
|
-
const shouldRemoveChildren = sel === 'slot' && vnode.owner.shadowMode === 1
|
|
4337
|
-
/* ShadowMode.Synthetic */
|
|
4338
|
-
;
|
|
4168
|
+
const shouldRemoveChildren = sel === 'slot' && vnode.owner.shadowMode === 1 /* ShadowMode.Synthetic */;
|
|
4339
4169
|
unmountVNodes(vnode.children, elm, renderer, shouldRemoveChildren);
|
|
4340
4170
|
break;
|
|
4341
4171
|
}
|
|
4342
|
-
|
|
4343
|
-
case 3
|
|
4344
|
-
/* VNodeType.CustomElement */
|
|
4345
|
-
:
|
|
4172
|
+
case 3 /* VNodeType.CustomElement */:
|
|
4346
4173
|
{
|
|
4347
4174
|
const {
|
|
4348
4175
|
vm
|
|
4349
|
-
} = vnode;
|
|
4176
|
+
} = vnode;
|
|
4177
|
+
// No need to unmount the children here, `removeVM` will take care of removing the
|
|
4350
4178
|
// children.
|
|
4351
|
-
|
|
4352
4179
|
if (!isUndefined$1(vm)) {
|
|
4353
4180
|
removeVM(vm);
|
|
4354
4181
|
}
|
|
4355
4182
|
}
|
|
4356
4183
|
}
|
|
4357
4184
|
}
|
|
4358
|
-
|
|
4359
4185
|
function unmountVNodes(vnodes, parent, renderer, doRemove = false, start = 0, end = vnodes.length) {
|
|
4360
4186
|
for (; start < end; ++start) {
|
|
4361
4187
|
const ch = vnodes[start];
|
|
4362
|
-
|
|
4363
4188
|
if (isVNode(ch)) {
|
|
4364
4189
|
unmount(ch, parent, renderer, doRemove);
|
|
4365
4190
|
}
|
|
4366
4191
|
}
|
|
4367
4192
|
}
|
|
4368
|
-
|
|
4369
4193
|
function isVNode(vnode) {
|
|
4370
4194
|
return vnode != null;
|
|
4371
4195
|
}
|
|
4372
|
-
|
|
4373
4196
|
function linkNodeToShadow(elm, owner, renderer) {
|
|
4374
4197
|
const {
|
|
4375
4198
|
renderRoot,
|
|
@@ -4378,19 +4201,14 @@
|
|
|
4378
4201
|
} = owner;
|
|
4379
4202
|
const {
|
|
4380
4203
|
isSyntheticShadowDefined
|
|
4381
|
-
} = renderer;
|
|
4382
|
-
|
|
4204
|
+
} = renderer;
|
|
4205
|
+
// TODO [#1164]: this should eventually be done by the polyfill directly
|
|
4383
4206
|
if (isSyntheticShadowDefined) {
|
|
4384
|
-
if (shadowMode === 1
|
|
4385
|
-
/* ShadowMode.Synthetic */
|
|
4386
|
-
|| renderMode === 0
|
|
4387
|
-
/* RenderMode.Light */
|
|
4388
|
-
) {
|
|
4207
|
+
if (shadowMode === 1 /* ShadowMode.Synthetic */ || renderMode === 0 /* RenderMode.Light */) {
|
|
4389
4208
|
elm[KEY__SHADOW_RESOLVER] = renderRoot[KEY__SHADOW_RESOLVER];
|
|
4390
4209
|
}
|
|
4391
4210
|
}
|
|
4392
4211
|
}
|
|
4393
|
-
|
|
4394
4212
|
function updateTextContent(vnode, renderer) {
|
|
4395
4213
|
const {
|
|
4396
4214
|
elm,
|
|
@@ -4399,120 +4217,87 @@
|
|
|
4399
4217
|
const {
|
|
4400
4218
|
setText
|
|
4401
4219
|
} = renderer;
|
|
4402
|
-
|
|
4403
4220
|
if (process.env.NODE_ENV !== 'production') {
|
|
4404
4221
|
unlockDomMutation();
|
|
4405
4222
|
}
|
|
4406
|
-
|
|
4407
4223
|
setText(elm, text);
|
|
4408
|
-
|
|
4409
4224
|
if (process.env.NODE_ENV !== 'production') {
|
|
4410
4225
|
lockDomMutation();
|
|
4411
4226
|
}
|
|
4412
4227
|
}
|
|
4413
|
-
|
|
4414
4228
|
function insertNode(node, parent, anchor, renderer) {
|
|
4415
4229
|
if (process.env.NODE_ENV !== 'production') {
|
|
4416
4230
|
unlockDomMutation();
|
|
4417
4231
|
}
|
|
4418
|
-
|
|
4419
4232
|
renderer.insert(node, parent, anchor);
|
|
4420
|
-
|
|
4421
4233
|
if (process.env.NODE_ENV !== 'production') {
|
|
4422
4234
|
lockDomMutation();
|
|
4423
4235
|
}
|
|
4424
4236
|
}
|
|
4425
|
-
|
|
4426
4237
|
function removeNode(node, parent, renderer) {
|
|
4427
4238
|
if (process.env.NODE_ENV !== 'production') {
|
|
4428
4239
|
unlockDomMutation();
|
|
4429
4240
|
}
|
|
4430
|
-
|
|
4431
4241
|
renderer.remove(node, parent);
|
|
4432
|
-
|
|
4433
4242
|
if (process.env.NODE_ENV !== 'production') {
|
|
4434
4243
|
lockDomMutation();
|
|
4435
4244
|
}
|
|
4436
4245
|
}
|
|
4437
|
-
|
|
4438
4246
|
function patchElementPropsAndAttrs$1(oldVnode, vnode, renderer) {
|
|
4439
4247
|
if (isNull(oldVnode)) {
|
|
4440
4248
|
applyEventListeners(vnode, renderer);
|
|
4441
4249
|
applyStaticClassAttribute(vnode, renderer);
|
|
4442
4250
|
applyStaticStyleAttribute(vnode, renderer);
|
|
4443
|
-
}
|
|
4251
|
+
}
|
|
4252
|
+
// Attrs need to be applied to element before props IE11 will wipe out value on radio inputs if
|
|
4444
4253
|
// value is set before type=radio.
|
|
4445
|
-
|
|
4446
|
-
|
|
4447
4254
|
patchClassAttribute(oldVnode, vnode, renderer);
|
|
4448
4255
|
patchStyleAttribute(oldVnode, vnode, renderer);
|
|
4449
4256
|
patchAttributes(oldVnode, vnode, renderer);
|
|
4450
4257
|
patchProps(oldVnode, vnode, renderer);
|
|
4451
4258
|
}
|
|
4452
|
-
|
|
4453
4259
|
function applyStyleScoping(elm, owner, renderer) {
|
|
4454
4260
|
// Set the class name for `*.scoped.css` style scoping.
|
|
4455
4261
|
const scopeToken = getScopeTokenClass(owner);
|
|
4456
|
-
|
|
4457
4262
|
if (!isNull(scopeToken)) {
|
|
4458
4263
|
const {
|
|
4459
4264
|
getClassList
|
|
4460
|
-
} = renderer;
|
|
4265
|
+
} = renderer;
|
|
4266
|
+
// TODO [#2762]: this dot notation with add is probably problematic
|
|
4461
4267
|
// probably we should have a renderer api for just the add operation
|
|
4462
|
-
|
|
4463
4268
|
getClassList(elm).add(scopeToken);
|
|
4464
|
-
}
|
|
4465
|
-
|
|
4466
|
-
|
|
4269
|
+
}
|
|
4270
|
+
// Set property element for synthetic shadow DOM style scoping.
|
|
4467
4271
|
const {
|
|
4468
4272
|
stylesheetToken: syntheticToken
|
|
4469
4273
|
} = owner.context;
|
|
4470
|
-
|
|
4471
|
-
if (owner.shadowMode === 1
|
|
4472
|
-
/* ShadowMode.Synthetic */
|
|
4473
|
-
&& !isUndefined$1(syntheticToken)) {
|
|
4274
|
+
if (owner.shadowMode === 1 /* ShadowMode.Synthetic */ && !isUndefined$1(syntheticToken)) {
|
|
4474
4275
|
elm.$shadowToken$ = syntheticToken;
|
|
4475
4276
|
}
|
|
4476
4277
|
}
|
|
4477
|
-
|
|
4478
4278
|
function applyDomManual(elm, vnode) {
|
|
4479
4279
|
var _a;
|
|
4480
|
-
|
|
4481
4280
|
const {
|
|
4482
4281
|
owner,
|
|
4483
4282
|
data: {
|
|
4484
4283
|
context
|
|
4485
4284
|
}
|
|
4486
4285
|
} = vnode;
|
|
4487
|
-
|
|
4488
|
-
if (owner.shadowMode === 1
|
|
4489
|
-
/* ShadowMode.Synthetic */
|
|
4490
|
-
&& ((_a = context === null || context === void 0 ? void 0 : context.lwc) === null || _a === void 0 ? void 0 : _a.dom) === "manual"
|
|
4491
|
-
/* LwcDomMode.Manual */
|
|
4492
|
-
) {
|
|
4286
|
+
if (owner.shadowMode === 1 /* ShadowMode.Synthetic */ && ((_a = context === null || context === void 0 ? void 0 : context.lwc) === null || _a === void 0 ? void 0 : _a.dom) === "manual" /* LwcDomMode.Manual */) {
|
|
4493
4287
|
elm.$domManual$ = true;
|
|
4494
4288
|
}
|
|
4495
4289
|
}
|
|
4496
|
-
|
|
4497
4290
|
function applyElementRestrictions(elm, vnode) {
|
|
4498
4291
|
var _a, _b;
|
|
4499
|
-
|
|
4500
4292
|
if (process.env.NODE_ENV !== 'production') {
|
|
4501
|
-
const isPortal = vnode.type === 2
|
|
4502
|
-
/*
|
|
4503
|
-
&& ((_b = (_a = vnode.data.context) === null || _a === void 0 ? void 0 : _a.lwc) === null || _b === void 0 ? void 0 : _b.dom) === "manual"
|
|
4504
|
-
/* LwcDomMode.Manual */
|
|
4505
|
-
;
|
|
4506
|
-
const isLight = vnode.owner.renderMode === 0
|
|
4507
|
-
/* RenderMode.Light */
|
|
4508
|
-
;
|
|
4293
|
+
const isPortal = vnode.type === 2 /* VNodeType.Element */ && ((_b = (_a = vnode.data.context) === null || _a === void 0 ? void 0 : _a.lwc) === null || _b === void 0 ? void 0 : _b.dom) === "manual" /* LwcDomMode.Manual */;
|
|
4294
|
+
const isLight = vnode.owner.renderMode === 0 /* RenderMode.Light */;
|
|
4509
4295
|
patchElementWithRestrictions(elm, {
|
|
4510
4296
|
isPortal,
|
|
4511
4297
|
isLight
|
|
4512
4298
|
});
|
|
4513
4299
|
}
|
|
4514
4300
|
}
|
|
4515
|
-
|
|
4516
4301
|
function allocateChildren(vnode, vm) {
|
|
4517
4302
|
// A component with slots will re-render because:
|
|
4518
4303
|
// 1- There is a change of the internal state.
|
|
@@ -4530,41 +4315,31 @@
|
|
|
4530
4315
|
renderMode,
|
|
4531
4316
|
shadowMode
|
|
4532
4317
|
} = vm;
|
|
4533
|
-
|
|
4534
4318
|
if (process.env.NODE_ENV !== 'production') {
|
|
4535
4319
|
// If any of the children being allocated is a scoped slot fragment, make sure the receiving
|
|
4536
4320
|
// component is a light DOM component. This is mainly to validate light dom parent running
|
|
4537
4321
|
// in native shadow mode.
|
|
4538
|
-
if (renderMode !== 0
|
|
4539
|
-
/* RenderMode.Light */
|
|
4540
|
-
&& ArraySome.call(children, child => !isNull(child) && isVScopedSlotFragment(child))) {
|
|
4322
|
+
if (renderMode !== 0 /* RenderMode.Light */ && ArraySome.call(children, child => !isNull(child) && isVScopedSlotFragment(child))) {
|
|
4541
4323
|
logError(`Invalid usage of 'lwc:slot-data' on ${getComponentTag(vm)} tag. Scoped slot content can only be passed to a light dom child.`);
|
|
4542
4324
|
}
|
|
4543
4325
|
}
|
|
4544
|
-
|
|
4545
|
-
if (shadowMode === 1
|
|
4546
|
-
/* ShadowMode.Synthetic */
|
|
4547
|
-
|| renderMode === 0
|
|
4548
|
-
/* RenderMode.Light */
|
|
4549
|
-
) {
|
|
4326
|
+
if (shadowMode === 1 /* ShadowMode.Synthetic */ || renderMode === 0 /* RenderMode.Light */) {
|
|
4550
4327
|
// slow path
|
|
4551
|
-
allocateInSlot(vm, children, vnode.owner);
|
|
4552
|
-
|
|
4553
|
-
vnode.aChildren = children;
|
|
4554
|
-
|
|
4328
|
+
allocateInSlot(vm, children, vnode.owner);
|
|
4329
|
+
// save the allocated children in case this vnode is reused.
|
|
4330
|
+
vnode.aChildren = children;
|
|
4331
|
+
// every child vnode is now allocated, and the host should receive none directly, it receives them via the shadow!
|
|
4555
4332
|
vnode.children = EmptyArray;
|
|
4556
4333
|
}
|
|
4557
4334
|
}
|
|
4558
|
-
|
|
4559
4335
|
function createViewModelHook(elm, vnode, renderer) {
|
|
4560
|
-
let vm = getAssociatedVMIfPresent(elm);
|
|
4336
|
+
let vm = getAssociatedVMIfPresent(elm);
|
|
4337
|
+
// There is a possibility that a custom element is registered under tagName, in which case, the
|
|
4561
4338
|
// initialization is already carry on, and there is nothing else to do here since this hook is
|
|
4562
4339
|
// called right after invoking `document.createElement`.
|
|
4563
|
-
|
|
4564
4340
|
if (!isUndefined$1(vm)) {
|
|
4565
4341
|
return vm;
|
|
4566
4342
|
}
|
|
4567
|
-
|
|
4568
4343
|
const {
|
|
4569
4344
|
sel,
|
|
4570
4345
|
mode,
|
|
@@ -4576,48 +4351,37 @@
|
|
|
4576
4351
|
owner,
|
|
4577
4352
|
tagName: sel
|
|
4578
4353
|
});
|
|
4579
|
-
|
|
4580
4354
|
if (process.env.NODE_ENV !== 'production') {
|
|
4581
4355
|
assert.isTrue(isArray$1(vnode.children), `Invalid vnode for a custom element, it must have children defined.`);
|
|
4582
4356
|
}
|
|
4583
|
-
|
|
4584
4357
|
return vm;
|
|
4585
4358
|
}
|
|
4586
4359
|
/**
|
|
4587
4360
|
* Collects all slots into a SlotSet, traversing through VFragment Nodes
|
|
4588
4361
|
*/
|
|
4589
|
-
|
|
4590
|
-
|
|
4591
4362
|
function collectSlots(vm, children, cmpSlotsMapping) {
|
|
4592
4363
|
var _a, _b;
|
|
4593
|
-
|
|
4594
4364
|
for (let i = 0, len = children.length; i < len; i += 1) {
|
|
4595
4365
|
const vnode = children[i];
|
|
4596
|
-
|
|
4597
4366
|
if (isNull(vnode)) {
|
|
4598
4367
|
continue;
|
|
4599
|
-
}
|
|
4600
|
-
|
|
4601
|
-
|
|
4368
|
+
}
|
|
4369
|
+
// Dive further iff the content is wrapped in a VFragment
|
|
4602
4370
|
if (isVFragment(vnode)) {
|
|
4603
4371
|
// Remove the text delimiter nodes to avoid overriding default slot content
|
|
4604
4372
|
collectSlots(vm, vnode.children.slice(1, -1), cmpSlotsMapping);
|
|
4605
4373
|
continue;
|
|
4606
4374
|
}
|
|
4607
|
-
|
|
4608
4375
|
let slotName = '';
|
|
4609
|
-
|
|
4610
4376
|
if (isVBaseElement(vnode)) {
|
|
4611
4377
|
slotName = (_b = (_a = vnode.data.attrs) === null || _a === void 0 ? void 0 : _a.slot) !== null && _b !== void 0 ? _b : '';
|
|
4612
4378
|
} else if (isVScopedSlotFragment(vnode)) {
|
|
4613
4379
|
slotName = vnode.slotName;
|
|
4614
4380
|
}
|
|
4615
|
-
|
|
4616
4381
|
const vnodes = cmpSlotsMapping[slotName] = cmpSlotsMapping[slotName] || [];
|
|
4617
4382
|
ArrayPush$1.call(vnodes, vnode);
|
|
4618
4383
|
}
|
|
4619
4384
|
}
|
|
4620
|
-
|
|
4621
4385
|
function allocateInSlot(vm, children, owner) {
|
|
4622
4386
|
const {
|
|
4623
4387
|
cmpSlots: {
|
|
@@ -4630,28 +4394,22 @@
|
|
|
4630
4394
|
owner,
|
|
4631
4395
|
slotAssignments: cmpSlotsMapping
|
|
4632
4396
|
};
|
|
4633
|
-
|
|
4634
4397
|
if (isFalse(vm.isDirty)) {
|
|
4635
4398
|
// We need to determine if the old allocation is really different from the new one
|
|
4636
4399
|
// and mark the vm as dirty
|
|
4637
4400
|
const oldKeys = keys(oldSlotsMapping);
|
|
4638
|
-
|
|
4639
4401
|
if (oldKeys.length !== keys(cmpSlotsMapping).length) {
|
|
4640
4402
|
markComponentAsDirty(vm);
|
|
4641
4403
|
return;
|
|
4642
4404
|
}
|
|
4643
|
-
|
|
4644
4405
|
for (let i = 0, len = oldKeys.length; i < len; i += 1) {
|
|
4645
4406
|
const key = oldKeys[i];
|
|
4646
|
-
|
|
4647
4407
|
if (isUndefined$1(cmpSlotsMapping[key]) || oldSlotsMapping[key].length !== cmpSlotsMapping[key].length) {
|
|
4648
4408
|
markComponentAsDirty(vm);
|
|
4649
4409
|
return;
|
|
4650
4410
|
}
|
|
4651
|
-
|
|
4652
4411
|
const oldVNodes = oldSlotsMapping[key];
|
|
4653
4412
|
const vnodes = cmpSlotsMapping[key];
|
|
4654
|
-
|
|
4655
4413
|
for (let j = 0, a = cmpSlotsMapping[key].length; j < a; j += 1) {
|
|
4656
4414
|
if (oldVNodes[j] !== vnodes[j]) {
|
|
4657
4415
|
markComponentAsDirty(vm);
|
|
@@ -4660,40 +4418,33 @@
|
|
|
4660
4418
|
}
|
|
4661
4419
|
}
|
|
4662
4420
|
}
|
|
4663
|
-
}
|
|
4664
|
-
|
|
4665
|
-
|
|
4666
|
-
|
|
4421
|
+
}
|
|
4422
|
+
// Using a WeakMap instead of a WeakSet because this one works in IE11 :(
|
|
4423
|
+
const FromIteration = new WeakMap();
|
|
4424
|
+
// dynamic children means it was generated by an iteration
|
|
4667
4425
|
// in a template, and will require a more complex diffing algo.
|
|
4668
|
-
|
|
4669
4426
|
function markAsDynamicChildren(children) {
|
|
4670
4427
|
FromIteration.set(children, 1);
|
|
4671
4428
|
}
|
|
4672
|
-
|
|
4673
4429
|
function hasDynamicChildren(children) {
|
|
4674
4430
|
return FromIteration.has(children);
|
|
4675
4431
|
}
|
|
4676
|
-
|
|
4677
4432
|
function createKeyToOldIdx(children, beginIdx, endIdx) {
|
|
4678
|
-
const map = {};
|
|
4679
|
-
|
|
4433
|
+
const map = {};
|
|
4434
|
+
// TODO [#1637]: simplify this by assuming that all vnodes has keys
|
|
4680
4435
|
for (let j = beginIdx; j <= endIdx; ++j) {
|
|
4681
4436
|
const ch = children[j];
|
|
4682
|
-
|
|
4683
4437
|
if (isVNode(ch)) {
|
|
4684
4438
|
const {
|
|
4685
4439
|
key
|
|
4686
4440
|
} = ch;
|
|
4687
|
-
|
|
4688
4441
|
if (key !== undefined) {
|
|
4689
4442
|
map[key] = j;
|
|
4690
4443
|
}
|
|
4691
4444
|
}
|
|
4692
4445
|
}
|
|
4693
|
-
|
|
4694
4446
|
return map;
|
|
4695
4447
|
}
|
|
4696
|
-
|
|
4697
4448
|
function updateDynamicChildren(oldCh, newCh, parent, renderer) {
|
|
4698
4449
|
let oldStartIdx = 0;
|
|
4699
4450
|
let newStartIdx = 0;
|
|
@@ -4709,7 +4460,6 @@
|
|
|
4709
4460
|
let elmToMove;
|
|
4710
4461
|
let before;
|
|
4711
4462
|
let clonedOldCh = false;
|
|
4712
|
-
|
|
4713
4463
|
while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
|
|
4714
4464
|
if (!isVNode(oldStartVnode)) {
|
|
4715
4465
|
oldStartVnode = oldCh[++oldStartIdx]; // Vnode might have been moved left
|
|
@@ -4743,54 +4493,46 @@
|
|
|
4743
4493
|
if (oldKeyToIdx === undefined) {
|
|
4744
4494
|
oldKeyToIdx = createKeyToOldIdx(oldCh, oldStartIdx, oldEndIdx);
|
|
4745
4495
|
}
|
|
4746
|
-
|
|
4747
4496
|
idxInOld = oldKeyToIdx[newStartVnode.key];
|
|
4748
|
-
|
|
4749
4497
|
if (isUndefined$1(idxInOld)) {
|
|
4750
4498
|
// New element
|
|
4751
4499
|
mount(newStartVnode, parent, renderer, oldStartVnode.elm);
|
|
4752
4500
|
newStartVnode = newCh[++newStartIdx];
|
|
4753
4501
|
} else {
|
|
4754
4502
|
elmToMove = oldCh[idxInOld];
|
|
4755
|
-
|
|
4756
4503
|
if (isVNode(elmToMove)) {
|
|
4757
4504
|
if (elmToMove.sel !== newStartVnode.sel) {
|
|
4758
4505
|
// New element
|
|
4759
4506
|
mount(newStartVnode, parent, renderer, oldStartVnode.elm);
|
|
4760
4507
|
} else {
|
|
4761
|
-
patch(elmToMove, newStartVnode, parent, renderer);
|
|
4508
|
+
patch(elmToMove, newStartVnode, parent, renderer);
|
|
4509
|
+
// Delete the old child, but copy the array since it is read-only.
|
|
4762
4510
|
// The `oldCh` will be GC'ed after `updateDynamicChildren` is complete,
|
|
4763
4511
|
// so we only care about the `oldCh` object inside this function.
|
|
4764
4512
|
// To avoid cloning over and over again, we check `clonedOldCh`
|
|
4765
4513
|
// and only clone once.
|
|
4766
|
-
|
|
4767
4514
|
if (!clonedOldCh) {
|
|
4768
4515
|
clonedOldCh = true;
|
|
4769
4516
|
oldCh = [...oldCh];
|
|
4770
|
-
}
|
|
4771
|
-
|
|
4772
|
-
|
|
4517
|
+
}
|
|
4518
|
+
// We've already cloned at least once, so it's no longer read-only
|
|
4773
4519
|
oldCh[idxInOld] = undefined;
|
|
4774
4520
|
insertNode(elmToMove.elm, parent, oldStartVnode.elm, renderer);
|
|
4775
4521
|
}
|
|
4776
4522
|
}
|
|
4777
|
-
|
|
4778
4523
|
newStartVnode = newCh[++newStartIdx];
|
|
4779
4524
|
}
|
|
4780
4525
|
}
|
|
4781
4526
|
}
|
|
4782
|
-
|
|
4783
4527
|
if (oldStartIdx <= oldEndIdx || newStartIdx <= newEndIdx) {
|
|
4784
4528
|
if (oldStartIdx > oldEndIdx) {
|
|
4785
4529
|
// There's some cases in which the sub array of vnodes to be inserted is followed by null(s) and an
|
|
4786
4530
|
// already processed vnode, in such cases the vnodes to be inserted should be before that processed vnode.
|
|
4787
4531
|
let i = newEndIdx;
|
|
4788
4532
|
let n;
|
|
4789
|
-
|
|
4790
4533
|
do {
|
|
4791
4534
|
n = newCh[++i];
|
|
4792
4535
|
} while (!isVNode(n) && i < newChEnd);
|
|
4793
|
-
|
|
4794
4536
|
before = isVNode(n) ? n.elm : null;
|
|
4795
4537
|
mountVNodes(newCh, parent, renderer, before, newStartIdx, newEndIdx + 1);
|
|
4796
4538
|
} else {
|
|
@@ -4798,32 +4540,26 @@
|
|
|
4798
4540
|
}
|
|
4799
4541
|
}
|
|
4800
4542
|
}
|
|
4801
|
-
|
|
4802
4543
|
function updateStaticChildren(c1, c2, parent, renderer) {
|
|
4803
4544
|
const c1Length = c1.length;
|
|
4804
4545
|
const c2Length = c2.length;
|
|
4805
|
-
|
|
4806
4546
|
if (c1Length === 0) {
|
|
4807
4547
|
// the old list is empty, we can directly insert anything new
|
|
4808
4548
|
mountVNodes(c2, parent, renderer, null);
|
|
4809
4549
|
return;
|
|
4810
4550
|
}
|
|
4811
|
-
|
|
4812
4551
|
if (c2Length === 0) {
|
|
4813
4552
|
// the old list is nonempty and the new list is empty so we can directly remove all old nodes
|
|
4814
4553
|
// this is the case in which the dynamic children of an if-directive should be removed
|
|
4815
4554
|
unmountVNodes(c1, parent, renderer, true);
|
|
4816
4555
|
return;
|
|
4817
|
-
}
|
|
4556
|
+
}
|
|
4557
|
+
// if the old list is not empty, the new list MUST have the same
|
|
4818
4558
|
// amount of nodes, that's why we call this static children
|
|
4819
|
-
|
|
4820
|
-
|
|
4821
4559
|
let anchor = null;
|
|
4822
|
-
|
|
4823
4560
|
for (let i = c2Length - 1; i >= 0; i -= 1) {
|
|
4824
4561
|
const n1 = c1[i];
|
|
4825
4562
|
const n2 = c2[i];
|
|
4826
|
-
|
|
4827
4563
|
if (n2 !== n1) {
|
|
4828
4564
|
if (isVNode(n1)) {
|
|
4829
4565
|
if (isVNode(n2)) {
|
|
@@ -5813,42 +5549,30 @@
|
|
|
5813
5549
|
*/
|
|
5814
5550
|
let idx = 0;
|
|
5815
5551
|
/** The internal slot used to associate different objects the engine manipulates with the VM */
|
|
5816
|
-
|
|
5817
5552
|
const ViewModelReflection = new WeakMap();
|
|
5818
|
-
|
|
5819
5553
|
function callHook(cmp, fn, args = []) {
|
|
5820
5554
|
return fn.apply(cmp, args);
|
|
5821
5555
|
}
|
|
5822
|
-
|
|
5823
5556
|
function setHook(cmp, prop, newValue) {
|
|
5824
5557
|
cmp[prop] = newValue;
|
|
5825
5558
|
}
|
|
5826
|
-
|
|
5827
5559
|
function getHook(cmp, prop) {
|
|
5828
5560
|
return cmp[prop];
|
|
5829
5561
|
}
|
|
5830
|
-
|
|
5831
5562
|
function rerenderVM(vm) {
|
|
5832
5563
|
rehydrate(vm);
|
|
5833
5564
|
}
|
|
5834
5565
|
function connectRootElement(elm) {
|
|
5835
5566
|
const vm = getAssociatedVM(elm);
|
|
5836
|
-
logGlobalOperationStart(7
|
|
5837
|
-
|
|
5838
|
-
, vm); // Usually means moving the element from one place to another, which is observable via
|
|
5567
|
+
logGlobalOperationStart(7 /* OperationId.GlobalHydrate */, vm);
|
|
5568
|
+
// Usually means moving the element from one place to another, which is observable via
|
|
5839
5569
|
// life-cycle hooks.
|
|
5840
|
-
|
|
5841
|
-
if (vm.state === 1
|
|
5842
|
-
/* VMState.connected */
|
|
5843
|
-
) {
|
|
5570
|
+
if (vm.state === 1 /* VMState.connected */) {
|
|
5844
5571
|
disconnectRootElement(elm);
|
|
5845
5572
|
}
|
|
5846
|
-
|
|
5847
5573
|
runConnectedCallback(vm);
|
|
5848
5574
|
rehydrate(vm);
|
|
5849
|
-
logGlobalOperationEnd(7
|
|
5850
|
-
/* OperationId.GlobalHydrate */
|
|
5851
|
-
, vm);
|
|
5575
|
+
logGlobalOperationEnd(7 /* OperationId.GlobalHydrate */, vm);
|
|
5852
5576
|
}
|
|
5853
5577
|
function disconnectRootElement(elm) {
|
|
5854
5578
|
const vm = getAssociatedVM(elm);
|
|
@@ -5856,65 +5580,48 @@
|
|
|
5856
5580
|
}
|
|
5857
5581
|
function appendVM(vm) {
|
|
5858
5582
|
rehydrate(vm);
|
|
5859
|
-
}
|
|
5583
|
+
}
|
|
5584
|
+
// just in case the component comes back, with this we guarantee re-rendering it
|
|
5860
5585
|
// while preventing any attempt to rehydration until after reinsertion.
|
|
5861
|
-
|
|
5862
5586
|
function resetComponentStateWhenRemoved(vm) {
|
|
5863
5587
|
const {
|
|
5864
5588
|
state
|
|
5865
5589
|
} = vm;
|
|
5866
|
-
|
|
5867
|
-
if (state !== 2
|
|
5868
|
-
/* VMState.disconnected */
|
|
5869
|
-
) {
|
|
5590
|
+
if (state !== 2 /* VMState.disconnected */) {
|
|
5870
5591
|
const {
|
|
5871
5592
|
oar,
|
|
5872
5593
|
tro
|
|
5873
|
-
} = vm;
|
|
5874
|
-
|
|
5875
|
-
tro.reset();
|
|
5876
|
-
|
|
5594
|
+
} = vm;
|
|
5595
|
+
// Making sure that any observing record will not trigger the rehydrated on this vm
|
|
5596
|
+
tro.reset();
|
|
5597
|
+
// Making sure that any observing accessor record will not trigger the setter to be reinvoked
|
|
5877
5598
|
for (const key in oar) {
|
|
5878
5599
|
oar[key].reset();
|
|
5879
5600
|
}
|
|
5880
|
-
|
|
5881
|
-
|
|
5882
|
-
|
|
5601
|
+
runDisconnectedCallback(vm);
|
|
5602
|
+
// Spec: https://dom.spec.whatwg.org/#concept-node-remove (step 14-15)
|
|
5883
5603
|
runChildNodesDisconnectedCallback(vm);
|
|
5884
5604
|
runLightChildNodesDisconnectedCallback(vm);
|
|
5885
5605
|
}
|
|
5886
|
-
|
|
5887
5606
|
if (process.env.NODE_ENV !== 'production') {
|
|
5888
5607
|
removeActiveVM(vm);
|
|
5889
5608
|
}
|
|
5890
|
-
}
|
|
5609
|
+
}
|
|
5610
|
+
// this method is triggered by the diffing algo only when a vnode from the
|
|
5891
5611
|
// old vnode.children is removed from the DOM.
|
|
5892
|
-
|
|
5893
|
-
|
|
5894
5612
|
function removeVM(vm) {
|
|
5895
5613
|
if (process.env.NODE_ENV !== 'production') {
|
|
5896
|
-
assert.isTrue(vm.state === 1
|
|
5897
|
-
/* VMState.connected */
|
|
5898
|
-
|| vm.state === 2
|
|
5899
|
-
/* VMState.disconnected */
|
|
5900
|
-
, `${vm} must have been connected.`);
|
|
5614
|
+
assert.isTrue(vm.state === 1 /* VMState.connected */ || vm.state === 2 /* VMState.disconnected */, `${vm} must have been connected.`);
|
|
5901
5615
|
}
|
|
5902
|
-
|
|
5903
5616
|
resetComponentStateWhenRemoved(vm);
|
|
5904
5617
|
}
|
|
5905
|
-
|
|
5906
5618
|
function getNearestShadowAncestor(vm) {
|
|
5907
5619
|
let ancestor = vm.owner;
|
|
5908
|
-
|
|
5909
|
-
while (!isNull(ancestor) && ancestor.renderMode === 0
|
|
5910
|
-
/* RenderMode.Light */
|
|
5911
|
-
) {
|
|
5620
|
+
while (!isNull(ancestor) && ancestor.renderMode === 0 /* RenderMode.Light */) {
|
|
5912
5621
|
ancestor = ancestor.owner;
|
|
5913
5622
|
}
|
|
5914
|
-
|
|
5915
5623
|
return ancestor;
|
|
5916
5624
|
}
|
|
5917
|
-
|
|
5918
5625
|
function createVM(elm, ctor, renderer, options) {
|
|
5919
5626
|
const {
|
|
5920
5627
|
mode,
|
|
@@ -5927,9 +5634,7 @@
|
|
|
5927
5634
|
elm,
|
|
5928
5635
|
def,
|
|
5929
5636
|
idx: idx++,
|
|
5930
|
-
state: 0
|
|
5931
|
-
/* VMState.created */
|
|
5932
|
-
,
|
|
5637
|
+
state: 0 /* VMState.created */,
|
|
5933
5638
|
isScheduled: false,
|
|
5934
5639
|
isDirty: true,
|
|
5935
5640
|
tagName,
|
|
@@ -5971,31 +5676,27 @@
|
|
|
5971
5676
|
getHook,
|
|
5972
5677
|
renderer
|
|
5973
5678
|
};
|
|
5679
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
5680
|
+
vm.debugInfo = create(null);
|
|
5681
|
+
}
|
|
5974
5682
|
vm.shadowMode = computeShadowMode(vm, renderer);
|
|
5975
5683
|
vm.tro = getTemplateReactiveObserver(vm);
|
|
5976
|
-
|
|
5977
5684
|
if (process.env.NODE_ENV !== 'production') {
|
|
5978
5685
|
vm.toString = () => {
|
|
5979
5686
|
return `[object:vm ${def.name} (${vm.idx})]`;
|
|
5980
5687
|
};
|
|
5981
|
-
|
|
5982
5688
|
if (lwcRuntimeFlags.ENABLE_FORCE_NATIVE_SHADOW_MODE_FOR_TEST) {
|
|
5983
|
-
vm.shadowMode = 0
|
|
5984
|
-
/* ShadowMode.Native */
|
|
5985
|
-
;
|
|
5689
|
+
vm.shadowMode = 0 /* ShadowMode.Native */;
|
|
5986
5690
|
}
|
|
5987
|
-
}
|
|
5988
|
-
|
|
5989
|
-
|
|
5990
|
-
|
|
5991
|
-
|
|
5691
|
+
}
|
|
5692
|
+
// Create component instance associated to the vm and the element.
|
|
5693
|
+
invokeComponentConstructor(vm, def.ctor);
|
|
5694
|
+
// Initializing the wire decorator per instance only when really needed
|
|
5992
5695
|
if (hasWireAdapters(vm)) {
|
|
5993
5696
|
installWireAdapters(vm);
|
|
5994
5697
|
}
|
|
5995
|
-
|
|
5996
5698
|
return vm;
|
|
5997
5699
|
}
|
|
5998
|
-
|
|
5999
5700
|
function computeShadowMode(vm, renderer) {
|
|
6000
5701
|
const {
|
|
6001
5702
|
def
|
|
@@ -6005,136 +5706,98 @@
|
|
|
6005
5706
|
isNativeShadowDefined
|
|
6006
5707
|
} = renderer;
|
|
6007
5708
|
let shadowMode;
|
|
6008
|
-
|
|
6009
5709
|
if (isSyntheticShadowDefined) {
|
|
6010
|
-
if (def.renderMode === 0
|
|
6011
|
-
/* RenderMode.Light */
|
|
6012
|
-
) {
|
|
5710
|
+
if (def.renderMode === 0 /* RenderMode.Light */) {
|
|
6013
5711
|
// ShadowMode.Native implies "not synthetic shadow" which is consistent with how
|
|
6014
5712
|
// everything defaults to native when the synthetic shadow polyfill is unavailable.
|
|
6015
|
-
shadowMode = 0
|
|
6016
|
-
/* ShadowMode.Native */
|
|
6017
|
-
;
|
|
5713
|
+
shadowMode = 0 /* ShadowMode.Native */;
|
|
6018
5714
|
} else if (isNativeShadowDefined) {
|
|
6019
5715
|
// Not combined with above condition because @lwc/features only supports identifiers in
|
|
6020
5716
|
// the if-condition.
|
|
6021
5717
|
if (lwcRuntimeFlags.ENABLE_MIXED_SHADOW_MODE) {
|
|
6022
|
-
if (def.shadowSupportMode === "any"
|
|
6023
|
-
|
|
6024
|
-
) {
|
|
6025
|
-
shadowMode = 0
|
|
6026
|
-
/* ShadowMode.Native */
|
|
6027
|
-
;
|
|
5718
|
+
if (def.shadowSupportMode === "any" /* ShadowSupportMode.Any */) {
|
|
5719
|
+
shadowMode = 0 /* ShadowMode.Native */;
|
|
6028
5720
|
} else {
|
|
6029
5721
|
const shadowAncestor = getNearestShadowAncestor(vm);
|
|
6030
|
-
|
|
6031
|
-
if (!isNull(shadowAncestor) && shadowAncestor.shadowMode === 0
|
|
6032
|
-
/* ShadowMode.Native */
|
|
6033
|
-
) {
|
|
5722
|
+
if (!isNull(shadowAncestor) && shadowAncestor.shadowMode === 0 /* ShadowMode.Native */) {
|
|
6034
5723
|
// Transitive support for native Shadow DOM. A component in native mode
|
|
6035
5724
|
// transitively opts all of its descendants into native.
|
|
6036
|
-
shadowMode = 0
|
|
6037
|
-
/* ShadowMode.Native */
|
|
6038
|
-
;
|
|
5725
|
+
shadowMode = 0 /* ShadowMode.Native */;
|
|
6039
5726
|
} else {
|
|
6040
5727
|
// Synthetic if neither this component nor any of its ancestors are configured
|
|
6041
5728
|
// to be native.
|
|
6042
|
-
shadowMode = 1
|
|
6043
|
-
/* ShadowMode.Synthetic */
|
|
6044
|
-
;
|
|
5729
|
+
shadowMode = 1 /* ShadowMode.Synthetic */;
|
|
6045
5730
|
}
|
|
6046
5731
|
}
|
|
6047
5732
|
} else {
|
|
6048
|
-
shadowMode = 1
|
|
6049
|
-
/* ShadowMode.Synthetic */
|
|
6050
|
-
;
|
|
5733
|
+
shadowMode = 1 /* ShadowMode.Synthetic */;
|
|
6051
5734
|
}
|
|
6052
5735
|
} else {
|
|
6053
5736
|
// Synthetic if there is no native Shadow DOM support.
|
|
6054
|
-
shadowMode = 1
|
|
6055
|
-
/* ShadowMode.Synthetic */
|
|
6056
|
-
;
|
|
5737
|
+
shadowMode = 1 /* ShadowMode.Synthetic */;
|
|
6057
5738
|
}
|
|
6058
5739
|
} else {
|
|
6059
5740
|
// Native if the synthetic shadow polyfill is unavailable.
|
|
6060
|
-
shadowMode = 0
|
|
6061
|
-
/* ShadowMode.Native */
|
|
6062
|
-
;
|
|
5741
|
+
shadowMode = 0 /* ShadowMode.Native */;
|
|
6063
5742
|
}
|
|
6064
5743
|
|
|
6065
5744
|
return shadowMode;
|
|
6066
5745
|
}
|
|
6067
|
-
|
|
6068
5746
|
function assertIsVM(obj) {
|
|
6069
5747
|
if (isNull(obj) || !isObject(obj) || !('renderRoot' in obj)) {
|
|
6070
5748
|
throw new TypeError(`${obj} is not a VM.`);
|
|
6071
5749
|
}
|
|
6072
5750
|
}
|
|
6073
|
-
|
|
6074
5751
|
function associateVM(obj, vm) {
|
|
6075
5752
|
ViewModelReflection.set(obj, vm);
|
|
6076
5753
|
}
|
|
6077
5754
|
function getAssociatedVM(obj) {
|
|
6078
5755
|
const vm = ViewModelReflection.get(obj);
|
|
6079
|
-
|
|
6080
5756
|
if (process.env.NODE_ENV !== 'production') {
|
|
6081
5757
|
assertIsVM(vm);
|
|
6082
5758
|
}
|
|
6083
|
-
|
|
6084
5759
|
return vm;
|
|
6085
5760
|
}
|
|
6086
5761
|
function getAssociatedVMIfPresent(obj) {
|
|
6087
5762
|
const maybeVm = ViewModelReflection.get(obj);
|
|
6088
|
-
|
|
6089
5763
|
if (process.env.NODE_ENV !== 'production') {
|
|
6090
5764
|
if (!isUndefined$1(maybeVm)) {
|
|
6091
5765
|
assertIsVM(maybeVm);
|
|
6092
5766
|
}
|
|
6093
5767
|
}
|
|
6094
|
-
|
|
6095
5768
|
return maybeVm;
|
|
6096
5769
|
}
|
|
6097
|
-
|
|
6098
5770
|
function rehydrate(vm) {
|
|
6099
5771
|
if (isTrue(vm.isDirty)) {
|
|
6100
5772
|
const children = renderComponent(vm);
|
|
6101
5773
|
patchShadowRoot(vm, children);
|
|
6102
5774
|
}
|
|
6103
5775
|
}
|
|
6104
|
-
|
|
6105
5776
|
function patchShadowRoot(vm, newCh) {
|
|
6106
5777
|
const {
|
|
6107
5778
|
renderRoot,
|
|
6108
5779
|
children: oldCh,
|
|
6109
5780
|
renderer
|
|
6110
|
-
} = vm;
|
|
6111
|
-
|
|
5781
|
+
} = vm;
|
|
5782
|
+
// caching the new children collection
|
|
6112
5783
|
vm.children = newCh;
|
|
6113
|
-
|
|
6114
5784
|
if (newCh.length > 0 || oldCh.length > 0) {
|
|
6115
5785
|
// patch function mutates vnodes by adding the element reference,
|
|
6116
5786
|
// however, if patching fails it contains partial changes.
|
|
6117
5787
|
if (oldCh !== newCh) {
|
|
6118
5788
|
runWithBoundaryProtection(vm, vm, () => {
|
|
6119
5789
|
// pre
|
|
6120
|
-
logOperationStart(2
|
|
6121
|
-
/* OperationId.Patch */
|
|
6122
|
-
, vm);
|
|
5790
|
+
logOperationStart(2 /* OperationId.Patch */, vm);
|
|
6123
5791
|
}, () => {
|
|
6124
5792
|
// job
|
|
6125
5793
|
patchChildren(oldCh, newCh, renderRoot, renderer);
|
|
6126
5794
|
}, () => {
|
|
6127
5795
|
// post
|
|
6128
|
-
logOperationEnd(2
|
|
6129
|
-
/* OperationId.Patch */
|
|
6130
|
-
, vm);
|
|
5796
|
+
logOperationEnd(2 /* OperationId.Patch */, vm);
|
|
6131
5797
|
});
|
|
6132
5798
|
}
|
|
6133
5799
|
}
|
|
6134
|
-
|
|
6135
|
-
if (vm.state === 1
|
|
6136
|
-
/* VMState.connected */
|
|
6137
|
-
) {
|
|
5800
|
+
if (vm.state === 1 /* VMState.connected */) {
|
|
6138
5801
|
// If the element is connected, that means connectedCallback was already issued, and
|
|
6139
5802
|
// any successive rendering should finish with the call to renderedCallback, otherwise
|
|
6140
5803
|
// the connectedCallback will take care of calling it in the right order at the end of
|
|
@@ -6142,49 +5805,34 @@
|
|
|
6142
5805
|
runRenderedCallback(vm);
|
|
6143
5806
|
}
|
|
6144
5807
|
}
|
|
6145
|
-
|
|
6146
5808
|
function runRenderedCallback(vm) {
|
|
6147
5809
|
const {
|
|
6148
5810
|
def: {
|
|
6149
5811
|
renderedCallback
|
|
6150
5812
|
}
|
|
6151
5813
|
} = vm;
|
|
6152
|
-
|
|
6153
5814
|
const {
|
|
6154
5815
|
rendered
|
|
6155
5816
|
} = Services;
|
|
6156
|
-
|
|
6157
5817
|
if (rendered) {
|
|
6158
5818
|
invokeServiceHook(vm, rendered);
|
|
6159
5819
|
}
|
|
6160
|
-
|
|
6161
5820
|
if (!isUndefined$1(renderedCallback)) {
|
|
6162
|
-
logOperationStart(4
|
|
6163
|
-
/* OperationId.RenderedCallback */
|
|
6164
|
-
, vm);
|
|
5821
|
+
logOperationStart(4 /* OperationId.RenderedCallback */, vm);
|
|
6165
5822
|
invokeComponentCallback(vm, renderedCallback);
|
|
6166
|
-
logOperationEnd(4
|
|
6167
|
-
/* OperationId.RenderedCallback */
|
|
6168
|
-
, vm);
|
|
5823
|
+
logOperationEnd(4 /* OperationId.RenderedCallback */, vm);
|
|
6169
5824
|
}
|
|
6170
5825
|
}
|
|
6171
5826
|
let rehydrateQueue = [];
|
|
6172
|
-
|
|
6173
5827
|
function flushRehydrationQueue() {
|
|
6174
|
-
logGlobalOperationStart(8
|
|
6175
|
-
/* OperationId.GlobalRehydrate */
|
|
6176
|
-
);
|
|
6177
|
-
|
|
5828
|
+
logGlobalOperationStart(8 /* OperationId.GlobalRehydrate */);
|
|
6178
5829
|
if (process.env.NODE_ENV !== 'production') {
|
|
6179
5830
|
assert.invariant(rehydrateQueue.length, `If rehydrateQueue was scheduled, it is because there must be at least one VM on this pending queue instead of ${rehydrateQueue}.`);
|
|
6180
5831
|
}
|
|
6181
|
-
|
|
6182
5832
|
const vms = rehydrateQueue.sort((a, b) => a.idx - b.idx);
|
|
6183
5833
|
rehydrateQueue = []; // reset to a new queue
|
|
6184
|
-
|
|
6185
5834
|
for (let i = 0, len = vms.length; i < len; i += 1) {
|
|
6186
5835
|
const vm = vms[i];
|
|
6187
|
-
|
|
6188
5836
|
try {
|
|
6189
5837
|
rehydrate(vm);
|
|
6190
5838
|
} catch (error) {
|
|
@@ -6193,78 +5841,54 @@
|
|
|
6193
5841
|
if (rehydrateQueue.length === 0) {
|
|
6194
5842
|
addCallbackToNextTick(flushRehydrationQueue);
|
|
6195
5843
|
}
|
|
6196
|
-
|
|
6197
5844
|
ArrayUnshift.apply(rehydrateQueue, ArraySlice.call(vms, i + 1));
|
|
6198
|
-
}
|
|
6199
|
-
|
|
6200
|
-
|
|
6201
|
-
|
|
6202
|
-
/* OperationId.GlobalRehydrate */
|
|
6203
|
-
); // re-throwing the original error will break the current tick, but since the next tick is
|
|
5845
|
+
}
|
|
5846
|
+
// we need to end the measure before throwing.
|
|
5847
|
+
logGlobalOperationEnd(8 /* OperationId.GlobalRehydrate */);
|
|
5848
|
+
// re-throwing the original error will break the current tick, but since the next tick is
|
|
6204
5849
|
// already scheduled, it should continue patching the rest.
|
|
6205
|
-
|
|
6206
5850
|
throw error; // eslint-disable-line no-unsafe-finally
|
|
6207
5851
|
}
|
|
6208
5852
|
}
|
|
6209
5853
|
|
|
6210
|
-
logGlobalOperationEnd(8
|
|
6211
|
-
/* OperationId.GlobalRehydrate */
|
|
6212
|
-
);
|
|
5854
|
+
logGlobalOperationEnd(8 /* OperationId.GlobalRehydrate */);
|
|
6213
5855
|
}
|
|
6214
5856
|
|
|
6215
5857
|
function runConnectedCallback(vm) {
|
|
6216
5858
|
const {
|
|
6217
5859
|
state
|
|
6218
5860
|
} = vm;
|
|
6219
|
-
|
|
6220
|
-
if (state === 1
|
|
6221
|
-
/* VMState.connected */
|
|
6222
|
-
) {
|
|
5861
|
+
if (state === 1 /* VMState.connected */) {
|
|
6223
5862
|
return; // nothing to do since it was already connected
|
|
6224
5863
|
}
|
|
6225
5864
|
|
|
6226
|
-
vm.state = 1
|
|
6227
|
-
|
|
6228
|
-
; // reporting connection
|
|
6229
|
-
|
|
5865
|
+
vm.state = 1 /* VMState.connected */;
|
|
5866
|
+
// reporting connection
|
|
6230
5867
|
const {
|
|
6231
5868
|
connected
|
|
6232
5869
|
} = Services;
|
|
6233
|
-
|
|
6234
5870
|
if (connected) {
|
|
6235
5871
|
invokeServiceHook(vm, connected);
|
|
6236
5872
|
}
|
|
6237
|
-
|
|
6238
5873
|
if (hasWireAdapters(vm)) {
|
|
6239
5874
|
connectWireAdapters(vm);
|
|
6240
5875
|
}
|
|
6241
|
-
|
|
6242
5876
|
const {
|
|
6243
5877
|
connectedCallback
|
|
6244
5878
|
} = vm.def;
|
|
6245
|
-
|
|
6246
5879
|
if (!isUndefined$1(connectedCallback)) {
|
|
6247
|
-
logOperationStart(3
|
|
6248
|
-
/* OperationId.ConnectedCallback */
|
|
6249
|
-
, vm);
|
|
5880
|
+
logOperationStart(3 /* OperationId.ConnectedCallback */, vm);
|
|
6250
5881
|
invokeComponentCallback(vm, connectedCallback);
|
|
6251
|
-
logOperationEnd(3
|
|
6252
|
-
/* OperationId.ConnectedCallback */
|
|
6253
|
-
, vm);
|
|
5882
|
+
logOperationEnd(3 /* OperationId.ConnectedCallback */, vm);
|
|
6254
5883
|
}
|
|
6255
5884
|
}
|
|
6256
|
-
|
|
6257
5885
|
function hasWireAdapters(vm) {
|
|
6258
5886
|
return getOwnPropertyNames$1(vm.def.wire).length > 0;
|
|
6259
5887
|
}
|
|
6260
|
-
|
|
6261
5888
|
function runDisconnectedCallback(vm) {
|
|
6262
5889
|
if (process.env.NODE_ENV !== 'production') {
|
|
6263
|
-
assert.isTrue(vm.state !== 2
|
|
6264
|
-
/* VMState.disconnected */
|
|
6265
|
-
, `${vm} must be inserted.`);
|
|
5890
|
+
assert.isTrue(vm.state !== 2 /* VMState.disconnected */, `${vm} must be inserted.`);
|
|
6266
5891
|
}
|
|
6267
|
-
|
|
6268
5892
|
if (isFalse(vm.isDirty)) {
|
|
6269
5893
|
// this guarantees that if the component is reused/reinserted,
|
|
6270
5894
|
// it will be re-rendered because we are disconnecting the reactivity
|
|
@@ -6272,67 +5896,54 @@
|
|
|
6272
5896
|
// of disconnected components.
|
|
6273
5897
|
vm.isDirty = true;
|
|
6274
5898
|
}
|
|
6275
|
-
|
|
6276
|
-
|
|
6277
|
-
/* VMState.disconnected */
|
|
6278
|
-
; // reporting disconnection
|
|
6279
|
-
|
|
5899
|
+
vm.state = 2 /* VMState.disconnected */;
|
|
5900
|
+
// reporting disconnection
|
|
6280
5901
|
const {
|
|
6281
5902
|
disconnected
|
|
6282
5903
|
} = Services;
|
|
6283
|
-
|
|
6284
5904
|
if (disconnected) {
|
|
6285
5905
|
invokeServiceHook(vm, disconnected);
|
|
6286
5906
|
}
|
|
6287
|
-
|
|
6288
5907
|
if (hasWireAdapters(vm)) {
|
|
6289
5908
|
disconnectWireAdapters(vm);
|
|
6290
5909
|
}
|
|
6291
|
-
|
|
6292
5910
|
const {
|
|
6293
5911
|
disconnectedCallback
|
|
6294
5912
|
} = vm.def;
|
|
6295
|
-
|
|
6296
5913
|
if (!isUndefined$1(disconnectedCallback)) {
|
|
6297
|
-
logOperationStart(5
|
|
6298
|
-
/* OperationId.DisconnectedCallback */
|
|
6299
|
-
, vm);
|
|
5914
|
+
logOperationStart(5 /* OperationId.DisconnectedCallback */, vm);
|
|
6300
5915
|
invokeComponentCallback(vm, disconnectedCallback);
|
|
6301
|
-
logOperationEnd(5
|
|
6302
|
-
/* OperationId.DisconnectedCallback */
|
|
6303
|
-
, vm);
|
|
5916
|
+
logOperationEnd(5 /* OperationId.DisconnectedCallback */, vm);
|
|
6304
5917
|
}
|
|
6305
5918
|
}
|
|
6306
|
-
|
|
6307
5919
|
function runChildNodesDisconnectedCallback(vm) {
|
|
6308
5920
|
const {
|
|
6309
5921
|
velements: vCustomElementCollection
|
|
6310
|
-
} = vm;
|
|
5922
|
+
} = vm;
|
|
5923
|
+
// Reporting disconnection for every child in inverse order since they are
|
|
6311
5924
|
// inserted in reserved order.
|
|
6312
|
-
|
|
6313
5925
|
for (let i = vCustomElementCollection.length - 1; i >= 0; i -= 1) {
|
|
6314
5926
|
const {
|
|
6315
5927
|
elm
|
|
6316
|
-
} = vCustomElementCollection[i];
|
|
5928
|
+
} = vCustomElementCollection[i];
|
|
5929
|
+
// There are two cases where the element could be undefined:
|
|
6317
5930
|
// * when there is an error during the construction phase, and an error
|
|
6318
5931
|
// boundary picks it, there is a possibility that the VCustomElement
|
|
6319
5932
|
// is not properly initialized, and therefore is should be ignored.
|
|
6320
5933
|
// * when slotted custom element is not used by the element where it is
|
|
6321
5934
|
// slotted into it, as a result, the custom element was never
|
|
6322
5935
|
// initialized.
|
|
6323
|
-
|
|
6324
5936
|
if (!isUndefined$1(elm)) {
|
|
6325
|
-
const childVM = getAssociatedVMIfPresent(elm);
|
|
5937
|
+
const childVM = getAssociatedVMIfPresent(elm);
|
|
5938
|
+
// The VM associated with the element might be associated undefined
|
|
6326
5939
|
// in the case where the VM failed in the middle of its creation,
|
|
6327
5940
|
// eg: constructor throwing before invoking super().
|
|
6328
|
-
|
|
6329
5941
|
if (!isUndefined$1(childVM)) {
|
|
6330
5942
|
resetComponentStateWhenRemoved(childVM);
|
|
6331
5943
|
}
|
|
6332
5944
|
}
|
|
6333
5945
|
}
|
|
6334
5946
|
}
|
|
6335
|
-
|
|
6336
5947
|
function runLightChildNodesDisconnectedCallback(vm) {
|
|
6337
5948
|
const {
|
|
6338
5949
|
aChildren: adoptedChildren
|
|
@@ -6346,23 +5957,15 @@
|
|
|
6346
5957
|
* custom element itself will trigger the removal of anything slotted or anything
|
|
6347
5958
|
* defined on its shadow.
|
|
6348
5959
|
*/
|
|
6349
|
-
|
|
6350
|
-
|
|
6351
5960
|
function recursivelyDisconnectChildren(vnodes) {
|
|
6352
5961
|
for (let i = 0, len = vnodes.length; i < len; i += 1) {
|
|
6353
5962
|
const vnode = vnodes[i];
|
|
6354
|
-
|
|
6355
5963
|
if (!isNull(vnode) && !isUndefined$1(vnode.elm)) {
|
|
6356
5964
|
switch (vnode.type) {
|
|
6357
|
-
case 2
|
|
6358
|
-
/* VNodeType.Element */
|
|
6359
|
-
:
|
|
5965
|
+
case 2 /* VNodeType.Element */:
|
|
6360
5966
|
recursivelyDisconnectChildren(vnode.children);
|
|
6361
5967
|
break;
|
|
6362
|
-
|
|
6363
|
-
case 3
|
|
6364
|
-
/* VNodeType.CustomElement */
|
|
6365
|
-
:
|
|
5968
|
+
case 3 /* VNodeType.CustomElement */:
|
|
6366
5969
|
{
|
|
6367
5970
|
const vm = getAssociatedVM(vnode.elm);
|
|
6368
5971
|
resetComponentStateWhenRemoved(vm);
|
|
@@ -6371,12 +5974,11 @@
|
|
|
6371
5974
|
}
|
|
6372
5975
|
}
|
|
6373
5976
|
}
|
|
6374
|
-
}
|
|
5977
|
+
}
|
|
5978
|
+
// This is a super optimized mechanism to remove the content of the root node (shadow root
|
|
6375
5979
|
// for shadow DOM components and the root element itself for light DOM) without having to go
|
|
6376
5980
|
// into snabbdom. Especially useful when the reset is a consequence of an error, in which case the
|
|
6377
5981
|
// children VNodes might not be representing the current state of the DOM.
|
|
6378
|
-
|
|
6379
|
-
|
|
6380
5982
|
function resetComponentRoot(vm) {
|
|
6381
5983
|
const {
|
|
6382
5984
|
children,
|
|
@@ -6385,15 +5987,12 @@
|
|
|
6385
5987
|
remove
|
|
6386
5988
|
}
|
|
6387
5989
|
} = vm;
|
|
6388
|
-
|
|
6389
5990
|
for (let i = 0, len = children.length; i < len; i++) {
|
|
6390
5991
|
const child = children[i];
|
|
6391
|
-
|
|
6392
5992
|
if (!isNull(child) && !isUndefined$1(child.elm)) {
|
|
6393
5993
|
remove(child.elm, renderRoot);
|
|
6394
5994
|
}
|
|
6395
5995
|
}
|
|
6396
|
-
|
|
6397
5996
|
vm.children = EmptyArray;
|
|
6398
5997
|
runChildNodesDisconnectedCallback(vm);
|
|
6399
5998
|
vm.velements = EmptyArray;
|
|
@@ -6402,58 +6001,43 @@
|
|
|
6402
6001
|
if (isTrue(vm.isScheduled)) {
|
|
6403
6002
|
return;
|
|
6404
6003
|
}
|
|
6405
|
-
|
|
6406
6004
|
vm.isScheduled = true;
|
|
6407
|
-
|
|
6408
6005
|
if (rehydrateQueue.length === 0) {
|
|
6409
6006
|
addCallbackToNextTick(flushRehydrationQueue);
|
|
6410
6007
|
}
|
|
6411
|
-
|
|
6412
6008
|
ArrayPush$1.call(rehydrateQueue, vm);
|
|
6413
6009
|
}
|
|
6414
|
-
|
|
6415
6010
|
function getErrorBoundaryVM(vm) {
|
|
6416
6011
|
let currentVm = vm;
|
|
6417
|
-
|
|
6418
6012
|
while (!isNull(currentVm)) {
|
|
6419
6013
|
if (!isUndefined$1(currentVm.def.errorCallback)) {
|
|
6420
6014
|
return currentVm;
|
|
6421
6015
|
}
|
|
6422
|
-
|
|
6423
6016
|
currentVm = currentVm.owner;
|
|
6424
6017
|
}
|
|
6425
6018
|
}
|
|
6426
|
-
|
|
6427
6019
|
function runWithBoundaryProtection(vm, owner, pre, job, post) {
|
|
6428
6020
|
let error;
|
|
6429
6021
|
pre();
|
|
6430
|
-
|
|
6431
6022
|
try {
|
|
6432
6023
|
job();
|
|
6433
6024
|
} catch (e) {
|
|
6434
6025
|
error = Object(e);
|
|
6435
6026
|
} finally {
|
|
6436
6027
|
post();
|
|
6437
|
-
|
|
6438
6028
|
if (!isUndefined$1(error)) {
|
|
6439
6029
|
addErrorComponentStack(vm, error);
|
|
6440
6030
|
const errorBoundaryVm = isNull(owner) ? undefined : getErrorBoundaryVM(owner);
|
|
6441
|
-
|
|
6442
6031
|
if (isUndefined$1(errorBoundaryVm)) {
|
|
6443
6032
|
throw error; // eslint-disable-line no-unsafe-finally
|
|
6444
6033
|
}
|
|
6445
6034
|
|
|
6446
6035
|
resetComponentRoot(vm); // remove offenders
|
|
6447
|
-
|
|
6448
|
-
|
|
6449
|
-
/* OperationId.ErrorCallback */
|
|
6450
|
-
, vm); // error boundaries must have an ErrorCallback
|
|
6451
|
-
|
|
6036
|
+
logOperationStart(6 /* OperationId.ErrorCallback */, vm);
|
|
6037
|
+
// error boundaries must have an ErrorCallback
|
|
6452
6038
|
const errorCallback = errorBoundaryVm.def.errorCallback;
|
|
6453
6039
|
invokeComponentCallback(errorBoundaryVm, errorCallback, [error, error.wcStack]);
|
|
6454
|
-
logOperationEnd(6
|
|
6455
|
-
/* OperationId.ErrorCallback */
|
|
6456
|
-
, vm);
|
|
6040
|
+
logOperationEnd(6 /* OperationId.ErrorCallback */, vm);
|
|
6457
6041
|
}
|
|
6458
6042
|
}
|
|
6459
6043
|
}
|
|
@@ -6467,7 +6051,6 @@
|
|
|
6467
6051
|
// content of the shadowRoot, this way we can guarantee that all children
|
|
6468
6052
|
// elements will be throw away, and new instances will be created.
|
|
6469
6053
|
vm.cmpTemplate = () => [];
|
|
6470
|
-
|
|
6471
6054
|
if (isFalse(vm.isDirty)) {
|
|
6472
6055
|
// forcing the vm to rehydrate in the next tick
|
|
6473
6056
|
markComponentAsDirty(vm);
|
|
@@ -6483,6 +6066,7 @@
|
|
|
6483
6066
|
*/
|
|
6484
6067
|
const DeprecatedWiredElementHost = '$$DeprecatedWiredElementHostKey$$';
|
|
6485
6068
|
const DeprecatedWiredParamsMeta = '$$DeprecatedWiredParamsMetaKey$$';
|
|
6069
|
+
const WIRE_DEBUG_ENTRY = '@wire';
|
|
6486
6070
|
const WireMetaMap = new Map();
|
|
6487
6071
|
class WireContextRegistrationEvent extends CustomEvent {
|
|
6488
6072
|
constructor(adapterToken, {
|
|
@@ -6502,15 +6086,12 @@
|
|
|
6502
6086
|
}
|
|
6503
6087
|
});
|
|
6504
6088
|
}
|
|
6505
|
-
|
|
6506
6089
|
}
|
|
6507
|
-
|
|
6508
6090
|
function createFieldDataCallback(vm, name) {
|
|
6509
6091
|
return value => {
|
|
6510
6092
|
updateComponentValue(vm, name, value);
|
|
6511
6093
|
};
|
|
6512
6094
|
}
|
|
6513
|
-
|
|
6514
6095
|
function createMethodDataCallback(vm, method) {
|
|
6515
6096
|
return value => {
|
|
6516
6097
|
// dispatching new value into the wired method
|
|
@@ -6520,45 +6101,40 @@
|
|
|
6520
6101
|
}, noop);
|
|
6521
6102
|
};
|
|
6522
6103
|
}
|
|
6523
|
-
|
|
6524
6104
|
function createConfigWatcher(component, configCallback, callbackWhenConfigIsReady) {
|
|
6525
|
-
let hasPendingConfig = false;
|
|
6526
|
-
|
|
6105
|
+
let hasPendingConfig = false;
|
|
6106
|
+
// creating the reactive observer for reactive params when needed
|
|
6527
6107
|
const ro = createReactiveObserver(() => {
|
|
6528
6108
|
if (hasPendingConfig === false) {
|
|
6529
|
-
hasPendingConfig = true;
|
|
6530
|
-
|
|
6109
|
+
hasPendingConfig = true;
|
|
6110
|
+
// collect new config in the micro-task
|
|
6531
6111
|
Promise.resolve().then(() => {
|
|
6532
|
-
hasPendingConfig = false;
|
|
6533
|
-
|
|
6534
|
-
ro.reset();
|
|
6535
|
-
|
|
6112
|
+
hasPendingConfig = false;
|
|
6113
|
+
// resetting current reactive params
|
|
6114
|
+
ro.reset();
|
|
6115
|
+
// dispatching a new config due to a change in the configuration
|
|
6536
6116
|
computeConfigAndUpdate();
|
|
6537
6117
|
});
|
|
6538
6118
|
}
|
|
6539
6119
|
});
|
|
6540
|
-
|
|
6541
6120
|
const computeConfigAndUpdate = () => {
|
|
6542
6121
|
let config;
|
|
6543
|
-
ro.observe(() => config = configCallback(component));
|
|
6122
|
+
ro.observe(() => config = configCallback(component));
|
|
6123
|
+
// eslint-disable-next-line @lwc/lwc-internal/no-invalid-todo
|
|
6544
6124
|
// TODO: dev-mode validation of config based on the adapter.configSchema
|
|
6545
6125
|
// @ts-ignore it is assigned in the observe() callback
|
|
6546
|
-
|
|
6547
6126
|
callbackWhenConfigIsReady(config);
|
|
6548
6127
|
};
|
|
6549
|
-
|
|
6550
6128
|
return {
|
|
6551
6129
|
computeConfigAndUpdate,
|
|
6552
6130
|
ro
|
|
6553
6131
|
};
|
|
6554
6132
|
}
|
|
6555
|
-
|
|
6556
6133
|
function createContextWatcher(vm, wireDef, callbackWhenContextIsReady) {
|
|
6557
6134
|
const {
|
|
6558
6135
|
adapter
|
|
6559
6136
|
} = wireDef;
|
|
6560
6137
|
const adapterContextToken = getAdapterToken(adapter);
|
|
6561
|
-
|
|
6562
6138
|
if (isUndefined$1(adapterContextToken)) {
|
|
6563
6139
|
return; // no provider found, nothing to be done
|
|
6564
6140
|
}
|
|
@@ -6572,8 +6148,8 @@
|
|
|
6572
6148
|
renderer: {
|
|
6573
6149
|
dispatchEvent
|
|
6574
6150
|
}
|
|
6575
|
-
} = vm;
|
|
6576
|
-
|
|
6151
|
+
} = vm;
|
|
6152
|
+
// waiting for the component to be connected to formally request the context via the token
|
|
6577
6153
|
ArrayPush$1.call(wiredConnecting, () => {
|
|
6578
6154
|
// This event is responsible for connecting the host element with another
|
|
6579
6155
|
// element in the composed path that is providing contextual data. The provider
|
|
@@ -6586,18 +6162,15 @@
|
|
|
6586
6162
|
// TODO: dev-mode validation of config based on the adapter.contextSchema
|
|
6587
6163
|
callbackWhenContextIsReady(newContext);
|
|
6588
6164
|
},
|
|
6589
|
-
|
|
6590
6165
|
setDisconnectedCallback(disconnectCallback) {
|
|
6591
6166
|
// adds this callback into the disconnect bucket so it gets disconnected from parent
|
|
6592
6167
|
// the the element hosting the wire is disconnected
|
|
6593
6168
|
ArrayPush$1.call(wiredDisconnecting, disconnectCallback);
|
|
6594
6169
|
}
|
|
6595
|
-
|
|
6596
6170
|
});
|
|
6597
6171
|
dispatchEvent(elm, contextRegistrationEvent);
|
|
6598
6172
|
});
|
|
6599
6173
|
}
|
|
6600
|
-
|
|
6601
6174
|
function createConnector(vm, name, wireDef) {
|
|
6602
6175
|
const {
|
|
6603
6176
|
method,
|
|
@@ -6605,10 +6178,27 @@
|
|
|
6605
6178
|
configCallback,
|
|
6606
6179
|
dynamic
|
|
6607
6180
|
} = wireDef;
|
|
6608
|
-
|
|
6181
|
+
let debugInfo;
|
|
6182
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
6183
|
+
const wiredPropOrMethod = isUndefined$1(method) ? name : method.name;
|
|
6184
|
+
debugInfo = create(null);
|
|
6185
|
+
debugInfo.wasDataProvisionedForConfig = false;
|
|
6186
|
+
vm.debugInfo[WIRE_DEBUG_ENTRY][wiredPropOrMethod] = debugInfo;
|
|
6187
|
+
}
|
|
6188
|
+
const fieldOrMethodCallback = isUndefined$1(method) ? createFieldDataCallback(vm, name) : createMethodDataCallback(vm, method);
|
|
6189
|
+
const dataCallback = value => {
|
|
6190
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
6191
|
+
debugInfo.data = value;
|
|
6192
|
+
// Note: most of the time, the data provided is for the current config, but there may be
|
|
6193
|
+
// some conditions in which it does not, ex:
|
|
6194
|
+
// race conditions in a poor network while the adapter does not cancel a previous request.
|
|
6195
|
+
debugInfo.wasDataProvisionedForConfig = true;
|
|
6196
|
+
}
|
|
6197
|
+
fieldOrMethodCallback(value);
|
|
6198
|
+
};
|
|
6609
6199
|
let context;
|
|
6610
|
-
let connector;
|
|
6611
|
-
|
|
6200
|
+
let connector;
|
|
6201
|
+
// Workaround to pass the component element associated to this wire adapter instance.
|
|
6612
6202
|
defineProperty(dataCallback, DeprecatedWiredElementHost, {
|
|
6613
6203
|
value: vm.elm
|
|
6614
6204
|
});
|
|
@@ -6619,41 +6209,41 @@
|
|
|
6619
6209
|
// job
|
|
6620
6210
|
connector = new adapter(dataCallback);
|
|
6621
6211
|
}, noop);
|
|
6622
|
-
|
|
6623
6212
|
const updateConnectorConfig = config => {
|
|
6624
6213
|
// every time the config is recomputed due to tracking,
|
|
6625
6214
|
// this callback will be invoked with the new computed config
|
|
6626
6215
|
runWithBoundaryProtection(vm, vm, noop, () => {
|
|
6627
6216
|
// job
|
|
6217
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
6218
|
+
debugInfo.config = config;
|
|
6219
|
+
debugInfo.context = context;
|
|
6220
|
+
debugInfo.wasDataProvisionedForConfig = false;
|
|
6221
|
+
}
|
|
6628
6222
|
connector.update(config, context);
|
|
6629
6223
|
}, noop);
|
|
6630
|
-
};
|
|
6224
|
+
};
|
|
6225
|
+
// Computes the current wire config and calls the update method on the wire adapter.
|
|
6631
6226
|
// If it has params, we will need to observe changes in the next tick.
|
|
6632
|
-
|
|
6633
|
-
|
|
6634
6227
|
const {
|
|
6635
6228
|
computeConfigAndUpdate,
|
|
6636
6229
|
ro
|
|
6637
|
-
} = createConfigWatcher(vm.component, configCallback, updateConnectorConfig);
|
|
6638
|
-
|
|
6230
|
+
} = createConfigWatcher(vm.component, configCallback, updateConnectorConfig);
|
|
6231
|
+
// if the adapter needs contextualization, we need to watch for new context and push it alongside the config
|
|
6639
6232
|
if (!isUndefined$1(adapter.contextSchema)) {
|
|
6640
6233
|
createContextWatcher(vm, wireDef, newContext => {
|
|
6641
6234
|
// every time the context is pushed into this component,
|
|
6642
6235
|
// this callback will be invoked with the new computed context
|
|
6643
6236
|
if (context !== newContext) {
|
|
6644
|
-
context = newContext;
|
|
6237
|
+
context = newContext;
|
|
6238
|
+
// Note: when new context arrives, the config will be recomputed and pushed along side the new
|
|
6645
6239
|
// context, this is to preserve the identity characteristics, config should not have identity
|
|
6646
6240
|
// (ever), while context can have identity
|
|
6647
|
-
|
|
6648
|
-
if (vm.state === 1
|
|
6649
|
-
/* VMState.connected */
|
|
6650
|
-
) {
|
|
6241
|
+
if (vm.state === 1 /* VMState.connected */) {
|
|
6651
6242
|
computeConfigAndUpdate();
|
|
6652
6243
|
}
|
|
6653
6244
|
}
|
|
6654
6245
|
});
|
|
6655
6246
|
}
|
|
6656
|
-
|
|
6657
6247
|
return {
|
|
6658
6248
|
// @ts-ignore the boundary protection executes sync, connector is always defined
|
|
6659
6249
|
connector,
|
|
@@ -6661,7 +6251,6 @@
|
|
|
6661
6251
|
resetConfigWatcher: () => ro.reset()
|
|
6662
6252
|
};
|
|
6663
6253
|
}
|
|
6664
|
-
|
|
6665
6254
|
const AdapterToTokenMap = new Map();
|
|
6666
6255
|
function getAdapterToken(adapter) {
|
|
6667
6256
|
return AdapterToTokenMap.get(adapter);
|
|
@@ -6674,7 +6263,6 @@
|
|
|
6674
6263
|
if (adapter.adapter) {
|
|
6675
6264
|
adapter = adapter.adapter;
|
|
6676
6265
|
}
|
|
6677
|
-
|
|
6678
6266
|
const method = descriptor.value;
|
|
6679
6267
|
const def = {
|
|
6680
6268
|
adapter,
|
|
@@ -6689,7 +6277,6 @@
|
|
|
6689
6277
|
if (adapter.adapter) {
|
|
6690
6278
|
adapter = adapter.adapter;
|
|
6691
6279
|
}
|
|
6692
|
-
|
|
6693
6280
|
const def = {
|
|
6694
6281
|
adapter,
|
|
6695
6282
|
configCallback,
|
|
@@ -6704,17 +6291,15 @@
|
|
|
6704
6291
|
wire
|
|
6705
6292
|
}
|
|
6706
6293
|
} = vm;
|
|
6294
|
+
vm.debugInfo[WIRE_DEBUG_ENTRY] = create(null);
|
|
6707
6295
|
const wiredConnecting = context.wiredConnecting = [];
|
|
6708
6296
|
const wiredDisconnecting = context.wiredDisconnecting = [];
|
|
6709
|
-
|
|
6710
6297
|
for (const fieldNameOrMethod in wire) {
|
|
6711
6298
|
const descriptor = wire[fieldNameOrMethod];
|
|
6712
6299
|
const wireDef = WireMetaMap.get(descriptor);
|
|
6713
|
-
|
|
6714
6300
|
if (process.env.NODE_ENV !== 'production') {
|
|
6715
6301
|
assert.invariant(wireDef, `Internal Error: invalid wire definition found.`);
|
|
6716
6302
|
}
|
|
6717
|
-
|
|
6718
6303
|
if (!isUndefined$1(wireDef)) {
|
|
6719
6304
|
const {
|
|
6720
6305
|
connector,
|
|
@@ -6724,14 +6309,12 @@
|
|
|
6724
6309
|
const hasDynamicParams = wireDef.dynamic.length > 0;
|
|
6725
6310
|
ArrayPush$1.call(wiredConnecting, () => {
|
|
6726
6311
|
connector.connect();
|
|
6727
|
-
|
|
6728
6312
|
if (!lwcRuntimeFlags.ENABLE_WIRE_SYNC_EMIT) {
|
|
6729
6313
|
if (hasDynamicParams) {
|
|
6730
6314
|
Promise.resolve().then(computeConfigAndUpdate);
|
|
6731
6315
|
return;
|
|
6732
6316
|
}
|
|
6733
6317
|
}
|
|
6734
|
-
|
|
6735
6318
|
computeConfigAndUpdate();
|
|
6736
6319
|
});
|
|
6737
6320
|
ArrayPush$1.call(wiredDisconnecting, () => {
|
|
@@ -6745,7 +6328,6 @@
|
|
|
6745
6328
|
const {
|
|
6746
6329
|
wiredConnecting
|
|
6747
6330
|
} = vm.context;
|
|
6748
|
-
|
|
6749
6331
|
for (let i = 0, len = wiredConnecting.length; i < len; i += 1) {
|
|
6750
6332
|
wiredConnecting[i]();
|
|
6751
6333
|
}
|
|
@@ -7359,7 +6941,87 @@
|
|
|
7359
6941
|
}
|
|
7360
6942
|
return ctor;
|
|
7361
6943
|
}
|
|
7362
|
-
/* version: 2.
|
|
6944
|
+
/* version: 2.30.0 */
|
|
6945
|
+
|
|
6946
|
+
/*
|
|
6947
|
+
* Copyright (c) 2018, salesforce.com, inc.
|
|
6948
|
+
* All rights reserved.
|
|
6949
|
+
* SPDX-License-Identifier: MIT
|
|
6950
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
6951
|
+
*/
|
|
6952
|
+
/**
|
|
6953
|
+
* Displays the header for a custom element.
|
|
6954
|
+
*
|
|
6955
|
+
* @param ce the custom element
|
|
6956
|
+
* @param componentInstance component instance associated with the custom element.
|
|
6957
|
+
*/
|
|
6958
|
+
function getHeaderForCustomElement(ce, componentInstance) {
|
|
6959
|
+
// [element]
|
|
6960
|
+
// LWC component instance: [vm.component]
|
|
6961
|
+
return [
|
|
6962
|
+
'div',
|
|
6963
|
+
{},
|
|
6964
|
+
['object', { object: ce, config: { skip: true } }],
|
|
6965
|
+
[
|
|
6966
|
+
'div',
|
|
6967
|
+
{},
|
|
6968
|
+
['span', { style: 'margin: 0 5px; color: red' }, 'LWC:'],
|
|
6969
|
+
['object', { object: componentInstance }],
|
|
6970
|
+
],
|
|
6971
|
+
];
|
|
6972
|
+
}
|
|
6973
|
+
function getHeaderForComponentInstance(componentInstance, debugInfo) {
|
|
6974
|
+
if (keys(debugInfo).length === 0) {
|
|
6975
|
+
// there is no debug information, no need to customize this component instance
|
|
6976
|
+
return null;
|
|
6977
|
+
}
|
|
6978
|
+
// [component]
|
|
6979
|
+
// Debug information: [vm.debugInfo]
|
|
6980
|
+
return [
|
|
6981
|
+
'div',
|
|
6982
|
+
{},
|
|
6983
|
+
['object', { object: componentInstance, config: { skip: true } }],
|
|
6984
|
+
[
|
|
6985
|
+
'div',
|
|
6986
|
+
{},
|
|
6987
|
+
['span', { style: 'margin: 0 5px; color: red' }, 'Debug:'],
|
|
6988
|
+
['object', { object: debugInfo }],
|
|
6989
|
+
],
|
|
6990
|
+
];
|
|
6991
|
+
}
|
|
6992
|
+
const LightningElementFormatter = {
|
|
6993
|
+
name: 'LightningElementFormatter',
|
|
6994
|
+
header(obj, config) {
|
|
6995
|
+
const vm = getAssociatedVMIfPresent(obj);
|
|
6996
|
+
if (!isUndefined$1(vm) && (isUndefined$1(config) || !config.skip)) {
|
|
6997
|
+
if (obj instanceof HTMLElement) {
|
|
6998
|
+
return getHeaderForCustomElement(obj, vm.component);
|
|
6999
|
+
}
|
|
7000
|
+
else {
|
|
7001
|
+
return getHeaderForComponentInstance(obj, vm.debugInfo);
|
|
7002
|
+
}
|
|
7003
|
+
}
|
|
7004
|
+
return null;
|
|
7005
|
+
},
|
|
7006
|
+
hasBody() {
|
|
7007
|
+
return false;
|
|
7008
|
+
},
|
|
7009
|
+
};
|
|
7010
|
+
|
|
7011
|
+
/*
|
|
7012
|
+
* Copyright (c) 2018, salesforce.com, inc.
|
|
7013
|
+
* All rights reserved.
|
|
7014
|
+
* SPDX-License-Identifier: MIT
|
|
7015
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
7016
|
+
*/
|
|
7017
|
+
function init() {
|
|
7018
|
+
const devtoolsFormatters = _globalThis.devtoolsFormatters || [];
|
|
7019
|
+
ArrayPush$1.call(devtoolsFormatters, LightningElementFormatter);
|
|
7020
|
+
_globalThis.devtoolsFormatters = devtoolsFormatters;
|
|
7021
|
+
}
|
|
7022
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
7023
|
+
init();
|
|
7024
|
+
}
|
|
7363
7025
|
|
|
7364
7026
|
/*
|
|
7365
7027
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
@@ -8058,10 +7720,10 @@
|
|
|
8058
7720
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
8059
7721
|
*/
|
|
8060
7722
|
let createScopedConstructor;
|
|
8061
|
-
let CachedHTMLElement;
|
|
7723
|
+
let CachedHTMLElement;
|
|
7724
|
+
// We only call `createScopedRegistry()` if the browser supports custom elements and
|
|
8062
7725
|
// ENABLE_SCOPED_CUSTOM_ELEMENT_REGISTRY is enabled, because we don't want to patch eagerly if the flag is disabled
|
|
8063
7726
|
// or we're in a legacy browser.
|
|
8064
|
-
|
|
8065
7727
|
if (lwcRuntimeFlags.ENABLE_SCOPED_CUSTOM_ELEMENT_REGISTRY) {
|
|
8066
7728
|
if (hasCustomElements) {
|
|
8067
7729
|
// If ENABLE_SCOPED_CUSTOM_ELEMENT_REGISTRY is true, then we eagerly initialize the scoped registry.
|
|
@@ -8075,7 +7737,8 @@
|
|
|
8075
7737
|
// 4. `customElements.define('x-foo', Ctor)` // throws error because class is bound to stale HTMLElement
|
|
8076
7738
|
//
|
|
8077
7739
|
// To reduce the risk of this, it's safer to patch the registry eagerly.
|
|
8078
|
-
createScopedConstructor = createScopedRegistry();
|
|
7740
|
+
createScopedConstructor = createScopedRegistry();
|
|
7741
|
+
// It's important to cache window.HTMLElement here. Otherwise, someone else could overwrite window.HTMLElement (e.g.
|
|
8079
7742
|
// another copy of the engine, or another scoping implementation) and we would get "Illegal constructor" errors
|
|
8080
7743
|
// because the HTMLElement prototypes are mixed up.
|
|
8081
7744
|
//
|
|
@@ -8083,14 +7746,12 @@
|
|
|
8083
7746
|
// with that version of HTMLElement. So if you load two copies of the scoping implementation in the same environment,
|
|
8084
7747
|
// the second one may accidentally grab window.HTMLElement from the first (when doing `class extends HTMLElement`).
|
|
8085
7748
|
// Caching avoids this problem.
|
|
8086
|
-
|
|
8087
7749
|
CachedHTMLElement = window.HTMLElement;
|
|
8088
7750
|
}
|
|
8089
|
-
}
|
|
7751
|
+
}
|
|
7752
|
+
// Creates a constructor that is intended to be used as the UserConstructor in a scoped (pivots) registry.
|
|
8090
7753
|
// In this case, the upgradeCallback only needs to be defined once because we create these on-demand,
|
|
8091
7754
|
// multiple times per tag name.
|
|
8092
|
-
|
|
8093
|
-
|
|
8094
7755
|
const createUserConstructor = (upgradeCallback, connectedCallback, disconnectedCallback, HTMLElementToExtend) => {
|
|
8095
7756
|
// TODO [#2972]: this class should expose observedAttributes as necessary
|
|
8096
7757
|
return class UserConstructor extends HTMLElementToExtend {
|
|
@@ -8098,24 +7759,19 @@
|
|
|
8098
7759
|
super();
|
|
8099
7760
|
upgradeCallback(this);
|
|
8100
7761
|
}
|
|
8101
|
-
|
|
8102
7762
|
connectedCallback() {
|
|
8103
7763
|
connectedCallback(this);
|
|
8104
7764
|
}
|
|
8105
|
-
|
|
8106
7765
|
disconnectedCallback() {
|
|
8107
7766
|
disconnectedCallback(this);
|
|
8108
7767
|
}
|
|
8109
|
-
|
|
8110
7768
|
};
|
|
8111
7769
|
};
|
|
8112
|
-
|
|
8113
7770
|
function createCustomElementScoped(tagName, upgradeCallback, connectedCallback, disconnectedCallback) {
|
|
8114
7771
|
if (isUndefined$1(createScopedConstructor) || isUndefined$1(CachedHTMLElement)) {
|
|
8115
7772
|
// This error should be impossible to hit
|
|
8116
7773
|
throw new Error('The flag ENABLE_SCOPED_CUSTOM_ELEMENT_REGISTRY must be set to true to use this feature');
|
|
8117
7774
|
}
|
|
8118
|
-
|
|
8119
7775
|
const UserConstructor = createUserConstructor(upgradeCallback, connectedCallback, disconnectedCallback, CachedHTMLElement);
|
|
8120
7776
|
const ScopedConstructor = createScopedConstructor(tagName, UserConstructor);
|
|
8121
7777
|
return new ScopedConstructor(UserConstructor);
|
|
@@ -8140,9 +7796,7 @@
|
|
|
8140
7796
|
* between LWC components and third-party elements. This uses a similar trick to #2, but is much more complex
|
|
8141
7797
|
* because it must patch the global `customElements` and `HTMLElement` objects.
|
|
8142
7798
|
*/
|
|
8143
|
-
|
|
8144
7799
|
let createCustomElement;
|
|
8145
|
-
|
|
8146
7800
|
if (hasCustomElements) {
|
|
8147
7801
|
if (lwcRuntimeFlags.ENABLE_SCOPED_CUSTOM_ELEMENT_REGISTRY) {
|
|
8148
7802
|
createCustomElement = createCustomElementScoped;
|
|
@@ -8215,7 +7869,7 @@
|
|
|
8215
7869
|
function isNull(obj) {
|
|
8216
7870
|
return obj === null;
|
|
8217
7871
|
}
|
|
8218
|
-
/** version: 2.
|
|
7872
|
+
/** version: 2.30.0 */
|
|
8219
7873
|
|
|
8220
7874
|
/*
|
|
8221
7875
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
@@ -8604,23 +8258,19 @@
|
|
|
8604
8258
|
* SPDX-License-Identifier: MIT
|
|
8605
8259
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
8606
8260
|
*/
|
|
8261
|
+
// TODO [#2472]: Remove this workaround when appropriate.
|
|
8607
8262
|
// eslint-disable-next-line @lwc/lwc-internal/no-global-node
|
|
8608
|
-
|
|
8609
8263
|
const _Node$1 = Node;
|
|
8610
8264
|
const ConnectingSlot = new WeakMap();
|
|
8611
8265
|
const DisconnectingSlot = new WeakMap();
|
|
8612
|
-
|
|
8613
8266
|
function callNodeSlot(node, slot) {
|
|
8614
8267
|
if (process.env.NODE_ENV !== 'production') {
|
|
8615
8268
|
assert.isTrue(node, `callNodeSlot() should not be called for a non-object`);
|
|
8616
8269
|
}
|
|
8617
|
-
|
|
8618
8270
|
const fn = slot.get(node);
|
|
8619
|
-
|
|
8620
8271
|
if (!isUndefined$1(fn)) {
|
|
8621
8272
|
fn(node);
|
|
8622
8273
|
}
|
|
8623
|
-
|
|
8624
8274
|
return node; // for convenience
|
|
8625
8275
|
}
|
|
8626
8276
|
|
|
@@ -8638,24 +8288,20 @@
|
|
|
8638
8288
|
const appendedNode = appendChild.call(this, newChild);
|
|
8639
8289
|
return callNodeSlot(appendedNode, ConnectingSlot);
|
|
8640
8290
|
},
|
|
8641
|
-
|
|
8642
8291
|
insertBefore(newChild, referenceNode) {
|
|
8643
8292
|
const insertedNode = insertBefore.call(this, newChild, referenceNode);
|
|
8644
8293
|
return callNodeSlot(insertedNode, ConnectingSlot);
|
|
8645
8294
|
},
|
|
8646
|
-
|
|
8647
8295
|
removeChild(oldChild) {
|
|
8648
8296
|
const removedNode = removeChild.call(this, oldChild);
|
|
8649
8297
|
return callNodeSlot(removedNode, DisconnectingSlot);
|
|
8650
8298
|
},
|
|
8651
|
-
|
|
8652
8299
|
replaceChild(newChild, oldChild) {
|
|
8653
8300
|
const replacedNode = replaceChild.call(this, newChild, oldChild);
|
|
8654
8301
|
callNodeSlot(replacedNode, DisconnectingSlot);
|
|
8655
8302
|
callNodeSlot(newChild, ConnectingSlot);
|
|
8656
8303
|
return replacedNode;
|
|
8657
8304
|
}
|
|
8658
|
-
|
|
8659
8305
|
});
|
|
8660
8306
|
}
|
|
8661
8307
|
/**
|
|
@@ -8669,59 +8315,49 @@
|
|
|
8669
8315
|
* const el = createElement('x-foo', { is: FooCtor });
|
|
8670
8316
|
* ```
|
|
8671
8317
|
*/
|
|
8672
|
-
|
|
8673
|
-
|
|
8674
8318
|
function createElement(sel, options) {
|
|
8675
8319
|
if (!isObject(options) || isNull(options)) {
|
|
8676
8320
|
throw new TypeError(`"createElement" function expects an object as second parameter but received "${toString$1(options)}".`);
|
|
8677
8321
|
}
|
|
8678
|
-
|
|
8679
8322
|
const Ctor = options.is;
|
|
8680
|
-
|
|
8681
8323
|
if (!isFunction$1(Ctor)) {
|
|
8682
8324
|
throw new TypeError(`"createElement" function expects an "is" option with a valid component constructor.`);
|
|
8683
8325
|
}
|
|
8684
|
-
|
|
8685
8326
|
const {
|
|
8686
8327
|
createCustomElement
|
|
8687
|
-
} = renderer;
|
|
8328
|
+
} = renderer;
|
|
8329
|
+
// tagName must be all lowercase, unfortunately, we have legacy code that is
|
|
8688
8330
|
// passing `sel` as a camel-case, which makes them invalid custom elements name
|
|
8689
8331
|
// the following line guarantees that this does not leaks beyond this point.
|
|
8690
|
-
|
|
8691
|
-
|
|
8692
|
-
|
|
8332
|
+
const tagName = StringToLowerCase.call(sel);
|
|
8333
|
+
// the custom element from the registry is expecting an upgrade callback
|
|
8693
8334
|
/**
|
|
8694
8335
|
* Note: if the upgradable constructor does not expect, or throw when we new it
|
|
8695
8336
|
* with a callback as the first argument, we could implement a more advanced
|
|
8696
8337
|
* mechanism that only passes that argument if the constructor is known to be
|
|
8697
8338
|
* an upgradable custom element.
|
|
8698
8339
|
*/
|
|
8699
|
-
|
|
8700
8340
|
const upgradeCallback = elm => {
|
|
8701
8341
|
createVM(elm, Ctor, renderer, {
|
|
8702
8342
|
tagName,
|
|
8703
8343
|
mode: options.mode !== 'closed' ? 'open' : 'closed',
|
|
8704
8344
|
owner: null
|
|
8705
8345
|
});
|
|
8706
|
-
|
|
8707
8346
|
if (!lwcRuntimeFlags.ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE) {
|
|
8708
8347
|
ConnectingSlot.set(elm, connectRootElement);
|
|
8709
8348
|
DisconnectingSlot.set(elm, disconnectRootElement);
|
|
8710
8349
|
}
|
|
8711
8350
|
};
|
|
8712
|
-
|
|
8713
8351
|
const connectedCallback = elm => {
|
|
8714
8352
|
if (lwcRuntimeFlags.ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE) {
|
|
8715
8353
|
connectRootElement(elm);
|
|
8716
8354
|
}
|
|
8717
8355
|
};
|
|
8718
|
-
|
|
8719
8356
|
const disconnectedCallback = elm => {
|
|
8720
8357
|
if (lwcRuntimeFlags.ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE) {
|
|
8721
8358
|
disconnectRootElement(elm);
|
|
8722
8359
|
}
|
|
8723
8360
|
};
|
|
8724
|
-
|
|
8725
8361
|
const element = createCustomElement(tagName, upgradeCallback, connectedCallback, disconnectedCallback);
|
|
8726
8362
|
return element;
|
|
8727
8363
|
}
|
|
@@ -8794,7 +8430,7 @@
|
|
|
8794
8430
|
});
|
|
8795
8431
|
freeze(LightningElement);
|
|
8796
8432
|
seal(LightningElement.prototype);
|
|
8797
|
-
/* version: 2.
|
|
8433
|
+
/* version: 2.30.0 */
|
|
8798
8434
|
|
|
8799
8435
|
exports.LightningElement = LightningElement;
|
|
8800
8436
|
exports.__unstable__ProfilerControl = profilerControl;
|