lwc 2.7.4 → 2.10.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 +663 -470
- package/dist/engine-dom/iife/es2017/engine-dom.js +663 -470
- package/dist/engine-dom/iife/es2017/engine-dom.min.js +1 -1
- package/dist/engine-dom/iife/es2017/engine-dom_debug.js +544 -426
- package/dist/engine-dom/iife/es5/engine-dom.js +816 -594
- package/dist/engine-dom/iife/es5/engine-dom.min.js +1 -1
- package/dist/engine-dom/iife/es5/engine-dom_debug.js +624 -497
- package/dist/engine-dom/umd/es2017/engine-dom.js +663 -470
- package/dist/engine-dom/umd/es2017/engine-dom.min.js +1 -1
- package/dist/engine-dom/umd/es2017/engine-dom_debug.js +544 -426
- package/dist/engine-dom/umd/es5/engine-dom.js +816 -594
- package/dist/engine-dom/umd/es5/engine-dom.min.js +1 -1
- package/dist/engine-dom/umd/es5/engine-dom_debug.js +624 -497
- package/dist/engine-server/commonjs/es2017/engine-server.js +427 -299
- package/dist/engine-server/commonjs/es2017/engine-server.min.js +1 -1
- package/dist/engine-server/esm/es2017/engine-server.js +427 -299
- package/dist/synthetic-shadow/esm/es2017/synthetic-shadow.js +3 -3
- package/dist/synthetic-shadow/iife/es2017/synthetic-shadow.js +3 -3
- package/dist/synthetic-shadow/iife/es2017/synthetic-shadow_debug.js +3 -3
- package/dist/synthetic-shadow/iife/es5/synthetic-shadow.js +3 -3
- package/dist/synthetic-shadow/iife/es5/synthetic-shadow_debug.js +3 -3
- package/dist/synthetic-shadow/umd/es2017/synthetic-shadow.js +3 -3
- package/dist/synthetic-shadow/umd/es2017/synthetic-shadow_debug.js +3 -3
- package/dist/synthetic-shadow/umd/es5/synthetic-shadow.js +3 -3
- package/dist/synthetic-shadow/umd/es5/synthetic-shadow_debug.js +3 -3
- 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_debug.js +2 -2
- package/dist/wire-service/iife/es5/wire-service.js +2 -2
- package/dist/wire-service/iife/es5/wire-service_debug.js +2 -2
- package/dist/wire-service/umd/es2017/wire-service.js +2 -2
- package/dist/wire-service/umd/es2017/wire-service_debug.js +2 -2
- package/dist/wire-service/umd/es5/wire-service.js +2 -2
- package/dist/wire-service/umd/es5/wire-service_debug.js +2 -2
- package/package.json +8 -8
- package/LICENSE +0 -10
|
@@ -309,7 +309,17 @@
|
|
|
309
309
|
const XML_NAMESPACE = 'http://www.w3.org/XML/1998/namespace';
|
|
310
310
|
const SVG_NAMESPACE = 'http://www.w3.org/2000/svg';
|
|
311
311
|
const XLINK_NAMESPACE = 'http://www.w3.org/1999/xlink';
|
|
312
|
-
|
|
312
|
+
/*
|
|
313
|
+
* Copyright (c) 2018, salesforce.com, inc.
|
|
314
|
+
* All rights reserved.
|
|
315
|
+
* SPDX-License-Identifier: MIT
|
|
316
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
317
|
+
*/
|
|
318
|
+
// Increment whenever the LWC template compiler changes
|
|
319
|
+
|
|
320
|
+
const LWC_VERSION = "2.10.0";
|
|
321
|
+
const LWC_VERSION_COMMENT_REGEX = /\/\*LWC compiler v([\d.]+)\*\/\s*}/;
|
|
322
|
+
/** version: 2.10.0 */
|
|
313
323
|
|
|
314
324
|
/*
|
|
315
325
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
@@ -376,7 +386,7 @@
|
|
|
376
386
|
};
|
|
377
387
|
}
|
|
378
388
|
|
|
379
|
-
function patch(propName) {
|
|
389
|
+
function patch$1(propName) {
|
|
380
390
|
// Typescript is inferring the wrong function type for this particular
|
|
381
391
|
// overloaded method: https://github.com/Microsoft/TypeScript/issues/27972
|
|
382
392
|
// @ts-ignore type-mismatch
|
|
@@ -398,7 +408,7 @@
|
|
|
398
408
|
const propName = ElementPrototypeAriaPropertyNames[i];
|
|
399
409
|
|
|
400
410
|
if (detect(propName)) {
|
|
401
|
-
patch(propName);
|
|
411
|
+
patch$1(propName);
|
|
402
412
|
}
|
|
403
413
|
}
|
|
404
414
|
/**
|
|
@@ -414,14 +424,15 @@
|
|
|
414
424
|
|
|
415
425
|
|
|
416
426
|
const features = {
|
|
417
|
-
|
|
418
|
-
ENABLE_HMR: null,
|
|
419
|
-
ENABLE_INNER_OUTER_TEXT_PATCH: null,
|
|
427
|
+
DISABLE_MIXED_SHADOW_MODE: null,
|
|
420
428
|
ENABLE_ELEMENT_PATCH: null,
|
|
421
429
|
ENABLE_FORCE_NATIVE_SHADOW_MODE_FOR_TEST: null,
|
|
422
|
-
|
|
430
|
+
ENABLE_HMR: null,
|
|
423
431
|
ENABLE_HTML_COLLECTIONS_PATCH: null,
|
|
432
|
+
ENABLE_INNER_OUTER_TEXT_PATCH: null,
|
|
433
|
+
ENABLE_NODE_LIST_PATCH: null,
|
|
424
434
|
ENABLE_NODE_PATCH: null,
|
|
435
|
+
ENABLE_REACTIVE_SETTER: null,
|
|
425
436
|
ENABLE_WIRE_SYNC_EMIT: null
|
|
426
437
|
};
|
|
427
438
|
|
|
@@ -486,7 +497,7 @@
|
|
|
486
497
|
setFeatureFlag(name, value);
|
|
487
498
|
}
|
|
488
499
|
}
|
|
489
|
-
/** version: 2.
|
|
500
|
+
/** version: 2.10.0 */
|
|
490
501
|
|
|
491
502
|
/* proxy-compat-disable */
|
|
492
503
|
|
|
@@ -560,6 +571,33 @@
|
|
|
560
571
|
}
|
|
561
572
|
|
|
562
573
|
return styleMap;
|
|
574
|
+
} // Make a shallow copy of an object but omit the given key
|
|
575
|
+
|
|
576
|
+
|
|
577
|
+
function cloneAndOmitKey(object, keyToOmit) {
|
|
578
|
+
const result = {};
|
|
579
|
+
|
|
580
|
+
for (const key of Object.keys(object)) {
|
|
581
|
+
if (key !== keyToOmit) {
|
|
582
|
+
result[key] = object[key];
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
return result;
|
|
587
|
+
}
|
|
588
|
+
|
|
589
|
+
function flattenStylesheets(stylesheets) {
|
|
590
|
+
const list = [];
|
|
591
|
+
|
|
592
|
+
for (const stylesheet of stylesheets) {
|
|
593
|
+
if (!Array.isArray(stylesheet)) {
|
|
594
|
+
list.push(stylesheet);
|
|
595
|
+
} else {
|
|
596
|
+
list.push(...flattenStylesheets(stylesheet));
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
|
|
600
|
+
return list;
|
|
563
601
|
} //
|
|
564
602
|
// Primitives
|
|
565
603
|
//
|
|
@@ -3365,6 +3403,47 @@
|
|
|
3365
3403
|
const meta = signedDecoratorToMetaMap.get(Ctor);
|
|
3366
3404
|
return isUndefined$1(meta) ? defaultMeta : meta;
|
|
3367
3405
|
}
|
|
3406
|
+
/*
|
|
3407
|
+
* Copyright (c) 2018, salesforce.com, inc.
|
|
3408
|
+
* All rights reserved.
|
|
3409
|
+
* SPDX-License-Identifier: MIT
|
|
3410
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
3411
|
+
*/
|
|
3412
|
+
|
|
3413
|
+
|
|
3414
|
+
let warned = false;
|
|
3415
|
+
|
|
3416
|
+
if (process.env.NODE_ENV === 'development') {
|
|
3417
|
+
// @ts-ignore
|
|
3418
|
+
window.__lwcResetWarnedOnVersionMismatch = () => {
|
|
3419
|
+
warned = false;
|
|
3420
|
+
};
|
|
3421
|
+
}
|
|
3422
|
+
|
|
3423
|
+
function checkVersionMismatch(func, type) {
|
|
3424
|
+
const versionMatcher = func.toString().match(LWC_VERSION_COMMENT_REGEX);
|
|
3425
|
+
|
|
3426
|
+
if (!isNull(versionMatcher) && !warned) {
|
|
3427
|
+
const version = versionMatcher[1];
|
|
3428
|
+
const [major, minor] = version.split('.');
|
|
3429
|
+
const [expectedMajor, expectedMinor] = LWC_VERSION.split('.');
|
|
3430
|
+
|
|
3431
|
+
if (major !== expectedMajor || minor !== expectedMinor) {
|
|
3432
|
+
warned = true; // only warn once to avoid flooding the console
|
|
3433
|
+
// stylesheets and templates do not have user-meaningful names, but components do
|
|
3434
|
+
|
|
3435
|
+
const friendlyName = type === 'component' ? `${type} ${func.name}` : type;
|
|
3436
|
+
logError(`LWC WARNING: current engine is v${LWC_VERSION}, but ${friendlyName} was compiled with v${version}.\nPlease update your compiled code or LWC engine so that the versions match.\nNo further warnings will appear.`);
|
|
3437
|
+
}
|
|
3438
|
+
}
|
|
3439
|
+
}
|
|
3440
|
+
/*
|
|
3441
|
+
* Copyright (c) 2018, salesforce.com, inc.
|
|
3442
|
+
* All rights reserved.
|
|
3443
|
+
* SPDX-License-Identifier: MIT
|
|
3444
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
3445
|
+
*/
|
|
3446
|
+
|
|
3368
3447
|
|
|
3369
3448
|
const signedTemplateSet = new Set();
|
|
3370
3449
|
|
|
@@ -3377,6 +3456,16 @@
|
|
|
3377
3456
|
function isTemplateRegistered(tpl) {
|
|
3378
3457
|
return signedTemplateSet.has(tpl);
|
|
3379
3458
|
}
|
|
3459
|
+
|
|
3460
|
+
function checkTemplateVersionMismatch(template) {
|
|
3461
|
+
checkVersionMismatch(template, 'template');
|
|
3462
|
+
|
|
3463
|
+
if (!isUndefined$1(template.stylesheets)) {
|
|
3464
|
+
for (const stylesheet of flattenStylesheets(template.stylesheets)) {
|
|
3465
|
+
checkVersionMismatch(stylesheet, 'stylesheet');
|
|
3466
|
+
}
|
|
3467
|
+
}
|
|
3468
|
+
}
|
|
3380
3469
|
/**
|
|
3381
3470
|
* INTERNAL: This function can only be invoked by compiled code. The compiler
|
|
3382
3471
|
* will prevent this function from being imported by userland code.
|
|
@@ -3384,6 +3473,10 @@
|
|
|
3384
3473
|
|
|
3385
3474
|
|
|
3386
3475
|
function registerTemplate(tpl) {
|
|
3476
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
3477
|
+
checkTemplateVersionMismatch(tpl);
|
|
3478
|
+
}
|
|
3479
|
+
|
|
3387
3480
|
signedTemplateSet.add(tpl); // chaining this method as a way to wrap existing
|
|
3388
3481
|
// assignment of templates easily, without too much transformation
|
|
3389
3482
|
|
|
@@ -3679,20 +3772,6 @@
|
|
|
3679
3772
|
return canRefreshAllInstances;
|
|
3680
3773
|
}
|
|
3681
3774
|
|
|
3682
|
-
function flattenStylesheets(stylesheets) {
|
|
3683
|
-
const list = [];
|
|
3684
|
-
|
|
3685
|
-
for (const stylesheet of stylesheets) {
|
|
3686
|
-
if (!Array.isArray(stylesheet)) {
|
|
3687
|
-
list.push(stylesheet);
|
|
3688
|
-
} else {
|
|
3689
|
-
list.push(...flattenStylesheets(stylesheet));
|
|
3690
|
-
}
|
|
3691
|
-
}
|
|
3692
|
-
|
|
3693
|
-
return list;
|
|
3694
|
-
}
|
|
3695
|
-
|
|
3696
3775
|
function getTemplateOrSwappedTemplate(tpl) {
|
|
3697
3776
|
if (process.env.NODE_ENV === 'production') {
|
|
3698
3777
|
// this method should never leak to prod
|
|
@@ -4523,156 +4602,268 @@
|
|
|
4523
4602
|
*/
|
|
4524
4603
|
|
|
4525
4604
|
|
|
4526
|
-
|
|
4527
|
-
|
|
4528
|
-
|
|
4529
|
-
|
|
4530
|
-
|
|
4531
|
-
const elm = createText$1(vnode.text);
|
|
4532
|
-
linkNodeToShadow(elm, owner);
|
|
4533
|
-
vnode.elm = elm;
|
|
4534
|
-
},
|
|
4535
|
-
update: updateNodeHook,
|
|
4536
|
-
insert: insertNode,
|
|
4537
|
-
move: insertNode,
|
|
4538
|
-
remove: removeNode
|
|
4539
|
-
};
|
|
4540
|
-
const CommentHook = {
|
|
4541
|
-
create: vnode => {
|
|
4542
|
-
const {
|
|
4543
|
-
owner,
|
|
4544
|
-
text
|
|
4545
|
-
} = vnode;
|
|
4546
|
-
const elm = createComment$1(text);
|
|
4547
|
-
linkNodeToShadow(elm, owner);
|
|
4548
|
-
vnode.elm = elm;
|
|
4549
|
-
},
|
|
4550
|
-
update: updateNodeHook,
|
|
4551
|
-
insert: insertNode,
|
|
4552
|
-
move: insertNode,
|
|
4553
|
-
remove: removeNode
|
|
4554
|
-
}; // insert is called after update, which is used somewhere else (via a module)
|
|
4555
|
-
// to mark the vm as inserted, that means we cannot use update as the main channel
|
|
4556
|
-
// to rehydrate when dirty, because sometimes the element is not inserted just yet,
|
|
4557
|
-
// which breaks some invariants. For that reason, we have the following for any
|
|
4558
|
-
// Custom Element that is inserted via a template.
|
|
4559
|
-
|
|
4560
|
-
const ElementHook = {
|
|
4561
|
-
create: vnode => {
|
|
4562
|
-
const {
|
|
4563
|
-
sel,
|
|
4564
|
-
owner,
|
|
4565
|
-
data: {
|
|
4566
|
-
svg
|
|
4567
|
-
}
|
|
4568
|
-
} = vnode;
|
|
4569
|
-
const namespace = isTrue(svg) ? SVG_NAMESPACE : undefined;
|
|
4570
|
-
const elm = createElement$2(sel, namespace);
|
|
4571
|
-
linkNodeToShadow(elm, owner);
|
|
4572
|
-
fallbackElmHook(elm, vnode);
|
|
4573
|
-
vnode.elm = elm;
|
|
4574
|
-
patchElementPropsAndAttrs$1(null, vnode);
|
|
4575
|
-
},
|
|
4576
|
-
update: (oldVnode, vnode) => {
|
|
4577
|
-
patchElementPropsAndAttrs$1(oldVnode, vnode);
|
|
4578
|
-
patchChildren(vnode.elm, oldVnode.children, vnode.children);
|
|
4579
|
-
},
|
|
4580
|
-
insert: (vnode, parentNode, referenceNode) => {
|
|
4581
|
-
insertNode(vnode, parentNode, referenceNode);
|
|
4582
|
-
createChildrenHook(vnode);
|
|
4583
|
-
},
|
|
4584
|
-
move: insertNode,
|
|
4585
|
-
remove: (vnode, parentNode) => {
|
|
4586
|
-
removeNode(vnode, parentNode);
|
|
4587
|
-
removeChildren(vnode);
|
|
4605
|
+
function patchChildren(c1, c2, parent) {
|
|
4606
|
+
if (hasDynamicChildren(c2)) {
|
|
4607
|
+
updateDynamicChildren(c1, c2, parent);
|
|
4608
|
+
} else {
|
|
4609
|
+
updateStaticChildren(c1, c2, parent);
|
|
4588
4610
|
}
|
|
4589
|
-
}
|
|
4590
|
-
const CustomElementHook = {
|
|
4591
|
-
create: vnode => {
|
|
4592
|
-
const {
|
|
4593
|
-
sel,
|
|
4594
|
-
owner
|
|
4595
|
-
} = vnode;
|
|
4596
|
-
const UpgradableConstructor = getUpgradableConstructor(sel);
|
|
4597
|
-
/**
|
|
4598
|
-
* Note: if the upgradable constructor does not expect, or throw when we new it
|
|
4599
|
-
* with a callback as the first argument, we could implement a more advanced
|
|
4600
|
-
* mechanism that only passes that argument if the constructor is known to be
|
|
4601
|
-
* an upgradable custom element.
|
|
4602
|
-
*/
|
|
4603
|
-
|
|
4604
|
-
let vm;
|
|
4605
|
-
const elm = new UpgradableConstructor(elm => {
|
|
4606
|
-
// the custom element from the registry is expecting an upgrade callback
|
|
4607
|
-
vm = createViewModelHook(elm, vnode);
|
|
4608
|
-
});
|
|
4609
|
-
linkNodeToShadow(elm, owner);
|
|
4610
|
-
vnode.elm = elm;
|
|
4611
|
+
}
|
|
4611
4612
|
|
|
4612
|
-
|
|
4613
|
-
|
|
4614
|
-
|
|
4615
|
-
|
|
4613
|
+
function patch(n1, n2) {
|
|
4614
|
+
if (n1 === n2) {
|
|
4615
|
+
return;
|
|
4616
|
+
}
|
|
4617
|
+
|
|
4618
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
4619
|
+
if (!isSameVnode(n1, n2)) {
|
|
4620
|
+
throw new Error('Expected these VNodes to be the same: ' + JSON.stringify({
|
|
4621
|
+
sel: n1.sel,
|
|
4622
|
+
key: n1.key
|
|
4623
|
+
}) + ', ' + JSON.stringify({
|
|
4624
|
+
sel: n2.sel,
|
|
4625
|
+
key: n2.key
|
|
4626
|
+
}));
|
|
4616
4627
|
}
|
|
4628
|
+
}
|
|
4617
4629
|
|
|
4618
|
-
|
|
4619
|
-
|
|
4620
|
-
|
|
4621
|
-
|
|
4622
|
-
|
|
4630
|
+
switch (n2.type) {
|
|
4631
|
+
case 0
|
|
4632
|
+
/* Text */
|
|
4633
|
+
:
|
|
4634
|
+
patchText(n1, n2);
|
|
4635
|
+
break;
|
|
4636
|
+
|
|
4637
|
+
case 1
|
|
4638
|
+
/* Comment */
|
|
4639
|
+
:
|
|
4640
|
+
patchComment(n1, n2);
|
|
4641
|
+
break;
|
|
4642
|
+
|
|
4643
|
+
case 2
|
|
4644
|
+
/* Element */
|
|
4645
|
+
:
|
|
4646
|
+
patchElement(n1, n2);
|
|
4647
|
+
break;
|
|
4648
|
+
|
|
4649
|
+
case 3
|
|
4650
|
+
/* CustomElement */
|
|
4651
|
+
:
|
|
4652
|
+
patchCustomElement(n1, n2);
|
|
4653
|
+
break;
|
|
4654
|
+
}
|
|
4655
|
+
}
|
|
4623
4656
|
|
|
4624
|
-
|
|
4625
|
-
|
|
4626
|
-
|
|
4627
|
-
|
|
4628
|
-
|
|
4629
|
-
|
|
4657
|
+
function mount(node, parent, anchor) {
|
|
4658
|
+
switch (node.type) {
|
|
4659
|
+
case 0
|
|
4660
|
+
/* Text */
|
|
4661
|
+
:
|
|
4662
|
+
mountText(node, parent, anchor);
|
|
4663
|
+
break;
|
|
4630
4664
|
|
|
4665
|
+
case 1
|
|
4666
|
+
/* Comment */
|
|
4667
|
+
:
|
|
4668
|
+
mountComment(node, parent, anchor);
|
|
4669
|
+
break;
|
|
4631
4670
|
|
|
4632
|
-
|
|
4671
|
+
case 2
|
|
4672
|
+
/* Element */
|
|
4673
|
+
:
|
|
4674
|
+
mountElement(node, parent, anchor);
|
|
4675
|
+
break;
|
|
4633
4676
|
|
|
4634
|
-
|
|
4635
|
-
|
|
4636
|
-
|
|
4637
|
-
|
|
4638
|
-
|
|
4677
|
+
case 3
|
|
4678
|
+
/* CustomElement */
|
|
4679
|
+
:
|
|
4680
|
+
mountCustomElement(node, parent, anchor);
|
|
4681
|
+
break;
|
|
4682
|
+
}
|
|
4683
|
+
}
|
|
4684
|
+
|
|
4685
|
+
function patchText(n1, n2) {
|
|
4686
|
+
n2.elm = n1.elm;
|
|
4687
|
+
|
|
4688
|
+
if (n2.text !== n1.text) {
|
|
4689
|
+
updateTextContent(n2);
|
|
4690
|
+
}
|
|
4691
|
+
}
|
|
4692
|
+
|
|
4693
|
+
function mountText(node, parent, anchor) {
|
|
4694
|
+
const {
|
|
4695
|
+
owner
|
|
4696
|
+
} = node;
|
|
4697
|
+
const textNode = node.elm = createText$1(node.text);
|
|
4698
|
+
linkNodeToShadow(textNode, owner);
|
|
4699
|
+
insertNode(textNode, parent, anchor);
|
|
4700
|
+
}
|
|
4701
|
+
|
|
4702
|
+
function patchComment(n1, n2) {
|
|
4703
|
+
n2.elm = n1.elm; // FIXME: Comment nodes should be static, we shouldn't need to diff them together. However
|
|
4704
|
+
// it is the case today.
|
|
4705
|
+
|
|
4706
|
+
if (n2.text !== n1.text) {
|
|
4707
|
+
updateTextContent(n2);
|
|
4708
|
+
}
|
|
4709
|
+
}
|
|
4639
4710
|
|
|
4711
|
+
function mountComment(node, parent, anchor) {
|
|
4712
|
+
const {
|
|
4713
|
+
owner
|
|
4714
|
+
} = node;
|
|
4715
|
+
const commentNode = node.elm = createComment$1(node.text);
|
|
4716
|
+
linkNodeToShadow(commentNode, owner);
|
|
4717
|
+
insertNode(commentNode, parent, anchor);
|
|
4718
|
+
}
|
|
4640
4719
|
|
|
4641
|
-
|
|
4720
|
+
function mountElement(vnode, parent, anchor) {
|
|
4721
|
+
const {
|
|
4722
|
+
sel,
|
|
4723
|
+
owner,
|
|
4724
|
+
data: {
|
|
4725
|
+
svg
|
|
4642
4726
|
}
|
|
4643
|
-
}
|
|
4644
|
-
|
|
4645
|
-
|
|
4646
|
-
|
|
4727
|
+
} = vnode;
|
|
4728
|
+
const namespace = isTrue(svg) ? SVG_NAMESPACE : undefined;
|
|
4729
|
+
const elm = createElement$2(sel, namespace);
|
|
4730
|
+
linkNodeToShadow(elm, owner);
|
|
4731
|
+
fallbackElmHook(elm, vnode);
|
|
4732
|
+
vnode.elm = elm;
|
|
4733
|
+
patchElementPropsAndAttrs$1(null, vnode);
|
|
4734
|
+
insertNode(elm, parent, anchor);
|
|
4735
|
+
mountVNodes(vnode.children, elm, null);
|
|
4736
|
+
}
|
|
4647
4737
|
|
|
4648
|
-
|
|
4649
|
-
|
|
4650
|
-
|
|
4651
|
-
|
|
4652
|
-
|
|
4653
|
-
|
|
4738
|
+
function patchElement(n1, n2) {
|
|
4739
|
+
const elm = n2.elm = n1.elm;
|
|
4740
|
+
patchElementPropsAndAttrs$1(n1, n2);
|
|
4741
|
+
patchChildren(n1.children, n2.children, elm);
|
|
4742
|
+
}
|
|
4743
|
+
|
|
4744
|
+
function mountCustomElement(vnode, parent, anchor) {
|
|
4745
|
+
const {
|
|
4746
|
+
sel,
|
|
4747
|
+
owner
|
|
4748
|
+
} = vnode;
|
|
4749
|
+
const UpgradableConstructor = getUpgradableConstructor(sel);
|
|
4750
|
+
/**
|
|
4751
|
+
* Note: if the upgradable constructor does not expect, or throw when we new it
|
|
4752
|
+
* with a callback as the first argument, we could implement a more advanced
|
|
4753
|
+
* mechanism that only passes that argument if the constructor is known to be
|
|
4754
|
+
* an upgradable custom element.
|
|
4755
|
+
*/
|
|
4756
|
+
|
|
4757
|
+
let vm;
|
|
4758
|
+
const elm = new UpgradableConstructor(elm => {
|
|
4759
|
+
// the custom element from the registry is expecting an upgrade callback
|
|
4760
|
+
vm = createViewModelHook(elm, vnode);
|
|
4761
|
+
});
|
|
4762
|
+
linkNodeToShadow(elm, owner);
|
|
4763
|
+
vnode.elm = elm;
|
|
4764
|
+
vnode.vm = vm;
|
|
4765
|
+
|
|
4766
|
+
if (vm) {
|
|
4767
|
+
allocateChildren(vnode, vm);
|
|
4768
|
+
} else if (vnode.ctor !== UpgradableConstructor) {
|
|
4769
|
+
throw new TypeError(`Incorrect Component Constructor`);
|
|
4770
|
+
}
|
|
4771
|
+
|
|
4772
|
+
patchElementPropsAndAttrs$1(null, vnode);
|
|
4773
|
+
insertNode(elm, parent, anchor);
|
|
4654
4774
|
|
|
4655
|
-
|
|
4775
|
+
if (vm) {
|
|
4776
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
4777
|
+
assert.isTrue(vm.state === 0
|
|
4778
|
+
/* created */
|
|
4779
|
+
, `${vm} cannot be recycled.`);
|
|
4656
4780
|
}
|
|
4657
4781
|
|
|
4658
|
-
|
|
4782
|
+
runConnectedCallback(vm);
|
|
4783
|
+
}
|
|
4784
|
+
|
|
4785
|
+
mountVNodes(vnode.children, elm, null);
|
|
4786
|
+
|
|
4787
|
+
if (vm) {
|
|
4788
|
+
appendVM(vm);
|
|
4789
|
+
}
|
|
4790
|
+
}
|
|
4791
|
+
|
|
4792
|
+
function patchCustomElement(n1, n2) {
|
|
4793
|
+
const elm = n2.elm = n1.elm;
|
|
4794
|
+
const vm = n2.vm = n1.vm;
|
|
4795
|
+
patchElementPropsAndAttrs$1(n1, n2);
|
|
4796
|
+
|
|
4797
|
+
if (!isUndefined$1(vm)) {
|
|
4798
|
+
// in fallback mode, the allocation will always set children to
|
|
4799
|
+
// empty and delegate the real allocation to the slot elements
|
|
4800
|
+
allocateChildren(n2, vm);
|
|
4801
|
+
} // in fallback mode, the children will be always empty, so, nothing
|
|
4802
|
+
// will happen, but in native, it does allocate the light dom
|
|
4803
|
+
|
|
4804
|
+
|
|
4805
|
+
patchChildren(n1.children, n2.children, elm);
|
|
4806
|
+
|
|
4807
|
+
if (!isUndefined$1(vm)) {
|
|
4808
|
+
// this will probably update the shadowRoot, but only if the vm is in a dirty state
|
|
4809
|
+
// this is important to preserve the top to bottom synchronous rendering phase.
|
|
4810
|
+
rerenderVM(vm);
|
|
4811
|
+
}
|
|
4812
|
+
}
|
|
4813
|
+
|
|
4814
|
+
function mountVNodes(vnodes, parent, anchor, start = 0, end = vnodes.length) {
|
|
4815
|
+
for (; start < end; ++start) {
|
|
4816
|
+
const vnode = vnodes[start];
|
|
4659
4817
|
|
|
4660
|
-
if (
|
|
4661
|
-
|
|
4818
|
+
if (isVNode(vnode)) {
|
|
4819
|
+
mount(vnode, parent, anchor);
|
|
4662
4820
|
}
|
|
4663
|
-
}
|
|
4664
|
-
|
|
4665
|
-
|
|
4666
|
-
|
|
4667
|
-
|
|
4821
|
+
}
|
|
4822
|
+
}
|
|
4823
|
+
|
|
4824
|
+
function unmount(vnode, parent, doRemove = false) {
|
|
4825
|
+
const {
|
|
4826
|
+
type,
|
|
4827
|
+
elm
|
|
4828
|
+
} = vnode; // When unmounting a VNode subtree not all the elements have to removed from the DOM. The
|
|
4829
|
+
// subtree root, is the only element worth unmounting from the subtree.
|
|
4830
|
+
|
|
4831
|
+
if (doRemove) {
|
|
4832
|
+
removeNode(elm, parent);
|
|
4833
|
+
}
|
|
4834
|
+
|
|
4835
|
+
switch (type) {
|
|
4836
|
+
case 2
|
|
4837
|
+
/* Element */
|
|
4838
|
+
:
|
|
4839
|
+
unmountVNodes(vnode.children, elm);
|
|
4840
|
+
break;
|
|
4841
|
+
|
|
4842
|
+
case 3
|
|
4843
|
+
/* CustomElement */
|
|
4844
|
+
:
|
|
4845
|
+
{
|
|
4846
|
+
const {
|
|
4847
|
+
vm
|
|
4848
|
+
} = vnode; // No need to unmount the children here, `removeVM` will take care of removing the
|
|
4849
|
+
// children.
|
|
4850
|
+
|
|
4851
|
+
if (!isUndefined$1(vm)) {
|
|
4852
|
+
removeVM(vm);
|
|
4853
|
+
}
|
|
4854
|
+
}
|
|
4855
|
+
}
|
|
4856
|
+
}
|
|
4857
|
+
|
|
4858
|
+
function unmountVNodes(vnodes, parent, doRemove = false, start = 0, end = vnodes.length) {
|
|
4859
|
+
for (; start < end; ++start) {
|
|
4860
|
+
const ch = vnodes[start];
|
|
4668
4861
|
|
|
4669
|
-
if (
|
|
4670
|
-
|
|
4671
|
-
// will take care of disconnecting any child VM attached to its shadow as well.
|
|
4672
|
-
removeVM(vm);
|
|
4862
|
+
if (isVNode(ch)) {
|
|
4863
|
+
unmount(ch, parent, doRemove);
|
|
4673
4864
|
}
|
|
4674
4865
|
}
|
|
4675
|
-
}
|
|
4866
|
+
}
|
|
4676
4867
|
|
|
4677
4868
|
function isVNode(vnode) {
|
|
4678
4869
|
return vnode != null;
|
|
@@ -4717,43 +4908,41 @@
|
|
|
4717
4908
|
}
|
|
4718
4909
|
}
|
|
4719
4910
|
|
|
4720
|
-
function
|
|
4911
|
+
function updateTextContent(vnode) {
|
|
4721
4912
|
const {
|
|
4722
4913
|
elm,
|
|
4723
4914
|
text
|
|
4724
4915
|
} = vnode;
|
|
4725
4916
|
|
|
4726
|
-
if (
|
|
4727
|
-
|
|
4728
|
-
|
|
4729
|
-
}
|
|
4917
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
4918
|
+
unlockDomMutation();
|
|
4919
|
+
}
|
|
4730
4920
|
|
|
4731
|
-
|
|
4921
|
+
setText$1(elm, text);
|
|
4732
4922
|
|
|
4733
|
-
|
|
4734
|
-
|
|
4735
|
-
}
|
|
4923
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
4924
|
+
lockDomMutation();
|
|
4736
4925
|
}
|
|
4737
4926
|
}
|
|
4738
4927
|
|
|
4739
|
-
function insertNode(
|
|
4928
|
+
function insertNode(node, parent, anchor) {
|
|
4740
4929
|
if (process.env.NODE_ENV !== 'production') {
|
|
4741
4930
|
unlockDomMutation();
|
|
4742
4931
|
}
|
|
4743
4932
|
|
|
4744
|
-
insert$1(
|
|
4933
|
+
insert$1(node, parent, anchor);
|
|
4745
4934
|
|
|
4746
4935
|
if (process.env.NODE_ENV !== 'production') {
|
|
4747
4936
|
lockDomMutation();
|
|
4748
4937
|
}
|
|
4749
4938
|
}
|
|
4750
4939
|
|
|
4751
|
-
function removeNode(
|
|
4940
|
+
function removeNode(node, parent) {
|
|
4752
4941
|
if (process.env.NODE_ENV !== 'production') {
|
|
4753
4942
|
unlockDomMutation();
|
|
4754
4943
|
}
|
|
4755
4944
|
|
|
4756
|
-
remove$1(
|
|
4945
|
+
remove$1(node, parent);
|
|
4757
4946
|
|
|
4758
4947
|
if (process.env.NODE_ENV !== 'production') {
|
|
4759
4948
|
lockDomMutation();
|
|
@@ -4798,11 +4987,13 @@
|
|
|
4798
4987
|
) {
|
|
4799
4988
|
// this element will now accept any manual content inserted into it
|
|
4800
4989
|
observeElementChildNodes(elm);
|
|
4801
|
-
}
|
|
4802
|
-
// into each element from the template, so they can be styled accordingly.
|
|
4803
|
-
|
|
4990
|
+
}
|
|
4804
4991
|
|
|
4805
|
-
|
|
4992
|
+
if (!isUndefined$1(stylesheetToken)) {
|
|
4993
|
+
// when running in synthetic shadow mode, we need to set the shadowToken value
|
|
4994
|
+
// into each element from the template, so they can be styled accordingly.
|
|
4995
|
+
setElementShadowToken(elm, stylesheetToken);
|
|
4996
|
+
}
|
|
4806
4997
|
}
|
|
4807
4998
|
|
|
4808
4999
|
if (process.env.NODE_ENV !== 'production') {
|
|
@@ -4824,14 +5015,6 @@
|
|
|
4824
5015
|
}
|
|
4825
5016
|
}
|
|
4826
5017
|
|
|
4827
|
-
function patchChildren(parent, oldCh, newCh) {
|
|
4828
|
-
if (hasDynamicChildren(newCh)) {
|
|
4829
|
-
updateDynamicChildren(parent, oldCh, newCh);
|
|
4830
|
-
} else {
|
|
4831
|
-
updateStaticChildren(parent, oldCh, newCh);
|
|
4832
|
-
}
|
|
4833
|
-
}
|
|
4834
|
-
|
|
4835
5018
|
function allocateChildren(vnode, vm) {
|
|
4836
5019
|
// A component with slots will re-render because:
|
|
4837
5020
|
// 1- There is a change of the internal state.
|
|
@@ -4889,7 +5072,9 @@
|
|
|
4889
5072
|
} = owner.context; // when running in synthetic shadow mode, we need to set the shadowToken value
|
|
4890
5073
|
// into each element from the template, so they can be styled accordingly.
|
|
4891
5074
|
|
|
4892
|
-
|
|
5075
|
+
if (!isUndefined$1(stylesheetToken)) {
|
|
5076
|
+
setElementShadowToken(elm, stylesheetToken);
|
|
5077
|
+
}
|
|
4893
5078
|
}
|
|
4894
5079
|
|
|
4895
5080
|
vm = createVM(elm, ctor, {
|
|
@@ -4905,40 +5090,6 @@
|
|
|
4905
5090
|
return vm;
|
|
4906
5091
|
}
|
|
4907
5092
|
|
|
4908
|
-
function createChildrenHook(vnode) {
|
|
4909
|
-
const {
|
|
4910
|
-
elm,
|
|
4911
|
-
children
|
|
4912
|
-
} = vnode;
|
|
4913
|
-
|
|
4914
|
-
for (let j = 0; j < children.length; ++j) {
|
|
4915
|
-
const ch = children[j];
|
|
4916
|
-
|
|
4917
|
-
if (ch != null) {
|
|
4918
|
-
ch.hook.create(ch);
|
|
4919
|
-
ch.hook.insert(ch, elm, null);
|
|
4920
|
-
}
|
|
4921
|
-
}
|
|
4922
|
-
}
|
|
4923
|
-
|
|
4924
|
-
function removeChildren(vnode) {
|
|
4925
|
-
// this method only needs to search on child vnodes from template
|
|
4926
|
-
// to trigger the remove hook just in case some of those children
|
|
4927
|
-
// are custom elements.
|
|
4928
|
-
const {
|
|
4929
|
-
children,
|
|
4930
|
-
elm
|
|
4931
|
-
} = vnode;
|
|
4932
|
-
|
|
4933
|
-
for (let j = 0, len = children.length; j < len; ++j) {
|
|
4934
|
-
const ch = children[j];
|
|
4935
|
-
|
|
4936
|
-
if (!isNull(ch)) {
|
|
4937
|
-
ch.hook.remove(ch, elm);
|
|
4938
|
-
}
|
|
4939
|
-
}
|
|
4940
|
-
}
|
|
4941
|
-
|
|
4942
5093
|
function allocateInSlot(vm, children) {
|
|
4943
5094
|
var _a;
|
|
4944
5095
|
|
|
@@ -5035,28 +5186,7 @@
|
|
|
5035
5186
|
return map;
|
|
5036
5187
|
}
|
|
5037
5188
|
|
|
5038
|
-
function
|
|
5039
|
-
for (; startIdx <= endIdx; ++startIdx) {
|
|
5040
|
-
const ch = vnodes[startIdx];
|
|
5041
|
-
|
|
5042
|
-
if (isVNode(ch)) {
|
|
5043
|
-
ch.hook.create(ch);
|
|
5044
|
-
ch.hook.insert(ch, parentElm, before);
|
|
5045
|
-
}
|
|
5046
|
-
}
|
|
5047
|
-
}
|
|
5048
|
-
|
|
5049
|
-
function removeVnodes(parentElm, vnodes, startIdx, endIdx) {
|
|
5050
|
-
for (; startIdx <= endIdx; ++startIdx) {
|
|
5051
|
-
const ch = vnodes[startIdx]; // text nodes do not have logic associated to them
|
|
5052
|
-
|
|
5053
|
-
if (isVNode(ch)) {
|
|
5054
|
-
ch.hook.remove(ch, parentElm);
|
|
5055
|
-
}
|
|
5056
|
-
}
|
|
5057
|
-
}
|
|
5058
|
-
|
|
5059
|
-
function updateDynamicChildren(parentElm, oldCh, newCh) {
|
|
5189
|
+
function updateDynamicChildren(oldCh, newCh, parent) {
|
|
5060
5190
|
let oldStartIdx = 0;
|
|
5061
5191
|
let newStartIdx = 0;
|
|
5062
5192
|
let oldEndIdx = oldCh.length - 1;
|
|
@@ -5070,6 +5200,7 @@
|
|
|
5070
5200
|
let idxInOld;
|
|
5071
5201
|
let elmToMove;
|
|
5072
5202
|
let before;
|
|
5203
|
+
let clonedOldCh = false;
|
|
5073
5204
|
|
|
5074
5205
|
while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
|
|
5075
5206
|
if (!isVNode(oldStartVnode)) {
|
|
@@ -5081,23 +5212,23 @@
|
|
|
5081
5212
|
} else if (!isVNode(newEndVnode)) {
|
|
5082
5213
|
newEndVnode = newCh[--newEndIdx];
|
|
5083
5214
|
} else if (isSameVnode(oldStartVnode, newStartVnode)) {
|
|
5084
|
-
|
|
5215
|
+
patch(oldStartVnode, newStartVnode);
|
|
5085
5216
|
oldStartVnode = oldCh[++oldStartIdx];
|
|
5086
5217
|
newStartVnode = newCh[++newStartIdx];
|
|
5087
5218
|
} else if (isSameVnode(oldEndVnode, newEndVnode)) {
|
|
5088
|
-
|
|
5219
|
+
patch(oldEndVnode, newEndVnode);
|
|
5089
5220
|
oldEndVnode = oldCh[--oldEndIdx];
|
|
5090
5221
|
newEndVnode = newCh[--newEndIdx];
|
|
5091
5222
|
} else if (isSameVnode(oldStartVnode, newEndVnode)) {
|
|
5092
5223
|
// Vnode moved right
|
|
5093
|
-
|
|
5094
|
-
|
|
5224
|
+
patch(oldStartVnode, newEndVnode);
|
|
5225
|
+
insertNode(oldStartVnode.elm, parent, nextSibling$1(oldEndVnode.elm));
|
|
5095
5226
|
oldStartVnode = oldCh[++oldStartIdx];
|
|
5096
5227
|
newEndVnode = newCh[--newEndIdx];
|
|
5097
5228
|
} else if (isSameVnode(oldEndVnode, newStartVnode)) {
|
|
5098
5229
|
// Vnode moved left
|
|
5099
|
-
|
|
5100
|
-
newStartVnode.
|
|
5230
|
+
patch(oldEndVnode, newStartVnode);
|
|
5231
|
+
insertNode(newStartVnode.elm, parent, oldStartVnode.elm);
|
|
5101
5232
|
oldEndVnode = oldCh[--oldEndIdx];
|
|
5102
5233
|
newStartVnode = newCh[++newStartIdx];
|
|
5103
5234
|
} else {
|
|
@@ -5109,8 +5240,7 @@
|
|
|
5109
5240
|
|
|
5110
5241
|
if (isUndefined$1(idxInOld)) {
|
|
5111
5242
|
// New element
|
|
5112
|
-
newStartVnode.
|
|
5113
|
-
newStartVnode.hook.insert(newStartVnode, parentElm, oldStartVnode.elm);
|
|
5243
|
+
mount(newStartVnode, parent, oldStartVnode.elm);
|
|
5114
5244
|
newStartVnode = newCh[++newStartIdx];
|
|
5115
5245
|
} else {
|
|
5116
5246
|
elmToMove = oldCh[idxInOld];
|
|
@@ -5118,12 +5248,22 @@
|
|
|
5118
5248
|
if (isVNode(elmToMove)) {
|
|
5119
5249
|
if (elmToMove.sel !== newStartVnode.sel) {
|
|
5120
5250
|
// New element
|
|
5121
|
-
newStartVnode.
|
|
5122
|
-
newStartVnode.hook.insert(newStartVnode, parentElm, oldStartVnode.elm);
|
|
5251
|
+
mount(newStartVnode, parent, oldStartVnode.elm);
|
|
5123
5252
|
} else {
|
|
5124
|
-
|
|
5253
|
+
patch(elmToMove, newStartVnode); // Delete the old child, but copy the array since it is read-only.
|
|
5254
|
+
// The `oldCh` will be GC'ed after `updateDynamicChildren` is complete,
|
|
5255
|
+
// so we only care about the `oldCh` object inside this function.
|
|
5256
|
+
// To avoid cloning over and over again, we check `clonedOldCh`
|
|
5257
|
+
// and only clone once.
|
|
5258
|
+
|
|
5259
|
+
if (!clonedOldCh) {
|
|
5260
|
+
clonedOldCh = true;
|
|
5261
|
+
oldCh = [...oldCh];
|
|
5262
|
+
} // We've already cloned at least once, so it's no longer read-only
|
|
5263
|
+
|
|
5264
|
+
|
|
5125
5265
|
oldCh[idxInOld] = undefined;
|
|
5126
|
-
|
|
5266
|
+
insertNode(elmToMove.elm, parent, oldStartVnode.elm);
|
|
5127
5267
|
}
|
|
5128
5268
|
}
|
|
5129
5269
|
|
|
@@ -5144,65 +5284,55 @@
|
|
|
5144
5284
|
} while (!isVNode(n) && i < newChEnd);
|
|
5145
5285
|
|
|
5146
5286
|
before = isVNode(n) ? n.elm : null;
|
|
5147
|
-
|
|
5287
|
+
mountVNodes(newCh, parent, before, newStartIdx, newEndIdx + 1);
|
|
5148
5288
|
} else {
|
|
5149
|
-
|
|
5289
|
+
unmountVNodes(oldCh, parent, true, oldStartIdx, oldEndIdx + 1);
|
|
5150
5290
|
}
|
|
5151
5291
|
}
|
|
5152
5292
|
}
|
|
5153
5293
|
|
|
5154
|
-
function updateStaticChildren(
|
|
5155
|
-
const
|
|
5156
|
-
const
|
|
5294
|
+
function updateStaticChildren(c1, c2, parent) {
|
|
5295
|
+
const c1Length = c1.length;
|
|
5296
|
+
const c2Length = c2.length;
|
|
5157
5297
|
|
|
5158
|
-
if (
|
|
5298
|
+
if (c1Length === 0) {
|
|
5159
5299
|
// the old list is empty, we can directly insert anything new
|
|
5160
|
-
|
|
5300
|
+
mountVNodes(c2, parent, null);
|
|
5161
5301
|
return;
|
|
5162
5302
|
}
|
|
5163
5303
|
|
|
5164
|
-
if (
|
|
5304
|
+
if (c2Length === 0) {
|
|
5165
5305
|
// the old list is nonempty and the new list is empty so we can directly remove all old nodes
|
|
5166
5306
|
// this is the case in which the dynamic children of an if-directive should be removed
|
|
5167
|
-
|
|
5307
|
+
unmountVNodes(c1, parent, true);
|
|
5168
5308
|
return;
|
|
5169
5309
|
} // if the old list is not empty, the new list MUST have the same
|
|
5170
5310
|
// amount of nodes, that's why we call this static children
|
|
5171
5311
|
|
|
5172
5312
|
|
|
5173
|
-
let
|
|
5313
|
+
let anchor = null;
|
|
5174
5314
|
|
|
5175
|
-
for (let i =
|
|
5176
|
-
const
|
|
5177
|
-
const
|
|
5315
|
+
for (let i = c2Length - 1; i >= 0; i -= 1) {
|
|
5316
|
+
const n1 = c1[i];
|
|
5317
|
+
const n2 = c2[i];
|
|
5178
5318
|
|
|
5179
|
-
if (
|
|
5180
|
-
if (isVNode(
|
|
5181
|
-
if (isVNode(
|
|
5182
|
-
// both vnodes
|
|
5183
|
-
|
|
5184
|
-
|
|
5319
|
+
if (n2 !== n1) {
|
|
5320
|
+
if (isVNode(n1)) {
|
|
5321
|
+
if (isVNode(n2)) {
|
|
5322
|
+
// both vnodes are equivalent, and we just need to patch them
|
|
5323
|
+
patch(n1, n2);
|
|
5324
|
+
anchor = n2.elm;
|
|
5185
5325
|
} else {
|
|
5186
5326
|
// removing the old vnode since the new one is null
|
|
5187
|
-
|
|
5327
|
+
unmount(n1, parent, true);
|
|
5188
5328
|
}
|
|
5189
|
-
} else if (isVNode(
|
|
5190
|
-
|
|
5191
|
-
|
|
5192
|
-
|
|
5193
|
-
vnode.hook.insert(vnode, parentElm, referenceElm);
|
|
5194
|
-
referenceElm = vnode.elm;
|
|
5329
|
+
} else if (isVNode(n2)) {
|
|
5330
|
+
mount(n2, parent, anchor);
|
|
5331
|
+
anchor = n2.elm;
|
|
5195
5332
|
}
|
|
5196
5333
|
}
|
|
5197
5334
|
}
|
|
5198
5335
|
}
|
|
5199
|
-
|
|
5200
|
-
function patchVnode(oldVnode, vnode) {
|
|
5201
|
-
if (oldVnode !== vnode) {
|
|
5202
|
-
vnode.elm = oldVnode.elm;
|
|
5203
|
-
vnode.hook.update(oldVnode, vnode);
|
|
5204
|
-
}
|
|
5205
|
-
}
|
|
5206
5336
|
/*
|
|
5207
5337
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
5208
5338
|
* All rights reserved.
|
|
@@ -5218,7 +5348,7 @@
|
|
|
5218
5348
|
} // [h]tml node
|
|
5219
5349
|
|
|
5220
5350
|
|
|
5221
|
-
function h(sel, data, children) {
|
|
5351
|
+
function h(sel, data, children = EmptyArray) {
|
|
5222
5352
|
const vmBeingRendered = getVMBeingRendered();
|
|
5223
5353
|
|
|
5224
5354
|
if (process.env.NODE_ENV !== 'production') {
|
|
@@ -5254,7 +5384,6 @@
|
|
|
5254
5384
|
children,
|
|
5255
5385
|
elm,
|
|
5256
5386
|
key,
|
|
5257
|
-
hook: ElementHook,
|
|
5258
5387
|
owner: vmBeingRendered
|
|
5259
5388
|
};
|
|
5260
5389
|
} // [t]ab[i]ndex function
|
|
@@ -5341,7 +5470,7 @@
|
|
|
5341
5470
|
const {
|
|
5342
5471
|
key
|
|
5343
5472
|
} = data;
|
|
5344
|
-
let elm;
|
|
5473
|
+
let elm, aChildren, vm;
|
|
5345
5474
|
const vnode = {
|
|
5346
5475
|
type: 3
|
|
5347
5476
|
/* CustomElement */
|
|
@@ -5351,11 +5480,11 @@
|
|
|
5351
5480
|
children,
|
|
5352
5481
|
elm,
|
|
5353
5482
|
key,
|
|
5354
|
-
hook: CustomElementHook,
|
|
5355
5483
|
ctor: Ctor,
|
|
5356
5484
|
owner: vmBeingRendered,
|
|
5357
|
-
mode: 'open'
|
|
5358
|
-
|
|
5485
|
+
mode: 'open',
|
|
5486
|
+
aChildren,
|
|
5487
|
+
vm
|
|
5359
5488
|
};
|
|
5360
5489
|
addVNodeToChildLWC(vnode);
|
|
5361
5490
|
return vnode;
|
|
@@ -5485,7 +5614,6 @@
|
|
|
5485
5614
|
text,
|
|
5486
5615
|
elm,
|
|
5487
5616
|
key,
|
|
5488
|
-
hook: TextHook,
|
|
5489
5617
|
owner: getVMBeingRendered()
|
|
5490
5618
|
};
|
|
5491
5619
|
} // [co]mment node
|
|
@@ -5501,7 +5629,6 @@
|
|
|
5501
5629
|
text,
|
|
5502
5630
|
elm,
|
|
5503
5631
|
key,
|
|
5504
|
-
hook: CommentHook,
|
|
5505
5632
|
owner: getVMBeingRendered()
|
|
5506
5633
|
};
|
|
5507
5634
|
} // [d]ynamic text
|
|
@@ -5616,7 +5743,7 @@
|
|
|
5616
5743
|
* create a dynamic component via `<x-foo lwc:dynamic={Ctor}>`
|
|
5617
5744
|
*/
|
|
5618
5745
|
|
|
5619
|
-
function dc(sel, Ctor, data, children) {
|
|
5746
|
+
function dc(sel, Ctor, data, children = EmptyArray) {
|
|
5620
5747
|
if (process.env.NODE_ENV !== 'production') {
|
|
5621
5748
|
assert.isTrue(isString(sel), `dc() 1st argument sel must be a string.`);
|
|
5622
5749
|
assert.isTrue(isObject(data), `dc() 3nd argument data must be an object.`);
|
|
@@ -5640,10 +5767,14 @@
|
|
|
5640
5767
|
} // the new vnode key is a mix of idx and compiler key, this is required by the diffing algo
|
|
5641
5768
|
// to identify different constructors as vnodes with different keys to avoid reusing the
|
|
5642
5769
|
// element used for previous constructors.
|
|
5770
|
+
// Shallow clone is necessary here becuase VElementData may be shared across VNodes due to
|
|
5771
|
+
// hoisting optimization.
|
|
5643
5772
|
|
|
5644
5773
|
|
|
5645
|
-
|
|
5646
|
-
|
|
5774
|
+
const newData = Object.assign(Object.assign({}, data), {
|
|
5775
|
+
key: `dc:${idx}:${data.key}`
|
|
5776
|
+
});
|
|
5777
|
+
return c(sel, Ctor, newData, children);
|
|
5647
5778
|
}
|
|
5648
5779
|
/**
|
|
5649
5780
|
* slow children collection marking mechanism. this API allows the compiler to signal
|
|
@@ -5763,12 +5894,14 @@
|
|
|
5763
5894
|
hasTokenInAttribute: oldHasTokenInAttribute
|
|
5764
5895
|
} = context;
|
|
5765
5896
|
|
|
5766
|
-
if (
|
|
5767
|
-
|
|
5768
|
-
|
|
5897
|
+
if (!isUndefined$1(oldToken)) {
|
|
5898
|
+
if (oldHasTokenInClass) {
|
|
5899
|
+
getClassList$1(elm).remove(makeHostToken(oldToken));
|
|
5900
|
+
}
|
|
5769
5901
|
|
|
5770
|
-
|
|
5771
|
-
|
|
5902
|
+
if (oldHasTokenInAttribute) {
|
|
5903
|
+
removeAttribute$1(elm, makeHostToken(oldToken));
|
|
5904
|
+
}
|
|
5772
5905
|
} // Apply the new template styling token to the host element, if the new template has any
|
|
5773
5906
|
// associated stylesheets. In the case of light DOM, also ensure there is at least one scoped stylesheet.
|
|
5774
5907
|
|
|
@@ -6362,6 +6495,10 @@
|
|
|
6362
6495
|
function registerComponent(Ctor, {
|
|
6363
6496
|
tmpl
|
|
6364
6497
|
}) {
|
|
6498
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
6499
|
+
checkVersionMismatch(Ctor, 'component');
|
|
6500
|
+
}
|
|
6501
|
+
|
|
6365
6502
|
signedTemplateMap.set(Ctor, tmpl); // chaining this method as a way to wrap existing assignment of component constructor easily,
|
|
6366
6503
|
// without too much transformation
|
|
6367
6504
|
|
|
@@ -6486,7 +6623,7 @@
|
|
|
6486
6623
|
*/
|
|
6487
6624
|
|
|
6488
6625
|
|
|
6489
|
-
function hydrate
|
|
6626
|
+
function hydrate(vnode, node) {
|
|
6490
6627
|
switch (vnode.type) {
|
|
6491
6628
|
case 0
|
|
6492
6629
|
/* Text */
|
|
@@ -6518,16 +6655,18 @@
|
|
|
6518
6655
|
var _a;
|
|
6519
6656
|
|
|
6520
6657
|
if (process.env.NODE_ENV !== 'production') {
|
|
6521
|
-
|
|
6522
|
-
|
|
6658
|
+
validateNodeType(vnode, node, 3
|
|
6659
|
+
/* TEXT */
|
|
6660
|
+
);
|
|
6661
|
+
const nodeValue = getProperty$1(node, 'nodeValue');
|
|
6523
6662
|
|
|
6524
|
-
if (
|
|
6663
|
+
if (nodeValue !== vnode.text && !(nodeValue === '\u200D' && vnode.text === '')) {
|
|
6525
6664
|
logWarn('Hydration mismatch: text values do not match, will recover from the difference', vnode.owner);
|
|
6526
6665
|
}
|
|
6527
6666
|
} // always set the text value to the one from the vnode.
|
|
6528
6667
|
|
|
6529
6668
|
|
|
6530
|
-
node
|
|
6669
|
+
setText$1(node, (_a = vnode.text) !== null && _a !== void 0 ? _a : null);
|
|
6531
6670
|
vnode.elm = node;
|
|
6532
6671
|
}
|
|
6533
6672
|
|
|
@@ -6535,23 +6674,25 @@
|
|
|
6535
6674
|
var _a;
|
|
6536
6675
|
|
|
6537
6676
|
if (process.env.NODE_ENV !== 'production') {
|
|
6538
|
-
|
|
6539
|
-
|
|
6677
|
+
validateNodeType(vnode, node, 8
|
|
6678
|
+
/* COMMENT */
|
|
6679
|
+
);
|
|
6540
6680
|
|
|
6541
|
-
if (node
|
|
6681
|
+
if (getProperty$1(node, 'nodeValue') !== vnode.text) {
|
|
6542
6682
|
logWarn('Hydration mismatch: comment values do not match, will recover from the difference', vnode.owner);
|
|
6543
6683
|
}
|
|
6544
6684
|
} // always set the text value to the one from the vnode.
|
|
6545
6685
|
|
|
6546
6686
|
|
|
6547
|
-
node
|
|
6687
|
+
setProperty$1(node, 'nodeValue', (_a = vnode.text) !== null && _a !== void 0 ? _a : null);
|
|
6548
6688
|
vnode.elm = node;
|
|
6549
6689
|
}
|
|
6550
6690
|
|
|
6551
6691
|
function hydrateElement(vnode, node) {
|
|
6552
6692
|
if (process.env.NODE_ENV !== 'production') {
|
|
6553
|
-
|
|
6554
|
-
|
|
6693
|
+
validateNodeType(vnode, node, 1
|
|
6694
|
+
/* ELEMENT */
|
|
6695
|
+
);
|
|
6555
6696
|
validateElement(vnode, node);
|
|
6556
6697
|
}
|
|
6557
6698
|
|
|
@@ -6572,10 +6713,13 @@
|
|
|
6572
6713
|
} = vnode.data;
|
|
6573
6714
|
|
|
6574
6715
|
if (!isUndefined$1(props) && !isUndefined$1(props.innerHTML)) {
|
|
6575
|
-
if (elm
|
|
6576
|
-
|
|
6716
|
+
if (getProperty$1(elm, 'innerHTML') === props.innerHTML) {
|
|
6717
|
+
// Do a shallow clone since VNodeData may be shared across VNodes due to hoist optimization
|
|
6718
|
+
vnode.data = Object.assign(Object.assign({}, vnode.data), {
|
|
6719
|
+
props: cloneAndOmitKey(props, 'innerHTML')
|
|
6720
|
+
});
|
|
6577
6721
|
} else {
|
|
6578
|
-
logWarn(`Mismatch hydrating element <${elm
|
|
6722
|
+
logWarn(`Mismatch hydrating element <${getProperty$1(elm, 'tagName').toLowerCase()}>: innerHTML values do not match for element, will recover from the difference`, vnode.owner);
|
|
6579
6723
|
}
|
|
6580
6724
|
}
|
|
6581
6725
|
}
|
|
@@ -6583,19 +6727,19 @@
|
|
|
6583
6727
|
patchElementPropsAndAttrs(vnode);
|
|
6584
6728
|
|
|
6585
6729
|
if (!isDomManual) {
|
|
6586
|
-
hydrateChildren(vnode.elm
|
|
6730
|
+
hydrateChildren(getChildNodes$1(vnode.elm), vnode.children, vnode.owner);
|
|
6587
6731
|
}
|
|
6588
6732
|
}
|
|
6589
6733
|
|
|
6590
6734
|
function hydrateCustomElement(vnode, node) {
|
|
6591
6735
|
if (process.env.NODE_ENV !== 'production') {
|
|
6592
|
-
|
|
6593
|
-
|
|
6736
|
+
validateNodeType(vnode, node, 1
|
|
6737
|
+
/* ELEMENT */
|
|
6738
|
+
);
|
|
6594
6739
|
validateElement(vnode, node);
|
|
6595
6740
|
}
|
|
6596
6741
|
|
|
6597
6742
|
const elm = node;
|
|
6598
|
-
vnode.elm = elm;
|
|
6599
6743
|
const {
|
|
6600
6744
|
sel,
|
|
6601
6745
|
mode,
|
|
@@ -6607,6 +6751,8 @@
|
|
|
6607
6751
|
owner,
|
|
6608
6752
|
tagName: sel
|
|
6609
6753
|
});
|
|
6754
|
+
vnode.elm = elm;
|
|
6755
|
+
vnode.vm = vm;
|
|
6610
6756
|
allocateChildren(vnode, vm);
|
|
6611
6757
|
patchElementPropsAndAttrs(vnode); // Insert hook section:
|
|
6612
6758
|
|
|
@@ -6623,7 +6769,7 @@
|
|
|
6623
6769
|
) {
|
|
6624
6770
|
// VM is not rendering in Light DOM, we can proceed and hydrate the slotted content.
|
|
6625
6771
|
// Note: for Light DOM, this is handled while hydrating the VM
|
|
6626
|
-
hydrateChildren(vnode.elm
|
|
6772
|
+
hydrateChildren(getChildNodes$1(vnode.elm), vnode.children, vm);
|
|
6627
6773
|
}
|
|
6628
6774
|
|
|
6629
6775
|
hydrateVM(vm);
|
|
@@ -6646,7 +6792,7 @@
|
|
|
6646
6792
|
|
|
6647
6793
|
if (!isNull(childVnode)) {
|
|
6648
6794
|
const childNode = elmChildren[childNodeIndex];
|
|
6649
|
-
hydrate
|
|
6795
|
+
hydrate(childVnode, childNode);
|
|
6650
6796
|
childNodeIndex++;
|
|
6651
6797
|
}
|
|
6652
6798
|
}
|
|
@@ -6662,15 +6808,15 @@
|
|
|
6662
6808
|
}
|
|
6663
6809
|
|
|
6664
6810
|
function validateNodeType(vnode, node, nodeType) {
|
|
6665
|
-
if (node
|
|
6811
|
+
if (getProperty$1(node, 'nodeType') !== nodeType) {
|
|
6666
6812
|
logError('Hydration mismatch: incorrect node type received', vnode.owner);
|
|
6667
6813
|
assert.fail('Hydration mismatch: incorrect node type received.');
|
|
6668
6814
|
}
|
|
6669
6815
|
}
|
|
6670
6816
|
|
|
6671
6817
|
function validateElement(vnode, elm) {
|
|
6672
|
-
if (vnode.sel.toLowerCase() !== elm
|
|
6673
|
-
logError(`Hydration mismatch: expecting element with tag "${vnode.sel.toLowerCase()}" but found "${elm
|
|
6818
|
+
if (vnode.sel.toLowerCase() !== getProperty$1(elm, 'tagName').toLowerCase()) {
|
|
6819
|
+
logError(`Hydration mismatch: expecting element with tag "${vnode.sel.toLowerCase()}" but found "${getProperty$1(elm, 'tagName').toLowerCase()}".`, vnode.owner);
|
|
6674
6820
|
throwHydrationError();
|
|
6675
6821
|
}
|
|
6676
6822
|
|
|
@@ -6697,7 +6843,7 @@
|
|
|
6697
6843
|
const elmAttrValue = getAttribute$1(elm, attrName);
|
|
6698
6844
|
|
|
6699
6845
|
if (String(attrValue) !== elmAttrValue) {
|
|
6700
|
-
logError(`Mismatch hydrating element <${elm
|
|
6846
|
+
logError(`Mismatch hydrating element <${getProperty$1(elm, 'tagName').toLowerCase()}>: attribute "${attrName}" has different values, expected "${attrValue}" but found "${elmAttrValue}"`, vnode.owner);
|
|
6701
6847
|
nodesAreCompatible = false;
|
|
6702
6848
|
}
|
|
6703
6849
|
}
|
|
@@ -6715,7 +6861,7 @@
|
|
|
6715
6861
|
let nodesAreCompatible = true;
|
|
6716
6862
|
let vnodeClassName;
|
|
6717
6863
|
|
|
6718
|
-
if (!isUndefined$1(className) && String(className) !== elm
|
|
6864
|
+
if (!isUndefined$1(className) && String(className) !== getProperty$1(elm, 'className')) {
|
|
6719
6865
|
// className is used when class is bound to an expr.
|
|
6720
6866
|
nodesAreCompatible = false;
|
|
6721
6867
|
vnodeClassName = className;
|
|
@@ -6740,7 +6886,7 @@
|
|
|
6740
6886
|
}
|
|
6741
6887
|
|
|
6742
6888
|
if (!nodesAreCompatible) {
|
|
6743
|
-
logError(`Mismatch hydrating element <${elm
|
|
6889
|
+
logError(`Mismatch hydrating element <${getProperty$1(elm, 'tagName').toLowerCase()}>: attribute "class" has different values, expected "${vnodeClassName}" but found "${getProperty$1(elm, 'className')}"`, vnode.owner);
|
|
6744
6890
|
}
|
|
6745
6891
|
|
|
6746
6892
|
return nodesAreCompatible;
|
|
@@ -6787,7 +6933,7 @@
|
|
|
6787
6933
|
|
|
6788
6934
|
if (!nodesAreCompatible) {
|
|
6789
6935
|
// style is used when class is bound to an expr.
|
|
6790
|
-
logError(`Mismatch hydrating element <${elm
|
|
6936
|
+
logError(`Mismatch hydrating element <${getProperty$1(elm, 'tagName').toLowerCase()}>: attribute "style" has different values, expected "${vnodeStyle}" but found "${elmStyle}".`, vnode.owner);
|
|
6791
6937
|
}
|
|
6792
6938
|
|
|
6793
6939
|
return nodesAreCompatible;
|
|
@@ -6857,7 +7003,19 @@
|
|
|
6857
7003
|
}
|
|
6858
7004
|
|
|
6859
7005
|
function hydrateVM(vm) {
|
|
6860
|
-
|
|
7006
|
+
if (isTrue(vm.isDirty)) {
|
|
7007
|
+
// manually diffing/patching here.
|
|
7008
|
+
// This routine is:
|
|
7009
|
+
// patchShadowRoot(vm, children);
|
|
7010
|
+
// -> addVnodes.
|
|
7011
|
+
const children = renderComponent(vm);
|
|
7012
|
+
vm.children = children;
|
|
7013
|
+
const vmChildren = vm.renderMode === 0
|
|
7014
|
+
/* Light */
|
|
7015
|
+
? getChildNodes$1(vm.elm) : getChildNodes$1(vm.elm.shadowRoot);
|
|
7016
|
+
hydrateChildren(vmChildren, children, vm);
|
|
7017
|
+
runRenderedCallback(vm);
|
|
7018
|
+
}
|
|
6861
7019
|
} // just in case the component comes back, with this we guarantee re-rendering it
|
|
6862
7020
|
// while preventing any attempt to rehydration until after reinsertion.
|
|
6863
7021
|
|
|
@@ -7008,7 +7166,11 @@
|
|
|
7008
7166
|
/* Native */
|
|
7009
7167
|
;
|
|
7010
7168
|
} else if (isNativeShadowDefined$1) {
|
|
7011
|
-
if (
|
|
7169
|
+
if (runtimeFlags.DISABLE_MIXED_SHADOW_MODE) {
|
|
7170
|
+
shadowMode = 1
|
|
7171
|
+
/* Synthetic */
|
|
7172
|
+
;
|
|
7173
|
+
} else if (def.shadowSupportMode === "any"
|
|
7012
7174
|
/* Any */
|
|
7013
7175
|
) {
|
|
7014
7176
|
shadowMode = 0
|
|
@@ -7088,22 +7250,6 @@
|
|
|
7088
7250
|
}
|
|
7089
7251
|
}
|
|
7090
7252
|
|
|
7091
|
-
function hydrate(vm) {
|
|
7092
|
-
if (isTrue(vm.isDirty)) {
|
|
7093
|
-
// manually diffing/patching here.
|
|
7094
|
-
// This routine is:
|
|
7095
|
-
// patchShadowRoot(vm, children);
|
|
7096
|
-
// -> addVnodes.
|
|
7097
|
-
const children = renderComponent(vm);
|
|
7098
|
-
vm.children = children;
|
|
7099
|
-
const vmChildren = vm.renderMode === 0
|
|
7100
|
-
/* Light */
|
|
7101
|
-
? vm.elm.childNodes : vm.elm.shadowRoot.childNodes;
|
|
7102
|
-
hydrateChildren(vmChildren, children, vm);
|
|
7103
|
-
runRenderedCallback(vm);
|
|
7104
|
-
}
|
|
7105
|
-
}
|
|
7106
|
-
|
|
7107
7253
|
function patchShadowRoot(vm, newCh) {
|
|
7108
7254
|
const {
|
|
7109
7255
|
renderRoot,
|
|
@@ -7123,7 +7269,7 @@
|
|
|
7123
7269
|
, vm);
|
|
7124
7270
|
}, () => {
|
|
7125
7271
|
// job
|
|
7126
|
-
patchChildren(
|
|
7272
|
+
patchChildren(oldCh, newCh, renderRoot);
|
|
7127
7273
|
}, () => {
|
|
7128
7274
|
// post
|
|
7129
7275
|
logOperationEnd(2
|
|
@@ -7870,7 +8016,7 @@
|
|
|
7870
8016
|
hooksAreSet = true;
|
|
7871
8017
|
setSanitizeHtmlContentHook(hooks.sanitizeHtmlContent);
|
|
7872
8018
|
}
|
|
7873
|
-
/* version: 2.
|
|
8019
|
+
/* version: 2.10.0 */
|
|
7874
8020
|
|
|
7875
8021
|
/*
|
|
7876
8022
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
@@ -7896,6 +8042,7 @@
|
|
|
7896
8042
|
// See also: https://github.com/whatwg/webidl/issues/1027#issuecomment-934510070
|
|
7897
8043
|
|
|
7898
8044
|
const supportsConstructableStyleSheets = isFunction$1(CSSStyleSheet.prototype.replaceSync) && isArray$1(document.adoptedStyleSheets);
|
|
8045
|
+
const supportsMutableAdoptedStyleSheets = supportsConstructableStyleSheets && getOwnPropertyDescriptor$1(document.adoptedStyleSheets, 'length').writable;
|
|
7899
8046
|
const styleElements = create(null);
|
|
7900
8047
|
const styleSheets = create(null);
|
|
7901
8048
|
const nodesToStyleSheets = new WeakMap();
|
|
@@ -7939,7 +8086,13 @@
|
|
|
7939
8086
|
}
|
|
7940
8087
|
|
|
7941
8088
|
if (!target.adoptedStyleSheets.includes(styleSheet)) {
|
|
7942
|
-
|
|
8089
|
+
if (supportsMutableAdoptedStyleSheets) {
|
|
8090
|
+
// This is only supported in later versions of Chromium:
|
|
8091
|
+
// https://chromestatus.com/feature/5638996492288000
|
|
8092
|
+
target.adoptedStyleSheets.push(styleSheet);
|
|
8093
|
+
} else {
|
|
8094
|
+
target.adoptedStyleSheets = [...target.adoptedStyleSheets, styleSheet];
|
|
8095
|
+
}
|
|
7943
8096
|
}
|
|
7944
8097
|
}
|
|
7945
8098
|
|
|
@@ -8241,6 +8394,156 @@
|
|
|
8241
8394
|
setSetText(setText);
|
|
8242
8395
|
setSsr(ssr);
|
|
8243
8396
|
setAddEventListener(addEventListener);
|
|
8397
|
+
/*
|
|
8398
|
+
* Copyright (c) 2018, salesforce.com, inc.
|
|
8399
|
+
* All rights reserved.
|
|
8400
|
+
* SPDX-License-Identifier: MIT
|
|
8401
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
8402
|
+
*/
|
|
8403
|
+
|
|
8404
|
+
function resetShadowRootAndLightDom(element, Ctor) {
|
|
8405
|
+
if (element.shadowRoot) {
|
|
8406
|
+
const shadowRoot = element.shadowRoot;
|
|
8407
|
+
|
|
8408
|
+
while (!isNull(shadowRoot.firstChild)) {
|
|
8409
|
+
shadowRoot.removeChild(shadowRoot.firstChild);
|
|
8410
|
+
}
|
|
8411
|
+
}
|
|
8412
|
+
|
|
8413
|
+
if (Ctor.renderMode === 'light') {
|
|
8414
|
+
while (!isNull(element.firstChild)) {
|
|
8415
|
+
element.removeChild(element.firstChild);
|
|
8416
|
+
}
|
|
8417
|
+
}
|
|
8418
|
+
}
|
|
8419
|
+
|
|
8420
|
+
function createVMWithProps(element, Ctor, props) {
|
|
8421
|
+
createVM(element, Ctor, {
|
|
8422
|
+
mode: 'open',
|
|
8423
|
+
owner: null,
|
|
8424
|
+
tagName: element.tagName.toLowerCase()
|
|
8425
|
+
});
|
|
8426
|
+
|
|
8427
|
+
for (const [key, value] of Object.entries(props)) {
|
|
8428
|
+
element[key] = value;
|
|
8429
|
+
}
|
|
8430
|
+
}
|
|
8431
|
+
|
|
8432
|
+
function hydrateComponent(element, Ctor, props = {}) {
|
|
8433
|
+
if (!(element instanceof Element)) {
|
|
8434
|
+
throw new TypeError(`"hydrateComponent" expects a valid DOM element as the first parameter but instead received ${element}.`);
|
|
8435
|
+
}
|
|
8436
|
+
|
|
8437
|
+
if (!isFunction$1(Ctor)) {
|
|
8438
|
+
throw new TypeError(`"hydrateComponent" expects a valid component constructor as the second parameter but instead received ${Ctor}.`);
|
|
8439
|
+
}
|
|
8440
|
+
|
|
8441
|
+
if (!isObject(props) || isNull(props)) {
|
|
8442
|
+
throw new TypeError(`"hydrateComponent" expects an object as the third parameter but instead received ${props}.`);
|
|
8443
|
+
}
|
|
8444
|
+
|
|
8445
|
+
if (getAssociatedVMIfPresent(element)) {
|
|
8446
|
+
/* eslint-disable-next-line no-console */
|
|
8447
|
+
console.warn(`"hydrateComponent" expects an element that is not hydrated.`, element);
|
|
8448
|
+
return;
|
|
8449
|
+
}
|
|
8450
|
+
|
|
8451
|
+
try {
|
|
8452
|
+
// Let the renderer know we are hydrating, so it does not replace the existing shadowRoot
|
|
8453
|
+
// and uses the same algo to create the stylesheets as in SSR.
|
|
8454
|
+
setIsHydrating(true);
|
|
8455
|
+
createVMWithProps(element, Ctor, props);
|
|
8456
|
+
hydrateRootElement(element); // set it back since now we finished hydration.
|
|
8457
|
+
|
|
8458
|
+
setIsHydrating(false);
|
|
8459
|
+
} catch (e) {
|
|
8460
|
+
// Fallback: In case there's an error while hydrating, let's log the error, and replace the element content
|
|
8461
|
+
// with the client generated DOM.
|
|
8462
|
+
|
|
8463
|
+
/* eslint-disable-next-line no-console */
|
|
8464
|
+
console.error('Recovering from error while hydrating: ', e); // We want to preserve the element, so we need to reset the shadowRoot and light dom.
|
|
8465
|
+
|
|
8466
|
+
resetShadowRootAndLightDom(element, Ctor); // we need to recreate the vm with the hydration flag on, so it re-uses the existing shadowRoot.
|
|
8467
|
+
|
|
8468
|
+
createVMWithProps(element, Ctor, props);
|
|
8469
|
+
setIsHydrating(false);
|
|
8470
|
+
connectRootElement(element);
|
|
8471
|
+
} finally {
|
|
8472
|
+
// in case there's an error during recovery
|
|
8473
|
+
setIsHydrating(false);
|
|
8474
|
+
}
|
|
8475
|
+
}
|
|
8476
|
+
/*
|
|
8477
|
+
* Copyright (c) 2018, salesforce.com, inc.
|
|
8478
|
+
* All rights reserved.
|
|
8479
|
+
* SPDX-License-Identifier: MIT
|
|
8480
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
8481
|
+
*/
|
|
8482
|
+
|
|
8483
|
+
/**
|
|
8484
|
+
* This function builds a Web Component class from a LWC constructor so it can be
|
|
8485
|
+
* registered as a new element via customElements.define() at any given time.
|
|
8486
|
+
*
|
|
8487
|
+
* @deprecated since version 1.3.11
|
|
8488
|
+
*
|
|
8489
|
+
* @example
|
|
8490
|
+
* ```
|
|
8491
|
+
* import { buildCustomElementConstructor } from 'lwc';
|
|
8492
|
+
* import Foo from 'ns/foo';
|
|
8493
|
+
* const WC = buildCustomElementConstructor(Foo);
|
|
8494
|
+
* customElements.define('x-foo', WC);
|
|
8495
|
+
* const elm = document.createElement('x-foo');
|
|
8496
|
+
* ```
|
|
8497
|
+
*/
|
|
8498
|
+
|
|
8499
|
+
|
|
8500
|
+
function deprecatedBuildCustomElementConstructor(Ctor) {
|
|
8501
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
8502
|
+
/* eslint-disable-next-line no-console */
|
|
8503
|
+
console.warn('Deprecated function called: "buildCustomElementConstructor" function is deprecated and it will be removed.' + `Use "${Ctor.name}.CustomElementConstructor" static property of the component constructor to access the corresponding custom element constructor instead.`);
|
|
8504
|
+
}
|
|
8505
|
+
|
|
8506
|
+
return Ctor.CustomElementConstructor;
|
|
8507
|
+
} // Note: WeakSet is not supported in IE11, and the polyfill is not performant enough.
|
|
8508
|
+
// This WeakSet usage is valid because this functionality is not meant to run in IE11.
|
|
8509
|
+
|
|
8510
|
+
|
|
8511
|
+
const hydratedCustomElements = new WeakSet();
|
|
8512
|
+
|
|
8513
|
+
function buildCustomElementConstructor(Ctor) {
|
|
8514
|
+
const HtmlPrototype = getComponentHtmlPrototype(Ctor);
|
|
8515
|
+
return class extends HtmlPrototype {
|
|
8516
|
+
constructor() {
|
|
8517
|
+
super();
|
|
8518
|
+
|
|
8519
|
+
if (this.isConnected) {
|
|
8520
|
+
// this if block is hit when there's already an un-upgraded element in the DOM with the same tag name.
|
|
8521
|
+
hydrateComponent(this, Ctor, {});
|
|
8522
|
+
hydratedCustomElements.add(this);
|
|
8523
|
+
} else {
|
|
8524
|
+
createVM(this, Ctor, {
|
|
8525
|
+
mode: 'open',
|
|
8526
|
+
owner: null,
|
|
8527
|
+
tagName: this.tagName
|
|
8528
|
+
});
|
|
8529
|
+
}
|
|
8530
|
+
}
|
|
8531
|
+
|
|
8532
|
+
connectedCallback() {
|
|
8533
|
+
if (hydratedCustomElements.has(this)) {
|
|
8534
|
+
// This is an un-upgraded element that was hydrated in the constructor.
|
|
8535
|
+
hydratedCustomElements.delete(this);
|
|
8536
|
+
} else {
|
|
8537
|
+
connectRootElement(this);
|
|
8538
|
+
}
|
|
8539
|
+
}
|
|
8540
|
+
|
|
8541
|
+
disconnectedCallback() {
|
|
8542
|
+
disconnectRootElement(this);
|
|
8543
|
+
}
|
|
8544
|
+
|
|
8545
|
+
};
|
|
8546
|
+
}
|
|
8244
8547
|
/*
|
|
8245
8548
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
8246
8549
|
* All rights reserved.
|
|
@@ -8250,6 +8553,7 @@
|
|
|
8250
8553
|
// TODO [#2472]: Remove this workaround when appropriate.
|
|
8251
8554
|
// eslint-disable-next-line lwc-internal/no-global-node
|
|
8252
8555
|
|
|
8556
|
+
|
|
8253
8557
|
const _Node$1 = Node;
|
|
8254
8558
|
const ConnectingSlot = new WeakMap();
|
|
8255
8559
|
const DisconnectingSlot = new WeakMap();
|
|
@@ -8358,118 +8662,6 @@
|
|
|
8358
8662
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
8359
8663
|
*/
|
|
8360
8664
|
|
|
8361
|
-
|
|
8362
|
-
function hydrateComponent(element, Ctor, props = {}) {
|
|
8363
|
-
if (!(element instanceof Element)) {
|
|
8364
|
-
throw new TypeError(`"hydrateComponent" expects a valid DOM element as the first parameter but instead received ${element}.`);
|
|
8365
|
-
}
|
|
8366
|
-
|
|
8367
|
-
if (!isFunction$1(Ctor)) {
|
|
8368
|
-
throw new TypeError(`"hydrateComponent" expects a valid component constructor as the second parameter but instead received ${Ctor}.`);
|
|
8369
|
-
}
|
|
8370
|
-
|
|
8371
|
-
if (!isObject(props) || isNull(props)) {
|
|
8372
|
-
throw new TypeError(`"hydrateComponent" expects an object as the third parameter but instead received ${props}.`);
|
|
8373
|
-
}
|
|
8374
|
-
|
|
8375
|
-
try {
|
|
8376
|
-
// Let the renderer know we are hydrating, so it does not replace the existing shadowRoot
|
|
8377
|
-
// and uses the same algo to create the stylesheets as in SSR.
|
|
8378
|
-
setIsHydrating(true);
|
|
8379
|
-
createVM(element, Ctor, {
|
|
8380
|
-
mode: 'open',
|
|
8381
|
-
owner: null,
|
|
8382
|
-
tagName: element.tagName.toLowerCase()
|
|
8383
|
-
});
|
|
8384
|
-
|
|
8385
|
-
for (const [key, value] of Object.entries(props)) {
|
|
8386
|
-
element[key] = value;
|
|
8387
|
-
}
|
|
8388
|
-
|
|
8389
|
-
hydrateRootElement(element); // set it back since now we finished hydration.
|
|
8390
|
-
|
|
8391
|
-
setIsHydrating(false);
|
|
8392
|
-
} catch (e) {
|
|
8393
|
-
// Fallback: In case there's an error while hydrating, let's log the error, and replace the element with
|
|
8394
|
-
// the client generated DOM.
|
|
8395
|
-
|
|
8396
|
-
/* eslint-disable-next-line no-console */
|
|
8397
|
-
console.error('Recovering from error while hydrating: ', e);
|
|
8398
|
-
setIsHydrating(false);
|
|
8399
|
-
const newElem = createElement(element.tagName, {
|
|
8400
|
-
is: Ctor,
|
|
8401
|
-
mode: 'open'
|
|
8402
|
-
});
|
|
8403
|
-
|
|
8404
|
-
for (const [key, value] of Object.entries(props)) {
|
|
8405
|
-
newElem[key] = value;
|
|
8406
|
-
}
|
|
8407
|
-
|
|
8408
|
-
element.parentNode.replaceChild(newElem, element);
|
|
8409
|
-
}
|
|
8410
|
-
}
|
|
8411
|
-
/*
|
|
8412
|
-
* Copyright (c) 2018, salesforce.com, inc.
|
|
8413
|
-
* All rights reserved.
|
|
8414
|
-
* SPDX-License-Identifier: MIT
|
|
8415
|
-
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
8416
|
-
*/
|
|
8417
|
-
|
|
8418
|
-
/**
|
|
8419
|
-
* This function builds a Web Component class from a LWC constructor so it can be
|
|
8420
|
-
* registered as a new element via customElements.define() at any given time.
|
|
8421
|
-
*
|
|
8422
|
-
* @deprecated since version 1.3.11
|
|
8423
|
-
*
|
|
8424
|
-
* @example
|
|
8425
|
-
* ```
|
|
8426
|
-
* import { buildCustomElementConstructor } from 'lwc';
|
|
8427
|
-
* import Foo from 'ns/foo';
|
|
8428
|
-
* const WC = buildCustomElementConstructor(Foo);
|
|
8429
|
-
* customElements.define('x-foo', WC);
|
|
8430
|
-
* const elm = document.createElement('x-foo');
|
|
8431
|
-
* ```
|
|
8432
|
-
*/
|
|
8433
|
-
|
|
8434
|
-
|
|
8435
|
-
function deprecatedBuildCustomElementConstructor(Ctor) {
|
|
8436
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
8437
|
-
/* eslint-disable-next-line no-console */
|
|
8438
|
-
console.warn('Deprecated function called: "buildCustomElementConstructor" function is deprecated and it will be removed.' + `Use "${Ctor.name}.CustomElementConstructor" static property of the component constructor to access the corresponding custom element constructor instead.`);
|
|
8439
|
-
}
|
|
8440
|
-
|
|
8441
|
-
return Ctor.CustomElementConstructor;
|
|
8442
|
-
}
|
|
8443
|
-
|
|
8444
|
-
function buildCustomElementConstructor(Ctor) {
|
|
8445
|
-
const HtmlPrototype = getComponentHtmlPrototype(Ctor);
|
|
8446
|
-
return class extends HtmlPrototype {
|
|
8447
|
-
constructor() {
|
|
8448
|
-
super();
|
|
8449
|
-
createVM(this, Ctor, {
|
|
8450
|
-
mode: 'open',
|
|
8451
|
-
owner: null,
|
|
8452
|
-
tagName: this.tagName
|
|
8453
|
-
});
|
|
8454
|
-
}
|
|
8455
|
-
|
|
8456
|
-
connectedCallback() {
|
|
8457
|
-
connectRootElement(this);
|
|
8458
|
-
}
|
|
8459
|
-
|
|
8460
|
-
disconnectedCallback() {
|
|
8461
|
-
disconnectRootElement(this);
|
|
8462
|
-
}
|
|
8463
|
-
|
|
8464
|
-
};
|
|
8465
|
-
}
|
|
8466
|
-
/*
|
|
8467
|
-
* Copyright (c) 2018, salesforce.com, inc.
|
|
8468
|
-
* All rights reserved.
|
|
8469
|
-
* SPDX-License-Identifier: MIT
|
|
8470
|
-
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
8471
|
-
*/
|
|
8472
|
-
|
|
8473
8665
|
/**
|
|
8474
8666
|
* EXPERIMENTAL: This function provides access to the component constructor, given an HTMLElement.
|
|
8475
8667
|
* This API is subject to change or being removed.
|
|
@@ -8501,30 +8693,31 @@
|
|
|
8501
8693
|
|
|
8502
8694
|
const _Node = Node;
|
|
8503
8695
|
/**
|
|
8504
|
-
* EXPERIMENTAL:
|
|
8505
|
-
*
|
|
8696
|
+
* EXPERIMENTAL: The purpose of this function is to detect shadowed nodes. THIS API WILL BE REMOVED
|
|
8697
|
+
* ONCE LOCKER V1 IS NO LONGER SUPPORTED.
|
|
8506
8698
|
*/
|
|
8507
8699
|
|
|
8508
|
-
function
|
|
8700
|
+
function isNodeShadowed(node) {
|
|
8509
8701
|
if (isFalse(node instanceof _Node)) {
|
|
8510
8702
|
return false;
|
|
8511
|
-
} //
|
|
8512
|
-
// this
|
|
8703
|
+
} // It's debatable whether shadow root instances should be considered as shadowed, but we keep
|
|
8704
|
+
// this unchanged for legacy reasons (#1250).
|
|
8513
8705
|
|
|
8514
8706
|
|
|
8515
8707
|
if (node instanceof ShadowRoot) {
|
|
8516
8708
|
return false;
|
|
8517
8709
|
}
|
|
8518
8710
|
|
|
8519
|
-
|
|
8520
|
-
|
|
8521
|
-
|
|
8522
|
-
|
|
8523
|
-
return
|
|
8524
|
-
}
|
|
8711
|
+
const rootNode = node.getRootNode(); // Handle the native case. We can return early here because an invariant of LWC is that
|
|
8712
|
+
// synthetic roots cannot be descendants of native roots.
|
|
8713
|
+
|
|
8714
|
+
if (rootNode instanceof ShadowRoot && isFalse(hasOwnProperty$1.call(getPrototypeOf$1(rootNode), 'synthetic'))) {
|
|
8715
|
+
return true;
|
|
8716
|
+
} // TODO [#1252]: Old behavior that is still used by some pieces of the platform. Manually
|
|
8717
|
+
// inserted nodes without the `lwc:dom=manual` directive will be considered as global elements.
|
|
8718
|
+
|
|
8525
8719
|
|
|
8526
|
-
|
|
8527
|
-
return root instanceof ShadowRoot;
|
|
8720
|
+
return isSyntheticShadowDefined && !isUndefined$1(node[KEY__SHADOW_RESOLVER]);
|
|
8528
8721
|
}
|
|
8529
8722
|
/*
|
|
8530
8723
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
@@ -8569,7 +8762,7 @@
|
|
|
8569
8762
|
});
|
|
8570
8763
|
freeze(LightningElement);
|
|
8571
8764
|
seal(LightningElement.prototype);
|
|
8572
|
-
/* version: 2.
|
|
8765
|
+
/* version: 2.10.0 */
|
|
8573
8766
|
|
|
8574
8767
|
exports.LightningElement = LightningElement;
|
|
8575
8768
|
exports.__unstable__ProfilerControl = profilerControl;
|
|
@@ -8581,7 +8774,7 @@
|
|
|
8581
8774
|
exports.getComponentDef = getComponentDef;
|
|
8582
8775
|
exports.hydrateComponent = hydrateComponent;
|
|
8583
8776
|
exports.isComponentConstructor = isComponentConstructor;
|
|
8584
|
-
exports.isNodeFromTemplate =
|
|
8777
|
+
exports.isNodeFromTemplate = isNodeShadowed;
|
|
8585
8778
|
exports.readonly = readonly;
|
|
8586
8779
|
exports.register = register;
|
|
8587
8780
|
exports.registerComponent = registerComponent;
|