lwc 2.28.1 → 2.30.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/engine-dom/esm/es2017/engine-dom.js +319 -683
- package/dist/engine-dom/iife/es2017/engine-dom.js +319 -683
- package/dist/engine-dom/iife/es2017/engine-dom.min.js +1 -1
- package/dist/engine-dom/iife/es2017/engine-dom_debug.js +201 -624
- package/dist/engine-dom/iife/es5/engine-dom.js +1138 -2843
- package/dist/engine-dom/iife/es5/engine-dom.min.js +1 -1
- package/dist/engine-dom/iife/es5/engine-dom_debug.js +892 -2428
- package/dist/engine-dom/umd/es2017/engine-dom.js +319 -683
- package/dist/engine-dom/umd/es2017/engine-dom.min.js +1 -1
- package/dist/engine-dom/umd/es2017/engine-dom_debug.js +201 -624
- package/dist/engine-dom/umd/es5/engine-dom.js +1138 -2843
- package/dist/engine-dom/umd/es5/engine-dom.min.js +1 -1
- package/dist/engine-dom/umd/es5/engine-dom_debug.js +892 -2428
- package/dist/engine-server/commonjs/es2017/engine-server.js +204 -584
- package/dist/engine-server/commonjs/es2017/engine-server.min.js +1 -1
- package/dist/engine-server/esm/es2017/engine-server.js +204 -584
- package/dist/synthetic-shadow/esm/es2017/synthetic-shadow.js +99 -323
- package/dist/synthetic-shadow/iife/es2017/synthetic-shadow.js +99 -323
- package/dist/synthetic-shadow/iife/es2017/synthetic-shadow_debug.js +98 -316
- package/dist/synthetic-shadow/iife/es5/synthetic-shadow.js +483 -1220
- package/dist/synthetic-shadow/iife/es5/synthetic-shadow_debug.js +470 -1187
- package/dist/synthetic-shadow/umd/es2017/synthetic-shadow.js +99 -323
- package/dist/synthetic-shadow/umd/es2017/synthetic-shadow_debug.js +98 -316
- package/dist/synthetic-shadow/umd/es5/synthetic-shadow.js +483 -1220
- package/dist/synthetic-shadow/umd/es5/synthetic-shadow_debug.js +470 -1187
- package/dist/wire-service/esm/es2017/wire-service.js +2 -2
- package/dist/wire-service/iife/es2017/wire-service.js +2 -2
- package/dist/wire-service/iife/es2017/wire-service.min.js +1 -1
- package/dist/wire-service/iife/es2017/wire-service_debug.js +2 -2
- package/dist/wire-service/iife/es5/wire-service.js +13 -68
- package/dist/wire-service/iife/es5/wire-service_debug.js +13 -68
- package/dist/wire-service/umd/es2017/wire-service.js +2 -2
- package/dist/wire-service/umd/es2017/wire-service.min.js +1 -1
- package/dist/wire-service/umd/es2017/wire-service_debug.js +2 -2
- package/dist/wire-service/umd/es5/wire-service.js +13 -68
- package/dist/wire-service/umd/es5/wire-service_debug.js +13 -68
- package/package.json +7 -7
|
@@ -436,9 +436,9 @@ function htmlEscape(str, attrMode = false) {
|
|
|
436
436
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
437
437
|
*/
|
|
438
438
|
// Increment whenever the LWC template compiler changes
|
|
439
|
-
const LWC_VERSION = "2.
|
|
439
|
+
const LWC_VERSION = "2.30.0";
|
|
440
440
|
const LWC_VERSION_COMMENT_REGEX = /\/\*LWC compiler v([\d.]+)\*\/\s*}/;
|
|
441
|
-
/** version: 2.
|
|
441
|
+
/** version: 2.30.0 */
|
|
442
442
|
|
|
443
443
|
/*
|
|
444
444
|
* Copyright (c) 2020, salesforce.com, inc.
|
|
@@ -550,7 +550,7 @@ function setFeatureFlagForTest(name, value) {
|
|
|
550
550
|
setFeatureFlag(name, value);
|
|
551
551
|
}
|
|
552
552
|
}
|
|
553
|
-
/** version: 2.
|
|
553
|
+
/** version: 2.30.0 */
|
|
554
554
|
|
|
555
555
|
/* proxy-compat-disable */
|
|
556
556
|
|
|
@@ -560,16 +560,14 @@ function setFeatureFlagForTest(name, value) {
|
|
|
560
560
|
* SPDX-License-Identifier: MIT
|
|
561
561
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
562
562
|
*/
|
|
563
|
+
// Only used in LWC's Karma tests
|
|
563
564
|
// @ts-ignore
|
|
564
|
-
|
|
565
565
|
if (process.env.NODE_ENV !== 'production' && typeof __karma__ !== 'undefined') {
|
|
566
566
|
window.addEventListener('test-dummy-flag', () => {
|
|
567
567
|
let hasFlag = false;
|
|
568
|
-
|
|
569
568
|
if (lwcRuntimeFlags.DUMMY_TEST_FLAG) {
|
|
570
569
|
hasFlag = true;
|
|
571
570
|
}
|
|
572
|
-
|
|
573
571
|
window.dispatchEvent(new CustomEvent('has-dummy-flag', {
|
|
574
572
|
detail: {
|
|
575
573
|
package: '@lwc/engine-core',
|
|
@@ -2240,36 +2238,29 @@ function api$1() {
|
|
|
2240
2238
|
if (process.env.NODE_ENV !== 'production') {
|
|
2241
2239
|
assert.fail(`@api decorator can only be used as a decorator function.`);
|
|
2242
2240
|
}
|
|
2243
|
-
|
|
2244
2241
|
throw new Error();
|
|
2245
2242
|
}
|
|
2246
2243
|
function createPublicPropertyDescriptor(key) {
|
|
2247
2244
|
return {
|
|
2248
2245
|
get() {
|
|
2249
2246
|
const vm = getAssociatedVM(this);
|
|
2250
|
-
|
|
2251
2247
|
if (isBeingConstructed(vm)) {
|
|
2252
2248
|
if (process.env.NODE_ENV !== 'production') {
|
|
2253
2249
|
logError(`Can’t read the value of property \`${toString$1(key)}\` from the constructor because the owner component hasn’t set the value yet. Instead, use the constructor to set a default value for the property.`, vm);
|
|
2254
2250
|
}
|
|
2255
|
-
|
|
2256
2251
|
return;
|
|
2257
2252
|
}
|
|
2258
2253
|
return vm.cmpProps[key];
|
|
2259
2254
|
},
|
|
2260
|
-
|
|
2261
2255
|
set(newValue) {
|
|
2262
2256
|
const vm = getAssociatedVM(this);
|
|
2263
|
-
|
|
2264
2257
|
if (process.env.NODE_ENV !== 'production') {
|
|
2265
2258
|
const vmBeingRendered = getVMBeingRendered();
|
|
2266
2259
|
assert.invariant(!isInvokingRender, `${vmBeingRendered}.render() method has side effects on the state of ${vm}.${toString$1(key)}`);
|
|
2267
2260
|
assert.invariant(!isUpdatingTemplate, `Updating the template of ${vmBeingRendered} has side effects on the state of ${vm}.${toString$1(key)}`);
|
|
2268
2261
|
}
|
|
2269
|
-
|
|
2270
2262
|
vm.cmpProps[key] = newValue;
|
|
2271
2263
|
},
|
|
2272
|
-
|
|
2273
2264
|
enumerable: true,
|
|
2274
2265
|
configurable: true
|
|
2275
2266
|
};
|
|
@@ -2281,46 +2272,37 @@ function createPublicAccessorDescriptor(key, descriptor) {
|
|
|
2281
2272
|
enumerable,
|
|
2282
2273
|
configurable
|
|
2283
2274
|
} = descriptor;
|
|
2284
|
-
|
|
2285
2275
|
if (!isFunction$1(get)) {
|
|
2286
2276
|
if (process.env.NODE_ENV !== 'production') {
|
|
2287
2277
|
assert.invariant(isFunction$1(get), `Invalid compiler output for public accessor ${toString$1(key)} decorated with @api`);
|
|
2288
2278
|
}
|
|
2289
|
-
|
|
2290
2279
|
throw new Error();
|
|
2291
2280
|
}
|
|
2292
|
-
|
|
2293
2281
|
return {
|
|
2294
2282
|
get() {
|
|
2295
2283
|
if (process.env.NODE_ENV !== 'production') {
|
|
2296
2284
|
// Assert that the this value is an actual Component with an associated VM.
|
|
2297
2285
|
getAssociatedVM(this);
|
|
2298
2286
|
}
|
|
2299
|
-
|
|
2300
2287
|
return get.call(this);
|
|
2301
2288
|
},
|
|
2302
|
-
|
|
2303
2289
|
set(newValue) {
|
|
2304
2290
|
const vm = getAssociatedVM(this);
|
|
2305
|
-
|
|
2306
2291
|
if (process.env.NODE_ENV !== 'production') {
|
|
2307
2292
|
const vmBeingRendered = getVMBeingRendered();
|
|
2308
2293
|
assert.invariant(!isInvokingRender, `${vmBeingRendered}.render() method has side effects on the state of ${vm}.${toString$1(key)}`);
|
|
2309
2294
|
assert.invariant(!isUpdatingTemplate, `Updating the template of ${vmBeingRendered} has side effects on the state of ${vm}.${toString$1(key)}`);
|
|
2310
2295
|
}
|
|
2311
|
-
|
|
2312
2296
|
if (set) {
|
|
2313
2297
|
if (lwcRuntimeFlags.ENABLE_REACTIVE_SETTER) {
|
|
2314
2298
|
let ro = vm.oar[key];
|
|
2315
|
-
|
|
2316
2299
|
if (isUndefined$1(ro)) {
|
|
2317
2300
|
ro = vm.oar[key] = createAccessorReactiveObserver();
|
|
2318
|
-
}
|
|
2301
|
+
}
|
|
2302
|
+
// every time we invoke this setter from outside (through this wrapper setter)
|
|
2319
2303
|
// we should reset the value and then debounce just in case there is a pending
|
|
2320
2304
|
// invocation the next tick that is not longer relevant since the value is changing
|
|
2321
2305
|
// from outside.
|
|
2322
|
-
|
|
2323
|
-
|
|
2324
2306
|
ro.reset(newValue);
|
|
2325
2307
|
ro.observe(() => {
|
|
2326
2308
|
set.call(this, newValue);
|
|
@@ -2332,7 +2314,6 @@ function createPublicAccessorDescriptor(key, descriptor) {
|
|
|
2332
2314
|
assert.fail(`Invalid attempt to set a new value for property ${toString$1(key)} of ${vm} that does not has a setter decorated with @api.`);
|
|
2333
2315
|
}
|
|
2334
2316
|
},
|
|
2335
|
-
|
|
2336
2317
|
enumerable,
|
|
2337
2318
|
configurable
|
|
2338
2319
|
};
|
|
@@ -3198,11 +3179,9 @@ function getComponentDef(Ctor) {
|
|
|
3198
3179
|
* SPDX-License-Identifier: MIT
|
|
3199
3180
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
3200
3181
|
*/
|
|
3201
|
-
|
|
3202
3182
|
function makeHostToken(token) {
|
|
3203
3183
|
return `${token}-host`;
|
|
3204
3184
|
}
|
|
3205
|
-
|
|
3206
3185
|
function createInlineStyleVNode(content) {
|
|
3207
3186
|
return api.h('style', {
|
|
3208
3187
|
key: 'style',
|
|
@@ -3211,7 +3190,6 @@ function createInlineStyleVNode(content) {
|
|
|
3211
3190
|
}
|
|
3212
3191
|
}, [api.t(content)]);
|
|
3213
3192
|
}
|
|
3214
|
-
|
|
3215
3193
|
function updateStylesheetToken(vm, template) {
|
|
3216
3194
|
const {
|
|
3217
3195
|
elm,
|
|
@@ -3228,112 +3206,81 @@ function updateStylesheetToken(vm, template) {
|
|
|
3228
3206
|
stylesheets: newStylesheets,
|
|
3229
3207
|
stylesheetToken: newStylesheetToken
|
|
3230
3208
|
} = template;
|
|
3231
|
-
const isSyntheticShadow = renderMode === 1
|
|
3232
|
-
/* RenderMode.Shadow */
|
|
3233
|
-
&& shadowMode === 1
|
|
3234
|
-
/* ShadowMode.Synthetic */
|
|
3235
|
-
;
|
|
3209
|
+
const isSyntheticShadow = renderMode === 1 /* RenderMode.Shadow */ && shadowMode === 1 /* ShadowMode.Synthetic */;
|
|
3236
3210
|
const {
|
|
3237
3211
|
hasScopedStyles
|
|
3238
3212
|
} = context;
|
|
3239
3213
|
let newToken;
|
|
3240
3214
|
let newHasTokenInClass;
|
|
3241
|
-
let newHasTokenInAttribute;
|
|
3242
|
-
|
|
3215
|
+
let newHasTokenInAttribute;
|
|
3216
|
+
// Reset the styling token applied to the host element.
|
|
3243
3217
|
const {
|
|
3244
3218
|
stylesheetToken: oldToken,
|
|
3245
3219
|
hasTokenInClass: oldHasTokenInClass,
|
|
3246
3220
|
hasTokenInAttribute: oldHasTokenInAttribute
|
|
3247
3221
|
} = context;
|
|
3248
|
-
|
|
3249
3222
|
if (!isUndefined$1(oldToken)) {
|
|
3250
3223
|
if (oldHasTokenInClass) {
|
|
3251
3224
|
getClassList(elm).remove(makeHostToken(oldToken));
|
|
3252
3225
|
}
|
|
3253
|
-
|
|
3254
3226
|
if (oldHasTokenInAttribute) {
|
|
3255
3227
|
removeAttribute(elm, makeHostToken(oldToken));
|
|
3256
3228
|
}
|
|
3257
|
-
}
|
|
3229
|
+
}
|
|
3230
|
+
// Apply the new template styling token to the host element, if the new template has any
|
|
3258
3231
|
// associated stylesheets. In the case of light DOM, also ensure there is at least one scoped stylesheet.
|
|
3259
|
-
|
|
3260
|
-
|
|
3261
3232
|
if (!isUndefined$1(newStylesheets) && newStylesheets.length !== 0) {
|
|
3262
3233
|
newToken = newStylesheetToken;
|
|
3263
|
-
}
|
|
3264
|
-
|
|
3265
|
-
|
|
3234
|
+
}
|
|
3235
|
+
// Set the new styling token on the host element
|
|
3266
3236
|
if (!isUndefined$1(newToken)) {
|
|
3267
3237
|
if (hasScopedStyles) {
|
|
3268
3238
|
getClassList(elm).add(makeHostToken(newToken));
|
|
3269
3239
|
newHasTokenInClass = true;
|
|
3270
3240
|
}
|
|
3271
|
-
|
|
3272
3241
|
if (isSyntheticShadow) {
|
|
3273
3242
|
setAttribute(elm, makeHostToken(newToken), '');
|
|
3274
3243
|
newHasTokenInAttribute = true;
|
|
3275
3244
|
}
|
|
3276
|
-
}
|
|
3277
|
-
|
|
3278
|
-
|
|
3245
|
+
}
|
|
3246
|
+
// Update the styling tokens present on the context object.
|
|
3279
3247
|
context.stylesheetToken = newToken;
|
|
3280
3248
|
context.hasTokenInClass = newHasTokenInClass;
|
|
3281
3249
|
context.hasTokenInAttribute = newHasTokenInAttribute;
|
|
3282
3250
|
}
|
|
3283
|
-
|
|
3284
3251
|
function evaluateStylesheetsContent(stylesheets, stylesheetToken, vm) {
|
|
3285
3252
|
const content = [];
|
|
3286
3253
|
let root;
|
|
3287
|
-
|
|
3288
3254
|
for (let i = 0; i < stylesheets.length; i++) {
|
|
3289
3255
|
let stylesheet = stylesheets[i];
|
|
3290
|
-
|
|
3291
3256
|
if (isArray$1(stylesheet)) {
|
|
3292
3257
|
ArrayPush$1.apply(content, evaluateStylesheetsContent(stylesheet, stylesheetToken, vm));
|
|
3293
3258
|
} else {
|
|
3294
3259
|
if (process.env.NODE_ENV !== 'production') {
|
|
3295
3260
|
// Check for compiler version mismatch in dev mode only
|
|
3296
|
-
checkVersionMismatch(stylesheet, 'stylesheet');
|
|
3261
|
+
checkVersionMismatch(stylesheet, 'stylesheet');
|
|
3262
|
+
// in dev-mode, we support hot swapping of stylesheet, which means that
|
|
3297
3263
|
// the component instance might be attempting to use an old version of
|
|
3298
3264
|
// the stylesheet, while internally, we have a replacement for it.
|
|
3299
|
-
|
|
3300
3265
|
stylesheet = getStyleOrSwappedStyle(stylesheet);
|
|
3301
3266
|
}
|
|
3302
|
-
|
|
3303
3267
|
const isScopedCss = stylesheet[KEY__SCOPED_CSS];
|
|
3304
|
-
|
|
3305
3268
|
if (lwcRuntimeFlags.DISABLE_LIGHT_DOM_UNSCOPED_CSS) {
|
|
3306
|
-
if (!isScopedCss && vm.renderMode === 0
|
|
3307
|
-
/* RenderMode.Light */
|
|
3308
|
-
) {
|
|
3269
|
+
if (!isScopedCss && vm.renderMode === 0 /* RenderMode.Light */) {
|
|
3309
3270
|
logError('Unscoped CSS is not supported in Light DOM. Please use scoped CSS (*.scoped.css) instead of unscoped CSS (*.css).');
|
|
3310
3271
|
continue;
|
|
3311
3272
|
}
|
|
3312
|
-
}
|
|
3313
|
-
|
|
3314
|
-
|
|
3315
|
-
|
|
3316
|
-
/* ShadowMode.Synthetic */
|
|
3317
|
-
&& vm.renderMode === 1
|
|
3318
|
-
/* RenderMode.Shadow */
|
|
3319
|
-
? stylesheetToken : undefined; // Use the actual `:host` selector if we're rendering global CSS for light DOM, or if we're rendering
|
|
3273
|
+
}
|
|
3274
|
+
// Apply the scope token only if the stylesheet itself is scoped, or if we're rendering synthetic shadow.
|
|
3275
|
+
const scopeToken = isScopedCss || vm.shadowMode === 1 /* ShadowMode.Synthetic */ && vm.renderMode === 1 /* RenderMode.Shadow */ ? stylesheetToken : undefined;
|
|
3276
|
+
// Use the actual `:host` selector if we're rendering global CSS for light DOM, or if we're rendering
|
|
3320
3277
|
// native shadow DOM. Synthetic shadow DOM never uses `:host`.
|
|
3321
|
-
|
|
3322
|
-
|
|
3323
|
-
/* RenderMode.Light */
|
|
3324
|
-
? !isScopedCss : vm.shadowMode === 0
|
|
3325
|
-
/* ShadowMode.Native */
|
|
3326
|
-
; // Use the native :dir() pseudoclass only in native shadow DOM. Otherwise, in synthetic shadow,
|
|
3278
|
+
const useActualHostSelector = vm.renderMode === 0 /* RenderMode.Light */ ? !isScopedCss : vm.shadowMode === 0 /* ShadowMode.Native */;
|
|
3279
|
+
// Use the native :dir() pseudoclass only in native shadow DOM. Otherwise, in synthetic shadow,
|
|
3327
3280
|
// we use an attribute selector on the host to simulate :dir().
|
|
3328
|
-
|
|
3329
3281
|
let useNativeDirPseudoclass;
|
|
3330
|
-
|
|
3331
|
-
|
|
3332
|
-
/* RenderMode.Shadow */
|
|
3333
|
-
) {
|
|
3334
|
-
useNativeDirPseudoclass = vm.shadowMode === 0
|
|
3335
|
-
/* ShadowMode.Native */
|
|
3336
|
-
;
|
|
3282
|
+
if (vm.renderMode === 1 /* RenderMode.Shadow */) {
|
|
3283
|
+
useNativeDirPseudoclass = vm.shadowMode === 0 /* ShadowMode.Native */;
|
|
3337
3284
|
} else {
|
|
3338
3285
|
// Light DOM components should only render `[dir]` if they're inside of a synthetic shadow root.
|
|
3339
3286
|
// At the top level (root is null) or inside of a native shadow root, they should use `:dir()`.
|
|
@@ -3341,48 +3288,36 @@ function evaluateStylesheetsContent(stylesheets, stylesheetToken, vm) {
|
|
|
3341
3288
|
// Only calculate the root once as necessary
|
|
3342
3289
|
root = getNearestShadowComponent(vm);
|
|
3343
3290
|
}
|
|
3344
|
-
|
|
3345
|
-
useNativeDirPseudoclass = isNull(root) || root.shadowMode === 0
|
|
3346
|
-
/* ShadowMode.Native */
|
|
3347
|
-
;
|
|
3291
|
+
useNativeDirPseudoclass = isNull(root) || root.shadowMode === 0 /* ShadowMode.Native */;
|
|
3348
3292
|
}
|
|
3349
3293
|
|
|
3350
3294
|
ArrayPush$1.call(content, stylesheet(scopeToken, useActualHostSelector, useNativeDirPseudoclass));
|
|
3351
3295
|
}
|
|
3352
3296
|
}
|
|
3353
|
-
|
|
3354
3297
|
return content;
|
|
3355
3298
|
}
|
|
3356
|
-
|
|
3357
3299
|
function getStylesheetsContent(vm, template) {
|
|
3358
3300
|
const {
|
|
3359
3301
|
stylesheets,
|
|
3360
3302
|
stylesheetToken
|
|
3361
3303
|
} = template;
|
|
3362
3304
|
let content = [];
|
|
3363
|
-
|
|
3364
3305
|
if (!isUndefined$1(stylesheets) && stylesheets.length !== 0) {
|
|
3365
3306
|
content = evaluateStylesheetsContent(stylesheets, stylesheetToken, vm);
|
|
3366
3307
|
}
|
|
3367
|
-
|
|
3368
3308
|
return content;
|
|
3369
|
-
}
|
|
3309
|
+
}
|
|
3310
|
+
// It might be worth caching this to avoid doing the lookup repeatedly, but
|
|
3370
3311
|
// perf testing has not shown it to be a huge improvement yet:
|
|
3371
3312
|
// https://github.com/salesforce/lwc/pull/2460#discussion_r691208892
|
|
3372
|
-
|
|
3373
3313
|
function getNearestShadowComponent(vm) {
|
|
3374
3314
|
let owner = vm;
|
|
3375
|
-
|
|
3376
3315
|
while (!isNull(owner)) {
|
|
3377
|
-
if (owner.renderMode === 1
|
|
3378
|
-
/* RenderMode.Shadow */
|
|
3379
|
-
) {
|
|
3316
|
+
if (owner.renderMode === 1 /* RenderMode.Shadow */) {
|
|
3380
3317
|
return owner;
|
|
3381
3318
|
}
|
|
3382
|
-
|
|
3383
3319
|
owner = owner.owner;
|
|
3384
3320
|
}
|
|
3385
|
-
|
|
3386
3321
|
return owner;
|
|
3387
3322
|
}
|
|
3388
3323
|
/**
|
|
@@ -3390,8 +3325,6 @@ function getNearestShadowComponent(vm) {
|
|
|
3390
3325
|
* this returns the unique token for that scoped stylesheet. Otherwise
|
|
3391
3326
|
* it returns null.
|
|
3392
3327
|
*/
|
|
3393
|
-
|
|
3394
|
-
|
|
3395
3328
|
function getScopeTokenClass(owner) {
|
|
3396
3329
|
const {
|
|
3397
3330
|
cmpTemplate,
|
|
@@ -3399,7 +3332,6 @@ function getScopeTokenClass(owner) {
|
|
|
3399
3332
|
} = owner;
|
|
3400
3333
|
return context.hasScopedStyles && (cmpTemplate === null || cmpTemplate === void 0 ? void 0 : cmpTemplate.stylesheetToken) || null;
|
|
3401
3334
|
}
|
|
3402
|
-
|
|
3403
3335
|
function createStylesheet(vm, stylesheets) {
|
|
3404
3336
|
const {
|
|
3405
3337
|
renderMode,
|
|
@@ -3408,12 +3340,7 @@ function createStylesheet(vm, stylesheets) {
|
|
|
3408
3340
|
insertStylesheet
|
|
3409
3341
|
}
|
|
3410
3342
|
} = vm;
|
|
3411
|
-
|
|
3412
|
-
if (renderMode === 1
|
|
3413
|
-
/* RenderMode.Shadow */
|
|
3414
|
-
&& shadowMode === 1
|
|
3415
|
-
/* ShadowMode.Synthetic */
|
|
3416
|
-
) {
|
|
3343
|
+
if (renderMode === 1 /* RenderMode.Shadow */ && shadowMode === 1 /* ShadowMode.Synthetic */) {
|
|
3417
3344
|
for (let i = 0; i < stylesheets.length; i++) {
|
|
3418
3345
|
insertStylesheet(stylesheets[i]);
|
|
3419
3346
|
}
|
|
@@ -3424,7 +3351,6 @@ function createStylesheet(vm, stylesheets) {
|
|
|
3424
3351
|
// native shadow or light DOM, SSR
|
|
3425
3352
|
return ArrayMap.call(stylesheets, createInlineStyleVNode);
|
|
3426
3353
|
}
|
|
3427
|
-
|
|
3428
3354
|
return null;
|
|
3429
3355
|
}
|
|
3430
3356
|
|
|
@@ -3699,14 +3625,11 @@ function patchChildren(c1, c2, parent, renderer) {
|
|
|
3699
3625
|
updateStaticChildren(c1, c2, parent, renderer);
|
|
3700
3626
|
}
|
|
3701
3627
|
}
|
|
3702
|
-
|
|
3703
3628
|
function patch(n1, n2, parent, renderer) {
|
|
3704
3629
|
var _a, _b;
|
|
3705
|
-
|
|
3706
3630
|
if (n1 === n2) {
|
|
3707
3631
|
return;
|
|
3708
3632
|
}
|
|
3709
|
-
|
|
3710
3633
|
if (process.env.NODE_ENV !== 'production') {
|
|
3711
3634
|
if (!isSameVnode(n1, n2)) {
|
|
3712
3635
|
throw new Error('Expected these VNodes to be the same: ' + JSON.stringify({
|
|
@@ -3718,103 +3641,63 @@ function patch(n1, n2, parent, renderer) {
|
|
|
3718
3641
|
}));
|
|
3719
3642
|
}
|
|
3720
3643
|
}
|
|
3721
|
-
|
|
3722
3644
|
switch (n2.type) {
|
|
3723
|
-
case 0
|
|
3724
|
-
/* VNodeType.Text */
|
|
3725
|
-
:
|
|
3645
|
+
case 0 /* VNodeType.Text */:
|
|
3726
3646
|
// VText has no special capability, fallback to the owner's renderer
|
|
3727
3647
|
patchText(n1, n2, renderer);
|
|
3728
3648
|
break;
|
|
3729
|
-
|
|
3730
|
-
case 1
|
|
3731
|
-
/* VNodeType.Comment */
|
|
3732
|
-
:
|
|
3649
|
+
case 1 /* VNodeType.Comment */:
|
|
3733
3650
|
// VComment has no special capability, fallback to the owner's renderer
|
|
3734
3651
|
patchComment(n1, n2, renderer);
|
|
3735
3652
|
break;
|
|
3736
|
-
|
|
3737
|
-
case 4
|
|
3738
|
-
/* VNodeType.Static */
|
|
3739
|
-
:
|
|
3653
|
+
case 4 /* VNodeType.Static */:
|
|
3740
3654
|
n2.elm = n1.elm;
|
|
3741
3655
|
break;
|
|
3742
|
-
|
|
3743
|
-
case 5
|
|
3744
|
-
/* VNodeType.Fragment */
|
|
3745
|
-
:
|
|
3656
|
+
case 5 /* VNodeType.Fragment */:
|
|
3746
3657
|
patchFragment(n1, n2, parent, renderer);
|
|
3747
3658
|
break;
|
|
3748
|
-
|
|
3749
|
-
case 2
|
|
3750
|
-
/* VNodeType.Element */
|
|
3751
|
-
:
|
|
3659
|
+
case 2 /* VNodeType.Element */:
|
|
3752
3660
|
patchElement(n1, n2, (_a = n2.data.renderer) !== null && _a !== void 0 ? _a : renderer);
|
|
3753
3661
|
break;
|
|
3754
|
-
|
|
3755
|
-
case 3
|
|
3756
|
-
/* VNodeType.CustomElement */
|
|
3757
|
-
:
|
|
3662
|
+
case 3 /* VNodeType.CustomElement */:
|
|
3758
3663
|
patchCustomElement(n1, n2, parent, (_b = n2.data.renderer) !== null && _b !== void 0 ? _b : renderer);
|
|
3759
3664
|
break;
|
|
3760
3665
|
}
|
|
3761
3666
|
}
|
|
3762
|
-
|
|
3763
3667
|
function mount(node, parent, renderer, anchor) {
|
|
3764
3668
|
var _a, _b;
|
|
3765
|
-
|
|
3766
3669
|
switch (node.type) {
|
|
3767
|
-
case 0
|
|
3768
|
-
/* VNodeType.Text */
|
|
3769
|
-
:
|
|
3670
|
+
case 0 /* VNodeType.Text */:
|
|
3770
3671
|
// VText has no special capability, fallback to the owner's renderer
|
|
3771
3672
|
mountText(node, parent, anchor, renderer);
|
|
3772
3673
|
break;
|
|
3773
|
-
|
|
3774
|
-
case 1
|
|
3775
|
-
/* VNodeType.Comment */
|
|
3776
|
-
:
|
|
3674
|
+
case 1 /* VNodeType.Comment */:
|
|
3777
3675
|
// VComment has no special capability, fallback to the owner's renderer
|
|
3778
3676
|
mountComment(node, parent, anchor, renderer);
|
|
3779
3677
|
break;
|
|
3780
|
-
|
|
3781
|
-
case 4
|
|
3782
|
-
/* VNodeType.Static */
|
|
3783
|
-
:
|
|
3678
|
+
case 4 /* VNodeType.Static */:
|
|
3784
3679
|
// VStatic cannot have a custom renderer associated to them, using owner's renderer
|
|
3785
3680
|
mountStatic(node, parent, anchor, renderer);
|
|
3786
3681
|
break;
|
|
3787
|
-
|
|
3788
|
-
case 5
|
|
3789
|
-
/* VNodeType.Fragment */
|
|
3790
|
-
:
|
|
3682
|
+
case 5 /* VNodeType.Fragment */:
|
|
3791
3683
|
mountFragment(node, parent, anchor, renderer);
|
|
3792
3684
|
break;
|
|
3793
|
-
|
|
3794
|
-
case 2
|
|
3795
|
-
/* VNodeType.Element */
|
|
3796
|
-
:
|
|
3685
|
+
case 2 /* VNodeType.Element */:
|
|
3797
3686
|
// If the vnode data has a renderer override use it, else fallback to owner's renderer
|
|
3798
3687
|
mountElement(node, parent, anchor, (_a = node.data.renderer) !== null && _a !== void 0 ? _a : renderer);
|
|
3799
3688
|
break;
|
|
3800
|
-
|
|
3801
|
-
case 3
|
|
3802
|
-
/* VNodeType.CustomElement */
|
|
3803
|
-
:
|
|
3689
|
+
case 3 /* VNodeType.CustomElement */:
|
|
3804
3690
|
// If the vnode data has a renderer override use it, else fallback to owner's renderer
|
|
3805
3691
|
mountCustomElement(node, parent, anchor, (_b = node.data.renderer) !== null && _b !== void 0 ? _b : renderer);
|
|
3806
3692
|
break;
|
|
3807
3693
|
}
|
|
3808
3694
|
}
|
|
3809
|
-
|
|
3810
3695
|
function patchText(n1, n2, renderer) {
|
|
3811
3696
|
n2.elm = n1.elm;
|
|
3812
|
-
|
|
3813
3697
|
if (n2.text !== n1.text) {
|
|
3814
3698
|
updateTextContent(n2, renderer);
|
|
3815
3699
|
}
|
|
3816
3700
|
}
|
|
3817
|
-
|
|
3818
3701
|
function mountText(vnode, parent, anchor, renderer) {
|
|
3819
3702
|
const {
|
|
3820
3703
|
owner
|
|
@@ -3826,16 +3709,14 @@ function mountText(vnode, parent, anchor, renderer) {
|
|
|
3826
3709
|
linkNodeToShadow(textNode, owner, renderer);
|
|
3827
3710
|
insertNode(textNode, parent, anchor, renderer);
|
|
3828
3711
|
}
|
|
3829
|
-
|
|
3830
3712
|
function patchComment(n1, n2, renderer) {
|
|
3831
|
-
n2.elm = n1.elm;
|
|
3713
|
+
n2.elm = n1.elm;
|
|
3714
|
+
// FIXME: Comment nodes should be static, we shouldn't need to diff them together. However
|
|
3832
3715
|
// it is the case today.
|
|
3833
|
-
|
|
3834
3716
|
if (n2.text !== n1.text) {
|
|
3835
3717
|
updateTextContent(n2, renderer);
|
|
3836
3718
|
}
|
|
3837
3719
|
}
|
|
3838
|
-
|
|
3839
3720
|
function mountComment(vnode, parent, anchor, renderer) {
|
|
3840
3721
|
const {
|
|
3841
3722
|
owner
|
|
@@ -3847,32 +3728,27 @@ function mountComment(vnode, parent, anchor, renderer) {
|
|
|
3847
3728
|
linkNodeToShadow(commentNode, owner, renderer);
|
|
3848
3729
|
insertNode(commentNode, parent, anchor, renderer);
|
|
3849
3730
|
}
|
|
3850
|
-
|
|
3851
3731
|
function mountFragment(vnode, parent, anchor, renderer) {
|
|
3852
3732
|
const {
|
|
3853
3733
|
children
|
|
3854
3734
|
} = vnode;
|
|
3855
|
-
mountVNodes(children, parent, renderer, anchor);
|
|
3856
|
-
|
|
3735
|
+
mountVNodes(children, parent, renderer, anchor);
|
|
3736
|
+
// children of a fragment will always have at least the two delimiters.
|
|
3857
3737
|
vnode.elm = children[children.length - 1].elm;
|
|
3858
3738
|
}
|
|
3859
|
-
|
|
3860
3739
|
function patchFragment(n1, n2, parent, renderer) {
|
|
3861
3740
|
const {
|
|
3862
3741
|
children,
|
|
3863
3742
|
stable
|
|
3864
3743
|
} = n2;
|
|
3865
|
-
|
|
3866
3744
|
if (stable) {
|
|
3867
3745
|
updateStaticChildren(n1.children, children, parent, renderer);
|
|
3868
3746
|
} else {
|
|
3869
3747
|
updateDynamicChildren(n1.children, children, parent, renderer);
|
|
3870
|
-
}
|
|
3871
|
-
|
|
3872
|
-
|
|
3748
|
+
}
|
|
3749
|
+
// Note: not reusing n1.elm, because during patching, it may be patched with another text node.
|
|
3873
3750
|
n2.elm = children[children.length - 1].elm;
|
|
3874
3751
|
}
|
|
3875
|
-
|
|
3876
3752
|
function mountElement(vnode, parent, anchor, renderer) {
|
|
3877
3753
|
const {
|
|
3878
3754
|
sel,
|
|
@@ -3894,13 +3770,11 @@ function mountElement(vnode, parent, anchor, renderer) {
|
|
|
3894
3770
|
insertNode(elm, parent, anchor, renderer);
|
|
3895
3771
|
mountVNodes(vnode.children, elm, renderer, null);
|
|
3896
3772
|
}
|
|
3897
|
-
|
|
3898
3773
|
function patchElement(n1, n2, renderer) {
|
|
3899
3774
|
const elm = n2.elm = n1.elm;
|
|
3900
3775
|
patchElementPropsAndAttrs$1(n1, n2, renderer);
|
|
3901
3776
|
patchChildren(n1.children, n2.children, elm, renderer);
|
|
3902
3777
|
}
|
|
3903
|
-
|
|
3904
3778
|
function mountStatic(vnode, parent, anchor, renderer) {
|
|
3905
3779
|
const {
|
|
3906
3780
|
owner
|
|
@@ -3911,26 +3785,19 @@ function mountStatic(vnode, parent, anchor, renderer) {
|
|
|
3911
3785
|
} = renderer;
|
|
3912
3786
|
const elm = vnode.elm = cloneNode(vnode.fragment, true);
|
|
3913
3787
|
linkNodeToShadow(elm, owner, renderer);
|
|
3914
|
-
applyElementRestrictions(elm, vnode);
|
|
3915
|
-
|
|
3788
|
+
applyElementRestrictions(elm, vnode);
|
|
3789
|
+
// Marks this node as Static to propagate the shadow resolver. must happen after elm is assigned to the proper shadow
|
|
3916
3790
|
const {
|
|
3917
3791
|
renderMode,
|
|
3918
3792
|
shadowMode
|
|
3919
3793
|
} = owner;
|
|
3920
|
-
|
|
3921
3794
|
if (isSyntheticShadowDefined) {
|
|
3922
|
-
if (shadowMode === 1
|
|
3923
|
-
/* ShadowMode.Synthetic */
|
|
3924
|
-
|| renderMode === 0
|
|
3925
|
-
/* RenderMode.Light */
|
|
3926
|
-
) {
|
|
3795
|
+
if (shadowMode === 1 /* ShadowMode.Synthetic */ || renderMode === 0 /* RenderMode.Light */) {
|
|
3927
3796
|
elm[KEY__SHADOW_STATIC] = true;
|
|
3928
3797
|
}
|
|
3929
3798
|
}
|
|
3930
|
-
|
|
3931
3799
|
insertNode(elm, parent, anchor, renderer);
|
|
3932
3800
|
}
|
|
3933
|
-
|
|
3934
3801
|
function mountCustomElement(vnode, parent, anchor, renderer) {
|
|
3935
3802
|
const {
|
|
3936
3803
|
sel,
|
|
@@ -3945,44 +3812,36 @@ function mountCustomElement(vnode, parent, anchor, renderer) {
|
|
|
3945
3812
|
* mechanism that only passes that argument if the constructor is known to be
|
|
3946
3813
|
* an upgradable custom element.
|
|
3947
3814
|
*/
|
|
3948
|
-
|
|
3949
3815
|
let vm;
|
|
3950
|
-
|
|
3951
3816
|
const upgradeCallback = elm => {
|
|
3952
3817
|
// the custom element from the registry is expecting an upgrade callback
|
|
3953
3818
|
vm = createViewModelHook(elm, vnode, renderer);
|
|
3954
3819
|
};
|
|
3955
|
-
|
|
3956
3820
|
const connectedCallback = elm => {
|
|
3957
3821
|
if (lwcRuntimeFlags.ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE) {
|
|
3958
3822
|
connectRootElement(elm);
|
|
3959
3823
|
}
|
|
3960
3824
|
};
|
|
3961
|
-
|
|
3962
3825
|
const disconnectedCallback = elm => {
|
|
3963
3826
|
if (lwcRuntimeFlags.ENABLE_NATIVE_CUSTOM_ELEMENT_LIFECYCLE) {
|
|
3964
3827
|
disconnectRootElement(elm);
|
|
3965
3828
|
}
|
|
3966
|
-
};
|
|
3829
|
+
};
|
|
3830
|
+
// Should never get a tag with upper case letter at this point; the compiler
|
|
3967
3831
|
// should produce only tags with lowercase letters. However, the Java
|
|
3968
3832
|
// compiler may generate tagnames with uppercase letters so - for backwards
|
|
3969
3833
|
// compatibility, we lower case the tagname here.
|
|
3970
|
-
|
|
3971
|
-
|
|
3972
3834
|
const normalizedTagname = sel.toLowerCase();
|
|
3973
3835
|
const elm = createCustomElement(normalizedTagname, upgradeCallback, connectedCallback, disconnectedCallback);
|
|
3974
3836
|
vnode.elm = elm;
|
|
3975
3837
|
vnode.vm = vm;
|
|
3976
3838
|
linkNodeToShadow(elm, owner, renderer);
|
|
3977
3839
|
applyStyleScoping(elm, owner, renderer);
|
|
3978
|
-
|
|
3979
3840
|
if (vm) {
|
|
3980
3841
|
allocateChildren(vnode, vm);
|
|
3981
3842
|
}
|
|
3982
|
-
|
|
3983
3843
|
patchElementPropsAndAttrs$1(null, vnode, renderer);
|
|
3984
3844
|
insertNode(elm, parent, anchor, renderer);
|
|
3985
|
-
|
|
3986
3845
|
if (vm) {
|
|
3987
3846
|
{
|
|
3988
3847
|
// On the server, we don't have native custom element lifecycle callbacks, so we must
|
|
@@ -3990,14 +3849,11 @@ function mountCustomElement(vnode, parent, anchor, renderer) {
|
|
|
3990
3849
|
runConnectedCallback(vm);
|
|
3991
3850
|
}
|
|
3992
3851
|
}
|
|
3993
|
-
|
|
3994
3852
|
mountVNodes(vnode.children, elm, renderer, null);
|
|
3995
|
-
|
|
3996
3853
|
if (vm) {
|
|
3997
3854
|
appendVM(vm);
|
|
3998
3855
|
}
|
|
3999
3856
|
}
|
|
4000
|
-
|
|
4001
3857
|
function patchCustomElement(n1, n2, parent, renderer) {
|
|
4002
3858
|
if (n1.ctor !== n2.ctor) {
|
|
4003
3859
|
// If the constructor, unmount the current component and mount a new one using the new
|
|
@@ -4010,17 +3866,14 @@ function patchCustomElement(n1, n2, parent, renderer) {
|
|
|
4010
3866
|
const elm = n2.elm = n1.elm;
|
|
4011
3867
|
const vm = n2.vm = n1.vm;
|
|
4012
3868
|
patchElementPropsAndAttrs$1(n1, n2, renderer);
|
|
4013
|
-
|
|
4014
3869
|
if (!isUndefined$1(vm)) {
|
|
4015
3870
|
// in fallback mode, the allocation will always set children to
|
|
4016
3871
|
// empty and delegate the real allocation to the slot elements
|
|
4017
3872
|
allocateChildren(n2, vm);
|
|
4018
|
-
}
|
|
3873
|
+
}
|
|
3874
|
+
// in fallback mode, the children will be always empty, so, nothing
|
|
4019
3875
|
// will happen, but in native, it does allocate the light dom
|
|
4020
|
-
|
|
4021
|
-
|
|
4022
3876
|
patchChildren(n1.children, n2.children, elm, renderer);
|
|
4023
|
-
|
|
4024
3877
|
if (!isUndefined$1(vm)) {
|
|
4025
3878
|
// this will probably update the shadowRoot, but only if the vm is in a dirty state
|
|
4026
3879
|
// this is important to preserve the top to bottom synchronous rendering phase.
|
|
@@ -4028,29 +3881,24 @@ function patchCustomElement(n1, n2, parent, renderer) {
|
|
|
4028
3881
|
}
|
|
4029
3882
|
}
|
|
4030
3883
|
}
|
|
4031
|
-
|
|
4032
3884
|
function mountVNodes(vnodes, parent, renderer, anchor, start = 0, end = vnodes.length) {
|
|
4033
3885
|
for (; start < end; ++start) {
|
|
4034
3886
|
const vnode = vnodes[start];
|
|
4035
|
-
|
|
4036
3887
|
if (isVNode(vnode)) {
|
|
4037
3888
|
mount(vnode, parent, renderer, anchor);
|
|
4038
3889
|
}
|
|
4039
3890
|
}
|
|
4040
3891
|
}
|
|
4041
|
-
|
|
4042
3892
|
function unmount(vnode, parent, renderer, doRemove = false) {
|
|
4043
3893
|
const {
|
|
4044
3894
|
type,
|
|
4045
3895
|
elm,
|
|
4046
3896
|
sel
|
|
4047
|
-
} = vnode;
|
|
3897
|
+
} = vnode;
|
|
3898
|
+
// When unmounting a VNode subtree not all the elements have to removed from the DOM. The
|
|
4048
3899
|
// subtree root, is the only element worth unmounting from the subtree.
|
|
4049
|
-
|
|
4050
3900
|
if (doRemove) {
|
|
4051
|
-
if (type === 5
|
|
4052
|
-
/* VNodeType.Fragment */
|
|
4053
|
-
) {
|
|
3901
|
+
if (type === 5 /* VNodeType.Fragment */) {
|
|
4054
3902
|
unmountVNodes(vnode.children, parent, renderer, doRemove);
|
|
4055
3903
|
} else {
|
|
4056
3904
|
// The vnode might or might not have a data.renderer associated to it
|
|
@@ -4058,51 +3906,39 @@ function unmount(vnode, parent, renderer, doRemove = false) {
|
|
|
4058
3906
|
removeNode(elm, parent, renderer);
|
|
4059
3907
|
}
|
|
4060
3908
|
}
|
|
4061
|
-
|
|
4062
3909
|
switch (type) {
|
|
4063
|
-
case 2
|
|
4064
|
-
/* VNodeType.Element */
|
|
4065
|
-
:
|
|
3910
|
+
case 2 /* VNodeType.Element */:
|
|
4066
3911
|
{
|
|
4067
3912
|
// Slot content is removed to trigger slotchange event when removing slot.
|
|
4068
3913
|
// Only required for synthetic shadow.
|
|
4069
|
-
const shouldRemoveChildren = sel === 'slot' && vnode.owner.shadowMode === 1
|
|
4070
|
-
/* ShadowMode.Synthetic */
|
|
4071
|
-
;
|
|
3914
|
+
const shouldRemoveChildren = sel === 'slot' && vnode.owner.shadowMode === 1 /* ShadowMode.Synthetic */;
|
|
4072
3915
|
unmountVNodes(vnode.children, elm, renderer, shouldRemoveChildren);
|
|
4073
3916
|
break;
|
|
4074
3917
|
}
|
|
4075
|
-
|
|
4076
|
-
case 3
|
|
4077
|
-
/* VNodeType.CustomElement */
|
|
4078
|
-
:
|
|
3918
|
+
case 3 /* VNodeType.CustomElement */:
|
|
4079
3919
|
{
|
|
4080
3920
|
const {
|
|
4081
3921
|
vm
|
|
4082
|
-
} = vnode;
|
|
3922
|
+
} = vnode;
|
|
3923
|
+
// No need to unmount the children here, `removeVM` will take care of removing the
|
|
4083
3924
|
// children.
|
|
4084
|
-
|
|
4085
3925
|
if (!isUndefined$1(vm)) {
|
|
4086
3926
|
removeVM(vm);
|
|
4087
3927
|
}
|
|
4088
3928
|
}
|
|
4089
3929
|
}
|
|
4090
3930
|
}
|
|
4091
|
-
|
|
4092
3931
|
function unmountVNodes(vnodes, parent, renderer, doRemove = false, start = 0, end = vnodes.length) {
|
|
4093
3932
|
for (; start < end; ++start) {
|
|
4094
3933
|
const ch = vnodes[start];
|
|
4095
|
-
|
|
4096
3934
|
if (isVNode(ch)) {
|
|
4097
3935
|
unmount(ch, parent, renderer, doRemove);
|
|
4098
3936
|
}
|
|
4099
3937
|
}
|
|
4100
3938
|
}
|
|
4101
|
-
|
|
4102
3939
|
function isVNode(vnode) {
|
|
4103
3940
|
return vnode != null;
|
|
4104
3941
|
}
|
|
4105
|
-
|
|
4106
3942
|
function linkNodeToShadow(elm, owner, renderer) {
|
|
4107
3943
|
const {
|
|
4108
3944
|
renderRoot,
|
|
@@ -4111,19 +3947,14 @@ function linkNodeToShadow(elm, owner, renderer) {
|
|
|
4111
3947
|
} = owner;
|
|
4112
3948
|
const {
|
|
4113
3949
|
isSyntheticShadowDefined
|
|
4114
|
-
} = renderer;
|
|
4115
|
-
|
|
3950
|
+
} = renderer;
|
|
3951
|
+
// TODO [#1164]: this should eventually be done by the polyfill directly
|
|
4116
3952
|
if (isSyntheticShadowDefined) {
|
|
4117
|
-
if (shadowMode === 1
|
|
4118
|
-
/* ShadowMode.Synthetic */
|
|
4119
|
-
|| renderMode === 0
|
|
4120
|
-
/* RenderMode.Light */
|
|
4121
|
-
) {
|
|
3953
|
+
if (shadowMode === 1 /* ShadowMode.Synthetic */ || renderMode === 0 /* RenderMode.Light */) {
|
|
4122
3954
|
elm[KEY__SHADOW_RESOLVER] = renderRoot[KEY__SHADOW_RESOLVER];
|
|
4123
3955
|
}
|
|
4124
3956
|
}
|
|
4125
3957
|
}
|
|
4126
|
-
|
|
4127
3958
|
function updateTextContent(vnode, renderer) {
|
|
4128
3959
|
const {
|
|
4129
3960
|
elm,
|
|
@@ -4132,120 +3963,87 @@ function updateTextContent(vnode, renderer) {
|
|
|
4132
3963
|
const {
|
|
4133
3964
|
setText
|
|
4134
3965
|
} = renderer;
|
|
4135
|
-
|
|
4136
3966
|
if (process.env.NODE_ENV !== 'production') {
|
|
4137
3967
|
unlockDomMutation();
|
|
4138
3968
|
}
|
|
4139
|
-
|
|
4140
3969
|
setText(elm, text);
|
|
4141
|
-
|
|
4142
3970
|
if (process.env.NODE_ENV !== 'production') {
|
|
4143
3971
|
lockDomMutation();
|
|
4144
3972
|
}
|
|
4145
3973
|
}
|
|
4146
|
-
|
|
4147
3974
|
function insertNode(node, parent, anchor, renderer) {
|
|
4148
3975
|
if (process.env.NODE_ENV !== 'production') {
|
|
4149
3976
|
unlockDomMutation();
|
|
4150
3977
|
}
|
|
4151
|
-
|
|
4152
3978
|
renderer.insert(node, parent, anchor);
|
|
4153
|
-
|
|
4154
3979
|
if (process.env.NODE_ENV !== 'production') {
|
|
4155
3980
|
lockDomMutation();
|
|
4156
3981
|
}
|
|
4157
3982
|
}
|
|
4158
|
-
|
|
4159
3983
|
function removeNode(node, parent, renderer) {
|
|
4160
3984
|
if (process.env.NODE_ENV !== 'production') {
|
|
4161
3985
|
unlockDomMutation();
|
|
4162
3986
|
}
|
|
4163
|
-
|
|
4164
3987
|
renderer.remove(node, parent);
|
|
4165
|
-
|
|
4166
3988
|
if (process.env.NODE_ENV !== 'production') {
|
|
4167
3989
|
lockDomMutation();
|
|
4168
3990
|
}
|
|
4169
3991
|
}
|
|
4170
|
-
|
|
4171
3992
|
function patchElementPropsAndAttrs$1(oldVnode, vnode, renderer) {
|
|
4172
3993
|
if (isNull(oldVnode)) {
|
|
4173
3994
|
applyEventListeners(vnode, renderer);
|
|
4174
3995
|
applyStaticClassAttribute(vnode, renderer);
|
|
4175
3996
|
applyStaticStyleAttribute(vnode, renderer);
|
|
4176
|
-
}
|
|
3997
|
+
}
|
|
3998
|
+
// Attrs need to be applied to element before props IE11 will wipe out value on radio inputs if
|
|
4177
3999
|
// value is set before type=radio.
|
|
4178
|
-
|
|
4179
|
-
|
|
4180
4000
|
patchClassAttribute(oldVnode, vnode, renderer);
|
|
4181
4001
|
patchStyleAttribute(oldVnode, vnode, renderer);
|
|
4182
4002
|
patchAttributes(oldVnode, vnode, renderer);
|
|
4183
4003
|
patchProps(oldVnode, vnode, renderer);
|
|
4184
4004
|
}
|
|
4185
|
-
|
|
4186
4005
|
function applyStyleScoping(elm, owner, renderer) {
|
|
4187
4006
|
// Set the class name for `*.scoped.css` style scoping.
|
|
4188
4007
|
const scopeToken = getScopeTokenClass(owner);
|
|
4189
|
-
|
|
4190
4008
|
if (!isNull(scopeToken)) {
|
|
4191
4009
|
const {
|
|
4192
4010
|
getClassList
|
|
4193
|
-
} = renderer;
|
|
4011
|
+
} = renderer;
|
|
4012
|
+
// TODO [#2762]: this dot notation with add is probably problematic
|
|
4194
4013
|
// probably we should have a renderer api for just the add operation
|
|
4195
|
-
|
|
4196
4014
|
getClassList(elm).add(scopeToken);
|
|
4197
|
-
}
|
|
4198
|
-
|
|
4199
|
-
|
|
4015
|
+
}
|
|
4016
|
+
// Set property element for synthetic shadow DOM style scoping.
|
|
4200
4017
|
const {
|
|
4201
4018
|
stylesheetToken: syntheticToken
|
|
4202
4019
|
} = owner.context;
|
|
4203
|
-
|
|
4204
|
-
if (owner.shadowMode === 1
|
|
4205
|
-
/* ShadowMode.Synthetic */
|
|
4206
|
-
&& !isUndefined$1(syntheticToken)) {
|
|
4020
|
+
if (owner.shadowMode === 1 /* ShadowMode.Synthetic */ && !isUndefined$1(syntheticToken)) {
|
|
4207
4021
|
elm.$shadowToken$ = syntheticToken;
|
|
4208
4022
|
}
|
|
4209
4023
|
}
|
|
4210
|
-
|
|
4211
4024
|
function applyDomManual(elm, vnode) {
|
|
4212
4025
|
var _a;
|
|
4213
|
-
|
|
4214
4026
|
const {
|
|
4215
4027
|
owner,
|
|
4216
4028
|
data: {
|
|
4217
4029
|
context
|
|
4218
4030
|
}
|
|
4219
4031
|
} = vnode;
|
|
4220
|
-
|
|
4221
|
-
if (owner.shadowMode === 1
|
|
4222
|
-
/* ShadowMode.Synthetic */
|
|
4223
|
-
&& ((_a = context === null || context === void 0 ? void 0 : context.lwc) === null || _a === void 0 ? void 0 : _a.dom) === "manual"
|
|
4224
|
-
/* LwcDomMode.Manual */
|
|
4225
|
-
) {
|
|
4032
|
+
if (owner.shadowMode === 1 /* ShadowMode.Synthetic */ && ((_a = context === null || context === void 0 ? void 0 : context.lwc) === null || _a === void 0 ? void 0 : _a.dom) === "manual" /* LwcDomMode.Manual */) {
|
|
4226
4033
|
elm.$domManual$ = true;
|
|
4227
4034
|
}
|
|
4228
4035
|
}
|
|
4229
|
-
|
|
4230
4036
|
function applyElementRestrictions(elm, vnode) {
|
|
4231
4037
|
var _a, _b;
|
|
4232
|
-
|
|
4233
4038
|
if (process.env.NODE_ENV !== 'production') {
|
|
4234
|
-
const isPortal = vnode.type === 2
|
|
4235
|
-
/*
|
|
4236
|
-
&& ((_b = (_a = vnode.data.context) === null || _a === void 0 ? void 0 : _a.lwc) === null || _b === void 0 ? void 0 : _b.dom) === "manual"
|
|
4237
|
-
/* LwcDomMode.Manual */
|
|
4238
|
-
;
|
|
4239
|
-
const isLight = vnode.owner.renderMode === 0
|
|
4240
|
-
/* RenderMode.Light */
|
|
4241
|
-
;
|
|
4039
|
+
const isPortal = vnode.type === 2 /* VNodeType.Element */ && ((_b = (_a = vnode.data.context) === null || _a === void 0 ? void 0 : _a.lwc) === null || _b === void 0 ? void 0 : _b.dom) === "manual" /* LwcDomMode.Manual */;
|
|
4040
|
+
const isLight = vnode.owner.renderMode === 0 /* RenderMode.Light */;
|
|
4242
4041
|
patchElementWithRestrictions(elm, {
|
|
4243
4042
|
isPortal,
|
|
4244
4043
|
isLight
|
|
4245
4044
|
});
|
|
4246
4045
|
}
|
|
4247
4046
|
}
|
|
4248
|
-
|
|
4249
4047
|
function allocateChildren(vnode, vm) {
|
|
4250
4048
|
// A component with slots will re-render because:
|
|
4251
4049
|
// 1- There is a change of the internal state.
|
|
@@ -4263,41 +4061,31 @@ function allocateChildren(vnode, vm) {
|
|
|
4263
4061
|
renderMode,
|
|
4264
4062
|
shadowMode
|
|
4265
4063
|
} = vm;
|
|
4266
|
-
|
|
4267
4064
|
if (process.env.NODE_ENV !== 'production') {
|
|
4268
4065
|
// If any of the children being allocated is a scoped slot fragment, make sure the receiving
|
|
4269
4066
|
// component is a light DOM component. This is mainly to validate light dom parent running
|
|
4270
4067
|
// in native shadow mode.
|
|
4271
|
-
if (renderMode !== 0
|
|
4272
|
-
/* RenderMode.Light */
|
|
4273
|
-
&& ArraySome.call(children, child => !isNull(child) && isVScopedSlotFragment(child))) {
|
|
4068
|
+
if (renderMode !== 0 /* RenderMode.Light */ && ArraySome.call(children, child => !isNull(child) && isVScopedSlotFragment(child))) {
|
|
4274
4069
|
logError(`Invalid usage of 'lwc:slot-data' on ${getComponentTag(vm)} tag. Scoped slot content can only be passed to a light dom child.`);
|
|
4275
4070
|
}
|
|
4276
4071
|
}
|
|
4277
|
-
|
|
4278
|
-
if (shadowMode === 1
|
|
4279
|
-
/* ShadowMode.Synthetic */
|
|
4280
|
-
|| renderMode === 0
|
|
4281
|
-
/* RenderMode.Light */
|
|
4282
|
-
) {
|
|
4072
|
+
if (shadowMode === 1 /* ShadowMode.Synthetic */ || renderMode === 0 /* RenderMode.Light */) {
|
|
4283
4073
|
// slow path
|
|
4284
|
-
allocateInSlot(vm, children, vnode.owner);
|
|
4285
|
-
|
|
4286
|
-
vnode.aChildren = children;
|
|
4287
|
-
|
|
4074
|
+
allocateInSlot(vm, children, vnode.owner);
|
|
4075
|
+
// save the allocated children in case this vnode is reused.
|
|
4076
|
+
vnode.aChildren = children;
|
|
4077
|
+
// every child vnode is now allocated, and the host should receive none directly, it receives them via the shadow!
|
|
4288
4078
|
vnode.children = EmptyArray;
|
|
4289
4079
|
}
|
|
4290
4080
|
}
|
|
4291
|
-
|
|
4292
4081
|
function createViewModelHook(elm, vnode, renderer) {
|
|
4293
|
-
let vm = getAssociatedVMIfPresent(elm);
|
|
4082
|
+
let vm = getAssociatedVMIfPresent(elm);
|
|
4083
|
+
// There is a possibility that a custom element is registered under tagName, in which case, the
|
|
4294
4084
|
// initialization is already carry on, and there is nothing else to do here since this hook is
|
|
4295
4085
|
// called right after invoking `document.createElement`.
|
|
4296
|
-
|
|
4297
4086
|
if (!isUndefined$1(vm)) {
|
|
4298
4087
|
return vm;
|
|
4299
4088
|
}
|
|
4300
|
-
|
|
4301
4089
|
const {
|
|
4302
4090
|
sel,
|
|
4303
4091
|
mode,
|
|
@@ -4309,48 +4097,37 @@ function createViewModelHook(elm, vnode, renderer) {
|
|
|
4309
4097
|
owner,
|
|
4310
4098
|
tagName: sel
|
|
4311
4099
|
});
|
|
4312
|
-
|
|
4313
4100
|
if (process.env.NODE_ENV !== 'production') {
|
|
4314
4101
|
assert.isTrue(isArray$1(vnode.children), `Invalid vnode for a custom element, it must have children defined.`);
|
|
4315
4102
|
}
|
|
4316
|
-
|
|
4317
4103
|
return vm;
|
|
4318
4104
|
}
|
|
4319
4105
|
/**
|
|
4320
4106
|
* Collects all slots into a SlotSet, traversing through VFragment Nodes
|
|
4321
4107
|
*/
|
|
4322
|
-
|
|
4323
|
-
|
|
4324
4108
|
function collectSlots(vm, children, cmpSlotsMapping) {
|
|
4325
4109
|
var _a, _b;
|
|
4326
|
-
|
|
4327
4110
|
for (let i = 0, len = children.length; i < len; i += 1) {
|
|
4328
4111
|
const vnode = children[i];
|
|
4329
|
-
|
|
4330
4112
|
if (isNull(vnode)) {
|
|
4331
4113
|
continue;
|
|
4332
|
-
}
|
|
4333
|
-
|
|
4334
|
-
|
|
4114
|
+
}
|
|
4115
|
+
// Dive further iff the content is wrapped in a VFragment
|
|
4335
4116
|
if (isVFragment(vnode)) {
|
|
4336
4117
|
// Remove the text delimiter nodes to avoid overriding default slot content
|
|
4337
4118
|
collectSlots(vm, vnode.children.slice(1, -1), cmpSlotsMapping);
|
|
4338
4119
|
continue;
|
|
4339
4120
|
}
|
|
4340
|
-
|
|
4341
4121
|
let slotName = '';
|
|
4342
|
-
|
|
4343
4122
|
if (isVBaseElement(vnode)) {
|
|
4344
4123
|
slotName = (_b = (_a = vnode.data.attrs) === null || _a === void 0 ? void 0 : _a.slot) !== null && _b !== void 0 ? _b : '';
|
|
4345
4124
|
} else if (isVScopedSlotFragment(vnode)) {
|
|
4346
4125
|
slotName = vnode.slotName;
|
|
4347
4126
|
}
|
|
4348
|
-
|
|
4349
4127
|
const vnodes = cmpSlotsMapping[slotName] = cmpSlotsMapping[slotName] || [];
|
|
4350
4128
|
ArrayPush$1.call(vnodes, vnode);
|
|
4351
4129
|
}
|
|
4352
4130
|
}
|
|
4353
|
-
|
|
4354
4131
|
function allocateInSlot(vm, children, owner) {
|
|
4355
4132
|
const {
|
|
4356
4133
|
cmpSlots: {
|
|
@@ -4363,28 +4140,22 @@ function allocateInSlot(vm, children, owner) {
|
|
|
4363
4140
|
owner,
|
|
4364
4141
|
slotAssignments: cmpSlotsMapping
|
|
4365
4142
|
};
|
|
4366
|
-
|
|
4367
4143
|
if (isFalse(vm.isDirty)) {
|
|
4368
4144
|
// We need to determine if the old allocation is really different from the new one
|
|
4369
4145
|
// and mark the vm as dirty
|
|
4370
4146
|
const oldKeys = keys(oldSlotsMapping);
|
|
4371
|
-
|
|
4372
4147
|
if (oldKeys.length !== keys(cmpSlotsMapping).length) {
|
|
4373
4148
|
markComponentAsDirty(vm);
|
|
4374
4149
|
return;
|
|
4375
4150
|
}
|
|
4376
|
-
|
|
4377
4151
|
for (let i = 0, len = oldKeys.length; i < len; i += 1) {
|
|
4378
4152
|
const key = oldKeys[i];
|
|
4379
|
-
|
|
4380
4153
|
if (isUndefined$1(cmpSlotsMapping[key]) || oldSlotsMapping[key].length !== cmpSlotsMapping[key].length) {
|
|
4381
4154
|
markComponentAsDirty(vm);
|
|
4382
4155
|
return;
|
|
4383
4156
|
}
|
|
4384
|
-
|
|
4385
4157
|
const oldVNodes = oldSlotsMapping[key];
|
|
4386
4158
|
const vnodes = cmpSlotsMapping[key];
|
|
4387
|
-
|
|
4388
4159
|
for (let j = 0, a = cmpSlotsMapping[key].length; j < a; j += 1) {
|
|
4389
4160
|
if (oldVNodes[j] !== vnodes[j]) {
|
|
4390
4161
|
markComponentAsDirty(vm);
|
|
@@ -4393,40 +4164,33 @@ function allocateInSlot(vm, children, owner) {
|
|
|
4393
4164
|
}
|
|
4394
4165
|
}
|
|
4395
4166
|
}
|
|
4396
|
-
}
|
|
4397
|
-
|
|
4398
|
-
|
|
4399
|
-
|
|
4167
|
+
}
|
|
4168
|
+
// Using a WeakMap instead of a WeakSet because this one works in IE11 :(
|
|
4169
|
+
const FromIteration = new WeakMap();
|
|
4170
|
+
// dynamic children means it was generated by an iteration
|
|
4400
4171
|
// in a template, and will require a more complex diffing algo.
|
|
4401
|
-
|
|
4402
4172
|
function markAsDynamicChildren(children) {
|
|
4403
4173
|
FromIteration.set(children, 1);
|
|
4404
4174
|
}
|
|
4405
|
-
|
|
4406
4175
|
function hasDynamicChildren(children) {
|
|
4407
4176
|
return FromIteration.has(children);
|
|
4408
4177
|
}
|
|
4409
|
-
|
|
4410
4178
|
function createKeyToOldIdx(children, beginIdx, endIdx) {
|
|
4411
|
-
const map = {};
|
|
4412
|
-
|
|
4179
|
+
const map = {};
|
|
4180
|
+
// TODO [#1637]: simplify this by assuming that all vnodes has keys
|
|
4413
4181
|
for (let j = beginIdx; j <= endIdx; ++j) {
|
|
4414
4182
|
const ch = children[j];
|
|
4415
|
-
|
|
4416
4183
|
if (isVNode(ch)) {
|
|
4417
4184
|
const {
|
|
4418
4185
|
key
|
|
4419
4186
|
} = ch;
|
|
4420
|
-
|
|
4421
4187
|
if (key !== undefined) {
|
|
4422
4188
|
map[key] = j;
|
|
4423
4189
|
}
|
|
4424
4190
|
}
|
|
4425
4191
|
}
|
|
4426
|
-
|
|
4427
4192
|
return map;
|
|
4428
4193
|
}
|
|
4429
|
-
|
|
4430
4194
|
function updateDynamicChildren(oldCh, newCh, parent, renderer) {
|
|
4431
4195
|
let oldStartIdx = 0;
|
|
4432
4196
|
let newStartIdx = 0;
|
|
@@ -4442,7 +4206,6 @@ function updateDynamicChildren(oldCh, newCh, parent, renderer) {
|
|
|
4442
4206
|
let elmToMove;
|
|
4443
4207
|
let before;
|
|
4444
4208
|
let clonedOldCh = false;
|
|
4445
|
-
|
|
4446
4209
|
while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
|
|
4447
4210
|
if (!isVNode(oldStartVnode)) {
|
|
4448
4211
|
oldStartVnode = oldCh[++oldStartIdx]; // Vnode might have been moved left
|
|
@@ -4476,54 +4239,46 @@ function updateDynamicChildren(oldCh, newCh, parent, renderer) {
|
|
|
4476
4239
|
if (oldKeyToIdx === undefined) {
|
|
4477
4240
|
oldKeyToIdx = createKeyToOldIdx(oldCh, oldStartIdx, oldEndIdx);
|
|
4478
4241
|
}
|
|
4479
|
-
|
|
4480
4242
|
idxInOld = oldKeyToIdx[newStartVnode.key];
|
|
4481
|
-
|
|
4482
4243
|
if (isUndefined$1(idxInOld)) {
|
|
4483
4244
|
// New element
|
|
4484
4245
|
mount(newStartVnode, parent, renderer, oldStartVnode.elm);
|
|
4485
4246
|
newStartVnode = newCh[++newStartIdx];
|
|
4486
4247
|
} else {
|
|
4487
4248
|
elmToMove = oldCh[idxInOld];
|
|
4488
|
-
|
|
4489
4249
|
if (isVNode(elmToMove)) {
|
|
4490
4250
|
if (elmToMove.sel !== newStartVnode.sel) {
|
|
4491
4251
|
// New element
|
|
4492
4252
|
mount(newStartVnode, parent, renderer, oldStartVnode.elm);
|
|
4493
4253
|
} else {
|
|
4494
|
-
patch(elmToMove, newStartVnode, parent, renderer);
|
|
4254
|
+
patch(elmToMove, newStartVnode, parent, renderer);
|
|
4255
|
+
// Delete the old child, but copy the array since it is read-only.
|
|
4495
4256
|
// The `oldCh` will be GC'ed after `updateDynamicChildren` is complete,
|
|
4496
4257
|
// so we only care about the `oldCh` object inside this function.
|
|
4497
4258
|
// To avoid cloning over and over again, we check `clonedOldCh`
|
|
4498
4259
|
// and only clone once.
|
|
4499
|
-
|
|
4500
4260
|
if (!clonedOldCh) {
|
|
4501
4261
|
clonedOldCh = true;
|
|
4502
4262
|
oldCh = [...oldCh];
|
|
4503
|
-
}
|
|
4504
|
-
|
|
4505
|
-
|
|
4263
|
+
}
|
|
4264
|
+
// We've already cloned at least once, so it's no longer read-only
|
|
4506
4265
|
oldCh[idxInOld] = undefined;
|
|
4507
4266
|
insertNode(elmToMove.elm, parent, oldStartVnode.elm, renderer);
|
|
4508
4267
|
}
|
|
4509
4268
|
}
|
|
4510
|
-
|
|
4511
4269
|
newStartVnode = newCh[++newStartIdx];
|
|
4512
4270
|
}
|
|
4513
4271
|
}
|
|
4514
4272
|
}
|
|
4515
|
-
|
|
4516
4273
|
if (oldStartIdx <= oldEndIdx || newStartIdx <= newEndIdx) {
|
|
4517
4274
|
if (oldStartIdx > oldEndIdx) {
|
|
4518
4275
|
// There's some cases in which the sub array of vnodes to be inserted is followed by null(s) and an
|
|
4519
4276
|
// already processed vnode, in such cases the vnodes to be inserted should be before that processed vnode.
|
|
4520
4277
|
let i = newEndIdx;
|
|
4521
4278
|
let n;
|
|
4522
|
-
|
|
4523
4279
|
do {
|
|
4524
4280
|
n = newCh[++i];
|
|
4525
4281
|
} while (!isVNode(n) && i < newChEnd);
|
|
4526
|
-
|
|
4527
4282
|
before = isVNode(n) ? n.elm : null;
|
|
4528
4283
|
mountVNodes(newCh, parent, renderer, before, newStartIdx, newEndIdx + 1);
|
|
4529
4284
|
} else {
|
|
@@ -4531,32 +4286,26 @@ function updateDynamicChildren(oldCh, newCh, parent, renderer) {
|
|
|
4531
4286
|
}
|
|
4532
4287
|
}
|
|
4533
4288
|
}
|
|
4534
|
-
|
|
4535
4289
|
function updateStaticChildren(c1, c2, parent, renderer) {
|
|
4536
4290
|
const c1Length = c1.length;
|
|
4537
4291
|
const c2Length = c2.length;
|
|
4538
|
-
|
|
4539
4292
|
if (c1Length === 0) {
|
|
4540
4293
|
// the old list is empty, we can directly insert anything new
|
|
4541
4294
|
mountVNodes(c2, parent, renderer, null);
|
|
4542
4295
|
return;
|
|
4543
4296
|
}
|
|
4544
|
-
|
|
4545
4297
|
if (c2Length === 0) {
|
|
4546
4298
|
// the old list is nonempty and the new list is empty so we can directly remove all old nodes
|
|
4547
4299
|
// this is the case in which the dynamic children of an if-directive should be removed
|
|
4548
4300
|
unmountVNodes(c1, parent, renderer, true);
|
|
4549
4301
|
return;
|
|
4550
|
-
}
|
|
4302
|
+
}
|
|
4303
|
+
// if the old list is not empty, the new list MUST have the same
|
|
4551
4304
|
// amount of nodes, that's why we call this static children
|
|
4552
|
-
|
|
4553
|
-
|
|
4554
4305
|
let anchor = null;
|
|
4555
|
-
|
|
4556
4306
|
for (let i = c2Length - 1; i >= 0; i -= 1) {
|
|
4557
4307
|
const n1 = c1[i];
|
|
4558
4308
|
const n2 = c2[i];
|
|
4559
|
-
|
|
4560
4309
|
if (n2 !== n1) {
|
|
4561
4310
|
if (isVNode(n1)) {
|
|
4562
4311
|
if (isVNode(n2)) {
|
|
@@ -5501,42 +5250,30 @@ function invokeServiceHook(vm, cbs) {
|
|
|
5501
5250
|
*/
|
|
5502
5251
|
let idx = 0;
|
|
5503
5252
|
/** The internal slot used to associate different objects the engine manipulates with the VM */
|
|
5504
|
-
|
|
5505
5253
|
const ViewModelReflection = new WeakMap();
|
|
5506
|
-
|
|
5507
5254
|
function callHook(cmp, fn, args = []) {
|
|
5508
5255
|
return fn.apply(cmp, args);
|
|
5509
5256
|
}
|
|
5510
|
-
|
|
5511
5257
|
function setHook(cmp, prop, newValue) {
|
|
5512
5258
|
cmp[prop] = newValue;
|
|
5513
5259
|
}
|
|
5514
|
-
|
|
5515
5260
|
function getHook(cmp, prop) {
|
|
5516
5261
|
return cmp[prop];
|
|
5517
5262
|
}
|
|
5518
|
-
|
|
5519
5263
|
function rerenderVM(vm) {
|
|
5520
5264
|
rehydrate(vm);
|
|
5521
5265
|
}
|
|
5522
5266
|
function connectRootElement(elm) {
|
|
5523
5267
|
const vm = getAssociatedVM(elm);
|
|
5524
|
-
logGlobalOperationStart(7
|
|
5525
|
-
|
|
5526
|
-
, vm); // Usually means moving the element from one place to another, which is observable via
|
|
5268
|
+
logGlobalOperationStart(7 /* OperationId.GlobalHydrate */, vm);
|
|
5269
|
+
// Usually means moving the element from one place to another, which is observable via
|
|
5527
5270
|
// life-cycle hooks.
|
|
5528
|
-
|
|
5529
|
-
if (vm.state === 1
|
|
5530
|
-
/* VMState.connected */
|
|
5531
|
-
) {
|
|
5271
|
+
if (vm.state === 1 /* VMState.connected */) {
|
|
5532
5272
|
disconnectRootElement(elm);
|
|
5533
5273
|
}
|
|
5534
|
-
|
|
5535
5274
|
runConnectedCallback(vm);
|
|
5536
5275
|
rehydrate(vm);
|
|
5537
|
-
logGlobalOperationEnd(7
|
|
5538
|
-
/* OperationId.GlobalHydrate */
|
|
5539
|
-
, vm);
|
|
5276
|
+
logGlobalOperationEnd(7 /* OperationId.GlobalHydrate */, vm);
|
|
5540
5277
|
}
|
|
5541
5278
|
function disconnectRootElement(elm) {
|
|
5542
5279
|
const vm = getAssociatedVM(elm);
|
|
@@ -5544,65 +5281,48 @@ function disconnectRootElement(elm) {
|
|
|
5544
5281
|
}
|
|
5545
5282
|
function appendVM(vm) {
|
|
5546
5283
|
rehydrate(vm);
|
|
5547
|
-
}
|
|
5284
|
+
}
|
|
5285
|
+
// just in case the component comes back, with this we guarantee re-rendering it
|
|
5548
5286
|
// while preventing any attempt to rehydration until after reinsertion.
|
|
5549
|
-
|
|
5550
5287
|
function resetComponentStateWhenRemoved(vm) {
|
|
5551
5288
|
const {
|
|
5552
5289
|
state
|
|
5553
5290
|
} = vm;
|
|
5554
|
-
|
|
5555
|
-
if (state !== 2
|
|
5556
|
-
/* VMState.disconnected */
|
|
5557
|
-
) {
|
|
5291
|
+
if (state !== 2 /* VMState.disconnected */) {
|
|
5558
5292
|
const {
|
|
5559
5293
|
oar,
|
|
5560
5294
|
tro
|
|
5561
|
-
} = vm;
|
|
5562
|
-
|
|
5563
|
-
tro.reset();
|
|
5564
|
-
|
|
5295
|
+
} = vm;
|
|
5296
|
+
// Making sure that any observing record will not trigger the rehydrated on this vm
|
|
5297
|
+
tro.reset();
|
|
5298
|
+
// Making sure that any observing accessor record will not trigger the setter to be reinvoked
|
|
5565
5299
|
for (const key in oar) {
|
|
5566
5300
|
oar[key].reset();
|
|
5567
5301
|
}
|
|
5568
|
-
|
|
5569
|
-
|
|
5570
|
-
|
|
5302
|
+
runDisconnectedCallback(vm);
|
|
5303
|
+
// Spec: https://dom.spec.whatwg.org/#concept-node-remove (step 14-15)
|
|
5571
5304
|
runChildNodesDisconnectedCallback(vm);
|
|
5572
5305
|
runLightChildNodesDisconnectedCallback(vm);
|
|
5573
5306
|
}
|
|
5574
|
-
|
|
5575
5307
|
if (process.env.NODE_ENV !== 'production') {
|
|
5576
5308
|
removeActiveVM(vm);
|
|
5577
5309
|
}
|
|
5578
|
-
}
|
|
5310
|
+
}
|
|
5311
|
+
// this method is triggered by the diffing algo only when a vnode from the
|
|
5579
5312
|
// old vnode.children is removed from the DOM.
|
|
5580
|
-
|
|
5581
|
-
|
|
5582
5313
|
function removeVM(vm) {
|
|
5583
5314
|
if (process.env.NODE_ENV !== 'production') {
|
|
5584
|
-
assert.isTrue(vm.state === 1
|
|
5585
|
-
/* VMState.connected */
|
|
5586
|
-
|| vm.state === 2
|
|
5587
|
-
/* VMState.disconnected */
|
|
5588
|
-
, `${vm} must have been connected.`);
|
|
5315
|
+
assert.isTrue(vm.state === 1 /* VMState.connected */ || vm.state === 2 /* VMState.disconnected */, `${vm} must have been connected.`);
|
|
5589
5316
|
}
|
|
5590
|
-
|
|
5591
5317
|
resetComponentStateWhenRemoved(vm);
|
|
5592
5318
|
}
|
|
5593
|
-
|
|
5594
5319
|
function getNearestShadowAncestor(vm) {
|
|
5595
5320
|
let ancestor = vm.owner;
|
|
5596
|
-
|
|
5597
|
-
while (!isNull(ancestor) && ancestor.renderMode === 0
|
|
5598
|
-
/* RenderMode.Light */
|
|
5599
|
-
) {
|
|
5321
|
+
while (!isNull(ancestor) && ancestor.renderMode === 0 /* RenderMode.Light */) {
|
|
5600
5322
|
ancestor = ancestor.owner;
|
|
5601
5323
|
}
|
|
5602
|
-
|
|
5603
5324
|
return ancestor;
|
|
5604
5325
|
}
|
|
5605
|
-
|
|
5606
5326
|
function createVM(elm, ctor, renderer, options) {
|
|
5607
5327
|
const {
|
|
5608
5328
|
mode,
|
|
@@ -5615,9 +5335,7 @@ function createVM(elm, ctor, renderer, options) {
|
|
|
5615
5335
|
elm,
|
|
5616
5336
|
def,
|
|
5617
5337
|
idx: idx++,
|
|
5618
|
-
state: 0
|
|
5619
|
-
/* VMState.created */
|
|
5620
|
-
,
|
|
5338
|
+
state: 0 /* VMState.created */,
|
|
5621
5339
|
isScheduled: false,
|
|
5622
5340
|
isDirty: true,
|
|
5623
5341
|
tagName,
|
|
@@ -5659,31 +5377,27 @@ function createVM(elm, ctor, renderer, options) {
|
|
|
5659
5377
|
getHook,
|
|
5660
5378
|
renderer
|
|
5661
5379
|
};
|
|
5380
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
5381
|
+
vm.debugInfo = create(null);
|
|
5382
|
+
}
|
|
5662
5383
|
vm.shadowMode = computeShadowMode(vm, renderer);
|
|
5663
5384
|
vm.tro = getTemplateReactiveObserver();
|
|
5664
|
-
|
|
5665
5385
|
if (process.env.NODE_ENV !== 'production') {
|
|
5666
5386
|
vm.toString = () => {
|
|
5667
5387
|
return `[object:vm ${def.name} (${vm.idx})]`;
|
|
5668
5388
|
};
|
|
5669
|
-
|
|
5670
5389
|
if (lwcRuntimeFlags.ENABLE_FORCE_NATIVE_SHADOW_MODE_FOR_TEST) {
|
|
5671
|
-
vm.shadowMode = 0
|
|
5672
|
-
/* ShadowMode.Native */
|
|
5673
|
-
;
|
|
5390
|
+
vm.shadowMode = 0 /* ShadowMode.Native */;
|
|
5674
5391
|
}
|
|
5675
|
-
}
|
|
5676
|
-
|
|
5677
|
-
|
|
5678
|
-
|
|
5679
|
-
|
|
5392
|
+
}
|
|
5393
|
+
// Create component instance associated to the vm and the element.
|
|
5394
|
+
invokeComponentConstructor(vm, def.ctor);
|
|
5395
|
+
// Initializing the wire decorator per instance only when really needed
|
|
5680
5396
|
if (hasWireAdapters(vm)) {
|
|
5681
5397
|
installWireAdapters(vm);
|
|
5682
5398
|
}
|
|
5683
|
-
|
|
5684
5399
|
return vm;
|
|
5685
5400
|
}
|
|
5686
|
-
|
|
5687
5401
|
function computeShadowMode(vm, renderer) {
|
|
5688
5402
|
const {
|
|
5689
5403
|
def
|
|
@@ -5693,191 +5407,135 @@ function computeShadowMode(vm, renderer) {
|
|
|
5693
5407
|
isNativeShadowDefined
|
|
5694
5408
|
} = renderer;
|
|
5695
5409
|
let shadowMode;
|
|
5696
|
-
|
|
5697
5410
|
if (isSyntheticShadowDefined) {
|
|
5698
|
-
if (def.renderMode === 0
|
|
5699
|
-
/* RenderMode.Light */
|
|
5700
|
-
) {
|
|
5411
|
+
if (def.renderMode === 0 /* RenderMode.Light */) {
|
|
5701
5412
|
// ShadowMode.Native implies "not synthetic shadow" which is consistent with how
|
|
5702
5413
|
// everything defaults to native when the synthetic shadow polyfill is unavailable.
|
|
5703
|
-
shadowMode = 0
|
|
5704
|
-
/* ShadowMode.Native */
|
|
5705
|
-
;
|
|
5414
|
+
shadowMode = 0 /* ShadowMode.Native */;
|
|
5706
5415
|
} else if (isNativeShadowDefined) {
|
|
5707
5416
|
// Not combined with above condition because @lwc/features only supports identifiers in
|
|
5708
5417
|
// the if-condition.
|
|
5709
5418
|
if (lwcRuntimeFlags.ENABLE_MIXED_SHADOW_MODE) {
|
|
5710
|
-
if (def.shadowSupportMode === "any"
|
|
5711
|
-
|
|
5712
|
-
) {
|
|
5713
|
-
shadowMode = 0
|
|
5714
|
-
/* ShadowMode.Native */
|
|
5715
|
-
;
|
|
5419
|
+
if (def.shadowSupportMode === "any" /* ShadowSupportMode.Any */) {
|
|
5420
|
+
shadowMode = 0 /* ShadowMode.Native */;
|
|
5716
5421
|
} else {
|
|
5717
5422
|
const shadowAncestor = getNearestShadowAncestor(vm);
|
|
5718
|
-
|
|
5719
|
-
if (!isNull(shadowAncestor) && shadowAncestor.shadowMode === 0
|
|
5720
|
-
/* ShadowMode.Native */
|
|
5721
|
-
) {
|
|
5423
|
+
if (!isNull(shadowAncestor) && shadowAncestor.shadowMode === 0 /* ShadowMode.Native */) {
|
|
5722
5424
|
// Transitive support for native Shadow DOM. A component in native mode
|
|
5723
5425
|
// transitively opts all of its descendants into native.
|
|
5724
|
-
shadowMode = 0
|
|
5725
|
-
/* ShadowMode.Native */
|
|
5726
|
-
;
|
|
5426
|
+
shadowMode = 0 /* ShadowMode.Native */;
|
|
5727
5427
|
} else {
|
|
5728
5428
|
// Synthetic if neither this component nor any of its ancestors are configured
|
|
5729
5429
|
// to be native.
|
|
5730
|
-
shadowMode = 1
|
|
5731
|
-
/* ShadowMode.Synthetic */
|
|
5732
|
-
;
|
|
5430
|
+
shadowMode = 1 /* ShadowMode.Synthetic */;
|
|
5733
5431
|
}
|
|
5734
5432
|
}
|
|
5735
5433
|
} else {
|
|
5736
|
-
shadowMode = 1
|
|
5737
|
-
/* ShadowMode.Synthetic */
|
|
5738
|
-
;
|
|
5434
|
+
shadowMode = 1 /* ShadowMode.Synthetic */;
|
|
5739
5435
|
}
|
|
5740
5436
|
} else {
|
|
5741
5437
|
// Synthetic if there is no native Shadow DOM support.
|
|
5742
|
-
shadowMode = 1
|
|
5743
|
-
/* ShadowMode.Synthetic */
|
|
5744
|
-
;
|
|
5438
|
+
shadowMode = 1 /* ShadowMode.Synthetic */;
|
|
5745
5439
|
}
|
|
5746
5440
|
} else {
|
|
5747
5441
|
// Native if the synthetic shadow polyfill is unavailable.
|
|
5748
|
-
shadowMode = 0
|
|
5749
|
-
/* ShadowMode.Native */
|
|
5750
|
-
;
|
|
5442
|
+
shadowMode = 0 /* ShadowMode.Native */;
|
|
5751
5443
|
}
|
|
5752
5444
|
|
|
5753
5445
|
return shadowMode;
|
|
5754
5446
|
}
|
|
5755
|
-
|
|
5756
5447
|
function assertIsVM(obj) {
|
|
5757
5448
|
if (isNull(obj) || !isObject(obj) || !('renderRoot' in obj)) {
|
|
5758
5449
|
throw new TypeError(`${obj} is not a VM.`);
|
|
5759
5450
|
}
|
|
5760
5451
|
}
|
|
5761
|
-
|
|
5762
5452
|
function associateVM(obj, vm) {
|
|
5763
5453
|
ViewModelReflection.set(obj, vm);
|
|
5764
5454
|
}
|
|
5765
5455
|
function getAssociatedVM(obj) {
|
|
5766
5456
|
const vm = ViewModelReflection.get(obj);
|
|
5767
|
-
|
|
5768
5457
|
if (process.env.NODE_ENV !== 'production') {
|
|
5769
5458
|
assertIsVM(vm);
|
|
5770
5459
|
}
|
|
5771
|
-
|
|
5772
5460
|
return vm;
|
|
5773
5461
|
}
|
|
5774
5462
|
function getAssociatedVMIfPresent(obj) {
|
|
5775
5463
|
const maybeVm = ViewModelReflection.get(obj);
|
|
5776
|
-
|
|
5777
5464
|
if (process.env.NODE_ENV !== 'production') {
|
|
5778
5465
|
if (!isUndefined$1(maybeVm)) {
|
|
5779
5466
|
assertIsVM(maybeVm);
|
|
5780
5467
|
}
|
|
5781
5468
|
}
|
|
5782
|
-
|
|
5783
5469
|
return maybeVm;
|
|
5784
5470
|
}
|
|
5785
|
-
|
|
5786
5471
|
function rehydrate(vm) {
|
|
5787
5472
|
if (isTrue(vm.isDirty)) {
|
|
5788
5473
|
const children = renderComponent$1(vm);
|
|
5789
5474
|
patchShadowRoot(vm, children);
|
|
5790
5475
|
}
|
|
5791
5476
|
}
|
|
5792
|
-
|
|
5793
5477
|
function patchShadowRoot(vm, newCh) {
|
|
5794
5478
|
const {
|
|
5795
5479
|
renderRoot,
|
|
5796
5480
|
children: oldCh,
|
|
5797
5481
|
renderer
|
|
5798
|
-
} = vm;
|
|
5799
|
-
|
|
5482
|
+
} = vm;
|
|
5483
|
+
// caching the new children collection
|
|
5800
5484
|
vm.children = newCh;
|
|
5801
|
-
|
|
5802
5485
|
if (newCh.length > 0 || oldCh.length > 0) {
|
|
5803
5486
|
// patch function mutates vnodes by adding the element reference,
|
|
5804
5487
|
// however, if patching fails it contains partial changes.
|
|
5805
5488
|
if (oldCh !== newCh) {
|
|
5806
5489
|
runWithBoundaryProtection(vm, vm, () => {
|
|
5807
5490
|
// pre
|
|
5808
|
-
logOperationStart(2
|
|
5809
|
-
/* OperationId.Patch */
|
|
5810
|
-
, vm);
|
|
5491
|
+
logOperationStart(2 /* OperationId.Patch */, vm);
|
|
5811
5492
|
}, () => {
|
|
5812
5493
|
// job
|
|
5813
5494
|
patchChildren(oldCh, newCh, renderRoot, renderer);
|
|
5814
5495
|
}, () => {
|
|
5815
5496
|
// post
|
|
5816
|
-
logOperationEnd(2
|
|
5817
|
-
/* OperationId.Patch */
|
|
5818
|
-
, vm);
|
|
5497
|
+
logOperationEnd(2 /* OperationId.Patch */, vm);
|
|
5819
5498
|
});
|
|
5820
5499
|
}
|
|
5821
5500
|
}
|
|
5822
|
-
|
|
5823
|
-
if (vm.state === 1
|
|
5824
|
-
/* VMState.connected */
|
|
5825
|
-
) ;
|
|
5501
|
+
if (vm.state === 1 /* VMState.connected */) ;
|
|
5826
5502
|
}
|
|
5827
5503
|
|
|
5828
5504
|
function runConnectedCallback(vm) {
|
|
5829
5505
|
const {
|
|
5830
5506
|
state
|
|
5831
5507
|
} = vm;
|
|
5832
|
-
|
|
5833
|
-
if (state === 1
|
|
5834
|
-
/* VMState.connected */
|
|
5835
|
-
) {
|
|
5508
|
+
if (state === 1 /* VMState.connected */) {
|
|
5836
5509
|
return; // nothing to do since it was already connected
|
|
5837
5510
|
}
|
|
5838
5511
|
|
|
5839
|
-
vm.state = 1
|
|
5840
|
-
|
|
5841
|
-
; // reporting connection
|
|
5842
|
-
|
|
5512
|
+
vm.state = 1 /* VMState.connected */;
|
|
5513
|
+
// reporting connection
|
|
5843
5514
|
const {
|
|
5844
5515
|
connected
|
|
5845
5516
|
} = Services;
|
|
5846
|
-
|
|
5847
5517
|
if (connected) {
|
|
5848
5518
|
invokeServiceHook(vm, connected);
|
|
5849
5519
|
}
|
|
5850
|
-
|
|
5851
5520
|
if (hasWireAdapters(vm)) {
|
|
5852
5521
|
connectWireAdapters(vm);
|
|
5853
5522
|
}
|
|
5854
|
-
|
|
5855
5523
|
const {
|
|
5856
5524
|
connectedCallback
|
|
5857
5525
|
} = vm.def;
|
|
5858
|
-
|
|
5859
5526
|
if (!isUndefined$1(connectedCallback)) {
|
|
5860
|
-
logOperationStart(3
|
|
5861
|
-
/* OperationId.ConnectedCallback */
|
|
5862
|
-
, vm);
|
|
5527
|
+
logOperationStart(3 /* OperationId.ConnectedCallback */, vm);
|
|
5863
5528
|
invokeComponentCallback(vm, connectedCallback);
|
|
5864
|
-
logOperationEnd(3
|
|
5865
|
-
/* OperationId.ConnectedCallback */
|
|
5866
|
-
, vm);
|
|
5529
|
+
logOperationEnd(3 /* OperationId.ConnectedCallback */, vm);
|
|
5867
5530
|
}
|
|
5868
5531
|
}
|
|
5869
|
-
|
|
5870
5532
|
function hasWireAdapters(vm) {
|
|
5871
5533
|
return getOwnPropertyNames$1(vm.def.wire).length > 0;
|
|
5872
5534
|
}
|
|
5873
|
-
|
|
5874
5535
|
function runDisconnectedCallback(vm) {
|
|
5875
5536
|
if (process.env.NODE_ENV !== 'production') {
|
|
5876
|
-
assert.isTrue(vm.state !== 2
|
|
5877
|
-
/* VMState.disconnected */
|
|
5878
|
-
, `${vm} must be inserted.`);
|
|
5537
|
+
assert.isTrue(vm.state !== 2 /* VMState.disconnected */, `${vm} must be inserted.`);
|
|
5879
5538
|
}
|
|
5880
|
-
|
|
5881
5539
|
if (isFalse(vm.isDirty)) {
|
|
5882
5540
|
// this guarantees that if the component is reused/reinserted,
|
|
5883
5541
|
// it will be re-rendered because we are disconnecting the reactivity
|
|
@@ -5885,67 +5543,54 @@ function runDisconnectedCallback(vm) {
|
|
|
5885
5543
|
// of disconnected components.
|
|
5886
5544
|
vm.isDirty = true;
|
|
5887
5545
|
}
|
|
5888
|
-
|
|
5889
|
-
|
|
5890
|
-
/* VMState.disconnected */
|
|
5891
|
-
; // reporting disconnection
|
|
5892
|
-
|
|
5546
|
+
vm.state = 2 /* VMState.disconnected */;
|
|
5547
|
+
// reporting disconnection
|
|
5893
5548
|
const {
|
|
5894
5549
|
disconnected
|
|
5895
5550
|
} = Services;
|
|
5896
|
-
|
|
5897
5551
|
if (disconnected) {
|
|
5898
5552
|
invokeServiceHook(vm, disconnected);
|
|
5899
5553
|
}
|
|
5900
|
-
|
|
5901
5554
|
if (hasWireAdapters(vm)) {
|
|
5902
5555
|
disconnectWireAdapters(vm);
|
|
5903
5556
|
}
|
|
5904
|
-
|
|
5905
5557
|
const {
|
|
5906
5558
|
disconnectedCallback
|
|
5907
5559
|
} = vm.def;
|
|
5908
|
-
|
|
5909
5560
|
if (!isUndefined$1(disconnectedCallback)) {
|
|
5910
|
-
logOperationStart(5
|
|
5911
|
-
/* OperationId.DisconnectedCallback */
|
|
5912
|
-
, vm);
|
|
5561
|
+
logOperationStart(5 /* OperationId.DisconnectedCallback */, vm);
|
|
5913
5562
|
invokeComponentCallback(vm, disconnectedCallback);
|
|
5914
|
-
logOperationEnd(5
|
|
5915
|
-
/* OperationId.DisconnectedCallback */
|
|
5916
|
-
, vm);
|
|
5563
|
+
logOperationEnd(5 /* OperationId.DisconnectedCallback */, vm);
|
|
5917
5564
|
}
|
|
5918
5565
|
}
|
|
5919
|
-
|
|
5920
5566
|
function runChildNodesDisconnectedCallback(vm) {
|
|
5921
5567
|
const {
|
|
5922
5568
|
velements: vCustomElementCollection
|
|
5923
|
-
} = vm;
|
|
5569
|
+
} = vm;
|
|
5570
|
+
// Reporting disconnection for every child in inverse order since they are
|
|
5924
5571
|
// inserted in reserved order.
|
|
5925
|
-
|
|
5926
5572
|
for (let i = vCustomElementCollection.length - 1; i >= 0; i -= 1) {
|
|
5927
5573
|
const {
|
|
5928
5574
|
elm
|
|
5929
|
-
} = vCustomElementCollection[i];
|
|
5575
|
+
} = vCustomElementCollection[i];
|
|
5576
|
+
// There are two cases where the element could be undefined:
|
|
5930
5577
|
// * when there is an error during the construction phase, and an error
|
|
5931
5578
|
// boundary picks it, there is a possibility that the VCustomElement
|
|
5932
5579
|
// is not properly initialized, and therefore is should be ignored.
|
|
5933
5580
|
// * when slotted custom element is not used by the element where it is
|
|
5934
5581
|
// slotted into it, as a result, the custom element was never
|
|
5935
5582
|
// initialized.
|
|
5936
|
-
|
|
5937
5583
|
if (!isUndefined$1(elm)) {
|
|
5938
|
-
const childVM = getAssociatedVMIfPresent(elm);
|
|
5584
|
+
const childVM = getAssociatedVMIfPresent(elm);
|
|
5585
|
+
// The VM associated with the element might be associated undefined
|
|
5939
5586
|
// in the case where the VM failed in the middle of its creation,
|
|
5940
5587
|
// eg: constructor throwing before invoking super().
|
|
5941
|
-
|
|
5942
5588
|
if (!isUndefined$1(childVM)) {
|
|
5943
5589
|
resetComponentStateWhenRemoved(childVM);
|
|
5944
5590
|
}
|
|
5945
5591
|
}
|
|
5946
5592
|
}
|
|
5947
5593
|
}
|
|
5948
|
-
|
|
5949
5594
|
function runLightChildNodesDisconnectedCallback(vm) {
|
|
5950
5595
|
const {
|
|
5951
5596
|
aChildren: adoptedChildren
|
|
@@ -5959,23 +5604,15 @@ function runLightChildNodesDisconnectedCallback(vm) {
|
|
|
5959
5604
|
* custom element itself will trigger the removal of anything slotted or anything
|
|
5960
5605
|
* defined on its shadow.
|
|
5961
5606
|
*/
|
|
5962
|
-
|
|
5963
|
-
|
|
5964
5607
|
function recursivelyDisconnectChildren(vnodes) {
|
|
5965
5608
|
for (let i = 0, len = vnodes.length; i < len; i += 1) {
|
|
5966
5609
|
const vnode = vnodes[i];
|
|
5967
|
-
|
|
5968
5610
|
if (!isNull(vnode) && !isUndefined$1(vnode.elm)) {
|
|
5969
5611
|
switch (vnode.type) {
|
|
5970
|
-
case 2
|
|
5971
|
-
/* VNodeType.Element */
|
|
5972
|
-
:
|
|
5612
|
+
case 2 /* VNodeType.Element */:
|
|
5973
5613
|
recursivelyDisconnectChildren(vnode.children);
|
|
5974
5614
|
break;
|
|
5975
|
-
|
|
5976
|
-
case 3
|
|
5977
|
-
/* VNodeType.CustomElement */
|
|
5978
|
-
:
|
|
5615
|
+
case 3 /* VNodeType.CustomElement */:
|
|
5979
5616
|
{
|
|
5980
5617
|
const vm = getAssociatedVM(vnode.elm);
|
|
5981
5618
|
resetComponentStateWhenRemoved(vm);
|
|
@@ -5984,12 +5621,11 @@ function recursivelyDisconnectChildren(vnodes) {
|
|
|
5984
5621
|
}
|
|
5985
5622
|
}
|
|
5986
5623
|
}
|
|
5987
|
-
}
|
|
5624
|
+
}
|
|
5625
|
+
// This is a super optimized mechanism to remove the content of the root node (shadow root
|
|
5988
5626
|
// for shadow DOM components and the root element itself for light DOM) without having to go
|
|
5989
5627
|
// into snabbdom. Especially useful when the reset is a consequence of an error, in which case the
|
|
5990
5628
|
// children VNodes might not be representing the current state of the DOM.
|
|
5991
|
-
|
|
5992
|
-
|
|
5993
5629
|
function resetComponentRoot(vm) {
|
|
5994
5630
|
const {
|
|
5995
5631
|
children,
|
|
@@ -5998,62 +5634,47 @@ function resetComponentRoot(vm) {
|
|
|
5998
5634
|
remove
|
|
5999
5635
|
}
|
|
6000
5636
|
} = vm;
|
|
6001
|
-
|
|
6002
5637
|
for (let i = 0, len = children.length; i < len; i++) {
|
|
6003
5638
|
const child = children[i];
|
|
6004
|
-
|
|
6005
5639
|
if (!isNull(child) && !isUndefined$1(child.elm)) {
|
|
6006
5640
|
remove(child.elm, renderRoot);
|
|
6007
5641
|
}
|
|
6008
5642
|
}
|
|
6009
|
-
|
|
6010
5643
|
vm.children = EmptyArray;
|
|
6011
5644
|
runChildNodesDisconnectedCallback(vm);
|
|
6012
5645
|
vm.velements = EmptyArray;
|
|
6013
5646
|
}
|
|
6014
|
-
|
|
6015
5647
|
function getErrorBoundaryVM(vm) {
|
|
6016
5648
|
let currentVm = vm;
|
|
6017
|
-
|
|
6018
5649
|
while (!isNull(currentVm)) {
|
|
6019
5650
|
if (!isUndefined$1(currentVm.def.errorCallback)) {
|
|
6020
5651
|
return currentVm;
|
|
6021
5652
|
}
|
|
6022
|
-
|
|
6023
5653
|
currentVm = currentVm.owner;
|
|
6024
5654
|
}
|
|
6025
5655
|
}
|
|
6026
|
-
|
|
6027
5656
|
function runWithBoundaryProtection(vm, owner, pre, job, post) {
|
|
6028
5657
|
let error;
|
|
6029
5658
|
pre();
|
|
6030
|
-
|
|
6031
5659
|
try {
|
|
6032
5660
|
job();
|
|
6033
5661
|
} catch (e) {
|
|
6034
5662
|
error = Object(e);
|
|
6035
5663
|
} finally {
|
|
6036
5664
|
post();
|
|
6037
|
-
|
|
6038
5665
|
if (!isUndefined$1(error)) {
|
|
6039
5666
|
addErrorComponentStack(vm, error);
|
|
6040
5667
|
const errorBoundaryVm = isNull(owner) ? undefined : getErrorBoundaryVM(owner);
|
|
6041
|
-
|
|
6042
5668
|
if (isUndefined$1(errorBoundaryVm)) {
|
|
6043
5669
|
throw error; // eslint-disable-line no-unsafe-finally
|
|
6044
5670
|
}
|
|
6045
5671
|
|
|
6046
5672
|
resetComponentRoot(vm); // remove offenders
|
|
6047
|
-
|
|
6048
|
-
|
|
6049
|
-
/* OperationId.ErrorCallback */
|
|
6050
|
-
, vm); // error boundaries must have an ErrorCallback
|
|
6051
|
-
|
|
5673
|
+
logOperationStart(6 /* OperationId.ErrorCallback */, vm);
|
|
5674
|
+
// error boundaries must have an ErrorCallback
|
|
6052
5675
|
const errorCallback = errorBoundaryVm.def.errorCallback;
|
|
6053
5676
|
invokeComponentCallback(errorBoundaryVm, errorCallback, [error, error.wcStack]);
|
|
6054
|
-
logOperationEnd(6
|
|
6055
|
-
/* OperationId.ErrorCallback */
|
|
6056
|
-
, vm);
|
|
5677
|
+
logOperationEnd(6 /* OperationId.ErrorCallback */, vm);
|
|
6057
5678
|
}
|
|
6058
5679
|
}
|
|
6059
5680
|
}
|
|
@@ -6066,6 +5687,7 @@ function runWithBoundaryProtection(vm, owner, pre, job, post) {
|
|
|
6066
5687
|
*/
|
|
6067
5688
|
const DeprecatedWiredElementHost = '$$DeprecatedWiredElementHostKey$$';
|
|
6068
5689
|
const DeprecatedWiredParamsMeta = '$$DeprecatedWiredParamsMetaKey$$';
|
|
5690
|
+
const WIRE_DEBUG_ENTRY = '@wire';
|
|
6069
5691
|
const WireMetaMap = new Map();
|
|
6070
5692
|
class WireContextRegistrationEvent extends CustomEvent {
|
|
6071
5693
|
constructor(adapterToken, {
|
|
@@ -6085,15 +5707,12 @@ class WireContextRegistrationEvent extends CustomEvent {
|
|
|
6085
5707
|
}
|
|
6086
5708
|
});
|
|
6087
5709
|
}
|
|
6088
|
-
|
|
6089
5710
|
}
|
|
6090
|
-
|
|
6091
5711
|
function createFieldDataCallback(vm, name) {
|
|
6092
5712
|
return value => {
|
|
6093
5713
|
updateComponentValue(vm, name, value);
|
|
6094
5714
|
};
|
|
6095
5715
|
}
|
|
6096
|
-
|
|
6097
5716
|
function createMethodDataCallback(vm, method) {
|
|
6098
5717
|
return value => {
|
|
6099
5718
|
// dispatching new value into the wired method
|
|
@@ -6103,32 +5722,27 @@ function createMethodDataCallback(vm, method) {
|
|
|
6103
5722
|
}, noop);
|
|
6104
5723
|
};
|
|
6105
5724
|
}
|
|
6106
|
-
|
|
6107
5725
|
function createConfigWatcher(component, configCallback, callbackWhenConfigIsReady) {
|
|
6108
|
-
|
|
5726
|
+
// creating the reactive observer for reactive params when needed
|
|
6109
5727
|
const ro = createReactiveObserver();
|
|
6110
|
-
|
|
6111
5728
|
const computeConfigAndUpdate = () => {
|
|
6112
5729
|
let config;
|
|
6113
|
-
ro.observe(() => config = configCallback(component));
|
|
5730
|
+
ro.observe(() => config = configCallback(component));
|
|
5731
|
+
// eslint-disable-next-line @lwc/lwc-internal/no-invalid-todo
|
|
6114
5732
|
// TODO: dev-mode validation of config based on the adapter.configSchema
|
|
6115
5733
|
// @ts-ignore it is assigned in the observe() callback
|
|
6116
|
-
|
|
6117
5734
|
callbackWhenConfigIsReady(config);
|
|
6118
5735
|
};
|
|
6119
|
-
|
|
6120
5736
|
return {
|
|
6121
5737
|
computeConfigAndUpdate,
|
|
6122
5738
|
ro
|
|
6123
5739
|
};
|
|
6124
5740
|
}
|
|
6125
|
-
|
|
6126
5741
|
function createContextWatcher(vm, wireDef, callbackWhenContextIsReady) {
|
|
6127
5742
|
const {
|
|
6128
5743
|
adapter
|
|
6129
5744
|
} = wireDef;
|
|
6130
5745
|
const adapterContextToken = getAdapterToken(adapter);
|
|
6131
|
-
|
|
6132
5746
|
if (isUndefined$1(adapterContextToken)) {
|
|
6133
5747
|
return; // no provider found, nothing to be done
|
|
6134
5748
|
}
|
|
@@ -6142,8 +5756,8 @@ function createContextWatcher(vm, wireDef, callbackWhenContextIsReady) {
|
|
|
6142
5756
|
renderer: {
|
|
6143
5757
|
dispatchEvent
|
|
6144
5758
|
}
|
|
6145
|
-
} = vm;
|
|
6146
|
-
|
|
5759
|
+
} = vm;
|
|
5760
|
+
// waiting for the component to be connected to formally request the context via the token
|
|
6147
5761
|
ArrayPush$1.call(wiredConnecting, () => {
|
|
6148
5762
|
// This event is responsible for connecting the host element with another
|
|
6149
5763
|
// element in the composed path that is providing contextual data. The provider
|
|
@@ -6156,18 +5770,15 @@ function createContextWatcher(vm, wireDef, callbackWhenContextIsReady) {
|
|
|
6156
5770
|
// TODO: dev-mode validation of config based on the adapter.contextSchema
|
|
6157
5771
|
callbackWhenContextIsReady(newContext);
|
|
6158
5772
|
},
|
|
6159
|
-
|
|
6160
5773
|
setDisconnectedCallback(disconnectCallback) {
|
|
6161
5774
|
// adds this callback into the disconnect bucket so it gets disconnected from parent
|
|
6162
5775
|
// the the element hosting the wire is disconnected
|
|
6163
5776
|
ArrayPush$1.call(wiredDisconnecting, disconnectCallback);
|
|
6164
5777
|
}
|
|
6165
|
-
|
|
6166
5778
|
});
|
|
6167
5779
|
dispatchEvent(elm, contextRegistrationEvent);
|
|
6168
5780
|
});
|
|
6169
5781
|
}
|
|
6170
|
-
|
|
6171
5782
|
function createConnector(vm, name, wireDef) {
|
|
6172
5783
|
const {
|
|
6173
5784
|
method,
|
|
@@ -6175,10 +5786,27 @@ function createConnector(vm, name, wireDef) {
|
|
|
6175
5786
|
configCallback,
|
|
6176
5787
|
dynamic
|
|
6177
5788
|
} = wireDef;
|
|
6178
|
-
|
|
5789
|
+
let debugInfo;
|
|
5790
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
5791
|
+
const wiredPropOrMethod = isUndefined$1(method) ? name : method.name;
|
|
5792
|
+
debugInfo = create(null);
|
|
5793
|
+
debugInfo.wasDataProvisionedForConfig = false;
|
|
5794
|
+
vm.debugInfo[WIRE_DEBUG_ENTRY][wiredPropOrMethod] = debugInfo;
|
|
5795
|
+
}
|
|
5796
|
+
const fieldOrMethodCallback = isUndefined$1(method) ? createFieldDataCallback(vm, name) : createMethodDataCallback(vm, method);
|
|
5797
|
+
const dataCallback = value => {
|
|
5798
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
5799
|
+
debugInfo.data = value;
|
|
5800
|
+
// Note: most of the time, the data provided is for the current config, but there may be
|
|
5801
|
+
// some conditions in which it does not, ex:
|
|
5802
|
+
// race conditions in a poor network while the adapter does not cancel a previous request.
|
|
5803
|
+
debugInfo.wasDataProvisionedForConfig = true;
|
|
5804
|
+
}
|
|
5805
|
+
fieldOrMethodCallback(value);
|
|
5806
|
+
};
|
|
6179
5807
|
let context;
|
|
6180
|
-
let connector;
|
|
6181
|
-
|
|
5808
|
+
let connector;
|
|
5809
|
+
// Workaround to pass the component element associated to this wire adapter instance.
|
|
6182
5810
|
defineProperty(dataCallback, DeprecatedWiredElementHost, {
|
|
6183
5811
|
value: vm.elm
|
|
6184
5812
|
});
|
|
@@ -6189,41 +5817,41 @@ function createConnector(vm, name, wireDef) {
|
|
|
6189
5817
|
// job
|
|
6190
5818
|
connector = new adapter(dataCallback);
|
|
6191
5819
|
}, noop);
|
|
6192
|
-
|
|
6193
5820
|
const updateConnectorConfig = config => {
|
|
6194
5821
|
// every time the config is recomputed due to tracking,
|
|
6195
5822
|
// this callback will be invoked with the new computed config
|
|
6196
5823
|
runWithBoundaryProtection(vm, vm, noop, () => {
|
|
6197
5824
|
// job
|
|
5825
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
5826
|
+
debugInfo.config = config;
|
|
5827
|
+
debugInfo.context = context;
|
|
5828
|
+
debugInfo.wasDataProvisionedForConfig = false;
|
|
5829
|
+
}
|
|
6198
5830
|
connector.update(config, context);
|
|
6199
5831
|
}, noop);
|
|
6200
|
-
};
|
|
5832
|
+
};
|
|
5833
|
+
// Computes the current wire config and calls the update method on the wire adapter.
|
|
6201
5834
|
// If it has params, we will need to observe changes in the next tick.
|
|
6202
|
-
|
|
6203
|
-
|
|
6204
5835
|
const {
|
|
6205
5836
|
computeConfigAndUpdate,
|
|
6206
5837
|
ro
|
|
6207
|
-
} = createConfigWatcher(vm.component, configCallback, updateConnectorConfig);
|
|
6208
|
-
|
|
5838
|
+
} = createConfigWatcher(vm.component, configCallback, updateConnectorConfig);
|
|
5839
|
+
// if the adapter needs contextualization, we need to watch for new context and push it alongside the config
|
|
6209
5840
|
if (!isUndefined$1(adapter.contextSchema)) {
|
|
6210
5841
|
createContextWatcher(vm, wireDef, newContext => {
|
|
6211
5842
|
// every time the context is pushed into this component,
|
|
6212
5843
|
// this callback will be invoked with the new computed context
|
|
6213
5844
|
if (context !== newContext) {
|
|
6214
|
-
context = newContext;
|
|
5845
|
+
context = newContext;
|
|
5846
|
+
// Note: when new context arrives, the config will be recomputed and pushed along side the new
|
|
6215
5847
|
// context, this is to preserve the identity characteristics, config should not have identity
|
|
6216
5848
|
// (ever), while context can have identity
|
|
6217
|
-
|
|
6218
|
-
if (vm.state === 1
|
|
6219
|
-
/* VMState.connected */
|
|
6220
|
-
) {
|
|
5849
|
+
if (vm.state === 1 /* VMState.connected */) {
|
|
6221
5850
|
computeConfigAndUpdate();
|
|
6222
5851
|
}
|
|
6223
5852
|
}
|
|
6224
5853
|
});
|
|
6225
5854
|
}
|
|
6226
|
-
|
|
6227
5855
|
return {
|
|
6228
5856
|
// @ts-ignore the boundary protection executes sync, connector is always defined
|
|
6229
5857
|
connector,
|
|
@@ -6231,7 +5859,6 @@ function createConnector(vm, name, wireDef) {
|
|
|
6231
5859
|
resetConfigWatcher: () => ro.reset()
|
|
6232
5860
|
};
|
|
6233
5861
|
}
|
|
6234
|
-
|
|
6235
5862
|
const AdapterToTokenMap = new Map();
|
|
6236
5863
|
function getAdapterToken(adapter) {
|
|
6237
5864
|
return AdapterToTokenMap.get(adapter);
|
|
@@ -6244,7 +5871,6 @@ function storeWiredMethodMeta(descriptor, adapter, configCallback, dynamic) {
|
|
|
6244
5871
|
if (adapter.adapter) {
|
|
6245
5872
|
adapter = adapter.adapter;
|
|
6246
5873
|
}
|
|
6247
|
-
|
|
6248
5874
|
const method = descriptor.value;
|
|
6249
5875
|
const def = {
|
|
6250
5876
|
adapter,
|
|
@@ -6259,7 +5885,6 @@ function storeWiredFieldMeta(descriptor, adapter, configCallback, dynamic) {
|
|
|
6259
5885
|
if (adapter.adapter) {
|
|
6260
5886
|
adapter = adapter.adapter;
|
|
6261
5887
|
}
|
|
6262
|
-
|
|
6263
5888
|
const def = {
|
|
6264
5889
|
adapter,
|
|
6265
5890
|
configCallback,
|
|
@@ -6274,17 +5899,15 @@ function installWireAdapters(vm) {
|
|
|
6274
5899
|
wire
|
|
6275
5900
|
}
|
|
6276
5901
|
} = vm;
|
|
5902
|
+
vm.debugInfo[WIRE_DEBUG_ENTRY] = create(null);
|
|
6277
5903
|
const wiredConnecting = context.wiredConnecting = [];
|
|
6278
5904
|
const wiredDisconnecting = context.wiredDisconnecting = [];
|
|
6279
|
-
|
|
6280
5905
|
for (const fieldNameOrMethod in wire) {
|
|
6281
5906
|
const descriptor = wire[fieldNameOrMethod];
|
|
6282
5907
|
const wireDef = WireMetaMap.get(descriptor);
|
|
6283
|
-
|
|
6284
5908
|
if (process.env.NODE_ENV !== 'production') {
|
|
6285
5909
|
assert.invariant(wireDef, `Internal Error: invalid wire definition found.`);
|
|
6286
5910
|
}
|
|
6287
|
-
|
|
6288
5911
|
if (!isUndefined$1(wireDef)) {
|
|
6289
5912
|
const {
|
|
6290
5913
|
connector,
|
|
@@ -6294,14 +5917,12 @@ function installWireAdapters(vm) {
|
|
|
6294
5917
|
const hasDynamicParams = wireDef.dynamic.length > 0;
|
|
6295
5918
|
ArrayPush$1.call(wiredConnecting, () => {
|
|
6296
5919
|
connector.connect();
|
|
6297
|
-
|
|
6298
5920
|
if (!lwcRuntimeFlags.ENABLE_WIRE_SYNC_EMIT) {
|
|
6299
5921
|
if (hasDynamicParams) {
|
|
6300
5922
|
Promise.resolve().then(computeConfigAndUpdate);
|
|
6301
5923
|
return;
|
|
6302
5924
|
}
|
|
6303
5925
|
}
|
|
6304
|
-
|
|
6305
5926
|
computeConfigAndUpdate();
|
|
6306
5927
|
});
|
|
6307
5928
|
ArrayPush$1.call(wiredDisconnecting, () => {
|
|
@@ -6315,7 +5936,6 @@ function connectWireAdapters(vm) {
|
|
|
6315
5936
|
const {
|
|
6316
5937
|
wiredConnecting
|
|
6317
5938
|
} = vm.context;
|
|
6318
|
-
|
|
6319
5939
|
for (let i = 0, len = wiredConnecting.length; i < len; i += 1) {
|
|
6320
5940
|
wiredConnecting[i]();
|
|
6321
5941
|
}
|
|
@@ -6504,7 +6124,7 @@ function freezeTemplate(tmpl) {
|
|
|
6504
6124
|
});
|
|
6505
6125
|
}
|
|
6506
6126
|
}
|
|
6507
|
-
/* version: 2.
|
|
6127
|
+
/* version: 2.30.0 */
|
|
6508
6128
|
|
|
6509
6129
|
/*
|
|
6510
6130
|
* Copyright (c) 2020, salesforce.com, inc.
|
|
@@ -6975,7 +6595,7 @@ function renderComponent(tagName, Ctor, props = {}) {
|
|
|
6975
6595
|
*/
|
|
6976
6596
|
freeze(LightningElement);
|
|
6977
6597
|
seal(LightningElement.prototype);
|
|
6978
|
-
/* version: 2.
|
|
6598
|
+
/* version: 2.30.0 */
|
|
6979
6599
|
|
|
6980
6600
|
exports.LightningElement = LightningElement;
|
|
6981
6601
|
exports.api = api$1;
|