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