@lwc/engine-core 2.13.3 → 2.13.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/engine-core.cjs.js +141 -22
- package/dist/engine-core.js +141 -22
- package/package.json +3 -3
- package/types/framework/freeze-template.d.ts +2 -0
- package/types/framework/main.d.ts +2 -1
- package/types/framework/vm.d.ts +3 -0
- package/types/index.d.ts +1 -0
- package/types/renderer.d.ts +1 -4
- package/types/testFeatureFlag.d.ts +1 -0
package/dist/engine-core.cjs.js
CHANGED
|
@@ -3,8 +3,33 @@
|
|
|
3
3
|
|
|
4
4
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
5
|
|
|
6
|
-
var shared = require('@lwc/shared');
|
|
7
6
|
var features = require('@lwc/features');
|
|
7
|
+
var shared = require('@lwc/shared');
|
|
8
|
+
|
|
9
|
+
/*
|
|
10
|
+
* Copyright (c) 2018, salesforce.com, inc.
|
|
11
|
+
* All rights reserved.
|
|
12
|
+
* SPDX-License-Identifier: MIT
|
|
13
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
14
|
+
*/
|
|
15
|
+
// @ts-ignore
|
|
16
|
+
|
|
17
|
+
if (process.env.NODE_ENV !== 'production' && typeof __karma__ !== 'undefined') {
|
|
18
|
+
window.addEventListener('test-dummy-flag', () => {
|
|
19
|
+
let hasFlag = false;
|
|
20
|
+
|
|
21
|
+
if (features.runtimeFlags.DUMMY_TEST_FLAG) {
|
|
22
|
+
hasFlag = true;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
window.dispatchEvent(new CustomEvent('has-dummy-flag', {
|
|
26
|
+
detail: {
|
|
27
|
+
package: '@lwc/engine-core',
|
|
28
|
+
hasFlag
|
|
29
|
+
}
|
|
30
|
+
}));
|
|
31
|
+
});
|
|
32
|
+
}
|
|
8
33
|
|
|
9
34
|
/*
|
|
10
35
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
@@ -106,9 +131,7 @@ let HTMLElementExported;
|
|
|
106
131
|
function setHTMLElement(HTMLElementImpl) {
|
|
107
132
|
HTMLElementExported = HTMLElementImpl;
|
|
108
133
|
}
|
|
109
|
-
let isHydrating;
|
|
110
134
|
function setIsHydrating(isHydratingImpl) {
|
|
111
|
-
isHydrating = isHydratingImpl;
|
|
112
135
|
}
|
|
113
136
|
let insert;
|
|
114
137
|
function setInsert(insertImpl) {
|
|
@@ -230,10 +253,6 @@ let isConnected;
|
|
|
230
253
|
function setIsConnected(isConnectedImpl) {
|
|
231
254
|
isConnected = isConnectedImpl;
|
|
232
255
|
}
|
|
233
|
-
let insertGlobalStylesheet;
|
|
234
|
-
function setInsertGlobalStylesheet(insertGlobalStylesheetImpl) {
|
|
235
|
-
insertGlobalStylesheet = insertGlobalStylesheetImpl;
|
|
236
|
-
}
|
|
237
256
|
let insertStylesheet;
|
|
238
257
|
function setInsertStylesheet(insertStylesheetImpl) {
|
|
239
258
|
insertStylesheet = insertStylesheetImpl;
|
|
@@ -2349,6 +2368,8 @@ function registerTemplate(tpl) {
|
|
|
2349
2368
|
// on top of stylesheetToken for anyone who is accessing the old internal API.
|
|
2350
2369
|
// Details: https://salesforce.quip.com/v1rmAFu2cKAr
|
|
2351
2370
|
shared.defineProperty(tpl, 'stylesheetTokens', {
|
|
2371
|
+
enumerable: true,
|
|
2372
|
+
configurable: true,
|
|
2352
2373
|
get() {
|
|
2353
2374
|
const { stylesheetToken } = this;
|
|
2354
2375
|
if (shared.isUndefined(stylesheetToken)) {
|
|
@@ -3432,15 +3453,16 @@ function mountVNodes(vnodes, parent, anchor, start = 0, end = vnodes.length) {
|
|
|
3432
3453
|
}
|
|
3433
3454
|
}
|
|
3434
3455
|
function unmount(vnode, parent, doRemove = false) {
|
|
3435
|
-
const { type, elm } = vnode;
|
|
3456
|
+
const { type, elm, sel } = vnode;
|
|
3436
3457
|
// When unmounting a VNode subtree not all the elements have to removed from the DOM. The
|
|
3437
3458
|
// subtree root, is the only element worth unmounting from the subtree.
|
|
3438
3459
|
if (doRemove) {
|
|
3439
3460
|
removeNode(elm, parent);
|
|
3440
3461
|
}
|
|
3462
|
+
const removeChildren = sel === 'slot'; // slot content is removed to trigger slotchange event when removing slot
|
|
3441
3463
|
switch (type) {
|
|
3442
3464
|
case 2 /* Element */:
|
|
3443
|
-
unmountVNodes(vnode.children, elm);
|
|
3465
|
+
unmountVNodes(vnode.children, elm, removeChildren);
|
|
3444
3466
|
break;
|
|
3445
3467
|
case 3 /* CustomElement */: {
|
|
3446
3468
|
const { vm } = vnode;
|
|
@@ -4358,10 +4380,10 @@ function createStylesheet(vm, stylesheets) {
|
|
|
4358
4380
|
const { renderMode, shadowMode } = vm;
|
|
4359
4381
|
if (renderMode === 1 /* Shadow */ && shadowMode === 1 /* Synthetic */) {
|
|
4360
4382
|
for (let i = 0; i < stylesheets.length; i++) {
|
|
4361
|
-
|
|
4383
|
+
insertStylesheet(stylesheets[i]);
|
|
4362
4384
|
}
|
|
4363
4385
|
}
|
|
4364
|
-
else if (ssr ||
|
|
4386
|
+
else if (ssr || vm.hydrated) {
|
|
4365
4387
|
// Note: We need to ensure that during hydration, the stylesheets method is the same as those in ssr.
|
|
4366
4388
|
// This works in the client, because the stylesheets are created, and cached in the VM
|
|
4367
4389
|
// the first time the VM renders.
|
|
@@ -4372,15 +4394,10 @@ function createStylesheet(vm, stylesheets) {
|
|
|
4372
4394
|
else {
|
|
4373
4395
|
// native shadow or light DOM, DOM renderer
|
|
4374
4396
|
const root = getNearestNativeShadowComponent(vm);
|
|
4375
|
-
|
|
4397
|
+
// null root means a global style
|
|
4398
|
+
const target = shared.isNull(root) ? undefined : root.shadowRoot;
|
|
4376
4399
|
for (let i = 0; i < stylesheets.length; i++) {
|
|
4377
|
-
|
|
4378
|
-
insertGlobalStylesheet(stylesheets[i]);
|
|
4379
|
-
}
|
|
4380
|
-
else {
|
|
4381
|
-
// local level
|
|
4382
|
-
insertStylesheet(stylesheets[i], root.shadowRoot);
|
|
4383
|
-
}
|
|
4400
|
+
insertStylesheet(stylesheets[i], target);
|
|
4384
4401
|
}
|
|
4385
4402
|
}
|
|
4386
4403
|
return null;
|
|
@@ -4928,7 +4945,8 @@ function createVM(elm, ctor, options) {
|
|
|
4928
4945
|
const {
|
|
4929
4946
|
mode,
|
|
4930
4947
|
owner,
|
|
4931
|
-
tagName
|
|
4948
|
+
tagName,
|
|
4949
|
+
hydrated
|
|
4932
4950
|
} = options;
|
|
4933
4951
|
const def = getComponentInternalDef(ctor);
|
|
4934
4952
|
const vm = {
|
|
@@ -4951,6 +4969,7 @@ function createVM(elm, ctor, options) {
|
|
|
4951
4969
|
cmpSlots: shared.create(null),
|
|
4952
4970
|
oar: shared.create(null),
|
|
4953
4971
|
cmpTemplate: null,
|
|
4972
|
+
hydrated: Boolean(hydrated),
|
|
4954
4973
|
renderMode: def.renderMode,
|
|
4955
4974
|
shadowMode: computeShadowMode(def, owner),
|
|
4956
4975
|
nearestShadowMode: (owner === null || owner === void 0 ? void 0 : owner.shadowRoot) ? owner.shadowMode : (_a = owner === null || owner === void 0 ? void 0 : owner.nearestShadowMode) !== null && _a !== void 0 ? _a : null,
|
|
@@ -5925,6 +5944,7 @@ function hydrateCustomElement(elm, vnode) {
|
|
|
5925
5944
|
mode,
|
|
5926
5945
|
owner,
|
|
5927
5946
|
tagName: sel,
|
|
5947
|
+
hydrated: true,
|
|
5928
5948
|
});
|
|
5929
5949
|
vnode.elm = elm;
|
|
5930
5950
|
vnode.vm = vm;
|
|
@@ -6119,6 +6139,105 @@ function setHooks(hooks) {
|
|
|
6119
6139
|
setSanitizeHtmlContentHook(hooks.sanitizeHtmlContent);
|
|
6120
6140
|
}
|
|
6121
6141
|
|
|
6142
|
+
/*
|
|
6143
|
+
* Copyright (c) 2018, salesforce.com, inc.
|
|
6144
|
+
* All rights reserved.
|
|
6145
|
+
* SPDX-License-Identifier: MIT
|
|
6146
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
6147
|
+
*/
|
|
6148
|
+
// See @lwc/engine-core/src/framework/template.ts
|
|
6149
|
+
const TEMPLATE_PROPS = ['slots', 'stylesheetToken', 'stylesheets', 'renderMode'];
|
|
6150
|
+
// Via https://www.npmjs.com/package/object-observer
|
|
6151
|
+
const ARRAY_MUTATION_METHODS = [
|
|
6152
|
+
'pop',
|
|
6153
|
+
'push',
|
|
6154
|
+
'shift',
|
|
6155
|
+
'unshift',
|
|
6156
|
+
'reverse',
|
|
6157
|
+
'sort',
|
|
6158
|
+
'fill',
|
|
6159
|
+
'splice',
|
|
6160
|
+
'copyWithin',
|
|
6161
|
+
];
|
|
6162
|
+
function getOriginalArrayMethod(prop) {
|
|
6163
|
+
switch (prop) {
|
|
6164
|
+
case 'pop':
|
|
6165
|
+
return shared.ArrayPop;
|
|
6166
|
+
case 'push':
|
|
6167
|
+
return shared.ArrayPush;
|
|
6168
|
+
case 'shift':
|
|
6169
|
+
return shared.ArrayShift;
|
|
6170
|
+
case 'unshift':
|
|
6171
|
+
return shared.ArrayUnshift;
|
|
6172
|
+
case 'reverse':
|
|
6173
|
+
return shared.ArrayReverse;
|
|
6174
|
+
case 'sort':
|
|
6175
|
+
return shared.ArraySort;
|
|
6176
|
+
case 'fill':
|
|
6177
|
+
return shared.ArrayFill;
|
|
6178
|
+
case 'splice':
|
|
6179
|
+
return shared.ArraySplice;
|
|
6180
|
+
case 'copyWithin':
|
|
6181
|
+
return shared.ArrayCopyWithin;
|
|
6182
|
+
}
|
|
6183
|
+
}
|
|
6184
|
+
let mutationWarningsSilenced = false;
|
|
6185
|
+
// Warn if the user tries to mutate tmpl.stylesheets, e.g.:
|
|
6186
|
+
// `tmpl.stylesheets.push(someStylesheetFunction)`
|
|
6187
|
+
function warnOnArrayMutation(stylesheets) {
|
|
6188
|
+
// We can't handle users calling Array.prototype.slice.call(tmpl.stylesheets), but
|
|
6189
|
+
// we can at least warn when they use the most common mutation methods.
|
|
6190
|
+
for (const prop of ARRAY_MUTATION_METHODS) {
|
|
6191
|
+
const originalArrayMethod = getOriginalArrayMethod(prop);
|
|
6192
|
+
stylesheets[prop] = function arrayMutationWarningWrapper() {
|
|
6193
|
+
logError(`Mutating the "stylesheets" array on a template function ` +
|
|
6194
|
+
`is deprecated and may be removed in a future version of LWC.`);
|
|
6195
|
+
// @ts-ignore
|
|
6196
|
+
return originalArrayMethod.apply(this, arguments);
|
|
6197
|
+
};
|
|
6198
|
+
}
|
|
6199
|
+
}
|
|
6200
|
+
// TODO [#2782]: eventually freezeTemplate() will _actually_ freeze the tmpl object. Today it
|
|
6201
|
+
// just warns on mutation.
|
|
6202
|
+
function freezeTemplate(tmpl) {
|
|
6203
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
6204
|
+
if (!shared.isUndefined(tmpl.stylesheets)) {
|
|
6205
|
+
warnOnArrayMutation(tmpl.stylesheets);
|
|
6206
|
+
}
|
|
6207
|
+
for (const prop of TEMPLATE_PROPS) {
|
|
6208
|
+
let value = tmpl[prop];
|
|
6209
|
+
shared.defineProperty(tmpl, prop, {
|
|
6210
|
+
enumerable: true,
|
|
6211
|
+
configurable: true,
|
|
6212
|
+
get() {
|
|
6213
|
+
return value;
|
|
6214
|
+
},
|
|
6215
|
+
set(newValue) {
|
|
6216
|
+
if (!mutationWarningsSilenced) {
|
|
6217
|
+
logError(`Dynamically setting the "${prop}" property on a template function ` +
|
|
6218
|
+
`is deprecated and may be removed in a future version of LWC.`);
|
|
6219
|
+
}
|
|
6220
|
+
value = newValue;
|
|
6221
|
+
},
|
|
6222
|
+
});
|
|
6223
|
+
}
|
|
6224
|
+
const originalDescriptor = shared.getOwnPropertyDescriptor(tmpl, 'stylesheetTokens');
|
|
6225
|
+
shared.defineProperty(tmpl, 'stylesheetTokens', {
|
|
6226
|
+
enumerable: true,
|
|
6227
|
+
configurable: true,
|
|
6228
|
+
get: originalDescriptor.get,
|
|
6229
|
+
set(value) {
|
|
6230
|
+
logError(`Dynamically setting the "stylesheetTokens" property on a template function ` +
|
|
6231
|
+
`is deprecated and may be removed in a future version of LWC.`);
|
|
6232
|
+
// Avoid logging twice (for both stylesheetToken and stylesheetTokens)
|
|
6233
|
+
mutationWarningsSilenced = true;
|
|
6234
|
+
originalDescriptor.set.call(this, value);
|
|
6235
|
+
mutationWarningsSilenced = false;
|
|
6236
|
+
},
|
|
6237
|
+
});
|
|
6238
|
+
}
|
|
6239
|
+
}
|
|
6240
|
+
|
|
6122
6241
|
/*
|
|
6123
6242
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
6124
6243
|
* All rights reserved.
|
|
@@ -6157,6 +6276,7 @@ exports.connectRootElement = connectRootElement;
|
|
|
6157
6276
|
exports.createContextProvider = createContextProvider;
|
|
6158
6277
|
exports.createVM = createVM;
|
|
6159
6278
|
exports.disconnectRootElement = disconnectRootElement;
|
|
6279
|
+
exports.freezeTemplate = freezeTemplate;
|
|
6160
6280
|
exports.getAssociatedVMIfPresent = getAssociatedVMIfPresent;
|
|
6161
6281
|
exports.getComponentConstructor = getComponentConstructor;
|
|
6162
6282
|
exports.getComponentDef = getComponentDef;
|
|
@@ -6194,7 +6314,6 @@ exports.setGetProperty = setGetProperty;
|
|
|
6194
6314
|
exports.setHTMLElement = setHTMLElement;
|
|
6195
6315
|
exports.setHooks = setHooks;
|
|
6196
6316
|
exports.setInsert = setInsert;
|
|
6197
|
-
exports.setInsertGlobalStylesheet = setInsertGlobalStylesheet;
|
|
6198
6317
|
exports.setInsertStylesheet = setInsertStylesheet;
|
|
6199
6318
|
exports.setIsConnected = setIsConnected;
|
|
6200
6319
|
exports.setIsHydrating = setIsHydrating;
|
|
@@ -6217,4 +6336,4 @@ exports.swapTemplate = swapTemplate;
|
|
|
6217
6336
|
exports.track = track;
|
|
6218
6337
|
exports.unwrap = unwrap;
|
|
6219
6338
|
exports.wire = wire;
|
|
6220
|
-
/* version: 2.13.
|
|
6339
|
+
/* version: 2.13.4 */
|
package/dist/engine-core.js
CHANGED
|
@@ -1,7 +1,32 @@
|
|
|
1
1
|
/* proxy-compat-disable */
|
|
2
|
-
import { seal, create, isFunction as isFunction$1, ArrayPush as ArrayPush$1, isUndefined as isUndefined$1, ArrayIndexOf, ArraySplice, StringToLowerCase, ArrayJoin, isNull, isFrozen, defineProperty, hasOwnProperty as hasOwnProperty$1, assign, forEach, keys, AriaPropNameToAttrNameMap, getPropertyDescriptor, defineProperties, getOwnPropertyNames as getOwnPropertyNames$1, getPrototypeOf as getPrototypeOf$1, setPrototypeOf, isObject, assert, KEY__SYNTHETIC_MODE, toString as toString$1, isFalse, isTrue, getOwnPropertyDescriptor as getOwnPropertyDescriptor$1, LWC_VERSION_COMMENT_REGEX, LWC_VERSION, freeze, htmlPropertyToAttribute, ArraySlice, StringCharCodeAt, XML_NAMESPACE, XLINK_NAMESPACE, isString, StringSlice, SVG_NAMESPACE, KEY__SHADOW_RESOLVER, isArray as isArray$1, isNumber, StringReplace, KEY__SCOPED_CSS, noop, ArrayUnshift } from '@lwc/shared';
|
|
3
2
|
import { runtimeFlags } from '@lwc/features';
|
|
4
3
|
export { setFeatureFlag, setFeatureFlagForTest } from '@lwc/features';
|
|
4
|
+
import { seal, create, isFunction as isFunction$1, ArrayPush as ArrayPush$1, isUndefined as isUndefined$1, ArrayIndexOf, ArraySplice, StringToLowerCase, ArrayJoin, isNull, isFrozen, defineProperty, hasOwnProperty as hasOwnProperty$1, assign, forEach, keys, AriaPropNameToAttrNameMap, getPropertyDescriptor, defineProperties, getOwnPropertyNames as getOwnPropertyNames$1, getPrototypeOf as getPrototypeOf$1, setPrototypeOf, isObject, assert, KEY__SYNTHETIC_MODE, toString as toString$1, isFalse, isTrue, getOwnPropertyDescriptor as getOwnPropertyDescriptor$1, LWC_VERSION_COMMENT_REGEX, LWC_VERSION, freeze, htmlPropertyToAttribute, ArraySlice, StringCharCodeAt, XML_NAMESPACE, XLINK_NAMESPACE, isString, StringSlice, SVG_NAMESPACE, KEY__SHADOW_RESOLVER, isArray as isArray$1, isNumber, StringReplace, KEY__SCOPED_CSS, noop, ArrayUnshift, ArrayCopyWithin, ArrayFill, ArraySort, ArrayReverse, ArrayShift, ArrayPop } from '@lwc/shared';
|
|
5
|
+
|
|
6
|
+
/*
|
|
7
|
+
* Copyright (c) 2018, salesforce.com, inc.
|
|
8
|
+
* All rights reserved.
|
|
9
|
+
* SPDX-License-Identifier: MIT
|
|
10
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
11
|
+
*/
|
|
12
|
+
// @ts-ignore
|
|
13
|
+
|
|
14
|
+
if (process.env.NODE_ENV !== 'production' && typeof __karma__ !== 'undefined') {
|
|
15
|
+
window.addEventListener('test-dummy-flag', () => {
|
|
16
|
+
let hasFlag = false;
|
|
17
|
+
|
|
18
|
+
if (runtimeFlags.DUMMY_TEST_FLAG) {
|
|
19
|
+
hasFlag = true;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
window.dispatchEvent(new CustomEvent('has-dummy-flag', {
|
|
23
|
+
detail: {
|
|
24
|
+
package: '@lwc/engine-core',
|
|
25
|
+
hasFlag
|
|
26
|
+
}
|
|
27
|
+
}));
|
|
28
|
+
});
|
|
29
|
+
}
|
|
5
30
|
|
|
6
31
|
/*
|
|
7
32
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
@@ -103,9 +128,7 @@ let HTMLElementExported;
|
|
|
103
128
|
function setHTMLElement(HTMLElementImpl) {
|
|
104
129
|
HTMLElementExported = HTMLElementImpl;
|
|
105
130
|
}
|
|
106
|
-
let isHydrating;
|
|
107
131
|
function setIsHydrating(isHydratingImpl) {
|
|
108
|
-
isHydrating = isHydratingImpl;
|
|
109
132
|
}
|
|
110
133
|
let insert;
|
|
111
134
|
function setInsert(insertImpl) {
|
|
@@ -227,10 +250,6 @@ let isConnected;
|
|
|
227
250
|
function setIsConnected(isConnectedImpl) {
|
|
228
251
|
isConnected = isConnectedImpl;
|
|
229
252
|
}
|
|
230
|
-
let insertGlobalStylesheet;
|
|
231
|
-
function setInsertGlobalStylesheet(insertGlobalStylesheetImpl) {
|
|
232
|
-
insertGlobalStylesheet = insertGlobalStylesheetImpl;
|
|
233
|
-
}
|
|
234
253
|
let insertStylesheet;
|
|
235
254
|
function setInsertStylesheet(insertStylesheetImpl) {
|
|
236
255
|
insertStylesheet = insertStylesheetImpl;
|
|
@@ -2346,6 +2365,8 @@ function registerTemplate(tpl) {
|
|
|
2346
2365
|
// on top of stylesheetToken for anyone who is accessing the old internal API.
|
|
2347
2366
|
// Details: https://salesforce.quip.com/v1rmAFu2cKAr
|
|
2348
2367
|
defineProperty(tpl, 'stylesheetTokens', {
|
|
2368
|
+
enumerable: true,
|
|
2369
|
+
configurable: true,
|
|
2349
2370
|
get() {
|
|
2350
2371
|
const { stylesheetToken } = this;
|
|
2351
2372
|
if (isUndefined$1(stylesheetToken)) {
|
|
@@ -3429,15 +3450,16 @@ function mountVNodes(vnodes, parent, anchor, start = 0, end = vnodes.length) {
|
|
|
3429
3450
|
}
|
|
3430
3451
|
}
|
|
3431
3452
|
function unmount(vnode, parent, doRemove = false) {
|
|
3432
|
-
const { type, elm } = vnode;
|
|
3453
|
+
const { type, elm, sel } = vnode;
|
|
3433
3454
|
// When unmounting a VNode subtree not all the elements have to removed from the DOM. The
|
|
3434
3455
|
// subtree root, is the only element worth unmounting from the subtree.
|
|
3435
3456
|
if (doRemove) {
|
|
3436
3457
|
removeNode(elm, parent);
|
|
3437
3458
|
}
|
|
3459
|
+
const removeChildren = sel === 'slot'; // slot content is removed to trigger slotchange event when removing slot
|
|
3438
3460
|
switch (type) {
|
|
3439
3461
|
case 2 /* Element */:
|
|
3440
|
-
unmountVNodes(vnode.children, elm);
|
|
3462
|
+
unmountVNodes(vnode.children, elm, removeChildren);
|
|
3441
3463
|
break;
|
|
3442
3464
|
case 3 /* CustomElement */: {
|
|
3443
3465
|
const { vm } = vnode;
|
|
@@ -4355,10 +4377,10 @@ function createStylesheet(vm, stylesheets) {
|
|
|
4355
4377
|
const { renderMode, shadowMode } = vm;
|
|
4356
4378
|
if (renderMode === 1 /* Shadow */ && shadowMode === 1 /* Synthetic */) {
|
|
4357
4379
|
for (let i = 0; i < stylesheets.length; i++) {
|
|
4358
|
-
|
|
4380
|
+
insertStylesheet(stylesheets[i]);
|
|
4359
4381
|
}
|
|
4360
4382
|
}
|
|
4361
|
-
else if (ssr ||
|
|
4383
|
+
else if (ssr || vm.hydrated) {
|
|
4362
4384
|
// Note: We need to ensure that during hydration, the stylesheets method is the same as those in ssr.
|
|
4363
4385
|
// This works in the client, because the stylesheets are created, and cached in the VM
|
|
4364
4386
|
// the first time the VM renders.
|
|
@@ -4369,15 +4391,10 @@ function createStylesheet(vm, stylesheets) {
|
|
|
4369
4391
|
else {
|
|
4370
4392
|
// native shadow or light DOM, DOM renderer
|
|
4371
4393
|
const root = getNearestNativeShadowComponent(vm);
|
|
4372
|
-
|
|
4394
|
+
// null root means a global style
|
|
4395
|
+
const target = isNull(root) ? undefined : root.shadowRoot;
|
|
4373
4396
|
for (let i = 0; i < stylesheets.length; i++) {
|
|
4374
|
-
|
|
4375
|
-
insertGlobalStylesheet(stylesheets[i]);
|
|
4376
|
-
}
|
|
4377
|
-
else {
|
|
4378
|
-
// local level
|
|
4379
|
-
insertStylesheet(stylesheets[i], root.shadowRoot);
|
|
4380
|
-
}
|
|
4397
|
+
insertStylesheet(stylesheets[i], target);
|
|
4381
4398
|
}
|
|
4382
4399
|
}
|
|
4383
4400
|
return null;
|
|
@@ -4925,7 +4942,8 @@ function createVM(elm, ctor, options) {
|
|
|
4925
4942
|
const {
|
|
4926
4943
|
mode,
|
|
4927
4944
|
owner,
|
|
4928
|
-
tagName
|
|
4945
|
+
tagName,
|
|
4946
|
+
hydrated
|
|
4929
4947
|
} = options;
|
|
4930
4948
|
const def = getComponentInternalDef(ctor);
|
|
4931
4949
|
const vm = {
|
|
@@ -4948,6 +4966,7 @@ function createVM(elm, ctor, options) {
|
|
|
4948
4966
|
cmpSlots: create(null),
|
|
4949
4967
|
oar: create(null),
|
|
4950
4968
|
cmpTemplate: null,
|
|
4969
|
+
hydrated: Boolean(hydrated),
|
|
4951
4970
|
renderMode: def.renderMode,
|
|
4952
4971
|
shadowMode: computeShadowMode(def, owner),
|
|
4953
4972
|
nearestShadowMode: (owner === null || owner === void 0 ? void 0 : owner.shadowRoot) ? owner.shadowMode : (_a = owner === null || owner === void 0 ? void 0 : owner.nearestShadowMode) !== null && _a !== void 0 ? _a : null,
|
|
@@ -5922,6 +5941,7 @@ function hydrateCustomElement(elm, vnode) {
|
|
|
5922
5941
|
mode,
|
|
5923
5942
|
owner,
|
|
5924
5943
|
tagName: sel,
|
|
5944
|
+
hydrated: true,
|
|
5925
5945
|
});
|
|
5926
5946
|
vnode.elm = elm;
|
|
5927
5947
|
vnode.vm = vm;
|
|
@@ -6116,6 +6136,105 @@ function setHooks(hooks) {
|
|
|
6116
6136
|
setSanitizeHtmlContentHook(hooks.sanitizeHtmlContent);
|
|
6117
6137
|
}
|
|
6118
6138
|
|
|
6139
|
+
/*
|
|
6140
|
+
* Copyright (c) 2018, salesforce.com, inc.
|
|
6141
|
+
* All rights reserved.
|
|
6142
|
+
* SPDX-License-Identifier: MIT
|
|
6143
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
6144
|
+
*/
|
|
6145
|
+
// See @lwc/engine-core/src/framework/template.ts
|
|
6146
|
+
const TEMPLATE_PROPS = ['slots', 'stylesheetToken', 'stylesheets', 'renderMode'];
|
|
6147
|
+
// Via https://www.npmjs.com/package/object-observer
|
|
6148
|
+
const ARRAY_MUTATION_METHODS = [
|
|
6149
|
+
'pop',
|
|
6150
|
+
'push',
|
|
6151
|
+
'shift',
|
|
6152
|
+
'unshift',
|
|
6153
|
+
'reverse',
|
|
6154
|
+
'sort',
|
|
6155
|
+
'fill',
|
|
6156
|
+
'splice',
|
|
6157
|
+
'copyWithin',
|
|
6158
|
+
];
|
|
6159
|
+
function getOriginalArrayMethod(prop) {
|
|
6160
|
+
switch (prop) {
|
|
6161
|
+
case 'pop':
|
|
6162
|
+
return ArrayPop;
|
|
6163
|
+
case 'push':
|
|
6164
|
+
return ArrayPush$1;
|
|
6165
|
+
case 'shift':
|
|
6166
|
+
return ArrayShift;
|
|
6167
|
+
case 'unshift':
|
|
6168
|
+
return ArrayUnshift;
|
|
6169
|
+
case 'reverse':
|
|
6170
|
+
return ArrayReverse;
|
|
6171
|
+
case 'sort':
|
|
6172
|
+
return ArraySort;
|
|
6173
|
+
case 'fill':
|
|
6174
|
+
return ArrayFill;
|
|
6175
|
+
case 'splice':
|
|
6176
|
+
return ArraySplice;
|
|
6177
|
+
case 'copyWithin':
|
|
6178
|
+
return ArrayCopyWithin;
|
|
6179
|
+
}
|
|
6180
|
+
}
|
|
6181
|
+
let mutationWarningsSilenced = false;
|
|
6182
|
+
// Warn if the user tries to mutate tmpl.stylesheets, e.g.:
|
|
6183
|
+
// `tmpl.stylesheets.push(someStylesheetFunction)`
|
|
6184
|
+
function warnOnArrayMutation(stylesheets) {
|
|
6185
|
+
// We can't handle users calling Array.prototype.slice.call(tmpl.stylesheets), but
|
|
6186
|
+
// we can at least warn when they use the most common mutation methods.
|
|
6187
|
+
for (const prop of ARRAY_MUTATION_METHODS) {
|
|
6188
|
+
const originalArrayMethod = getOriginalArrayMethod(prop);
|
|
6189
|
+
stylesheets[prop] = function arrayMutationWarningWrapper() {
|
|
6190
|
+
logError(`Mutating the "stylesheets" array on a template function ` +
|
|
6191
|
+
`is deprecated and may be removed in a future version of LWC.`);
|
|
6192
|
+
// @ts-ignore
|
|
6193
|
+
return originalArrayMethod.apply(this, arguments);
|
|
6194
|
+
};
|
|
6195
|
+
}
|
|
6196
|
+
}
|
|
6197
|
+
// TODO [#2782]: eventually freezeTemplate() will _actually_ freeze the tmpl object. Today it
|
|
6198
|
+
// just warns on mutation.
|
|
6199
|
+
function freezeTemplate(tmpl) {
|
|
6200
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
6201
|
+
if (!isUndefined$1(tmpl.stylesheets)) {
|
|
6202
|
+
warnOnArrayMutation(tmpl.stylesheets);
|
|
6203
|
+
}
|
|
6204
|
+
for (const prop of TEMPLATE_PROPS) {
|
|
6205
|
+
let value = tmpl[prop];
|
|
6206
|
+
defineProperty(tmpl, prop, {
|
|
6207
|
+
enumerable: true,
|
|
6208
|
+
configurable: true,
|
|
6209
|
+
get() {
|
|
6210
|
+
return value;
|
|
6211
|
+
},
|
|
6212
|
+
set(newValue) {
|
|
6213
|
+
if (!mutationWarningsSilenced) {
|
|
6214
|
+
logError(`Dynamically setting the "${prop}" property on a template function ` +
|
|
6215
|
+
`is deprecated and may be removed in a future version of LWC.`);
|
|
6216
|
+
}
|
|
6217
|
+
value = newValue;
|
|
6218
|
+
},
|
|
6219
|
+
});
|
|
6220
|
+
}
|
|
6221
|
+
const originalDescriptor = getOwnPropertyDescriptor$1(tmpl, 'stylesheetTokens');
|
|
6222
|
+
defineProperty(tmpl, 'stylesheetTokens', {
|
|
6223
|
+
enumerable: true,
|
|
6224
|
+
configurable: true,
|
|
6225
|
+
get: originalDescriptor.get,
|
|
6226
|
+
set(value) {
|
|
6227
|
+
logError(`Dynamically setting the "stylesheetTokens" property on a template function ` +
|
|
6228
|
+
`is deprecated and may be removed in a future version of LWC.`);
|
|
6229
|
+
// Avoid logging twice (for both stylesheetToken and stylesheetTokens)
|
|
6230
|
+
mutationWarningsSilenced = true;
|
|
6231
|
+
originalDescriptor.set.call(this, value);
|
|
6232
|
+
mutationWarningsSilenced = false;
|
|
6233
|
+
},
|
|
6234
|
+
});
|
|
6235
|
+
}
|
|
6236
|
+
}
|
|
6237
|
+
|
|
6119
6238
|
/*
|
|
6120
6239
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
6121
6240
|
* All rights reserved.
|
|
@@ -6139,5 +6258,5 @@ function getComponentConstructor(elm) {
|
|
|
6139
6258
|
return ctor;
|
|
6140
6259
|
}
|
|
6141
6260
|
|
|
6142
|
-
export { LightningElement, profilerControl as __unstable__ProfilerControl, api$1 as api, connectRootElement, createContextProvider, createVM, disconnectRootElement, getAssociatedVMIfPresent, getComponentConstructor, getComponentDef, getComponentHtmlPrototype, getUpgradableConstructor, hydrateRoot, isComponentConstructor, readonly, register, registerComponent, registerDecorators, registerTemplate, sanitizeAttribute, setAddEventListener, setAssertInstanceOfHTMLElement, setAttachShadow, setCreateComment, setCreateElement, setCreateText, setDefineCustomElement, setDispatchEvent, setGetAttribute, setGetBoundingClientRect, setGetChildNodes, setGetChildren, setGetClassList, setGetCustomElement, setGetElementsByClassName, setGetElementsByTagName, setGetFirstChild, setGetFirstElementChild, setGetLastChild, setGetLastElementChild, setGetProperty, setHTMLElement, setHooks, setInsert,
|
|
6143
|
-
/* version: 2.13.
|
|
6261
|
+
export { LightningElement, profilerControl as __unstable__ProfilerControl, api$1 as api, connectRootElement, createContextProvider, createVM, disconnectRootElement, freezeTemplate, getAssociatedVMIfPresent, getComponentConstructor, getComponentDef, getComponentHtmlPrototype, getUpgradableConstructor, hydrateRoot, isComponentConstructor, readonly, register, registerComponent, registerDecorators, registerTemplate, sanitizeAttribute, setAddEventListener, setAssertInstanceOfHTMLElement, setAttachShadow, setCreateComment, setCreateElement, setCreateText, setDefineCustomElement, setDispatchEvent, setGetAttribute, setGetBoundingClientRect, setGetChildNodes, setGetChildren, setGetClassList, setGetCustomElement, setGetElementsByClassName, setGetElementsByTagName, setGetFirstChild, setGetFirstElementChild, setGetLastChild, setGetLastElementChild, setGetProperty, setHTMLElement, setHooks, setInsert, setInsertStylesheet, setIsConnected, setIsHydrating, setIsNativeShadowDefined, setIsSyntheticShadowDefined, setNextSibling, setQuerySelector, setQuerySelectorAll, setRemove, setRemoveAttribute, setRemoveEventListener, setSetAttribute, setSetCSSStyleProperty, setSetProperty, setSetText, setSsr, swapComponent, swapStyle, swapTemplate, track, unwrap, wire };
|
|
6262
|
+
/* version: 2.13.4 */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lwc/engine-core",
|
|
3
|
-
"version": "2.13.
|
|
3
|
+
"version": "2.13.4",
|
|
4
4
|
"description": "Core LWC engine APIs.",
|
|
5
5
|
"homepage": "https://lwc.dev/",
|
|
6
6
|
"repository": {
|
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
"types/"
|
|
26
26
|
],
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@lwc/features": "2.13.
|
|
29
|
-
"@lwc/shared": "2.13.
|
|
28
|
+
"@lwc/features": "2.13.4",
|
|
29
|
+
"@lwc/shared": "2.13.4"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"observable-membrane": "2.0.0"
|
|
@@ -19,6 +19,7 @@ export { profilerControl as __unstable__ProfilerControl } from './profiler';
|
|
|
19
19
|
export { getUpgradableConstructor } from './upgradable-element';
|
|
20
20
|
export { swapTemplate, swapComponent, swapStyle } from './hot-swaps';
|
|
21
21
|
export { setHooks } from './overridable-hooks';
|
|
22
|
+
export { freezeTemplate } from './freeze-template';
|
|
22
23
|
export { getComponentConstructor } from './get-component-constructor';
|
|
23
24
|
export type { ConfigValue as WireConfigValue, ContextValue as WireContextValue, DataCallback, WireAdapter, WireAdapterConstructor, WireAdapterSchemaValue, } from './wiring';
|
|
24
|
-
export { setAssertInstanceOfHTMLElement, setAttachShadow, setCreateComment, setCreateElement, setCreateText, setDefineCustomElement, setDispatchEvent, setGetAttribute, setGetBoundingClientRect, setGetChildNodes, setGetChildren, setGetClassList, setGetCustomElement, setGetElementsByClassName, setGetElementsByTagName, setGetFirstChild, setGetFirstElementChild, setGetLastChild, setGetLastElementChild, setGetProperty, setHTMLElement, setInsert,
|
|
25
|
+
export { setAssertInstanceOfHTMLElement, setAttachShadow, setCreateComment, setCreateElement, setCreateText, setDefineCustomElement, setDispatchEvent, setGetAttribute, setGetBoundingClientRect, setGetChildNodes, setGetChildren, setGetClassList, setGetCustomElement, setGetElementsByClassName, setGetElementsByTagName, setGetFirstChild, setGetFirstElementChild, setGetLastChild, setGetLastElementChild, setGetProperty, setHTMLElement, setInsert, setIsConnected, setIsHydrating, setIsNativeShadowDefined, setIsSyntheticShadowDefined, setNextSibling, setQuerySelector, setQuerySelectorAll, setRemove, setRemoveAttribute, setRemoveEventListener, setSetAttribute, setSetCSSStyleProperty, setSetProperty, setSetText, setSsr, setAddEventListener, setInsertStylesheet, } from '../renderer';
|
package/types/framework/vm.d.ts
CHANGED
|
@@ -62,6 +62,8 @@ export interface VM<N = HostNode, E = HostElement> {
|
|
|
62
62
|
readonly context: Context;
|
|
63
63
|
/** The owner VM or null for root elements. */
|
|
64
64
|
readonly owner: VM<N, E> | null;
|
|
65
|
+
/** Whether or not the VM was hydrated */
|
|
66
|
+
readonly hydrated: boolean;
|
|
65
67
|
/** Rendering operations associated with the VM */
|
|
66
68
|
readonly renderMode: RenderMode;
|
|
67
69
|
shadowMode: ShadowMode;
|
|
@@ -133,6 +135,7 @@ export declare function createVM<HostNode, HostElement>(elm: HostElement, ctor:
|
|
|
133
135
|
mode: ShadowRootMode;
|
|
134
136
|
owner: VM<HostNode, HostElement> | null;
|
|
135
137
|
tagName: string;
|
|
138
|
+
hydrated?: boolean;
|
|
136
139
|
}): VM;
|
|
137
140
|
export declare function associateVM(obj: VMAssociable, vm: VM): void;
|
|
138
141
|
export declare function getAssociatedVM(obj: VMAssociable): VM;
|
package/types/index.d.ts
CHANGED
package/types/renderer.d.ts
CHANGED
|
@@ -105,10 +105,7 @@ export declare function setGetLastElementChild(getLastElementChildImpl: getLastE
|
|
|
105
105
|
declare type isConnectedFunc = (node: N) => boolean;
|
|
106
106
|
export declare let isConnected: isConnectedFunc;
|
|
107
107
|
export declare function setIsConnected(isConnectedImpl: isConnectedFunc): void;
|
|
108
|
-
declare type
|
|
109
|
-
export declare let insertGlobalStylesheet: insertGlobalStylesheetFunc;
|
|
110
|
-
export declare function setInsertGlobalStylesheet(insertGlobalStylesheetImpl: insertGlobalStylesheetFunc): void;
|
|
111
|
-
declare type insertStylesheetFunc = (content: string, target: ShadowRoot) => void;
|
|
108
|
+
declare type insertStylesheetFunc = (content: string, target?: ShadowRoot) => void;
|
|
112
109
|
export declare let insertStylesheet: insertStylesheetFunc;
|
|
113
110
|
export declare function setInsertStylesheet(insertStylesheetImpl: insertStylesheetFunc): void;
|
|
114
111
|
declare type assertInstanceOfHTMLElementFunc = (elm: any, msg: string) => void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|