@lwc/engine-core 2.23.1 → 2.23.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/engine-core.cjs.js +786 -517
- package/dist/engine-core.js +786 -517
- package/package.json +3 -3
- package/types/framework/main.d.ts +1 -0
package/dist/engine-core.js
CHANGED
|
@@ -3089,30 +3089,67 @@ function createStylesheet(vm, stylesheets) {
|
|
|
3089
3089
|
* SPDX-License-Identifier: MIT
|
|
3090
3090
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
3091
3091
|
*/
|
|
3092
|
+
|
|
3093
|
+
function checkHasVM(elm) {
|
|
3094
|
+
const hasVM = !isUndefined$1(getAssociatedVMIfPresent(elm));
|
|
3095
|
+
|
|
3096
|
+
if (process.env.NODE_ENV !== 'production' && !hasVM) {
|
|
3097
|
+
// Occurs when an element is manually created with the same tag name as an existing LWC component. In that case,
|
|
3098
|
+
// we skip calling the LWC connectedCallback/disconnectedCallback logic and log an error.
|
|
3099
|
+
logError(`VM for tag name "${elm.tagName.toLowerCase()}" is undefined. ` + `This indicates that an element was created with this tag name, ` + `which is already reserved by an LWC component. Use lwc.createElement ` + `instead to create elements.`);
|
|
3100
|
+
}
|
|
3101
|
+
|
|
3102
|
+
return hasVM;
|
|
3103
|
+
}
|
|
3104
|
+
|
|
3092
3105
|
function getUpgradableConstructor(tagName, renderer) {
|
|
3093
|
-
|
|
3094
|
-
|
|
3095
|
-
|
|
3096
|
-
|
|
3097
|
-
|
|
3098
|
-
|
|
3099
|
-
|
|
3100
|
-
|
|
3106
|
+
const {
|
|
3107
|
+
getCustomElement,
|
|
3108
|
+
HTMLElementExported: RendererHTMLElement,
|
|
3109
|
+
defineCustomElement
|
|
3110
|
+
} = renderer; // Should never get a tag with upper case letter at this point, the compiler should
|
|
3111
|
+
// produce only tags with lowercase letters
|
|
3112
|
+
// But, for backwards compatibility, we will lower case the tagName
|
|
3113
|
+
|
|
3114
|
+
tagName = tagName.toLowerCase();
|
|
3115
|
+
let CE = getCustomElement(tagName);
|
|
3116
|
+
|
|
3117
|
+
if (!isUndefined$1(CE)) {
|
|
3118
|
+
return CE;
|
|
3119
|
+
}
|
|
3120
|
+
/**
|
|
3121
|
+
* LWC Upgradable Element reference to an element that was created
|
|
3122
|
+
* via the scoped registry mechanism, and that is ready to be upgraded.
|
|
3123
|
+
*/
|
|
3124
|
+
|
|
3125
|
+
|
|
3126
|
+
CE = class LWCUpgradableElement extends RendererHTMLElement {
|
|
3127
|
+
constructor(upgradeCallback) {
|
|
3128
|
+
super();
|
|
3129
|
+
|
|
3130
|
+
if (isFunction$1(upgradeCallback)) {
|
|
3131
|
+
upgradeCallback(this); // nothing to do with the result for now
|
|
3132
|
+
}
|
|
3101
3133
|
}
|
|
3102
|
-
|
|
3103
|
-
|
|
3104
|
-
|
|
3105
|
-
|
|
3106
|
-
CE =
|
|
3107
|
-
|
|
3108
|
-
|
|
3109
|
-
|
|
3110
|
-
upgradeCallback(this); // nothing to do with the result for now
|
|
3111
|
-
}
|
|
3112
|
-
}
|
|
3134
|
+
|
|
3135
|
+
};
|
|
3136
|
+
|
|
3137
|
+
if (lwcRuntimeFlags.ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE) {
|
|
3138
|
+
CE.prototype.connectedCallback = function () {
|
|
3139
|
+
if (checkHasVM(this)) {
|
|
3140
|
+
connectRootElement(this);
|
|
3141
|
+
}
|
|
3113
3142
|
};
|
|
3114
|
-
|
|
3115
|
-
|
|
3143
|
+
|
|
3144
|
+
CE.prototype.disconnectedCallback = function () {
|
|
3145
|
+
if (checkHasVM(this)) {
|
|
3146
|
+
disconnectRootElement(this);
|
|
3147
|
+
}
|
|
3148
|
+
};
|
|
3149
|
+
}
|
|
3150
|
+
|
|
3151
|
+
defineCustomElement(tagName, CE);
|
|
3152
|
+
return CE;
|
|
3116
3153
|
}
|
|
3117
3154
|
|
|
3118
3155
|
/*
|
|
@@ -3200,6 +3237,14 @@ function patchProps(oldVnode, vnode, renderer) {
|
|
|
3200
3237
|
// different than the one previously set.
|
|
3201
3238
|
if (isFirstPatch ||
|
|
3202
3239
|
cur !== (isLiveBindingProp(sel, key) ? getProperty(elm, key) : oldProps[key])) {
|
|
3240
|
+
// Additional verification if properties are supported by the element
|
|
3241
|
+
// Validation relies on html properties and public properties being defined on the element,
|
|
3242
|
+
// SSR has its own custom validation.
|
|
3243
|
+
if (process.env.IS_BROWSER && process.env.NODE_ENV !== 'production') {
|
|
3244
|
+
if (!(key in elm)) {
|
|
3245
|
+
logWarn(`Unknown public property "${key}" of element <${elm.tagName.toLowerCase()}>. This is either a typo on the corresponding attribute "${htmlPropertyToAttribute(key)}", or the attribute does not exist in this browser or DOM implementation.`);
|
|
3246
|
+
}
|
|
3247
|
+
}
|
|
3203
3248
|
setProperty(elm, key, cur);
|
|
3204
3249
|
}
|
|
3205
3250
|
}
|
|
@@ -3358,579 +3403,802 @@ function applyStaticStyleAttribute(vnode, renderer) {
|
|
|
3358
3403
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
3359
3404
|
*/
|
|
3360
3405
|
function patchChildren(c1, c2, parent, renderer) {
|
|
3361
|
-
|
|
3362
|
-
|
|
3363
|
-
|
|
3364
|
-
|
|
3365
|
-
|
|
3366
|
-
}
|
|
3406
|
+
if (hasDynamicChildren(c2)) {
|
|
3407
|
+
updateDynamicChildren(c1, c2, parent, renderer);
|
|
3408
|
+
} else {
|
|
3409
|
+
updateStaticChildren(c1, c2, parent, renderer);
|
|
3410
|
+
}
|
|
3367
3411
|
}
|
|
3412
|
+
|
|
3368
3413
|
function patch(n1, n2, parent, renderer) {
|
|
3369
|
-
|
|
3370
|
-
|
|
3371
|
-
|
|
3372
|
-
|
|
3373
|
-
|
|
3374
|
-
|
|
3375
|
-
|
|
3376
|
-
|
|
3377
|
-
|
|
3378
|
-
|
|
3379
|
-
|
|
3380
|
-
|
|
3381
|
-
|
|
3382
|
-
|
|
3383
|
-
|
|
3384
|
-
patchText(n1, n2, renderer);
|
|
3385
|
-
break;
|
|
3386
|
-
case 1 /* VNodeType.Comment */:
|
|
3387
|
-
// VComment has no special capability, fallback to the owner's renderer
|
|
3388
|
-
patchComment(n1, n2, renderer);
|
|
3389
|
-
break;
|
|
3390
|
-
case 4 /* VNodeType.Static */:
|
|
3391
|
-
n2.elm = n1.elm;
|
|
3392
|
-
break;
|
|
3393
|
-
case 2 /* VNodeType.Element */:
|
|
3394
|
-
patchElement(n1, n2, (_a = n2.data.renderer) !== null && _a !== void 0 ? _a : renderer);
|
|
3395
|
-
break;
|
|
3396
|
-
case 3 /* VNodeType.CustomElement */:
|
|
3397
|
-
patchCustomElement(n1, n2, parent, (_b = n2.data.renderer) !== null && _b !== void 0 ? _b : renderer);
|
|
3398
|
-
break;
|
|
3414
|
+
var _a, _b;
|
|
3415
|
+
|
|
3416
|
+
if (n1 === n2) {
|
|
3417
|
+
return;
|
|
3418
|
+
}
|
|
3419
|
+
|
|
3420
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
3421
|
+
if (!isSameVnode(n1, n2)) {
|
|
3422
|
+
throw new Error('Expected these VNodes to be the same: ' + JSON.stringify({
|
|
3423
|
+
sel: n1.sel,
|
|
3424
|
+
key: n1.key
|
|
3425
|
+
}) + ', ' + JSON.stringify({
|
|
3426
|
+
sel: n2.sel,
|
|
3427
|
+
key: n2.key
|
|
3428
|
+
}));
|
|
3399
3429
|
}
|
|
3430
|
+
}
|
|
3431
|
+
|
|
3432
|
+
switch (n2.type) {
|
|
3433
|
+
case 0
|
|
3434
|
+
/* VNodeType.Text */
|
|
3435
|
+
:
|
|
3436
|
+
// VText has no special capability, fallback to the owner's renderer
|
|
3437
|
+
patchText(n1, n2, renderer);
|
|
3438
|
+
break;
|
|
3439
|
+
|
|
3440
|
+
case 1
|
|
3441
|
+
/* VNodeType.Comment */
|
|
3442
|
+
:
|
|
3443
|
+
// VComment has no special capability, fallback to the owner's renderer
|
|
3444
|
+
patchComment(n1, n2, renderer);
|
|
3445
|
+
break;
|
|
3446
|
+
|
|
3447
|
+
case 4
|
|
3448
|
+
/* VNodeType.Static */
|
|
3449
|
+
:
|
|
3450
|
+
n2.elm = n1.elm;
|
|
3451
|
+
break;
|
|
3452
|
+
|
|
3453
|
+
case 2
|
|
3454
|
+
/* VNodeType.Element */
|
|
3455
|
+
:
|
|
3456
|
+
patchElement(n1, n2, (_a = n2.data.renderer) !== null && _a !== void 0 ? _a : renderer);
|
|
3457
|
+
break;
|
|
3458
|
+
|
|
3459
|
+
case 3
|
|
3460
|
+
/* VNodeType.CustomElement */
|
|
3461
|
+
:
|
|
3462
|
+
patchCustomElement(n1, n2, parent, (_b = n2.data.renderer) !== null && _b !== void 0 ? _b : renderer);
|
|
3463
|
+
break;
|
|
3464
|
+
}
|
|
3400
3465
|
}
|
|
3466
|
+
|
|
3401
3467
|
function mount(node, parent, renderer, anchor) {
|
|
3402
|
-
|
|
3403
|
-
|
|
3404
|
-
|
|
3405
|
-
|
|
3406
|
-
|
|
3407
|
-
|
|
3408
|
-
|
|
3409
|
-
|
|
3410
|
-
|
|
3411
|
-
|
|
3412
|
-
|
|
3413
|
-
|
|
3414
|
-
|
|
3415
|
-
|
|
3416
|
-
|
|
3417
|
-
|
|
3418
|
-
|
|
3419
|
-
|
|
3420
|
-
|
|
3421
|
-
|
|
3422
|
-
|
|
3423
|
-
|
|
3424
|
-
|
|
3468
|
+
var _a, _b;
|
|
3469
|
+
|
|
3470
|
+
switch (node.type) {
|
|
3471
|
+
case 0
|
|
3472
|
+
/* VNodeType.Text */
|
|
3473
|
+
:
|
|
3474
|
+
// VText has no special capability, fallback to the owner's renderer
|
|
3475
|
+
mountText(node, parent, anchor, renderer);
|
|
3476
|
+
break;
|
|
3477
|
+
|
|
3478
|
+
case 1
|
|
3479
|
+
/* VNodeType.Comment */
|
|
3480
|
+
:
|
|
3481
|
+
// VComment has no special capability, fallback to the owner's renderer
|
|
3482
|
+
mountComment(node, parent, anchor, renderer);
|
|
3483
|
+
break;
|
|
3484
|
+
|
|
3485
|
+
case 4
|
|
3486
|
+
/* VNodeType.Static */
|
|
3487
|
+
:
|
|
3488
|
+
// VStatic cannot have a custom renderer associated to them, using owner's renderer
|
|
3489
|
+
mountStatic(node, parent, anchor, renderer);
|
|
3490
|
+
break;
|
|
3491
|
+
|
|
3492
|
+
case 2
|
|
3493
|
+
/* VNodeType.Element */
|
|
3494
|
+
:
|
|
3495
|
+
// If the vnode data has a renderer override use it, else fallback to owner's renderer
|
|
3496
|
+
mountElement(node, parent, anchor, (_a = node.data.renderer) !== null && _a !== void 0 ? _a : renderer);
|
|
3497
|
+
break;
|
|
3498
|
+
|
|
3499
|
+
case 3
|
|
3500
|
+
/* VNodeType.CustomElement */
|
|
3501
|
+
:
|
|
3502
|
+
// If the vnode data has a renderer override use it, else fallback to owner's renderer
|
|
3503
|
+
mountCustomElement(node, parent, anchor, (_b = node.data.renderer) !== null && _b !== void 0 ? _b : renderer);
|
|
3504
|
+
break;
|
|
3505
|
+
}
|
|
3425
3506
|
}
|
|
3507
|
+
|
|
3426
3508
|
function patchText(n1, n2, renderer) {
|
|
3427
|
-
|
|
3428
|
-
|
|
3429
|
-
|
|
3430
|
-
|
|
3509
|
+
n2.elm = n1.elm;
|
|
3510
|
+
|
|
3511
|
+
if (n2.text !== n1.text) {
|
|
3512
|
+
updateTextContent(n2, renderer);
|
|
3513
|
+
}
|
|
3431
3514
|
}
|
|
3515
|
+
|
|
3432
3516
|
function mountText(vnode, parent, anchor, renderer) {
|
|
3433
|
-
|
|
3434
|
-
|
|
3435
|
-
|
|
3436
|
-
|
|
3437
|
-
|
|
3517
|
+
const {
|
|
3518
|
+
owner
|
|
3519
|
+
} = vnode;
|
|
3520
|
+
const {
|
|
3521
|
+
createText
|
|
3522
|
+
} = renderer;
|
|
3523
|
+
const textNode = vnode.elm = createText(vnode.text);
|
|
3524
|
+
linkNodeToShadow(textNode, owner, renderer);
|
|
3525
|
+
insertNode(textNode, parent, anchor, renderer);
|
|
3438
3526
|
}
|
|
3527
|
+
|
|
3439
3528
|
function patchComment(n1, n2, renderer) {
|
|
3440
|
-
|
|
3441
|
-
|
|
3442
|
-
|
|
3443
|
-
|
|
3444
|
-
|
|
3445
|
-
|
|
3529
|
+
n2.elm = n1.elm; // FIXME: Comment nodes should be static, we shouldn't need to diff them together. However
|
|
3530
|
+
// it is the case today.
|
|
3531
|
+
|
|
3532
|
+
if (n2.text !== n1.text) {
|
|
3533
|
+
updateTextContent(n2, renderer);
|
|
3534
|
+
}
|
|
3446
3535
|
}
|
|
3536
|
+
|
|
3447
3537
|
function mountComment(vnode, parent, anchor, renderer) {
|
|
3448
|
-
|
|
3449
|
-
|
|
3450
|
-
|
|
3451
|
-
|
|
3452
|
-
|
|
3538
|
+
const {
|
|
3539
|
+
owner
|
|
3540
|
+
} = vnode;
|
|
3541
|
+
const {
|
|
3542
|
+
createComment
|
|
3543
|
+
} = renderer;
|
|
3544
|
+
const commentNode = vnode.elm = createComment(vnode.text);
|
|
3545
|
+
linkNodeToShadow(commentNode, owner, renderer);
|
|
3546
|
+
insertNode(commentNode, parent, anchor, renderer);
|
|
3453
3547
|
}
|
|
3548
|
+
|
|
3454
3549
|
function mountElement(vnode, parent, anchor, renderer) {
|
|
3455
|
-
|
|
3456
|
-
|
|
3457
|
-
|
|
3458
|
-
|
|
3459
|
-
|
|
3460
|
-
|
|
3461
|
-
|
|
3462
|
-
|
|
3463
|
-
|
|
3464
|
-
|
|
3465
|
-
|
|
3550
|
+
const {
|
|
3551
|
+
sel,
|
|
3552
|
+
owner,
|
|
3553
|
+
data: {
|
|
3554
|
+
svg
|
|
3555
|
+
}
|
|
3556
|
+
} = vnode;
|
|
3557
|
+
const {
|
|
3558
|
+
createElement
|
|
3559
|
+
} = renderer;
|
|
3560
|
+
const namespace = isTrue(svg) ? SVG_NAMESPACE : undefined;
|
|
3561
|
+
const elm = vnode.elm = createElement(sel, namespace);
|
|
3562
|
+
linkNodeToShadow(elm, owner, renderer);
|
|
3563
|
+
applyStyleScoping(elm, owner, renderer);
|
|
3564
|
+
applyDomManual(elm, vnode);
|
|
3565
|
+
applyElementRestrictions(elm, vnode);
|
|
3566
|
+
patchElementPropsAndAttrs$1(null, vnode, renderer);
|
|
3567
|
+
insertNode(elm, parent, anchor, renderer);
|
|
3568
|
+
mountVNodes(vnode.children, elm, renderer, null);
|
|
3466
3569
|
}
|
|
3570
|
+
|
|
3467
3571
|
function patchElement(n1, n2, renderer) {
|
|
3468
|
-
|
|
3469
|
-
|
|
3470
|
-
|
|
3572
|
+
const elm = n2.elm = n1.elm;
|
|
3573
|
+
patchElementPropsAndAttrs$1(n1, n2, renderer);
|
|
3574
|
+
patchChildren(n1.children, n2.children, elm, renderer);
|
|
3471
3575
|
}
|
|
3576
|
+
|
|
3472
3577
|
function mountStatic(vnode, parent, anchor, renderer) {
|
|
3473
|
-
|
|
3474
|
-
|
|
3475
|
-
|
|
3476
|
-
|
|
3477
|
-
|
|
3478
|
-
|
|
3479
|
-
|
|
3480
|
-
|
|
3481
|
-
|
|
3482
|
-
|
|
3483
|
-
|
|
3578
|
+
const {
|
|
3579
|
+
owner
|
|
3580
|
+
} = vnode;
|
|
3581
|
+
const {
|
|
3582
|
+
cloneNode,
|
|
3583
|
+
isSyntheticShadowDefined
|
|
3584
|
+
} = renderer;
|
|
3585
|
+
const elm = vnode.elm = cloneNode(vnode.fragment, true);
|
|
3586
|
+
linkNodeToShadow(elm, owner, renderer);
|
|
3587
|
+
applyElementRestrictions(elm, vnode); // Marks this node as Static to propagate the shadow resolver. must happen after elm is assigned to the proper shadow
|
|
3588
|
+
|
|
3589
|
+
const {
|
|
3590
|
+
renderMode,
|
|
3591
|
+
shadowMode
|
|
3592
|
+
} = owner;
|
|
3593
|
+
|
|
3594
|
+
if (isSyntheticShadowDefined) {
|
|
3595
|
+
if (shadowMode === 1
|
|
3596
|
+
/* ShadowMode.Synthetic */
|
|
3597
|
+
|| renderMode === 0
|
|
3598
|
+
/* RenderMode.Light */
|
|
3599
|
+
) {
|
|
3600
|
+
elm[KEY__SHADOW_STATIC] = true;
|
|
3484
3601
|
}
|
|
3485
|
-
|
|
3602
|
+
}
|
|
3603
|
+
|
|
3604
|
+
insertNode(elm, parent, anchor, renderer);
|
|
3486
3605
|
}
|
|
3606
|
+
|
|
3487
3607
|
function mountCustomElement(vnode, parent, anchor, renderer) {
|
|
3488
|
-
|
|
3489
|
-
|
|
3490
|
-
|
|
3491
|
-
|
|
3492
|
-
|
|
3493
|
-
|
|
3494
|
-
|
|
3495
|
-
|
|
3496
|
-
|
|
3497
|
-
|
|
3498
|
-
|
|
3499
|
-
|
|
3500
|
-
|
|
3501
|
-
|
|
3502
|
-
|
|
3503
|
-
|
|
3504
|
-
|
|
3505
|
-
|
|
3506
|
-
|
|
3507
|
-
|
|
3508
|
-
|
|
3509
|
-
|
|
3510
|
-
|
|
3511
|
-
|
|
3512
|
-
|
|
3513
|
-
|
|
3608
|
+
const {
|
|
3609
|
+
sel,
|
|
3610
|
+
owner
|
|
3611
|
+
} = vnode;
|
|
3612
|
+
const UpgradableConstructor = getUpgradableConstructor(sel, renderer);
|
|
3613
|
+
/**
|
|
3614
|
+
* Note: if the upgradable constructor does not expect, or throw when we new it
|
|
3615
|
+
* with a callback as the first argument, we could implement a more advanced
|
|
3616
|
+
* mechanism that only passes that argument if the constructor is known to be
|
|
3617
|
+
* an upgradable custom element.
|
|
3618
|
+
*/
|
|
3619
|
+
|
|
3620
|
+
let vm;
|
|
3621
|
+
const elm = new UpgradableConstructor(elm => {
|
|
3622
|
+
// the custom element from the registry is expecting an upgrade callback
|
|
3623
|
+
vm = createViewModelHook(elm, vnode, renderer);
|
|
3624
|
+
});
|
|
3625
|
+
vnode.elm = elm;
|
|
3626
|
+
vnode.vm = vm;
|
|
3627
|
+
linkNodeToShadow(elm, owner, renderer);
|
|
3628
|
+
applyStyleScoping(elm, owner, renderer);
|
|
3629
|
+
|
|
3630
|
+
if (vm) {
|
|
3631
|
+
allocateChildren(vnode, vm);
|
|
3632
|
+
} else if (vnode.ctor !== UpgradableConstructor) {
|
|
3633
|
+
throw new TypeError(`Incorrect Component Constructor`);
|
|
3634
|
+
}
|
|
3635
|
+
|
|
3636
|
+
patchElementPropsAndAttrs$1(null, vnode, renderer);
|
|
3637
|
+
insertNode(elm, parent, anchor, renderer);
|
|
3638
|
+
|
|
3639
|
+
if (vm) {
|
|
3640
|
+
if (process.env.IS_BROWSER) {
|
|
3641
|
+
if (!lwcRuntimeFlags.ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE) {
|
|
3514
3642
|
if (process.env.NODE_ENV !== 'production') {
|
|
3515
|
-
|
|
3643
|
+
// With synthetic lifecycle callbacks, it's possible for elements to be removed without the engine
|
|
3644
|
+
// noticing it (e.g. `appendChild` the same host element twice). This test ensures we don't regress.
|
|
3645
|
+
assert.isTrue(vm.state === 0
|
|
3646
|
+
/* VMState.created */
|
|
3647
|
+
, `${vm} cannot be recycled.`);
|
|
3516
3648
|
}
|
|
3649
|
+
|
|
3517
3650
|
runConnectedCallback(vm);
|
|
3651
|
+
}
|
|
3652
|
+
} else {
|
|
3653
|
+
// On the server, we don't have native custom element lifecycle callbacks, so we must
|
|
3654
|
+
// manually invoke the connectedCallback for a child component.
|
|
3655
|
+
runConnectedCallback(vm);
|
|
3518
3656
|
}
|
|
3519
|
-
|
|
3520
|
-
|
|
3521
|
-
|
|
3522
|
-
|
|
3657
|
+
}
|
|
3658
|
+
|
|
3659
|
+
mountVNodes(vnode.children, elm, renderer, null);
|
|
3660
|
+
|
|
3661
|
+
if (vm) {
|
|
3662
|
+
appendVM(vm);
|
|
3663
|
+
}
|
|
3523
3664
|
}
|
|
3665
|
+
|
|
3524
3666
|
function patchCustomElement(n1, n2, parent, renderer) {
|
|
3525
|
-
|
|
3526
|
-
|
|
3527
|
-
|
|
3528
|
-
|
|
3529
|
-
|
|
3530
|
-
|
|
3531
|
-
|
|
3532
|
-
|
|
3533
|
-
|
|
3534
|
-
|
|
3535
|
-
|
|
3536
|
-
|
|
3537
|
-
|
|
3538
|
-
|
|
3539
|
-
|
|
3540
|
-
|
|
3541
|
-
|
|
3542
|
-
|
|
3543
|
-
|
|
3544
|
-
|
|
3545
|
-
|
|
3546
|
-
|
|
3547
|
-
|
|
3548
|
-
|
|
3549
|
-
|
|
3667
|
+
if (n1.ctor !== n2.ctor) {
|
|
3668
|
+
// If the constructor, unmount the current component and mount a new one using the new
|
|
3669
|
+
// constructor.
|
|
3670
|
+
const anchor = renderer.nextSibling(n1.elm);
|
|
3671
|
+
unmount(n1, parent, renderer, true);
|
|
3672
|
+
mountCustomElement(n2, parent, anchor, renderer);
|
|
3673
|
+
} else {
|
|
3674
|
+
// Otherwise patch the existing component with new props/attrs/etc.
|
|
3675
|
+
const elm = n2.elm = n1.elm;
|
|
3676
|
+
const vm = n2.vm = n1.vm;
|
|
3677
|
+
patchElementPropsAndAttrs$1(n1, n2, renderer);
|
|
3678
|
+
|
|
3679
|
+
if (!isUndefined$1(vm)) {
|
|
3680
|
+
// in fallback mode, the allocation will always set children to
|
|
3681
|
+
// empty and delegate the real allocation to the slot elements
|
|
3682
|
+
allocateChildren(n2, vm);
|
|
3683
|
+
} // in fallback mode, the children will be always empty, so, nothing
|
|
3684
|
+
// will happen, but in native, it does allocate the light dom
|
|
3685
|
+
|
|
3686
|
+
|
|
3687
|
+
patchChildren(n1.children, n2.children, elm, renderer);
|
|
3688
|
+
|
|
3689
|
+
if (!isUndefined$1(vm)) {
|
|
3690
|
+
// this will probably update the shadowRoot, but only if the vm is in a dirty state
|
|
3691
|
+
// this is important to preserve the top to bottom synchronous rendering phase.
|
|
3692
|
+
rerenderVM(vm);
|
|
3550
3693
|
}
|
|
3694
|
+
}
|
|
3551
3695
|
}
|
|
3696
|
+
|
|
3552
3697
|
function mountVNodes(vnodes, parent, renderer, anchor, start = 0, end = vnodes.length) {
|
|
3553
|
-
|
|
3554
|
-
|
|
3555
|
-
|
|
3556
|
-
|
|
3557
|
-
|
|
3698
|
+
for (; start < end; ++start) {
|
|
3699
|
+
const vnode = vnodes[start];
|
|
3700
|
+
|
|
3701
|
+
if (isVNode(vnode)) {
|
|
3702
|
+
mount(vnode, parent, renderer, anchor);
|
|
3558
3703
|
}
|
|
3704
|
+
}
|
|
3559
3705
|
}
|
|
3706
|
+
|
|
3560
3707
|
function unmount(vnode, parent, renderer, doRemove = false) {
|
|
3561
|
-
|
|
3562
|
-
|
|
3563
|
-
|
|
3564
|
-
|
|
3565
|
-
|
|
3566
|
-
|
|
3567
|
-
|
|
3568
|
-
|
|
3569
|
-
|
|
3570
|
-
|
|
3571
|
-
|
|
3572
|
-
|
|
3573
|
-
|
|
3574
|
-
|
|
3575
|
-
|
|
3576
|
-
|
|
3577
|
-
|
|
3578
|
-
|
|
3579
|
-
|
|
3580
|
-
|
|
3581
|
-
|
|
3582
|
-
|
|
3583
|
-
|
|
3708
|
+
const {
|
|
3709
|
+
type,
|
|
3710
|
+
elm,
|
|
3711
|
+
sel
|
|
3712
|
+
} = vnode; // When unmounting a VNode subtree not all the elements have to removed from the DOM. The
|
|
3713
|
+
// subtree root, is the only element worth unmounting from the subtree.
|
|
3714
|
+
|
|
3715
|
+
if (doRemove) {
|
|
3716
|
+
// The vnode might or might not have a data.renderer associated to it
|
|
3717
|
+
// but the removal used here is from the owner instead.
|
|
3718
|
+
removeNode(elm, parent, renderer);
|
|
3719
|
+
}
|
|
3720
|
+
|
|
3721
|
+
switch (type) {
|
|
3722
|
+
case 2
|
|
3723
|
+
/* VNodeType.Element */
|
|
3724
|
+
:
|
|
3725
|
+
{
|
|
3726
|
+
// Slot content is removed to trigger slotchange event when removing slot.
|
|
3727
|
+
// Only required for synthetic shadow.
|
|
3728
|
+
const shouldRemoveChildren = sel === 'slot' && vnode.owner.shadowMode === 1
|
|
3729
|
+
/* ShadowMode.Synthetic */
|
|
3730
|
+
;
|
|
3731
|
+
unmountVNodes(vnode.children, elm, renderer, shouldRemoveChildren);
|
|
3732
|
+
break;
|
|
3733
|
+
}
|
|
3734
|
+
|
|
3735
|
+
case 3
|
|
3736
|
+
/* VNodeType.CustomElement */
|
|
3737
|
+
:
|
|
3738
|
+
{
|
|
3739
|
+
const {
|
|
3740
|
+
vm
|
|
3741
|
+
} = vnode; // No need to unmount the children here, `removeVM` will take care of removing the
|
|
3742
|
+
// children.
|
|
3743
|
+
|
|
3744
|
+
if (!isUndefined$1(vm)) {
|
|
3745
|
+
removeVM(vm);
|
|
3584
3746
|
}
|
|
3585
|
-
|
|
3747
|
+
}
|
|
3748
|
+
}
|
|
3586
3749
|
}
|
|
3750
|
+
|
|
3587
3751
|
function unmountVNodes(vnodes, parent, renderer, doRemove = false, start = 0, end = vnodes.length) {
|
|
3588
|
-
|
|
3589
|
-
|
|
3590
|
-
|
|
3591
|
-
|
|
3592
|
-
|
|
3752
|
+
for (; start < end; ++start) {
|
|
3753
|
+
const ch = vnodes[start];
|
|
3754
|
+
|
|
3755
|
+
if (isVNode(ch)) {
|
|
3756
|
+
unmount(ch, parent, renderer, doRemove);
|
|
3593
3757
|
}
|
|
3758
|
+
}
|
|
3594
3759
|
}
|
|
3760
|
+
|
|
3595
3761
|
function isVNode(vnode) {
|
|
3596
|
-
|
|
3762
|
+
return vnode != null;
|
|
3597
3763
|
}
|
|
3764
|
+
|
|
3598
3765
|
function linkNodeToShadow(elm, owner, renderer) {
|
|
3599
|
-
|
|
3600
|
-
|
|
3601
|
-
|
|
3602
|
-
|
|
3603
|
-
|
|
3604
|
-
|
|
3605
|
-
|
|
3766
|
+
const {
|
|
3767
|
+
renderRoot,
|
|
3768
|
+
renderMode,
|
|
3769
|
+
shadowMode
|
|
3770
|
+
} = owner;
|
|
3771
|
+
const {
|
|
3772
|
+
isSyntheticShadowDefined
|
|
3773
|
+
} = renderer; // TODO [#1164]: this should eventually be done by the polyfill directly
|
|
3774
|
+
|
|
3775
|
+
if (isSyntheticShadowDefined) {
|
|
3776
|
+
if (shadowMode === 1
|
|
3777
|
+
/* ShadowMode.Synthetic */
|
|
3778
|
+
|| renderMode === 0
|
|
3779
|
+
/* RenderMode.Light */
|
|
3780
|
+
) {
|
|
3781
|
+
elm[KEY__SHADOW_RESOLVER] = renderRoot[KEY__SHADOW_RESOLVER];
|
|
3606
3782
|
}
|
|
3783
|
+
}
|
|
3607
3784
|
}
|
|
3785
|
+
|
|
3608
3786
|
function updateTextContent(vnode, renderer) {
|
|
3609
|
-
|
|
3610
|
-
|
|
3611
|
-
|
|
3612
|
-
|
|
3613
|
-
|
|
3614
|
-
setText
|
|
3615
|
-
|
|
3616
|
-
|
|
3617
|
-
|
|
3787
|
+
const {
|
|
3788
|
+
elm,
|
|
3789
|
+
text
|
|
3790
|
+
} = vnode;
|
|
3791
|
+
const {
|
|
3792
|
+
setText
|
|
3793
|
+
} = renderer;
|
|
3794
|
+
|
|
3795
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
3796
|
+
unlockDomMutation();
|
|
3797
|
+
}
|
|
3798
|
+
|
|
3799
|
+
setText(elm, text);
|
|
3800
|
+
|
|
3801
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
3802
|
+
lockDomMutation();
|
|
3803
|
+
}
|
|
3618
3804
|
}
|
|
3805
|
+
|
|
3619
3806
|
function insertNode(node, parent, anchor, renderer) {
|
|
3620
|
-
|
|
3621
|
-
|
|
3622
|
-
|
|
3623
|
-
|
|
3624
|
-
|
|
3625
|
-
|
|
3626
|
-
|
|
3807
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
3808
|
+
unlockDomMutation();
|
|
3809
|
+
}
|
|
3810
|
+
|
|
3811
|
+
renderer.insert(node, parent, anchor);
|
|
3812
|
+
|
|
3813
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
3814
|
+
lockDomMutation();
|
|
3815
|
+
}
|
|
3627
3816
|
}
|
|
3817
|
+
|
|
3628
3818
|
function removeNode(node, parent, renderer) {
|
|
3629
|
-
|
|
3630
|
-
|
|
3631
|
-
|
|
3632
|
-
|
|
3633
|
-
|
|
3634
|
-
|
|
3635
|
-
|
|
3819
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
3820
|
+
unlockDomMutation();
|
|
3821
|
+
}
|
|
3822
|
+
|
|
3823
|
+
renderer.remove(node, parent);
|
|
3824
|
+
|
|
3825
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
3826
|
+
lockDomMutation();
|
|
3827
|
+
}
|
|
3636
3828
|
}
|
|
3829
|
+
|
|
3637
3830
|
function patchElementPropsAndAttrs$1(oldVnode, vnode, renderer) {
|
|
3638
|
-
|
|
3639
|
-
|
|
3640
|
-
|
|
3641
|
-
|
|
3642
|
-
|
|
3643
|
-
|
|
3644
|
-
|
|
3645
|
-
|
|
3646
|
-
|
|
3647
|
-
|
|
3648
|
-
|
|
3831
|
+
if (isNull(oldVnode)) {
|
|
3832
|
+
applyEventListeners(vnode, renderer);
|
|
3833
|
+
applyStaticClassAttribute(vnode, renderer);
|
|
3834
|
+
applyStaticStyleAttribute(vnode, renderer);
|
|
3835
|
+
} // Attrs need to be applied to element before props IE11 will wipe out value on radio inputs if
|
|
3836
|
+
// value is set before type=radio.
|
|
3837
|
+
|
|
3838
|
+
|
|
3839
|
+
patchClassAttribute(oldVnode, vnode, renderer);
|
|
3840
|
+
patchStyleAttribute(oldVnode, vnode, renderer);
|
|
3841
|
+
patchAttributes(oldVnode, vnode, renderer);
|
|
3842
|
+
patchProps(oldVnode, vnode, renderer);
|
|
3649
3843
|
}
|
|
3844
|
+
|
|
3650
3845
|
function applyStyleScoping(elm, owner, renderer) {
|
|
3651
|
-
|
|
3652
|
-
|
|
3653
|
-
|
|
3654
|
-
|
|
3655
|
-
|
|
3656
|
-
|
|
3657
|
-
|
|
3658
|
-
|
|
3659
|
-
|
|
3660
|
-
|
|
3661
|
-
|
|
3662
|
-
|
|
3663
|
-
|
|
3846
|
+
// Set the class name for `*.scoped.css` style scoping.
|
|
3847
|
+
const scopeToken = getScopeTokenClass(owner);
|
|
3848
|
+
|
|
3849
|
+
if (!isNull(scopeToken)) {
|
|
3850
|
+
const {
|
|
3851
|
+
getClassList
|
|
3852
|
+
} = renderer; // TODO [#2762]: this dot notation with add is probably problematic
|
|
3853
|
+
// probably we should have a renderer api for just the add operation
|
|
3854
|
+
|
|
3855
|
+
getClassList(elm).add(scopeToken);
|
|
3856
|
+
} // Set property element for synthetic shadow DOM style scoping.
|
|
3857
|
+
|
|
3858
|
+
|
|
3859
|
+
const {
|
|
3860
|
+
stylesheetToken: syntheticToken
|
|
3861
|
+
} = owner.context;
|
|
3862
|
+
|
|
3863
|
+
if (owner.shadowMode === 1
|
|
3864
|
+
/* ShadowMode.Synthetic */
|
|
3865
|
+
&& !isUndefined$1(syntheticToken)) {
|
|
3866
|
+
elm.$shadowToken$ = syntheticToken;
|
|
3867
|
+
}
|
|
3664
3868
|
}
|
|
3869
|
+
|
|
3665
3870
|
function applyDomManual(elm, vnode) {
|
|
3666
|
-
|
|
3667
|
-
|
|
3668
|
-
|
|
3669
|
-
|
|
3871
|
+
var _a;
|
|
3872
|
+
|
|
3873
|
+
const {
|
|
3874
|
+
owner,
|
|
3875
|
+
data: {
|
|
3876
|
+
context
|
|
3670
3877
|
}
|
|
3878
|
+
} = vnode;
|
|
3879
|
+
|
|
3880
|
+
if (owner.shadowMode === 1
|
|
3881
|
+
/* ShadowMode.Synthetic */
|
|
3882
|
+
&& ((_a = context === null || context === void 0 ? void 0 : context.lwc) === null || _a === void 0 ? void 0 : _a.dom) === "manual"
|
|
3883
|
+
/* LwcDomMode.Manual */
|
|
3884
|
+
) {
|
|
3885
|
+
elm.$domManual$ = true;
|
|
3886
|
+
}
|
|
3671
3887
|
}
|
|
3888
|
+
|
|
3672
3889
|
function applyElementRestrictions(elm, vnode) {
|
|
3673
|
-
|
|
3674
|
-
|
|
3675
|
-
|
|
3676
|
-
|
|
3677
|
-
|
|
3678
|
-
|
|
3679
|
-
|
|
3680
|
-
|
|
3681
|
-
|
|
3890
|
+
var _a, _b;
|
|
3891
|
+
|
|
3892
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
3893
|
+
const isPortal = vnode.type === 2
|
|
3894
|
+
/* VNodeType.Element */
|
|
3895
|
+
&& ((_b = (_a = vnode.data.context) === null || _a === void 0 ? void 0 : _a.lwc) === null || _b === void 0 ? void 0 : _b.dom) === "manual"
|
|
3896
|
+
/* LwcDomMode.Manual */
|
|
3897
|
+
;
|
|
3898
|
+
const isLight = vnode.owner.renderMode === 0
|
|
3899
|
+
/* RenderMode.Light */
|
|
3900
|
+
;
|
|
3901
|
+
patchElementWithRestrictions(elm, {
|
|
3902
|
+
isPortal,
|
|
3903
|
+
isLight
|
|
3904
|
+
});
|
|
3905
|
+
}
|
|
3682
3906
|
}
|
|
3907
|
+
|
|
3683
3908
|
function allocateChildren(vnode, vm) {
|
|
3684
|
-
|
|
3685
|
-
|
|
3686
|
-
|
|
3687
|
-
|
|
3688
|
-
|
|
3689
|
-
|
|
3690
|
-
|
|
3691
|
-
|
|
3692
|
-
|
|
3693
|
-
|
|
3694
|
-
|
|
3695
|
-
|
|
3696
|
-
|
|
3697
|
-
|
|
3698
|
-
|
|
3699
|
-
|
|
3700
|
-
|
|
3701
|
-
|
|
3702
|
-
|
|
3703
|
-
|
|
3704
|
-
|
|
3909
|
+
// A component with slots will re-render because:
|
|
3910
|
+
// 1- There is a change of the internal state.
|
|
3911
|
+
// 2- There is a change on the external api (ex: slots)
|
|
3912
|
+
//
|
|
3913
|
+
// In case #1, the vnodes in the cmpSlots will be reused since they didn't changed. This routine emptied the
|
|
3914
|
+
// slotted children when those VCustomElement were rendered and therefore in subsequent calls to allocate children
|
|
3915
|
+
// in a reused VCustomElement, there won't be any slotted children.
|
|
3916
|
+
// For those cases, we will use the reference for allocated children stored when rendering the fresh VCustomElement.
|
|
3917
|
+
//
|
|
3918
|
+
// In case #2, we will always get a fresh VCustomElement.
|
|
3919
|
+
const children = vnode.aChildren || vnode.children;
|
|
3920
|
+
vm.aChildren = children;
|
|
3921
|
+
const {
|
|
3922
|
+
renderMode,
|
|
3923
|
+
shadowMode
|
|
3924
|
+
} = vm;
|
|
3925
|
+
|
|
3926
|
+
if (shadowMode === 1
|
|
3927
|
+
/* ShadowMode.Synthetic */
|
|
3928
|
+
|| renderMode === 0
|
|
3929
|
+
/* RenderMode.Light */
|
|
3930
|
+
) {
|
|
3931
|
+
// slow path
|
|
3932
|
+
allocateInSlot(vm, children); // save the allocated children in case this vnode is reused.
|
|
3933
|
+
|
|
3934
|
+
vnode.aChildren = children; // every child vnode is now allocated, and the host should receive none directly, it receives them via the shadow!
|
|
3935
|
+
|
|
3936
|
+
vnode.children = EmptyArray;
|
|
3937
|
+
}
|
|
3705
3938
|
}
|
|
3939
|
+
|
|
3706
3940
|
function createViewModelHook(elm, vnode, renderer) {
|
|
3707
|
-
|
|
3708
|
-
|
|
3709
|
-
|
|
3710
|
-
|
|
3711
|
-
|
|
3712
|
-
return vm;
|
|
3713
|
-
}
|
|
3714
|
-
const { sel, mode, ctor, owner } = vnode;
|
|
3715
|
-
vm = createVM(elm, ctor, renderer, {
|
|
3716
|
-
mode,
|
|
3717
|
-
owner,
|
|
3718
|
-
tagName: sel,
|
|
3719
|
-
});
|
|
3720
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
3721
|
-
assert.isTrue(isArray$1(vnode.children), `Invalid vnode for a custom element, it must have children defined.`);
|
|
3722
|
-
}
|
|
3941
|
+
let vm = getAssociatedVMIfPresent(elm); // There is a possibility that a custom element is registered under tagName, in which case, the
|
|
3942
|
+
// initialization is already carry on, and there is nothing else to do here since this hook is
|
|
3943
|
+
// called right after invoking `document.createElement`.
|
|
3944
|
+
|
|
3945
|
+
if (!isUndefined$1(vm)) {
|
|
3723
3946
|
return vm;
|
|
3947
|
+
}
|
|
3948
|
+
|
|
3949
|
+
const {
|
|
3950
|
+
sel,
|
|
3951
|
+
mode,
|
|
3952
|
+
ctor,
|
|
3953
|
+
owner
|
|
3954
|
+
} = vnode;
|
|
3955
|
+
vm = createVM(elm, ctor, renderer, {
|
|
3956
|
+
mode,
|
|
3957
|
+
owner,
|
|
3958
|
+
tagName: sel
|
|
3959
|
+
});
|
|
3960
|
+
|
|
3961
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
3962
|
+
assert.isTrue(isArray$1(vnode.children), `Invalid vnode for a custom element, it must have children defined.`);
|
|
3963
|
+
}
|
|
3964
|
+
|
|
3965
|
+
return vm;
|
|
3724
3966
|
}
|
|
3967
|
+
|
|
3725
3968
|
function allocateInSlot(vm, children) {
|
|
3726
|
-
|
|
3727
|
-
|
|
3728
|
-
|
|
3729
|
-
|
|
3730
|
-
|
|
3731
|
-
|
|
3732
|
-
|
|
3733
|
-
|
|
3734
|
-
|
|
3735
|
-
|
|
3736
|
-
|
|
3737
|
-
|
|
3738
|
-
|
|
3739
|
-
|
|
3740
|
-
|
|
3741
|
-
|
|
3742
|
-
|
|
3743
|
-
|
|
3744
|
-
|
|
3745
|
-
|
|
3746
|
-
|
|
3747
|
-
|
|
3748
|
-
|
|
3749
|
-
|
|
3750
|
-
|
|
3751
|
-
|
|
3752
|
-
|
|
3753
|
-
|
|
3754
|
-
|
|
3755
|
-
|
|
3756
|
-
|
|
3757
|
-
|
|
3758
|
-
|
|
3759
|
-
|
|
3760
|
-
|
|
3761
|
-
|
|
3762
|
-
|
|
3969
|
+
var _a;
|
|
3970
|
+
|
|
3971
|
+
const {
|
|
3972
|
+
cmpSlots: oldSlots
|
|
3973
|
+
} = vm;
|
|
3974
|
+
const cmpSlots = vm.cmpSlots = create(null);
|
|
3975
|
+
|
|
3976
|
+
for (let i = 0, len = children.length; i < len; i += 1) {
|
|
3977
|
+
const vnode = children[i];
|
|
3978
|
+
|
|
3979
|
+
if (isNull(vnode)) {
|
|
3980
|
+
continue;
|
|
3981
|
+
}
|
|
3982
|
+
|
|
3983
|
+
let slotName = '';
|
|
3984
|
+
|
|
3985
|
+
if (isVBaseElement(vnode)) {
|
|
3986
|
+
slotName = ((_a = vnode.data.attrs) === null || _a === void 0 ? void 0 : _a.slot) || '';
|
|
3987
|
+
}
|
|
3988
|
+
|
|
3989
|
+
const vnodes = cmpSlots[slotName] = cmpSlots[slotName] || [];
|
|
3990
|
+
ArrayPush$1.call(vnodes, vnode);
|
|
3991
|
+
}
|
|
3992
|
+
|
|
3993
|
+
if (isFalse(vm.isDirty)) {
|
|
3994
|
+
// We need to determine if the old allocation is really different from the new one
|
|
3995
|
+
// and mark the vm as dirty
|
|
3996
|
+
const oldKeys = keys(oldSlots);
|
|
3997
|
+
|
|
3998
|
+
if (oldKeys.length !== keys(cmpSlots).length) {
|
|
3999
|
+
markComponentAsDirty(vm);
|
|
4000
|
+
return;
|
|
4001
|
+
}
|
|
4002
|
+
|
|
4003
|
+
for (let i = 0, len = oldKeys.length; i < len; i += 1) {
|
|
4004
|
+
const key = oldKeys[i];
|
|
4005
|
+
|
|
4006
|
+
if (isUndefined$1(cmpSlots[key]) || oldSlots[key].length !== cmpSlots[key].length) {
|
|
4007
|
+
markComponentAsDirty(vm);
|
|
4008
|
+
return;
|
|
4009
|
+
}
|
|
4010
|
+
|
|
4011
|
+
const oldVNodes = oldSlots[key];
|
|
4012
|
+
const vnodes = cmpSlots[key];
|
|
4013
|
+
|
|
4014
|
+
for (let j = 0, a = cmpSlots[key].length; j < a; j += 1) {
|
|
4015
|
+
if (oldVNodes[j] !== vnodes[j]) {
|
|
4016
|
+
markComponentAsDirty(vm);
|
|
4017
|
+
return;
|
|
3763
4018
|
}
|
|
4019
|
+
}
|
|
3764
4020
|
}
|
|
3765
|
-
}
|
|
3766
|
-
// Using a WeakMap instead of a WeakSet because this one works in IE11 :(
|
|
3767
|
-
|
|
3768
|
-
|
|
4021
|
+
}
|
|
4022
|
+
} // Using a WeakMap instead of a WeakSet because this one works in IE11 :(
|
|
4023
|
+
|
|
4024
|
+
|
|
4025
|
+
const FromIteration = new WeakMap(); // dynamic children means it was generated by an iteration
|
|
3769
4026
|
// in a template, and will require a more complex diffing algo.
|
|
4027
|
+
|
|
3770
4028
|
function markAsDynamicChildren(children) {
|
|
3771
|
-
|
|
4029
|
+
FromIteration.set(children, 1);
|
|
3772
4030
|
}
|
|
4031
|
+
|
|
3773
4032
|
function hasDynamicChildren(children) {
|
|
3774
|
-
|
|
4033
|
+
return FromIteration.has(children);
|
|
3775
4034
|
}
|
|
4035
|
+
|
|
3776
4036
|
function createKeyToOldIdx(children, beginIdx, endIdx) {
|
|
3777
|
-
|
|
3778
|
-
|
|
3779
|
-
|
|
3780
|
-
|
|
3781
|
-
|
|
3782
|
-
|
|
3783
|
-
|
|
3784
|
-
|
|
3785
|
-
|
|
3786
|
-
|
|
4037
|
+
const map = {}; // TODO [#1637]: simplify this by assuming that all vnodes has keys
|
|
4038
|
+
|
|
4039
|
+
for (let j = beginIdx; j <= endIdx; ++j) {
|
|
4040
|
+
const ch = children[j];
|
|
4041
|
+
|
|
4042
|
+
if (isVNode(ch)) {
|
|
4043
|
+
const {
|
|
4044
|
+
key
|
|
4045
|
+
} = ch;
|
|
4046
|
+
|
|
4047
|
+
if (key !== undefined) {
|
|
4048
|
+
map[key] = j;
|
|
4049
|
+
}
|
|
3787
4050
|
}
|
|
3788
|
-
|
|
4051
|
+
}
|
|
4052
|
+
|
|
4053
|
+
return map;
|
|
3789
4054
|
}
|
|
4055
|
+
|
|
3790
4056
|
function updateDynamicChildren(oldCh, newCh, parent, renderer) {
|
|
3791
|
-
|
|
3792
|
-
|
|
3793
|
-
|
|
3794
|
-
|
|
3795
|
-
|
|
3796
|
-
|
|
3797
|
-
|
|
3798
|
-
|
|
3799
|
-
|
|
3800
|
-
|
|
3801
|
-
|
|
3802
|
-
|
|
3803
|
-
|
|
3804
|
-
|
|
3805
|
-
|
|
3806
|
-
|
|
3807
|
-
|
|
3808
|
-
|
|
3809
|
-
|
|
3810
|
-
|
|
3811
|
-
|
|
3812
|
-
|
|
3813
|
-
|
|
3814
|
-
|
|
3815
|
-
|
|
3816
|
-
|
|
3817
|
-
|
|
3818
|
-
|
|
3819
|
-
|
|
3820
|
-
|
|
3821
|
-
|
|
3822
|
-
|
|
3823
|
-
|
|
3824
|
-
|
|
3825
|
-
|
|
3826
|
-
|
|
3827
|
-
|
|
3828
|
-
|
|
3829
|
-
|
|
3830
|
-
|
|
3831
|
-
|
|
3832
|
-
|
|
3833
|
-
|
|
3834
|
-
|
|
3835
|
-
|
|
3836
|
-
|
|
3837
|
-
|
|
3838
|
-
|
|
3839
|
-
|
|
3840
|
-
|
|
3841
|
-
|
|
3842
|
-
|
|
3843
|
-
|
|
3844
|
-
|
|
3845
|
-
|
|
3846
|
-
|
|
3847
|
-
|
|
3848
|
-
|
|
3849
|
-
|
|
3850
|
-
|
|
3851
|
-
|
|
3852
|
-
|
|
3853
|
-
|
|
3854
|
-
|
|
3855
|
-
|
|
3856
|
-
|
|
3857
|
-
|
|
3858
|
-
|
|
3859
|
-
|
|
3860
|
-
|
|
3861
|
-
|
|
3862
|
-
|
|
3863
|
-
|
|
3864
|
-
|
|
3865
|
-
|
|
3866
|
-
|
|
3867
|
-
|
|
3868
|
-
|
|
3869
|
-
}
|
|
3870
|
-
// We've already cloned at least once, so it's no longer read-only
|
|
3871
|
-
oldCh[idxInOld] = undefined;
|
|
3872
|
-
insertNode(elmToMove.elm, parent, oldStartVnode.elm, renderer);
|
|
3873
|
-
}
|
|
3874
|
-
}
|
|
3875
|
-
newStartVnode = newCh[++newStartIdx];
|
|
3876
|
-
}
|
|
4057
|
+
let oldStartIdx = 0;
|
|
4058
|
+
let newStartIdx = 0;
|
|
4059
|
+
let oldEndIdx = oldCh.length - 1;
|
|
4060
|
+
let oldStartVnode = oldCh[0];
|
|
4061
|
+
let oldEndVnode = oldCh[oldEndIdx];
|
|
4062
|
+
const newChEnd = newCh.length - 1;
|
|
4063
|
+
let newEndIdx = newChEnd;
|
|
4064
|
+
let newStartVnode = newCh[0];
|
|
4065
|
+
let newEndVnode = newCh[newEndIdx];
|
|
4066
|
+
let oldKeyToIdx;
|
|
4067
|
+
let idxInOld;
|
|
4068
|
+
let elmToMove;
|
|
4069
|
+
let before;
|
|
4070
|
+
let clonedOldCh = false;
|
|
4071
|
+
|
|
4072
|
+
while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
|
|
4073
|
+
if (!isVNode(oldStartVnode)) {
|
|
4074
|
+
oldStartVnode = oldCh[++oldStartIdx]; // Vnode might have been moved left
|
|
4075
|
+
} else if (!isVNode(oldEndVnode)) {
|
|
4076
|
+
oldEndVnode = oldCh[--oldEndIdx];
|
|
4077
|
+
} else if (!isVNode(newStartVnode)) {
|
|
4078
|
+
newStartVnode = newCh[++newStartIdx];
|
|
4079
|
+
} else if (!isVNode(newEndVnode)) {
|
|
4080
|
+
newEndVnode = newCh[--newEndIdx];
|
|
4081
|
+
} else if (isSameVnode(oldStartVnode, newStartVnode)) {
|
|
4082
|
+
patch(oldStartVnode, newStartVnode, parent, renderer);
|
|
4083
|
+
oldStartVnode = oldCh[++oldStartIdx];
|
|
4084
|
+
newStartVnode = newCh[++newStartIdx];
|
|
4085
|
+
} else if (isSameVnode(oldEndVnode, newEndVnode)) {
|
|
4086
|
+
patch(oldEndVnode, newEndVnode, parent, renderer);
|
|
4087
|
+
oldEndVnode = oldCh[--oldEndIdx];
|
|
4088
|
+
newEndVnode = newCh[--newEndIdx];
|
|
4089
|
+
} else if (isSameVnode(oldStartVnode, newEndVnode)) {
|
|
4090
|
+
// Vnode moved right
|
|
4091
|
+
patch(oldStartVnode, newEndVnode, parent, renderer);
|
|
4092
|
+
insertNode(oldStartVnode.elm, parent, renderer.nextSibling(oldEndVnode.elm), renderer);
|
|
4093
|
+
oldStartVnode = oldCh[++oldStartIdx];
|
|
4094
|
+
newEndVnode = newCh[--newEndIdx];
|
|
4095
|
+
} else if (isSameVnode(oldEndVnode, newStartVnode)) {
|
|
4096
|
+
// Vnode moved left
|
|
4097
|
+
patch(oldEndVnode, newStartVnode, parent, renderer);
|
|
4098
|
+
insertNode(newStartVnode.elm, parent, oldStartVnode.elm, renderer);
|
|
4099
|
+
oldEndVnode = oldCh[--oldEndIdx];
|
|
4100
|
+
newStartVnode = newCh[++newStartIdx];
|
|
4101
|
+
} else {
|
|
4102
|
+
if (oldKeyToIdx === undefined) {
|
|
4103
|
+
oldKeyToIdx = createKeyToOldIdx(oldCh, oldStartIdx, oldEndIdx);
|
|
4104
|
+
}
|
|
4105
|
+
|
|
4106
|
+
idxInOld = oldKeyToIdx[newStartVnode.key];
|
|
4107
|
+
|
|
4108
|
+
if (isUndefined$1(idxInOld)) {
|
|
4109
|
+
// New element
|
|
4110
|
+
mount(newStartVnode, parent, renderer, oldStartVnode.elm);
|
|
4111
|
+
newStartVnode = newCh[++newStartIdx];
|
|
4112
|
+
} else {
|
|
4113
|
+
elmToMove = oldCh[idxInOld];
|
|
4114
|
+
|
|
4115
|
+
if (isVNode(elmToMove)) {
|
|
4116
|
+
if (elmToMove.sel !== newStartVnode.sel) {
|
|
4117
|
+
// New element
|
|
4118
|
+
mount(newStartVnode, parent, renderer, oldStartVnode.elm);
|
|
4119
|
+
} else {
|
|
4120
|
+
patch(elmToMove, newStartVnode, parent, renderer); // Delete the old child, but copy the array since it is read-only.
|
|
4121
|
+
// The `oldCh` will be GC'ed after `updateDynamicChildren` is complete,
|
|
4122
|
+
// so we only care about the `oldCh` object inside this function.
|
|
4123
|
+
// To avoid cloning over and over again, we check `clonedOldCh`
|
|
4124
|
+
// and only clone once.
|
|
4125
|
+
|
|
4126
|
+
if (!clonedOldCh) {
|
|
4127
|
+
clonedOldCh = true;
|
|
4128
|
+
oldCh = [...oldCh];
|
|
4129
|
+
} // We've already cloned at least once, so it's no longer read-only
|
|
4130
|
+
|
|
4131
|
+
|
|
4132
|
+
oldCh[idxInOld] = undefined;
|
|
4133
|
+
insertNode(elmToMove.elm, parent, oldStartVnode.elm, renderer);
|
|
4134
|
+
}
|
|
3877
4135
|
}
|
|
4136
|
+
|
|
4137
|
+
newStartVnode = newCh[++newStartIdx];
|
|
4138
|
+
}
|
|
3878
4139
|
}
|
|
3879
|
-
|
|
3880
|
-
|
|
3881
|
-
|
|
3882
|
-
|
|
3883
|
-
|
|
3884
|
-
|
|
3885
|
-
|
|
3886
|
-
|
|
3887
|
-
|
|
3888
|
-
|
|
3889
|
-
|
|
3890
|
-
|
|
3891
|
-
|
|
3892
|
-
|
|
3893
|
-
|
|
4140
|
+
}
|
|
4141
|
+
|
|
4142
|
+
if (oldStartIdx <= oldEndIdx || newStartIdx <= newEndIdx) {
|
|
4143
|
+
if (oldStartIdx > oldEndIdx) {
|
|
4144
|
+
// There's some cases in which the sub array of vnodes to be inserted is followed by null(s) and an
|
|
4145
|
+
// already processed vnode, in such cases the vnodes to be inserted should be before that processed vnode.
|
|
4146
|
+
let i = newEndIdx;
|
|
4147
|
+
let n;
|
|
4148
|
+
|
|
4149
|
+
do {
|
|
4150
|
+
n = newCh[++i];
|
|
4151
|
+
} while (!isVNode(n) && i < newChEnd);
|
|
4152
|
+
|
|
4153
|
+
before = isVNode(n) ? n.elm : null;
|
|
4154
|
+
mountVNodes(newCh, parent, renderer, before, newStartIdx, newEndIdx + 1);
|
|
4155
|
+
} else {
|
|
4156
|
+
unmountVNodes(oldCh, parent, renderer, true, oldStartIdx, oldEndIdx + 1);
|
|
3894
4157
|
}
|
|
4158
|
+
}
|
|
3895
4159
|
}
|
|
4160
|
+
|
|
3896
4161
|
function updateStaticChildren(c1, c2, parent, renderer) {
|
|
3897
|
-
|
|
3898
|
-
|
|
3899
|
-
|
|
3900
|
-
|
|
3901
|
-
|
|
3902
|
-
|
|
3903
|
-
|
|
3904
|
-
|
|
3905
|
-
|
|
3906
|
-
|
|
3907
|
-
|
|
3908
|
-
|
|
3909
|
-
|
|
3910
|
-
|
|
3911
|
-
|
|
3912
|
-
|
|
3913
|
-
|
|
3914
|
-
|
|
3915
|
-
|
|
3916
|
-
|
|
3917
|
-
|
|
3918
|
-
|
|
3919
|
-
|
|
3920
|
-
|
|
3921
|
-
|
|
3922
|
-
|
|
3923
|
-
|
|
3924
|
-
|
|
3925
|
-
|
|
3926
|
-
|
|
3927
|
-
|
|
3928
|
-
|
|
3929
|
-
|
|
3930
|
-
anchor = n2.elm;
|
|
3931
|
-
}
|
|
4162
|
+
const c1Length = c1.length;
|
|
4163
|
+
const c2Length = c2.length;
|
|
4164
|
+
|
|
4165
|
+
if (c1Length === 0) {
|
|
4166
|
+
// the old list is empty, we can directly insert anything new
|
|
4167
|
+
mountVNodes(c2, parent, renderer, null);
|
|
4168
|
+
return;
|
|
4169
|
+
}
|
|
4170
|
+
|
|
4171
|
+
if (c2Length === 0) {
|
|
4172
|
+
// the old list is nonempty and the new list is empty so we can directly remove all old nodes
|
|
4173
|
+
// this is the case in which the dynamic children of an if-directive should be removed
|
|
4174
|
+
unmountVNodes(c1, parent, renderer, true);
|
|
4175
|
+
return;
|
|
4176
|
+
} // if the old list is not empty, the new list MUST have the same
|
|
4177
|
+
// amount of nodes, that's why we call this static children
|
|
4178
|
+
|
|
4179
|
+
|
|
4180
|
+
let anchor = null;
|
|
4181
|
+
|
|
4182
|
+
for (let i = c2Length - 1; i >= 0; i -= 1) {
|
|
4183
|
+
const n1 = c1[i];
|
|
4184
|
+
const n2 = c2[i];
|
|
4185
|
+
|
|
4186
|
+
if (n2 !== n1) {
|
|
4187
|
+
if (isVNode(n1)) {
|
|
4188
|
+
if (isVNode(n2)) {
|
|
4189
|
+
// both vnodes are equivalent, and we just need to patch them
|
|
4190
|
+
patch(n1, n2, parent, renderer);
|
|
4191
|
+
anchor = n2.elm;
|
|
4192
|
+
} else {
|
|
4193
|
+
// removing the old vnode since the new one is null
|
|
4194
|
+
unmount(n1, parent, renderer, true);
|
|
3932
4195
|
}
|
|
4196
|
+
} else if (isVNode(n2)) {
|
|
4197
|
+
mount(n2, parent, renderer, anchor);
|
|
4198
|
+
anchor = n2.elm;
|
|
4199
|
+
}
|
|
3933
4200
|
}
|
|
4201
|
+
}
|
|
3934
4202
|
}
|
|
3935
4203
|
|
|
3936
4204
|
/*
|
|
@@ -5889,6 +6157,7 @@ function hydrateNode(node, vnode, renderer) {
|
|
|
5889
6157
|
}
|
|
5890
6158
|
return renderer.nextSibling(hydratedNode);
|
|
5891
6159
|
}
|
|
6160
|
+
const NODE_VALUE_PROP = 'nodeValue';
|
|
5892
6161
|
function hydrateText(node, vnode, renderer) {
|
|
5893
6162
|
var _a;
|
|
5894
6163
|
if (!hasCorrectNodeType(vnode, node, 3 /* EnvNodeTypes.TEXT */, renderer)) {
|
|
@@ -5896,7 +6165,7 @@ function hydrateText(node, vnode, renderer) {
|
|
|
5896
6165
|
}
|
|
5897
6166
|
if (process.env.NODE_ENV !== 'production') {
|
|
5898
6167
|
const { getProperty } = renderer;
|
|
5899
|
-
const nodeValue = getProperty(node,
|
|
6168
|
+
const nodeValue = getProperty(node, NODE_VALUE_PROP);
|
|
5900
6169
|
if (nodeValue !== vnode.text && !(nodeValue === '\u200D' && vnode.text === '')) {
|
|
5901
6170
|
logWarn('Hydration mismatch: text values do not match, will recover from the difference', vnode.owner);
|
|
5902
6171
|
}
|
|
@@ -5913,13 +6182,13 @@ function hydrateComment(node, vnode, renderer) {
|
|
|
5913
6182
|
}
|
|
5914
6183
|
if (process.env.NODE_ENV !== 'production') {
|
|
5915
6184
|
const { getProperty } = renderer;
|
|
5916
|
-
const nodeValue = getProperty(node,
|
|
6185
|
+
const nodeValue = getProperty(node, NODE_VALUE_PROP);
|
|
5917
6186
|
if (nodeValue !== vnode.text) {
|
|
5918
6187
|
logWarn('Hydration mismatch: comment values do not match, will recover from the difference', vnode.owner);
|
|
5919
6188
|
}
|
|
5920
6189
|
}
|
|
5921
6190
|
const { setProperty } = renderer;
|
|
5922
|
-
setProperty(node,
|
|
6191
|
+
setProperty(node, NODE_VALUE_PROP, (_a = vnode.text) !== null && _a !== void 0 ? _a : null);
|
|
5923
6192
|
vnode.elm = node;
|
|
5924
6193
|
return node;
|
|
5925
6194
|
}
|
|
@@ -6187,13 +6456,13 @@ function areCompatibleNodes(client, ssr, vnode, renderer) {
|
|
|
6187
6456
|
if (!hasCorrectNodeType(vnode, ssr, 3 /* EnvNodeTypes.TEXT */, renderer)) {
|
|
6188
6457
|
return false;
|
|
6189
6458
|
}
|
|
6190
|
-
return getProperty(client,
|
|
6459
|
+
return getProperty(client, NODE_VALUE_PROP) === getProperty(ssr, NODE_VALUE_PROP);
|
|
6191
6460
|
}
|
|
6192
6461
|
if (getProperty(client, 'nodeType') === 8 /* EnvNodeTypes.COMMENT */) {
|
|
6193
6462
|
if (!hasCorrectNodeType(vnode, ssr, 8 /* EnvNodeTypes.COMMENT */, renderer)) {
|
|
6194
6463
|
return false;
|
|
6195
6464
|
}
|
|
6196
|
-
return getProperty(client,
|
|
6465
|
+
return getProperty(client, NODE_VALUE_PROP) === getProperty(ssr, NODE_VALUE_PROP);
|
|
6197
6466
|
}
|
|
6198
6467
|
if (!hasCorrectNodeType(vnode, ssr, 1 /* EnvNodeTypes.ELEMENT */, renderer)) {
|
|
6199
6468
|
return false;
|
|
@@ -6351,4 +6620,4 @@ function getComponentConstructor(elm) {
|
|
|
6351
6620
|
}
|
|
6352
6621
|
|
|
6353
6622
|
export { LightningElement, profilerControl as __unstable__ProfilerControl, api$1 as api, connectRootElement, createContextProvider, createVM, disconnectRootElement, freezeTemplate, getAssociatedVMIfPresent, getComponentConstructor, getComponentDef, getComponentHtmlPrototype, getUpgradableConstructor, hydrateRoot, isComponentConstructor, parseFragment, parseSVGFragment, readonly, register, registerComponent, registerDecorators, registerTemplate, sanitizeAttribute, setHooks, swapComponent, swapStyle, swapTemplate, track, unwrap, wire };
|
|
6354
|
-
/* version: 2.23.
|
|
6623
|
+
/* version: 2.23.2 */
|