lwc 2.31.1 → 2.32.1
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 +237 -264
- package/dist/engine-dom/iife/es2017/engine-dom.js +237 -264
- package/dist/engine-dom/iife/es2017/engine-dom.min.js +1 -1
- package/dist/engine-dom/iife/es2017/engine-dom_debug.js +109 -160
- package/dist/engine-dom/iife/es5/engine-dom.js +233 -242
- package/dist/engine-dom/iife/es5/engine-dom.min.js +1 -1
- package/dist/engine-dom/iife/es5/engine-dom_debug.js +142 -199
- package/dist/engine-dom/umd/es2017/engine-dom.js +237 -264
- package/dist/engine-dom/umd/es2017/engine-dom.min.js +1 -1
- package/dist/engine-dom/umd/es2017/engine-dom_debug.js +109 -160
- package/dist/engine-dom/umd/es5/engine-dom.js +233 -242
- package/dist/engine-dom/umd/es5/engine-dom.min.js +1 -1
- package/dist/engine-dom/umd/es5/engine-dom_debug.js +142 -199
- package/dist/engine-server/commonjs/es2017/engine-server.js +218 -224
- package/dist/engine-server/commonjs/es2017/engine-server.min.js +1 -1
- package/dist/engine-server/esm/es2017/engine-server.js +218 -224
- package/dist/synthetic-shadow/esm/es2017/synthetic-shadow.js +676 -909
- package/dist/synthetic-shadow/iife/es2017/synthetic-shadow.js +676 -909
- package/dist/synthetic-shadow/iife/es2017/synthetic-shadow.min.js +2 -2
- package/dist/synthetic-shadow/iife/es2017/synthetic-shadow_debug.js +644 -882
- package/dist/synthetic-shadow/iife/es5/synthetic-shadow.js +85 -345
- package/dist/synthetic-shadow/iife/es5/synthetic-shadow.min.js +2 -2
- package/dist/synthetic-shadow/iife/es5/synthetic-shadow_debug.js +85 -345
- package/dist/synthetic-shadow/umd/es2017/synthetic-shadow.js +676 -909
- package/dist/synthetic-shadow/umd/es2017/synthetic-shadow.min.js +2 -2
- package/dist/synthetic-shadow/umd/es2017/synthetic-shadow_debug.js +644 -882
- package/dist/synthetic-shadow/umd/es5/synthetic-shadow.js +85 -345
- package/dist/synthetic-shadow/umd/es5/synthetic-shadow.min.js +2 -2
- package/dist/synthetic-shadow/umd/es5/synthetic-shadow_debug.js +85 -345
- package/dist/wire-service/esm/es2017/wire-service.js +2 -2
- package/dist/wire-service/iife/es2017/wire-service.js +2 -2
- package/dist/wire-service/iife/es2017/wire-service_debug.js +2 -2
- package/dist/wire-service/iife/es5/wire-service.js +2 -2
- package/dist/wire-service/iife/es5/wire-service_debug.js +2 -2
- package/dist/wire-service/umd/es2017/wire-service.js +2 -2
- package/dist/wire-service/umd/es2017/wire-service_debug.js +2 -2
- package/dist/wire-service/umd/es5/wire-service.js +2 -2
- package/dist/wire-service/umd/es5/wire-service_debug.js +2 -2
- package/package.json +7 -7
|
@@ -87,7 +87,7 @@
|
|
|
87
87
|
const KEY__SHADOW_TOKEN = '$shadowToken$';
|
|
88
88
|
const KEY__SHADOW_TOKEN_PRIVATE = '$$ShadowTokenKey$$';
|
|
89
89
|
const KEY__SYNTHETIC_MODE = '$$lwc-synthetic-mode';
|
|
90
|
-
/** version: 2.
|
|
90
|
+
/** version: 2.32.1 */
|
|
91
91
|
|
|
92
92
|
/*
|
|
93
93
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
@@ -361,7 +361,8 @@
|
|
|
361
361
|
return win;
|
|
362
362
|
}
|
|
363
363
|
let skipGlobalPatching;
|
|
364
|
-
//
|
|
364
|
+
// Note: we deviate from native shadow here, but are not fixing
|
|
365
|
+
// due to backwards compat: https://github.com/salesforce/lwc/pull/3103
|
|
365
366
|
function isGlobalPatchingSkipped(node) {
|
|
366
367
|
// we lazily compute this value instead of doing it during evaluation, this helps
|
|
367
368
|
// for apps that are setting this after the engine code is evaluated.
|
|
@@ -401,7 +402,7 @@
|
|
|
401
402
|
Object.defineProperty(_globalThis, 'lwcRuntimeFlags', { value: create(null) });
|
|
402
403
|
}
|
|
403
404
|
const lwcRuntimeFlags = _globalThis.lwcRuntimeFlags;
|
|
404
|
-
/** version: 2.
|
|
405
|
+
/** version: 2.32.1 */
|
|
405
406
|
|
|
406
407
|
/*
|
|
407
408
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
@@ -1082,112 +1083,116 @@
|
|
|
1082
1083
|
* because we don't want to patch the children getters for those elements.
|
|
1083
1084
|
*/
|
|
1084
1085
|
function hasMountedChildren(node) {
|
|
1085
|
-
|
|
1086
|
+
return isSyntheticSlotElement(node) || isSyntheticShadowHost(node);
|
|
1086
1087
|
}
|
|
1087
1088
|
function getShadowParent(node, value) {
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
if (
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1089
|
+
const owner = getNodeOwner(node);
|
|
1090
|
+
if (value === owner) {
|
|
1091
|
+
// walking up via parent chain might end up in the shadow root element
|
|
1092
|
+
return getShadowRoot(owner);
|
|
1093
|
+
}
|
|
1094
|
+
else if (value instanceof Element) {
|
|
1095
|
+
if (getNodeNearestOwnerKey(node) === getNodeNearestOwnerKey(value)) {
|
|
1096
|
+
// the element and its parent node belong to the same shadow root
|
|
1097
|
+
return value;
|
|
1098
|
+
}
|
|
1099
|
+
else if (!isNull(owner) && isSlotElement(value)) {
|
|
1100
|
+
// slotted elements must be top level childNodes of the slot element
|
|
1101
|
+
// where they slotted into, but its shadowed parent is always the
|
|
1102
|
+
// owner of the slot.
|
|
1103
|
+
const slotOwner = getNodeOwner(value);
|
|
1104
|
+
if (!isNull(slotOwner) && isNodeOwnedBy(owner, slotOwner)) {
|
|
1105
|
+
// it is a slotted element, and therefore its parent is always going to be the host of the slot
|
|
1106
|
+
return slotOwner;
|
|
1107
|
+
}
|
|
1108
|
+
}
|
|
1105
1109
|
}
|
|
1106
|
-
|
|
1107
|
-
return null;
|
|
1110
|
+
return null;
|
|
1108
1111
|
}
|
|
1109
1112
|
function hasChildNodesPatched() {
|
|
1110
|
-
|
|
1113
|
+
return getInternalChildNodes(this).length > 0;
|
|
1111
1114
|
}
|
|
1112
1115
|
function firstChildGetterPatched() {
|
|
1113
|
-
|
|
1114
|
-
|
|
1116
|
+
const childNodes = getInternalChildNodes(this);
|
|
1117
|
+
return childNodes[0] || null;
|
|
1115
1118
|
}
|
|
1116
1119
|
function lastChildGetterPatched() {
|
|
1117
|
-
|
|
1118
|
-
|
|
1120
|
+
const childNodes = getInternalChildNodes(this);
|
|
1121
|
+
return childNodes[childNodes.length - 1] || null;
|
|
1119
1122
|
}
|
|
1120
1123
|
function textContentGetterPatched() {
|
|
1121
|
-
|
|
1124
|
+
return getTextContent(this);
|
|
1122
1125
|
}
|
|
1123
1126
|
function textContentSetterPatched(value) {
|
|
1124
|
-
|
|
1127
|
+
textContextSetter.call(this, value);
|
|
1125
1128
|
}
|
|
1126
1129
|
function parentNodeGetterPatched() {
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1130
|
+
const value = parentNodeGetter.call(this);
|
|
1131
|
+
if (isNull(value)) {
|
|
1132
|
+
return value;
|
|
1133
|
+
}
|
|
1134
|
+
// TODO [#1635]: this needs optimization, maybe implementing it based on this.assignedSlot
|
|
1135
|
+
return getShadowParent(this, value);
|
|
1133
1136
|
}
|
|
1134
1137
|
function parentElementGetterPatched() {
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1138
|
+
const value = parentNodeGetter.call(this);
|
|
1139
|
+
if (isNull(value)) {
|
|
1140
|
+
return null;
|
|
1141
|
+
}
|
|
1142
|
+
const parentNode = getShadowParent(this, value);
|
|
1143
|
+
// it could be that the parentNode is the shadowRoot, in which case
|
|
1144
|
+
// we need to return null.
|
|
1145
|
+
// TODO [#1635]: this needs optimization, maybe implementing it based on this.assignedSlot
|
|
1146
|
+
return parentNode instanceof Element ? parentNode : null;
|
|
1144
1147
|
}
|
|
1145
1148
|
function compareDocumentPositionPatched(otherNode) {
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1149
|
+
if (this === otherNode) {
|
|
1150
|
+
return 0;
|
|
1151
|
+
}
|
|
1152
|
+
else if (this.getRootNode() === otherNode) {
|
|
1153
|
+
// "this" is in a shadow tree where the shadow root is the "otherNode".
|
|
1154
|
+
return 10; // Node.DOCUMENT_POSITION_CONTAINS | Node.DOCUMENT_POSITION_PRECEDING
|
|
1155
|
+
}
|
|
1156
|
+
else if (getNodeOwnerKey(this) !== getNodeOwnerKey(otherNode)) {
|
|
1157
|
+
// "this" and "otherNode" belongs to 2 different shadow tree.
|
|
1158
|
+
return 35; // Node.DOCUMENT_POSITION_DISCONNECTED | Node.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC | Node.DOCUMENT_POSITION_PRECEDING
|
|
1159
|
+
}
|
|
1160
|
+
// Since "this" and "otherNode" are part of the same shadow tree we can safely rely to the native
|
|
1161
|
+
// Node.compareDocumentPosition implementation.
|
|
1162
|
+
return compareDocumentPosition.call(this, otherNode);
|
|
1158
1163
|
}
|
|
1159
1164
|
function containsPatched(otherNode) {
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
+
if (otherNode == null || getNodeOwnerKey(this) !== getNodeOwnerKey(otherNode)) {
|
|
1166
|
+
// it is from another shadow
|
|
1167
|
+
return false;
|
|
1168
|
+
}
|
|
1169
|
+
return (compareDocumentPosition.call(this, otherNode) & DOCUMENT_POSITION_CONTAINED_BY) !== 0;
|
|
1165
1170
|
}
|
|
1166
1171
|
function cloneNodePatched(deep) {
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1172
|
+
const clone = cloneNode.call(this, false);
|
|
1173
|
+
// Per spec, browsers only care about truthy values
|
|
1174
|
+
// Not strict true or false
|
|
1175
|
+
if (!deep) {
|
|
1176
|
+
return clone;
|
|
1177
|
+
}
|
|
1178
|
+
const childNodes = getInternalChildNodes(this);
|
|
1179
|
+
for (let i = 0, len = childNodes.length; i < len; i += 1) {
|
|
1180
|
+
clone.appendChild(childNodes[i].cloneNode(true));
|
|
1181
|
+
}
|
|
1171
1182
|
return clone;
|
|
1172
|
-
}
|
|
1173
|
-
const childNodes = getInternalChildNodes(this);
|
|
1174
|
-
for (let i = 0, len = childNodes.length; i < len; i += 1) {
|
|
1175
|
-
clone.appendChild(childNodes[i].cloneNode(true));
|
|
1176
|
-
}
|
|
1177
|
-
return clone;
|
|
1178
1183
|
}
|
|
1179
1184
|
/**
|
|
1180
1185
|
* This method only applies to elements with a shadow or slots
|
|
1181
1186
|
*/
|
|
1182
1187
|
function childNodesGetterPatched() {
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1188
|
+
if (isSyntheticShadowHost(this)) {
|
|
1189
|
+
const owner = getNodeOwner(this);
|
|
1190
|
+
const childNodes = isNull(owner) ? [] : getAllMatches(owner, getFilteredChildNodes(this));
|
|
1191
|
+
return createStaticNodeList(childNodes);
|
|
1192
|
+
}
|
|
1193
|
+
// nothing to do here since this does not have a synthetic shadow attached to it
|
|
1194
|
+
// TODO [#1636]: what about slot elements?
|
|
1195
|
+
return childNodesGetter.call(this);
|
|
1191
1196
|
}
|
|
1192
1197
|
const nativeGetRootNode = _Node.prototype.getRootNode;
|
|
1193
1198
|
/**
|
|
@@ -1195,14 +1200,16 @@
|
|
|
1195
1200
|
* If Node.prototype.getRootNode is supported, use it
|
|
1196
1201
|
* else, assume we are working in non-native shadow mode and climb using parentNode
|
|
1197
1202
|
*/
|
|
1198
|
-
const getDocumentOrRootNode = !isUndefined(nativeGetRootNode)
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1203
|
+
const getDocumentOrRootNode = !isUndefined(nativeGetRootNode)
|
|
1204
|
+
? nativeGetRootNode
|
|
1205
|
+
: function () {
|
|
1206
|
+
let node = this;
|
|
1207
|
+
let nodeParent;
|
|
1208
|
+
while (!isNull((nodeParent = parentNodeGetter.call(node)))) {
|
|
1209
|
+
node = nodeParent;
|
|
1210
|
+
}
|
|
1211
|
+
return node;
|
|
1212
|
+
};
|
|
1206
1213
|
/**
|
|
1207
1214
|
* Get the shadow root
|
|
1208
1215
|
* getNodeOwner() returns the host element that owns the given node
|
|
@@ -1213,12 +1220,12 @@
|
|
|
1213
1220
|
* @param {Node} node
|
|
1214
1221
|
*/
|
|
1215
1222
|
function getNearestRoot(node) {
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1223
|
+
const ownerNode = getNodeOwner(node);
|
|
1224
|
+
if (isNull(ownerNode)) {
|
|
1225
|
+
// we hit a wall, either we are in native shadow mode or the node is not in lwc boundary.
|
|
1226
|
+
return getDocumentOrRootNode.call(node);
|
|
1227
|
+
}
|
|
1228
|
+
return getShadowRoot(ownerNode);
|
|
1222
1229
|
}
|
|
1223
1230
|
/**
|
|
1224
1231
|
* If looking for a root node beyond shadow root by calling `node.getRootNode({composed: true})`, use the original `Node.prototype.getRootNode` method
|
|
@@ -1240,187 +1247,170 @@
|
|
|
1240
1247
|
*
|
|
1241
1248
|
**/
|
|
1242
1249
|
function getRootNodePatched(options) {
|
|
1243
|
-
|
|
1244
|
-
|
|
1250
|
+
const composed = isUndefined(options) ? false : !!options.composed;
|
|
1251
|
+
return isTrue(composed) ? getDocumentOrRootNode.call(this, options) : getNearestRoot(this);
|
|
1245
1252
|
}
|
|
1246
1253
|
// Non-deep-traversing patches: this descriptor map includes all descriptors that
|
|
1247
1254
|
// do not give access to nodes beyond the immediate children.
|
|
1248
1255
|
defineProperties(_Node.prototype, {
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1256
|
+
firstChild: {
|
|
1257
|
+
get() {
|
|
1258
|
+
if (hasMountedChildren(this)) {
|
|
1259
|
+
return firstChildGetterPatched.call(this);
|
|
1260
|
+
}
|
|
1261
|
+
return firstChildGetter.call(this);
|
|
1262
|
+
},
|
|
1263
|
+
enumerable: true,
|
|
1264
|
+
configurable: true,
|
|
1255
1265
|
},
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1266
|
+
lastChild: {
|
|
1267
|
+
get() {
|
|
1268
|
+
if (hasMountedChildren(this)) {
|
|
1269
|
+
return lastChildGetterPatched.call(this);
|
|
1270
|
+
}
|
|
1271
|
+
return lastChildGetter.call(this);
|
|
1272
|
+
},
|
|
1273
|
+
enumerable: true,
|
|
1274
|
+
configurable: true,
|
|
1265
1275
|
},
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
}
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
if (isGlobalPatchingSkipped(this)) {
|
|
1279
|
-
return textContentGetter.call(this);
|
|
1280
|
-
}
|
|
1281
|
-
return textContentGetterPatched.call(this);
|
|
1276
|
+
textContent: {
|
|
1277
|
+
get() {
|
|
1278
|
+
// Note: we deviate from native shadow here, but are not fixing
|
|
1279
|
+
// due to backwards compat: https://github.com/salesforce/lwc/pull/3103
|
|
1280
|
+
if (isNodeShadowed(this) || isSyntheticShadowHost(this)) {
|
|
1281
|
+
return textContentGetterPatched.call(this);
|
|
1282
|
+
}
|
|
1283
|
+
return textContentGetter.call(this);
|
|
1284
|
+
},
|
|
1285
|
+
set: textContentSetterPatched,
|
|
1286
|
+
enumerable: true,
|
|
1287
|
+
configurable: true,
|
|
1282
1288
|
},
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
return parentNode;
|
|
1289
|
+
parentNode: {
|
|
1290
|
+
get() {
|
|
1291
|
+
if (isNodeShadowed(this)) {
|
|
1292
|
+
return parentNodeGetterPatched.call(this);
|
|
1293
|
+
}
|
|
1294
|
+
const parentNode = parentNodeGetter.call(this);
|
|
1295
|
+
// Handle the case where a top level light DOM element is slotted into a synthetic
|
|
1296
|
+
// shadow slot.
|
|
1297
|
+
if (!isNull(parentNode) && isSyntheticSlotElement(parentNode)) {
|
|
1298
|
+
return getNodeOwner(parentNode);
|
|
1299
|
+
}
|
|
1300
|
+
return parentNode;
|
|
1301
|
+
},
|
|
1302
|
+
enumerable: true,
|
|
1303
|
+
configurable: true,
|
|
1299
1304
|
},
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1305
|
+
parentElement: {
|
|
1306
|
+
get() {
|
|
1307
|
+
if (isNodeShadowed(this)) {
|
|
1308
|
+
return parentElementGetterPatched.call(this);
|
|
1309
|
+
}
|
|
1310
|
+
const parentElement = parentElementGetter.call(this);
|
|
1311
|
+
// Handle the case where a top level light DOM element is slotted into a synthetic
|
|
1312
|
+
// shadow slot.
|
|
1313
|
+
if (!isNull(parentElement) && isSyntheticSlotElement(parentElement)) {
|
|
1314
|
+
return getNodeOwner(parentElement);
|
|
1315
|
+
}
|
|
1316
|
+
return parentElement;
|
|
1317
|
+
},
|
|
1318
|
+
enumerable: true,
|
|
1319
|
+
configurable: true,
|
|
1315
1320
|
},
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1321
|
+
childNodes: {
|
|
1322
|
+
get() {
|
|
1323
|
+
if (hasMountedChildren(this)) {
|
|
1324
|
+
return childNodesGetterPatched.call(this);
|
|
1325
|
+
}
|
|
1326
|
+
return childNodesGetter.call(this);
|
|
1327
|
+
},
|
|
1328
|
+
enumerable: true,
|
|
1329
|
+
configurable: true,
|
|
1325
1330
|
},
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1331
|
+
hasChildNodes: {
|
|
1332
|
+
value() {
|
|
1333
|
+
if (hasMountedChildren(this)) {
|
|
1334
|
+
return hasChildNodesPatched.call(this);
|
|
1335
|
+
}
|
|
1336
|
+
return hasChildNodes.call(this);
|
|
1337
|
+
},
|
|
1338
|
+
enumerable: true,
|
|
1339
|
+
writable: true,
|
|
1340
|
+
configurable: true,
|
|
1335
1341
|
},
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1342
|
+
compareDocumentPosition: {
|
|
1343
|
+
value(otherNode) {
|
|
1344
|
+
// Note: we deviate from native shadow here, but are not fixing
|
|
1345
|
+
// due to backwards compat: https://github.com/salesforce/lwc/pull/3103
|
|
1346
|
+
if (isGlobalPatchingSkipped(this)) {
|
|
1347
|
+
return compareDocumentPosition.call(this, otherNode);
|
|
1348
|
+
}
|
|
1349
|
+
return compareDocumentPositionPatched.call(this, otherNode);
|
|
1350
|
+
},
|
|
1351
|
+
enumerable: true,
|
|
1352
|
+
writable: true,
|
|
1353
|
+
configurable: true,
|
|
1347
1354
|
},
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
// TODO [#1222]: remove global bypass
|
|
1371
|
-
if (isGlobalPatchingSkipped(this)) {
|
|
1372
|
-
return contains.call(this, otherNode);
|
|
1373
|
-
}
|
|
1374
|
-
return containsPatched.call(this, otherNode);
|
|
1355
|
+
contains: {
|
|
1356
|
+
value(otherNode) {
|
|
1357
|
+
// 1. Node.prototype.contains() returns true if otherNode is an inclusive descendant
|
|
1358
|
+
// spec: https://dom.spec.whatwg.org/#dom-node-contains
|
|
1359
|
+
// 2. This normalizes the behavior of this api across all browsers.
|
|
1360
|
+
// In IE11, a disconnected dom element without children invoking contains() on self, returns false
|
|
1361
|
+
if (this === otherNode) {
|
|
1362
|
+
return true;
|
|
1363
|
+
}
|
|
1364
|
+
// Note: we deviate from native shadow here, but are not fixing
|
|
1365
|
+
// due to backwards compat: https://github.com/salesforce/lwc/pull/3103
|
|
1366
|
+
if (otherNode == null) {
|
|
1367
|
+
return false;
|
|
1368
|
+
}
|
|
1369
|
+
if (isNodeShadowed(this) || isSyntheticShadowHost(this)) {
|
|
1370
|
+
return containsPatched.call(this, otherNode);
|
|
1371
|
+
}
|
|
1372
|
+
return contains.call(this, otherNode);
|
|
1373
|
+
},
|
|
1374
|
+
enumerable: true,
|
|
1375
|
+
writable: true,
|
|
1376
|
+
configurable: true,
|
|
1375
1377
|
},
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1378
|
+
cloneNode: {
|
|
1379
|
+
value(deep) {
|
|
1380
|
+
// Note: we deviate from native shadow here, but are not fixing
|
|
1381
|
+
// due to backwards compat: https://github.com/salesforce/lwc/pull/3103
|
|
1382
|
+
if (isNodeShadowed(this) || isSyntheticShadowHost(this)) {
|
|
1383
|
+
return cloneNodePatched.call(this, deep);
|
|
1384
|
+
}
|
|
1385
|
+
return cloneNode.call(this, deep);
|
|
1386
|
+
},
|
|
1387
|
+
enumerable: true,
|
|
1388
|
+
writable: true,
|
|
1389
|
+
configurable: true,
|
|
1390
|
+
},
|
|
1391
|
+
getRootNode: {
|
|
1392
|
+
value: getRootNodePatched,
|
|
1393
|
+
enumerable: true,
|
|
1394
|
+
configurable: true,
|
|
1395
|
+
writable: true,
|
|
1396
|
+
},
|
|
1397
|
+
isConnected: {
|
|
1398
|
+
enumerable: true,
|
|
1399
|
+
configurable: true,
|
|
1400
|
+
get() {
|
|
1401
|
+
return isConnected.call(this);
|
|
1402
|
+
},
|
|
1396
1403
|
},
|
|
1397
|
-
enumerable: true,
|
|
1398
|
-
writable: true,
|
|
1399
|
-
configurable: true
|
|
1400
|
-
},
|
|
1401
|
-
getRootNode: {
|
|
1402
|
-
value: getRootNodePatched,
|
|
1403
|
-
enumerable: true,
|
|
1404
|
-
configurable: true,
|
|
1405
|
-
writable: true
|
|
1406
|
-
},
|
|
1407
|
-
isConnected: {
|
|
1408
|
-
enumerable: true,
|
|
1409
|
-
configurable: true,
|
|
1410
|
-
get() {
|
|
1411
|
-
return isConnected.call(this);
|
|
1412
|
-
}
|
|
1413
|
-
}
|
|
1414
1404
|
});
|
|
1415
1405
|
const getInternalChildNodes = function (node) {
|
|
1416
|
-
|
|
1417
|
-
|
|
1406
|
+
return node.childNodes;
|
|
1407
|
+
};
|
|
1418
1408
|
// IE11 extra patches for wrong prototypes
|
|
1419
1409
|
if (hasOwnProperty.call(HTMLElement.prototype, 'contains')) {
|
|
1420
|
-
|
|
1410
|
+
defineProperty(HTMLElement.prototype, 'contains', getOwnPropertyDescriptor(_Node.prototype, 'contains'));
|
|
1421
1411
|
}
|
|
1422
1412
|
if (hasOwnProperty.call(HTMLElement.prototype, 'parentElement')) {
|
|
1423
|
-
|
|
1413
|
+
defineProperty(HTMLElement.prototype, 'parentElement', getOwnPropertyDescriptor(_Node.prototype, 'parentElement'));
|
|
1424
1414
|
}
|
|
1425
1415
|
|
|
1426
1416
|
/*
|
|
@@ -2338,7 +2328,8 @@
|
|
|
2338
2328
|
if (isNull(elm)) {
|
|
2339
2329
|
return null;
|
|
2340
2330
|
}
|
|
2341
|
-
//
|
|
2331
|
+
// Note: we deviate from native shadow here, but are not fixing
|
|
2332
|
+
// due to backwards compat: https://github.com/salesforce/lwc/pull/3103
|
|
2342
2333
|
return isUndefined(getNodeOwnerKey(elm)) || isGlobalPatchingSkipped(elm) ? elm : null;
|
|
2343
2334
|
},
|
|
2344
2335
|
writable: true,
|
|
@@ -2349,7 +2340,8 @@
|
|
|
2349
2340
|
value() {
|
|
2350
2341
|
const elements = arrayFromCollection(querySelectorAll.apply(this, ArraySlice.call(arguments)));
|
|
2351
2342
|
const filtered = ArrayFind.call(elements,
|
|
2352
|
-
//
|
|
2343
|
+
// Note: we deviate from native shadow here, but are not fixing
|
|
2344
|
+
// due to backwards compat: https://github.com/salesforce/lwc/pull/3103
|
|
2353
2345
|
(elm) => isUndefined(getNodeOwnerKey(elm)) || isGlobalPatchingSkipped(elm));
|
|
2354
2346
|
return !isUndefined(filtered) ? filtered : null;
|
|
2355
2347
|
},
|
|
@@ -2361,7 +2353,8 @@
|
|
|
2361
2353
|
value() {
|
|
2362
2354
|
const elements = arrayFromCollection(querySelectorAll.apply(this, ArraySlice.call(arguments)));
|
|
2363
2355
|
const filtered = ArrayFilter.call(elements,
|
|
2364
|
-
//
|
|
2356
|
+
// Note: we deviate from native shadow here, but are not fixing
|
|
2357
|
+
// due to backwards compat: https://github.com/salesforce/lwc/pull/3103
|
|
2365
2358
|
(elm) => isUndefined(getNodeOwnerKey(elm)) || isGlobalPatchingSkipped(elm));
|
|
2366
2359
|
return createStaticNodeList(filtered);
|
|
2367
2360
|
},
|
|
@@ -2373,7 +2366,8 @@
|
|
|
2373
2366
|
value() {
|
|
2374
2367
|
const elements = arrayFromCollection(getElementsByClassName.apply(this, ArraySlice.call(arguments)));
|
|
2375
2368
|
const filtered = ArrayFilter.call(elements,
|
|
2376
|
-
//
|
|
2369
|
+
// Note: we deviate from native shadow here, but are not fixing
|
|
2370
|
+
// due to backwards compat: https://github.com/salesforce/lwc/pull/3103
|
|
2377
2371
|
(elm) => isUndefined(getNodeOwnerKey(elm)) || isGlobalPatchingSkipped(elm));
|
|
2378
2372
|
return createStaticHTMLCollection(filtered);
|
|
2379
2373
|
},
|
|
@@ -2385,7 +2379,8 @@
|
|
|
2385
2379
|
value() {
|
|
2386
2380
|
const elements = arrayFromCollection(getElementsByTagName.apply(this, ArraySlice.call(arguments)));
|
|
2387
2381
|
const filtered = ArrayFilter.call(elements,
|
|
2388
|
-
//
|
|
2382
|
+
// Note: we deviate from native shadow here, but are not fixing
|
|
2383
|
+
// due to backwards compat: https://github.com/salesforce/lwc/pull/3103
|
|
2389
2384
|
(elm) => isUndefined(getNodeOwnerKey(elm)) || isGlobalPatchingSkipped(elm));
|
|
2390
2385
|
return createStaticHTMLCollection(filtered);
|
|
2391
2386
|
},
|
|
@@ -2397,7 +2392,8 @@
|
|
|
2397
2392
|
value() {
|
|
2398
2393
|
const elements = arrayFromCollection(getElementsByTagNameNS.apply(this, ArraySlice.call(arguments)));
|
|
2399
2394
|
const filtered = ArrayFilter.call(elements,
|
|
2400
|
-
//
|
|
2395
|
+
// Note: we deviate from native shadow here, but are not fixing
|
|
2396
|
+
// due to backwards compat: https://github.com/salesforce/lwc/pull/3103
|
|
2401
2397
|
(elm) => isUndefined(getNodeOwnerKey(elm)) || isGlobalPatchingSkipped(elm));
|
|
2402
2398
|
return createStaticHTMLCollection(filtered);
|
|
2403
2399
|
},
|
|
@@ -2413,7 +2409,8 @@
|
|
|
2413
2409
|
value() {
|
|
2414
2410
|
const elements = arrayFromCollection(getElementsByName.apply(this, ArraySlice.call(arguments)));
|
|
2415
2411
|
const filtered = ArrayFilter.call(elements,
|
|
2416
|
-
//
|
|
2412
|
+
// Note: we deviate from native shadow here, but are not fixing
|
|
2413
|
+
// due to backwards compat: https://github.com/salesforce/lwc/pull/3103
|
|
2417
2414
|
(elm) => isUndefined(getNodeOwnerKey(elm)) || isGlobalPatchingSkipped(elm));
|
|
2418
2415
|
return createStaticNodeList(filtered);
|
|
2419
2416
|
},
|
|
@@ -3512,7 +3509,8 @@
|
|
|
3512
3509
|
else if (context instanceof HTMLBodyElement) {
|
|
3513
3510
|
// `context` is document.body which is already patched.
|
|
3514
3511
|
filtered = ArrayFilter.call(unfilteredNodes,
|
|
3515
|
-
//
|
|
3512
|
+
// Note: we deviate from native shadow here, but are not fixing
|
|
3513
|
+
// due to backwards compat: https://github.com/salesforce/lwc/pull/3103
|
|
3516
3514
|
(elm) => isUndefined(getNodeOwnerKey(elm)) || isGlobalPatchingSkipped(context));
|
|
3517
3515
|
}
|
|
3518
3516
|
else {
|
|
@@ -3529,247 +3527,233 @@
|
|
|
3529
3527
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
3530
3528
|
*/
|
|
3531
3529
|
function innerHTMLGetterPatched() {
|
|
3532
|
-
|
|
3533
|
-
|
|
3534
|
-
|
|
3535
|
-
|
|
3536
|
-
|
|
3537
|
-
|
|
3530
|
+
const childNodes = getInternalChildNodes(this);
|
|
3531
|
+
let innerHTML = '';
|
|
3532
|
+
for (let i = 0, len = childNodes.length; i < len; i += 1) {
|
|
3533
|
+
innerHTML += getOuterHTML(childNodes[i]);
|
|
3534
|
+
}
|
|
3535
|
+
return innerHTML;
|
|
3538
3536
|
}
|
|
3539
3537
|
function outerHTMLGetterPatched() {
|
|
3540
|
-
|
|
3538
|
+
return getOuterHTML(this);
|
|
3541
3539
|
}
|
|
3542
3540
|
function attachShadowPatched(options) {
|
|
3543
|
-
|
|
3544
|
-
|
|
3545
|
-
|
|
3546
|
-
|
|
3547
|
-
|
|
3541
|
+
// To retain native behavior of the API, provide synthetic shadowRoot only when specified
|
|
3542
|
+
if (options[KEY__SYNTHETIC_MODE]) {
|
|
3543
|
+
return attachShadow(this, options);
|
|
3544
|
+
}
|
|
3545
|
+
return attachShadow$1.call(this, options);
|
|
3548
3546
|
}
|
|
3549
3547
|
function shadowRootGetterPatched() {
|
|
3550
|
-
|
|
3551
|
-
|
|
3552
|
-
|
|
3553
|
-
|
|
3548
|
+
if (isSyntheticShadowHost(this)) {
|
|
3549
|
+
const shadow = getShadowRoot(this);
|
|
3550
|
+
if (shadow.mode === 'open') {
|
|
3551
|
+
return shadow;
|
|
3552
|
+
}
|
|
3554
3553
|
}
|
|
3555
|
-
|
|
3556
|
-
return shadowRootGetter.call(this);
|
|
3554
|
+
return shadowRootGetter.call(this);
|
|
3557
3555
|
}
|
|
3558
3556
|
function childrenGetterPatched() {
|
|
3559
|
-
|
|
3560
|
-
|
|
3561
|
-
|
|
3557
|
+
const owner = getNodeOwner(this);
|
|
3558
|
+
const childNodes = isNull(owner) ? [] : getAllMatches(owner, getFilteredChildNodes(this));
|
|
3559
|
+
return createStaticHTMLCollection(ArrayFilter.call(childNodes, (node) => node instanceof Element));
|
|
3562
3560
|
}
|
|
3563
3561
|
function childElementCountGetterPatched() {
|
|
3564
|
-
|
|
3562
|
+
return this.children.length;
|
|
3565
3563
|
}
|
|
3566
3564
|
function firstElementChildGetterPatched() {
|
|
3567
|
-
|
|
3565
|
+
return this.children[0] || null;
|
|
3568
3566
|
}
|
|
3569
3567
|
function lastElementChildGetterPatched() {
|
|
3570
|
-
|
|
3571
|
-
children
|
|
3572
|
-
} = this;
|
|
3573
|
-
return children.item(children.length - 1) || null;
|
|
3568
|
+
const { children } = this;
|
|
3569
|
+
return children.item(children.length - 1) || null;
|
|
3574
3570
|
}
|
|
3575
3571
|
// Non-deep-traversing patches: this descriptor map includes all descriptors that
|
|
3576
3572
|
// do not five access to nodes beyond the immediate children.
|
|
3577
3573
|
defineProperties(Element.prototype, {
|
|
3578
|
-
|
|
3579
|
-
|
|
3580
|
-
|
|
3581
|
-
|
|
3582
|
-
|
|
3583
|
-
|
|
3584
|
-
|
|
3585
|
-
|
|
3586
|
-
|
|
3587
|
-
|
|
3588
|
-
|
|
3589
|
-
|
|
3590
|
-
|
|
3574
|
+
innerHTML: {
|
|
3575
|
+
get() {
|
|
3576
|
+
// Note: we deviate from native shadow here, but are not fixing
|
|
3577
|
+
// due to backwards compat: https://github.com/salesforce/lwc/pull/3103
|
|
3578
|
+
if (isNodeShadowed(this) || isSyntheticShadowHost(this)) {
|
|
3579
|
+
return innerHTMLGetterPatched.call(this);
|
|
3580
|
+
}
|
|
3581
|
+
return innerHTMLGetter.call(this);
|
|
3582
|
+
},
|
|
3583
|
+
set(v) {
|
|
3584
|
+
innerHTMLSetter.call(this, v);
|
|
3585
|
+
},
|
|
3586
|
+
enumerable: true,
|
|
3587
|
+
configurable: true,
|
|
3591
3588
|
},
|
|
3592
|
-
|
|
3593
|
-
|
|
3589
|
+
outerHTML: {
|
|
3590
|
+
get() {
|
|
3591
|
+
// Note: we deviate from native shadow here, but are not fixing
|
|
3592
|
+
// due to backwards compat: https://github.com/salesforce/lwc/pull/3103
|
|
3593
|
+
if (isNodeShadowed(this) || isSyntheticShadowHost(this)) {
|
|
3594
|
+
return outerHTMLGetterPatched.call(this);
|
|
3595
|
+
}
|
|
3596
|
+
return outerHTMLGetter.call(this);
|
|
3597
|
+
},
|
|
3598
|
+
set(v) {
|
|
3599
|
+
outerHTMLSetter.call(this, v);
|
|
3600
|
+
},
|
|
3601
|
+
enumerable: true,
|
|
3602
|
+
configurable: true,
|
|
3594
3603
|
},
|
|
3595
|
-
|
|
3596
|
-
|
|
3597
|
-
|
|
3598
|
-
|
|
3599
|
-
|
|
3600
|
-
if (!lwcRuntimeFlags.ENABLE_ELEMENT_PATCH) {
|
|
3601
|
-
if (isNodeShadowed(this) || isSyntheticShadowHost(this)) {
|
|
3602
|
-
return outerHTMLGetterPatched.call(this);
|
|
3603
|
-
}
|
|
3604
|
-
return outerHTMLGetter.call(this);
|
|
3605
|
-
}
|
|
3606
|
-
// TODO [#1222]: remove global bypass
|
|
3607
|
-
if (isGlobalPatchingSkipped(this)) {
|
|
3608
|
-
return outerHTMLGetter.call(this);
|
|
3609
|
-
}
|
|
3610
|
-
return outerHTMLGetterPatched.call(this);
|
|
3604
|
+
attachShadow: {
|
|
3605
|
+
value: attachShadowPatched,
|
|
3606
|
+
enumerable: true,
|
|
3607
|
+
writable: true,
|
|
3608
|
+
configurable: true,
|
|
3611
3609
|
},
|
|
3612
|
-
|
|
3613
|
-
|
|
3610
|
+
shadowRoot: {
|
|
3611
|
+
get: shadowRootGetterPatched,
|
|
3612
|
+
enumerable: true,
|
|
3613
|
+
configurable: true,
|
|
3614
3614
|
},
|
|
3615
|
-
|
|
3616
|
-
|
|
3617
|
-
|
|
3618
|
-
|
|
3619
|
-
|
|
3620
|
-
|
|
3621
|
-
|
|
3622
|
-
|
|
3623
|
-
|
|
3624
|
-
|
|
3625
|
-
get: shadowRootGetterPatched,
|
|
3626
|
-
enumerable: true,
|
|
3627
|
-
configurable: true
|
|
3628
|
-
},
|
|
3629
|
-
// patched in HTMLElement if exists (IE11 is the one off here)
|
|
3630
|
-
children: {
|
|
3631
|
-
get() {
|
|
3632
|
-
if (hasMountedChildren(this)) {
|
|
3633
|
-
return childrenGetterPatched.call(this);
|
|
3634
|
-
}
|
|
3635
|
-
return childrenGetter.call(this);
|
|
3615
|
+
// patched in HTMLElement if exists (IE11 is the one off here)
|
|
3616
|
+
children: {
|
|
3617
|
+
get() {
|
|
3618
|
+
if (hasMountedChildren(this)) {
|
|
3619
|
+
return childrenGetterPatched.call(this);
|
|
3620
|
+
}
|
|
3621
|
+
return childrenGetter.call(this);
|
|
3622
|
+
},
|
|
3623
|
+
enumerable: true,
|
|
3624
|
+
configurable: true,
|
|
3636
3625
|
},
|
|
3637
|
-
|
|
3638
|
-
|
|
3639
|
-
|
|
3640
|
-
|
|
3641
|
-
|
|
3642
|
-
|
|
3643
|
-
|
|
3644
|
-
|
|
3645
|
-
|
|
3626
|
+
childElementCount: {
|
|
3627
|
+
get() {
|
|
3628
|
+
if (hasMountedChildren(this)) {
|
|
3629
|
+
return childElementCountGetterPatched.call(this);
|
|
3630
|
+
}
|
|
3631
|
+
return childElementCountGetter.call(this);
|
|
3632
|
+
},
|
|
3633
|
+
enumerable: true,
|
|
3634
|
+
configurable: true,
|
|
3646
3635
|
},
|
|
3647
|
-
|
|
3648
|
-
|
|
3649
|
-
|
|
3650
|
-
|
|
3651
|
-
|
|
3652
|
-
|
|
3653
|
-
|
|
3654
|
-
|
|
3655
|
-
|
|
3636
|
+
firstElementChild: {
|
|
3637
|
+
get() {
|
|
3638
|
+
if (hasMountedChildren(this)) {
|
|
3639
|
+
return firstElementChildGetterPatched.call(this);
|
|
3640
|
+
}
|
|
3641
|
+
return firstElementChildGetter.call(this);
|
|
3642
|
+
},
|
|
3643
|
+
enumerable: true,
|
|
3644
|
+
configurable: true,
|
|
3656
3645
|
},
|
|
3657
|
-
|
|
3658
|
-
|
|
3659
|
-
|
|
3660
|
-
|
|
3661
|
-
|
|
3662
|
-
|
|
3663
|
-
|
|
3664
|
-
|
|
3665
|
-
|
|
3646
|
+
lastElementChild: {
|
|
3647
|
+
get() {
|
|
3648
|
+
if (hasMountedChildren(this)) {
|
|
3649
|
+
return lastElementChildGetterPatched.call(this);
|
|
3650
|
+
}
|
|
3651
|
+
return lastElementChildGetter.call(this);
|
|
3652
|
+
},
|
|
3653
|
+
enumerable: true,
|
|
3654
|
+
configurable: true,
|
|
3655
|
+
},
|
|
3656
|
+
assignedSlot: {
|
|
3657
|
+
get: assignedSlotGetterPatched,
|
|
3658
|
+
enumerable: true,
|
|
3659
|
+
configurable: true,
|
|
3666
3660
|
},
|
|
3667
|
-
enumerable: true,
|
|
3668
|
-
configurable: true
|
|
3669
|
-
},
|
|
3670
|
-
assignedSlot: {
|
|
3671
|
-
get: assignedSlotGetterPatched,
|
|
3672
|
-
enumerable: true,
|
|
3673
|
-
configurable: true
|
|
3674
|
-
}
|
|
3675
3661
|
});
|
|
3676
3662
|
// IE11 extra patches for wrong prototypes
|
|
3677
3663
|
if (hasOwnProperty.call(HTMLElement.prototype, 'innerHTML')) {
|
|
3678
|
-
|
|
3664
|
+
defineProperty(HTMLElement.prototype, 'innerHTML', getOwnPropertyDescriptor(Element.prototype, 'innerHTML'));
|
|
3679
3665
|
}
|
|
3680
3666
|
if (hasOwnProperty.call(HTMLElement.prototype, 'outerHTML')) {
|
|
3681
|
-
|
|
3667
|
+
defineProperty(HTMLElement.prototype, 'outerHTML', getOwnPropertyDescriptor(Element.prototype, 'outerHTML'));
|
|
3682
3668
|
}
|
|
3683
3669
|
if (hasOwnProperty.call(HTMLElement.prototype, 'children')) {
|
|
3684
|
-
|
|
3670
|
+
defineProperty(HTMLElement.prototype, 'children', getOwnPropertyDescriptor(Element.prototype, 'children'));
|
|
3685
3671
|
}
|
|
3686
3672
|
// Deep-traversing patches from this point on:
|
|
3687
3673
|
function querySelectorPatched() {
|
|
3688
|
-
|
|
3689
|
-
|
|
3690
|
-
|
|
3691
|
-
|
|
3692
|
-
|
|
3693
|
-
|
|
3694
|
-
|
|
3695
|
-
|
|
3696
|
-
|
|
3697
|
-
|
|
3698
|
-
|
|
3699
|
-
|
|
3674
|
+
const nodeList = arrayFromCollection(querySelectorAll$1.apply(this, ArraySlice.call(arguments)));
|
|
3675
|
+
if (isSyntheticShadowHost(this)) {
|
|
3676
|
+
// element with shadowRoot attached
|
|
3677
|
+
const owner = getNodeOwner(this);
|
|
3678
|
+
if (!isUndefined(getNodeKey(this))) {
|
|
3679
|
+
// it is a custom element, and we should then filter by slotted elements
|
|
3680
|
+
return getFirstSlottedMatch(this, nodeList);
|
|
3681
|
+
}
|
|
3682
|
+
else if (isNull(owner)) {
|
|
3683
|
+
return null;
|
|
3684
|
+
}
|
|
3685
|
+
else {
|
|
3686
|
+
// regular element, we should then filter by ownership
|
|
3687
|
+
return getFirstMatch(owner, nodeList);
|
|
3688
|
+
}
|
|
3700
3689
|
}
|
|
3701
|
-
|
|
3702
|
-
|
|
3703
|
-
|
|
3704
|
-
|
|
3705
|
-
|
|
3706
|
-
|
|
3707
|
-
|
|
3708
|
-
|
|
3709
|
-
|
|
3710
|
-
|
|
3711
|
-
|
|
3712
|
-
|
|
3713
|
-
|
|
3714
|
-
|
|
3715
|
-
const contextNearestOwnerKey = getNodeNearestOwnerKey(this);
|
|
3716
|
-
const elm = ArrayFind.call(nodeList, elm => getNodeNearestOwnerKey(elm) === contextNearestOwnerKey);
|
|
3717
|
-
return isUndefined(elm) ? null : elm;
|
|
3690
|
+
else if (isNodeShadowed(this)) {
|
|
3691
|
+
// element inside a shadowRoot
|
|
3692
|
+
const ownerKey = getNodeOwnerKey(this);
|
|
3693
|
+
if (!isUndefined(ownerKey)) {
|
|
3694
|
+
// `this` is handled by lwc, using getNodeNearestOwnerKey to include manually inserted elements in the same shadow.
|
|
3695
|
+
const elm = ArrayFind.call(nodeList, (elm) => getNodeNearestOwnerKey(elm) === ownerKey);
|
|
3696
|
+
return isUndefined(elm) ? null : elm;
|
|
3697
|
+
}
|
|
3698
|
+
else {
|
|
3699
|
+
// Note: we deviate from native shadow here, but are not fixing
|
|
3700
|
+
// due to backwards compat: https://github.com/salesforce/lwc/pull/3103
|
|
3701
|
+
// `this` is a manually inserted element inside a shadowRoot, return the first element.
|
|
3702
|
+
return nodeList.length === 0 ? null : nodeList[0];
|
|
3703
|
+
}
|
|
3718
3704
|
}
|
|
3719
|
-
|
|
3720
|
-
|
|
3721
|
-
|
|
3722
|
-
|
|
3705
|
+
else {
|
|
3706
|
+
if (!(this instanceof HTMLBodyElement)) {
|
|
3707
|
+
const elm = nodeList[0];
|
|
3708
|
+
return isUndefined(elm) ? null : elm;
|
|
3709
|
+
}
|
|
3710
|
+
// element belonging to the document
|
|
3711
|
+
const elm = ArrayFind.call(nodeList, (elm) => isUndefined(getNodeOwnerKey(elm)) || isGlobalPatchingSkipped(this));
|
|
3723
3712
|
return isUndefined(elm) ? null : elm;
|
|
3724
|
-
}
|
|
3725
3713
|
}
|
|
3726
|
-
// element belonging to the document
|
|
3727
|
-
const elm = ArrayFind.call(nodeList,
|
|
3728
|
-
// TODO [#1222]: remove global bypass
|
|
3729
|
-
elm => isUndefined(getNodeOwnerKey(elm)) || isGlobalPatchingSkipped(this));
|
|
3730
|
-
return isUndefined(elm) ? null : elm;
|
|
3731
|
-
}
|
|
3732
3714
|
}
|
|
3733
|
-
function getFilteredArrayOfNodes(context, unfilteredNodes
|
|
3734
|
-
|
|
3735
|
-
|
|
3736
|
-
|
|
3737
|
-
|
|
3738
|
-
|
|
3739
|
-
|
|
3740
|
-
|
|
3741
|
-
|
|
3742
|
-
|
|
3743
|
-
|
|
3744
|
-
|
|
3745
|
-
|
|
3715
|
+
function getFilteredArrayOfNodes(context, unfilteredNodes) {
|
|
3716
|
+
let filtered;
|
|
3717
|
+
if (isSyntheticShadowHost(context)) {
|
|
3718
|
+
// element with shadowRoot attached
|
|
3719
|
+
const owner = getNodeOwner(context);
|
|
3720
|
+
if (!isUndefined(getNodeKey(context))) {
|
|
3721
|
+
// it is a custom element, and we should then filter by slotted elements
|
|
3722
|
+
filtered = getAllSlottedMatches(context, unfilteredNodes);
|
|
3723
|
+
}
|
|
3724
|
+
else if (isNull(owner)) {
|
|
3725
|
+
filtered = [];
|
|
3726
|
+
}
|
|
3727
|
+
else {
|
|
3728
|
+
// regular element, we should then filter by ownership
|
|
3729
|
+
filtered = getAllMatches(owner, unfilteredNodes);
|
|
3730
|
+
}
|
|
3746
3731
|
}
|
|
3747
|
-
|
|
3748
|
-
|
|
3749
|
-
|
|
3750
|
-
|
|
3751
|
-
|
|
3752
|
-
|
|
3753
|
-
|
|
3754
|
-
|
|
3755
|
-
|
|
3756
|
-
|
|
3757
|
-
|
|
3758
|
-
|
|
3759
|
-
|
|
3732
|
+
else if (isNodeShadowed(context)) {
|
|
3733
|
+
// element inside a shadowRoot
|
|
3734
|
+
const ownerKey = getNodeOwnerKey(context);
|
|
3735
|
+
if (!isUndefined(ownerKey)) {
|
|
3736
|
+
// context is handled by lwc, using getNodeNearestOwnerKey to include manually inserted elements in the same shadow.
|
|
3737
|
+
filtered = ArrayFilter.call(unfilteredNodes, (elm) => getNodeNearestOwnerKey(elm) === ownerKey);
|
|
3738
|
+
}
|
|
3739
|
+
else {
|
|
3740
|
+
// Note: we deviate from native shadow here, but are not fixing
|
|
3741
|
+
// due to backwards compat: https://github.com/salesforce/lwc/pull/3103
|
|
3742
|
+
// context is manually inserted without lwc:dom-manual, return everything
|
|
3743
|
+
filtered = ArraySlice.call(unfilteredNodes);
|
|
3744
|
+
}
|
|
3760
3745
|
}
|
|
3761
|
-
|
|
3762
|
-
|
|
3763
|
-
|
|
3764
|
-
|
|
3765
|
-
|
|
3766
|
-
|
|
3767
|
-
|
|
3768
|
-
|
|
3769
|
-
|
|
3746
|
+
else {
|
|
3747
|
+
if (context instanceof HTMLBodyElement) {
|
|
3748
|
+
// `context` is document.body or element belonging to the document with the patch enabled
|
|
3749
|
+
filtered = ArrayFilter.call(unfilteredNodes, (elm) => isUndefined(getNodeOwnerKey(elm)) || isGlobalPatchingSkipped(context));
|
|
3750
|
+
}
|
|
3751
|
+
else {
|
|
3752
|
+
// `context` is outside the lwc boundary and patch is not enabled.
|
|
3753
|
+
filtered = ArraySlice.call(unfilteredNodes);
|
|
3754
|
+
}
|
|
3770
3755
|
}
|
|
3771
|
-
|
|
3772
|
-
return filtered;
|
|
3756
|
+
return filtered;
|
|
3773
3757
|
}
|
|
3774
3758
|
// The following patched methods hide shadowed elements from global
|
|
3775
3759
|
// traversing mechanisms. They are simplified for performance reasons to
|
|
@@ -3781,263 +3765,66 @@
|
|
|
3781
3765
|
// is not a big problem considering the amount of code that is relying on
|
|
3782
3766
|
// the liveliness of these results are rare.
|
|
3783
3767
|
defineProperties(Element.prototype, {
|
|
3784
|
-
|
|
3785
|
-
|
|
3786
|
-
|
|
3787
|
-
|
|
3788
|
-
|
|
3789
|
-
|
|
3790
|
-
|
|
3791
|
-
|
|
3792
|
-
|
|
3793
|
-
|
|
3794
|
-
|
|
3795
|
-
|
|
3796
|
-
|
|
3797
|
-
|
|
3768
|
+
querySelector: {
|
|
3769
|
+
value: querySelectorPatched,
|
|
3770
|
+
writable: true,
|
|
3771
|
+
enumerable: true,
|
|
3772
|
+
configurable: true,
|
|
3773
|
+
},
|
|
3774
|
+
querySelectorAll: {
|
|
3775
|
+
value() {
|
|
3776
|
+
const nodeList = arrayFromCollection(querySelectorAll$1.apply(this, ArraySlice.call(arguments)));
|
|
3777
|
+
// Note: we deviate from native shadow here, but are not fixing
|
|
3778
|
+
// due to backwards compat: https://github.com/salesforce/lwc/pull/3103
|
|
3779
|
+
const filteredResults = getFilteredArrayOfNodes(this, nodeList);
|
|
3780
|
+
return createStaticNodeList(filteredResults);
|
|
3781
|
+
},
|
|
3782
|
+
writable: true,
|
|
3783
|
+
enumerable: true,
|
|
3784
|
+
configurable: true,
|
|
3798
3785
|
},
|
|
3799
|
-
|
|
3800
|
-
writable: true,
|
|
3801
|
-
enumerable: true,
|
|
3802
|
-
configurable: true
|
|
3803
|
-
}
|
|
3804
3786
|
});
|
|
3805
3787
|
// The following APIs are used directly by Jest internally so we avoid patching them during testing.
|
|
3806
3788
|
{
|
|
3807
|
-
|
|
3808
|
-
|
|
3809
|
-
|
|
3810
|
-
|
|
3811
|
-
|
|
3812
|
-
|
|
3813
|
-
|
|
3814
|
-
|
|
3815
|
-
|
|
3816
|
-
|
|
3817
|
-
|
|
3818
|
-
|
|
3819
|
-
|
|
3820
|
-
|
|
3821
|
-
|
|
3822
|
-
|
|
3823
|
-
|
|
3824
|
-
|
|
3825
|
-
|
|
3826
|
-
|
|
3827
|
-
|
|
3828
|
-
|
|
3829
|
-
|
|
3830
|
-
|
|
3831
|
-
|
|
3832
|
-
|
|
3833
|
-
|
|
3834
|
-
|
|
3835
|
-
|
|
3836
|
-
|
|
3837
|
-
|
|
3838
|
-
|
|
3839
|
-
|
|
3840
|
-
|
|
3841
|
-
|
|
3842
|
-
},
|
|
3843
|
-
writable: true,
|
|
3844
|
-
enumerable: true,
|
|
3845
|
-
configurable: true
|
|
3846
|
-
}
|
|
3847
|
-
});
|
|
3789
|
+
defineProperties(Element.prototype, {
|
|
3790
|
+
getElementsByClassName: {
|
|
3791
|
+
value() {
|
|
3792
|
+
const elements = arrayFromCollection(getElementsByClassName$1.apply(this, ArraySlice.call(arguments)));
|
|
3793
|
+
// Note: we deviate from native shadow here, but are not fixing
|
|
3794
|
+
// due to backwards compat: https://github.com/salesforce/lwc/pull/3103
|
|
3795
|
+
return createStaticHTMLCollection(getNonPatchedFilteredArrayOfNodes(this, elements));
|
|
3796
|
+
},
|
|
3797
|
+
writable: true,
|
|
3798
|
+
enumerable: true,
|
|
3799
|
+
configurable: true,
|
|
3800
|
+
},
|
|
3801
|
+
getElementsByTagName: {
|
|
3802
|
+
value() {
|
|
3803
|
+
const elements = arrayFromCollection(getElementsByTagName$1.apply(this, ArraySlice.call(arguments)));
|
|
3804
|
+
// Note: we deviate from native shadow here, but are not fixing
|
|
3805
|
+
// due to backwards compat: https://github.com/salesforce/lwc/pull/3103
|
|
3806
|
+
return createStaticHTMLCollection(getNonPatchedFilteredArrayOfNodes(this, elements));
|
|
3807
|
+
},
|
|
3808
|
+
writable: true,
|
|
3809
|
+
enumerable: true,
|
|
3810
|
+
configurable: true,
|
|
3811
|
+
},
|
|
3812
|
+
getElementsByTagNameNS: {
|
|
3813
|
+
value() {
|
|
3814
|
+
const elements = arrayFromCollection(getElementsByTagNameNS$1.apply(this, ArraySlice.call(arguments)));
|
|
3815
|
+
// Note: we deviate from native shadow here, but are not fixing
|
|
3816
|
+
// due to backwards compat: https://github.com/salesforce/lwc/pull/3103
|
|
3817
|
+
return createStaticHTMLCollection(getNonPatchedFilteredArrayOfNodes(this, elements));
|
|
3818
|
+
},
|
|
3819
|
+
writable: true,
|
|
3820
|
+
enumerable: true,
|
|
3821
|
+
configurable: true,
|
|
3822
|
+
},
|
|
3823
|
+
});
|
|
3848
3824
|
}
|
|
3849
3825
|
// IE11 extra patches for wrong prototypes
|
|
3850
3826
|
if (hasOwnProperty.call(HTMLElement.prototype, 'getElementsByClassName')) {
|
|
3851
|
-
|
|
3852
|
-
}
|
|
3853
|
-
|
|
3854
|
-
/*
|
|
3855
|
-
* Copyright (c) 2018, salesforce.com, inc.
|
|
3856
|
-
* All rights reserved.
|
|
3857
|
-
* SPDX-License-Identifier: MIT
|
|
3858
|
-
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
3859
|
-
*/
|
|
3860
|
-
function getElementComputedStyle(element) {
|
|
3861
|
-
const win = getOwnerWindow(element);
|
|
3862
|
-
return windowGetComputedStyle.call(win, element);
|
|
3863
|
-
}
|
|
3864
|
-
function getWindowSelection(node) {
|
|
3865
|
-
const win = getOwnerWindow(node);
|
|
3866
|
-
return windowGetSelection.call(win);
|
|
3867
|
-
}
|
|
3868
|
-
function nodeIsBeingRendered(nodeComputedStyle) {
|
|
3869
|
-
return nodeComputedStyle.visibility === 'visible' && nodeComputedStyle.display !== 'none';
|
|
3870
|
-
}
|
|
3871
|
-
function getSelectionState(element) {
|
|
3872
|
-
const win = getOwnerWindow(element);
|
|
3873
|
-
const selection = getWindowSelection(element);
|
|
3874
|
-
if (selection === null) {
|
|
3875
|
-
return null;
|
|
3876
|
-
}
|
|
3877
|
-
const ranges = [];
|
|
3878
|
-
for (let i = 0; i < selection.rangeCount; i++) {
|
|
3879
|
-
ranges.push(selection.getRangeAt(i));
|
|
3880
|
-
}
|
|
3881
|
-
const state = {
|
|
3882
|
-
element,
|
|
3883
|
-
onselect: win.onselect,
|
|
3884
|
-
onselectstart: win.onselectstart,
|
|
3885
|
-
onselectionchange: win.onselectionchange,
|
|
3886
|
-
ranges,
|
|
3887
|
-
};
|
|
3888
|
-
win.onselect = null;
|
|
3889
|
-
win.onselectstart = null;
|
|
3890
|
-
win.onselectionchange = null;
|
|
3891
|
-
return state;
|
|
3892
|
-
}
|
|
3893
|
-
function restoreSelectionState(state) {
|
|
3894
|
-
if (state === null) {
|
|
3895
|
-
return;
|
|
3896
|
-
}
|
|
3897
|
-
const { element, onselect, onselectstart, onselectionchange, ranges } = state;
|
|
3898
|
-
const win = getOwnerWindow(element);
|
|
3899
|
-
const selection = getWindowSelection(element);
|
|
3900
|
-
selection.removeAllRanges();
|
|
3901
|
-
for (let i = 0; i < ranges.length; i++) {
|
|
3902
|
-
selection.addRange(ranges[i]);
|
|
3903
|
-
}
|
|
3904
|
-
win.onselect = onselect;
|
|
3905
|
-
win.onselectstart = onselectstart;
|
|
3906
|
-
win.onselectionchange = onselectionchange;
|
|
3907
|
-
}
|
|
3908
|
-
/**
|
|
3909
|
-
* Gets the "innerText" of a text node using the Selection API
|
|
3910
|
-
*
|
|
3911
|
-
* NOTE: For performance reasons, since this function will be called multiple times while calculating the innerText of
|
|
3912
|
-
* an element, it does not restore the current selection.
|
|
3913
|
-
*/
|
|
3914
|
-
function getTextNodeInnerText(textNode) {
|
|
3915
|
-
const selection = getWindowSelection(textNode);
|
|
3916
|
-
if (selection === null) {
|
|
3917
|
-
return textNode.textContent || '';
|
|
3918
|
-
}
|
|
3919
|
-
const range = document.createRange();
|
|
3920
|
-
range.selectNodeContents(textNode);
|
|
3921
|
-
const domRect = range.getBoundingClientRect();
|
|
3922
|
-
if (domRect.height <= 0 || domRect.width <= 0) {
|
|
3923
|
-
// the text node is not rendered
|
|
3924
|
-
return '';
|
|
3925
|
-
}
|
|
3926
|
-
// Needed to remove non rendered characters from the text node.
|
|
3927
|
-
selection.removeAllRanges();
|
|
3928
|
-
selection.addRange(range);
|
|
3929
|
-
const selectionText = selection.toString();
|
|
3930
|
-
// The textNode is visible, but it may not be selectable. When the text is not selectable,
|
|
3931
|
-
// textContent is the nearest approximation to innerText.
|
|
3932
|
-
return selectionText ? selectionText : textNode.textContent || '';
|
|
3933
|
-
}
|
|
3934
|
-
const nodeIsElement = (node) => node.nodeType === ELEMENT_NODE;
|
|
3935
|
-
const nodeIsText = (node) => node.nodeType === TEXT_NODE;
|
|
3936
|
-
/**
|
|
3937
|
-
* Spec: https://html.spec.whatwg.org/multipage/dom.html#inner-text-collection-steps
|
|
3938
|
-
* One spec implementation: https://github.com/servo/servo/blob/721271dcd3c20db5ca8cf146e2b5907647afb4d6/components/layout/query.rs#L1132
|
|
3939
|
-
*/
|
|
3940
|
-
function innerTextCollectionSteps(node) {
|
|
3941
|
-
const items = [];
|
|
3942
|
-
if (nodeIsElement(node)) {
|
|
3943
|
-
const { tagName } = node;
|
|
3944
|
-
const computedStyle = getElementComputedStyle(node);
|
|
3945
|
-
if (tagName === 'OPTION') {
|
|
3946
|
-
// For options, is hard to get the "rendered" text, let's use the original getter.
|
|
3947
|
-
return [1, innerTextGetter.call(node), 1];
|
|
3948
|
-
}
|
|
3949
|
-
else if (tagName === 'TEXTAREA') {
|
|
3950
|
-
return [];
|
|
3951
|
-
}
|
|
3952
|
-
else {
|
|
3953
|
-
const childNodes = node.childNodes;
|
|
3954
|
-
for (let i = 0, n = childNodes.length; i < n; i++) {
|
|
3955
|
-
ArrayPush.apply(items, innerTextCollectionSteps(childNodes[i]));
|
|
3956
|
-
}
|
|
3957
|
-
}
|
|
3958
|
-
if (!nodeIsBeingRendered(computedStyle)) {
|
|
3959
|
-
if (tagName === 'SELECT' || tagName === 'DATALIST') {
|
|
3960
|
-
// the select is either: .visibility != 'visible' or .display === hidden, therefore this select should
|
|
3961
|
-
// not display any value.
|
|
3962
|
-
return [];
|
|
3963
|
-
}
|
|
3964
|
-
return items;
|
|
3965
|
-
}
|
|
3966
|
-
if (tagName === 'BR') {
|
|
3967
|
-
items.push('\u{000A}' /* line feed */);
|
|
3968
|
-
}
|
|
3969
|
-
const { display } = computedStyle;
|
|
3970
|
-
if (display === 'table-cell') {
|
|
3971
|
-
// omitting case: and node's CSS box is not the last 'table-cell' box of its enclosing 'table-row' box
|
|
3972
|
-
items.push('\u{0009}' /* tab */);
|
|
3973
|
-
}
|
|
3974
|
-
if (display === 'table-row') {
|
|
3975
|
-
// omitting case: and node's CSS box is not the last 'table-row' box of the nearest ancestor 'table' box
|
|
3976
|
-
items.push('\u{000A}' /* line feed */);
|
|
3977
|
-
}
|
|
3978
|
-
if (tagName === 'P') {
|
|
3979
|
-
items.unshift(2);
|
|
3980
|
-
items.push(2);
|
|
3981
|
-
}
|
|
3982
|
-
if (display === 'block' ||
|
|
3983
|
-
display === 'table-caption' ||
|
|
3984
|
-
display === 'flex' ||
|
|
3985
|
-
display === 'table') {
|
|
3986
|
-
items.unshift(1);
|
|
3987
|
-
items.push(1);
|
|
3988
|
-
}
|
|
3989
|
-
}
|
|
3990
|
-
else if (nodeIsText(node)) {
|
|
3991
|
-
items.push(getTextNodeInnerText(node));
|
|
3992
|
-
}
|
|
3993
|
-
return items;
|
|
3994
|
-
}
|
|
3995
|
-
/**
|
|
3996
|
-
* InnerText getter spec: https://html.spec.whatwg.org/multipage/dom.html#the-innertext-idl-attribute
|
|
3997
|
-
*
|
|
3998
|
-
* One spec implementation: https://github.com/servo/servo/blob/721271dcd3c20db5ca8cf146e2b5907647afb4d6/components/layout/query.rs#L1087
|
|
3999
|
-
*/
|
|
4000
|
-
function getInnerText(element) {
|
|
4001
|
-
const thisComputedStyle = getElementComputedStyle(element);
|
|
4002
|
-
if (!nodeIsBeingRendered(thisComputedStyle)) {
|
|
4003
|
-
return getTextContent(element) || '';
|
|
4004
|
-
}
|
|
4005
|
-
const selectionState = getSelectionState(element);
|
|
4006
|
-
const results = [];
|
|
4007
|
-
const childNodes = element.childNodes;
|
|
4008
|
-
for (let i = 0, n = childNodes.length; i < n; i++) {
|
|
4009
|
-
ArrayPush.apply(results, innerTextCollectionSteps(childNodes[i]));
|
|
4010
|
-
}
|
|
4011
|
-
restoreSelectionState(selectionState);
|
|
4012
|
-
let elementInnerText = '';
|
|
4013
|
-
let maxReqLineBreakCount = 0;
|
|
4014
|
-
for (let i = 0, n = results.length; i < n; i++) {
|
|
4015
|
-
const item = results[i];
|
|
4016
|
-
if (typeof item === 'string') {
|
|
4017
|
-
if (maxReqLineBreakCount > 0) {
|
|
4018
|
-
for (let j = 0; j < maxReqLineBreakCount; j++) {
|
|
4019
|
-
elementInnerText += '\u{000A}';
|
|
4020
|
-
}
|
|
4021
|
-
maxReqLineBreakCount = 0;
|
|
4022
|
-
}
|
|
4023
|
-
if (item.length > 0) {
|
|
4024
|
-
elementInnerText += item;
|
|
4025
|
-
}
|
|
4026
|
-
}
|
|
4027
|
-
else {
|
|
4028
|
-
if (elementInnerText.length == 0) {
|
|
4029
|
-
// Remove required line break count at the start.
|
|
4030
|
-
continue;
|
|
4031
|
-
}
|
|
4032
|
-
// Store the count if it's the max of this run,
|
|
4033
|
-
// but it may be ignored if no text item is found afterwards,
|
|
4034
|
-
// which means that these are consecutive line breaks at the end.
|
|
4035
|
-
if (item > maxReqLineBreakCount) {
|
|
4036
|
-
maxReqLineBreakCount = item;
|
|
4037
|
-
}
|
|
4038
|
-
}
|
|
4039
|
-
}
|
|
4040
|
-
return elementInnerText;
|
|
3827
|
+
defineProperty(HTMLElement.prototype, 'getElementsByClassName', getOwnPropertyDescriptor(Element.prototype, 'getElementsByClassName'));
|
|
4041
3828
|
}
|
|
4042
3829
|
|
|
4043
3830
|
/*
|
|
@@ -4378,209 +4165,184 @@
|
|
|
4378
4165
|
* SPDX-License-Identifier: MIT
|
|
4379
4166
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
4380
4167
|
*/
|
|
4381
|
-
const {
|
|
4382
|
-
blur,
|
|
4383
|
-
focus
|
|
4384
|
-
} = HTMLElement.prototype;
|
|
4168
|
+
const { blur, focus } = HTMLElement.prototype;
|
|
4385
4169
|
/**
|
|
4386
4170
|
* This method only applies to elements with a shadow attached to them
|
|
4387
4171
|
*/
|
|
4388
4172
|
function tabIndexGetterPatched() {
|
|
4389
|
-
|
|
4390
|
-
|
|
4391
|
-
|
|
4392
|
-
|
|
4393
|
-
|
|
4394
|
-
|
|
4173
|
+
if (isDelegatingFocus(this) && isFalse(hasAttribute.call(this, 'tabindex'))) {
|
|
4174
|
+
// this covers the case where the default tabindex should be 0 because the
|
|
4175
|
+
// custom element is delegating its focus
|
|
4176
|
+
return 0;
|
|
4177
|
+
}
|
|
4178
|
+
return tabIndexGetter.call(this);
|
|
4395
4179
|
}
|
|
4396
4180
|
/**
|
|
4397
4181
|
* This method only applies to elements with a shadow attached to them
|
|
4398
4182
|
*/
|
|
4399
4183
|
function tabIndexSetterPatched(value) {
|
|
4400
|
-
|
|
4401
|
-
|
|
4402
|
-
|
|
4403
|
-
|
|
4404
|
-
|
|
4405
|
-
|
|
4406
|
-
|
|
4407
|
-
|
|
4408
|
-
|
|
4409
|
-
|
|
4410
|
-
|
|
4411
|
-
|
|
4412
|
-
|
|
4413
|
-
|
|
4414
|
-
|
|
4415
|
-
|
|
4416
|
-
|
|
4417
|
-
|
|
4418
|
-
|
|
4419
|
-
|
|
4420
|
-
|
|
4421
|
-
|
|
4422
|
-
|
|
4423
|
-
|
|
4424
|
-
|
|
4184
|
+
// This tabIndex setter might be confusing unless it is understood that HTML
|
|
4185
|
+
// elements have default tabIndex property values. Natively focusable elements have
|
|
4186
|
+
// a default tabIndex value of 0 and all other elements have a default tabIndex
|
|
4187
|
+
// value of -1. For example, the tabIndex property value is -1 for both <x-foo> and
|
|
4188
|
+
// <x-foo tabindex="-1">, but our delegatesFocus polyfill should only kick in for
|
|
4189
|
+
// the latter case when the value of the tabindex attribute is -1.
|
|
4190
|
+
const delegatesFocus = isDelegatingFocus(this);
|
|
4191
|
+
// Record the state of things before invoking component setter.
|
|
4192
|
+
const prevValue = tabIndexGetter.call(this);
|
|
4193
|
+
const prevHasAttr = hasAttribute.call(this, 'tabindex');
|
|
4194
|
+
tabIndexSetter.call(this, value);
|
|
4195
|
+
// Record the state of things after invoking component setter.
|
|
4196
|
+
const currValue = tabIndexGetter.call(this);
|
|
4197
|
+
const currHasAttr = hasAttribute.call(this, 'tabindex');
|
|
4198
|
+
const didValueChange = prevValue !== currValue;
|
|
4199
|
+
// If the tabindex attribute is initially rendered, we can assume that this setter has
|
|
4200
|
+
// previously executed and a listener has been added. We must remove that listener if
|
|
4201
|
+
// the tabIndex property value has changed or if the component no longer renders a
|
|
4202
|
+
// tabindex attribute.
|
|
4203
|
+
if (prevHasAttr && (didValueChange || isFalse(currHasAttr))) {
|
|
4204
|
+
if (prevValue === -1) {
|
|
4205
|
+
ignoreFocusIn(this);
|
|
4206
|
+
}
|
|
4207
|
+
if (prevValue === 0 && delegatesFocus) {
|
|
4208
|
+
ignoreFocus(this);
|
|
4209
|
+
}
|
|
4210
|
+
}
|
|
4211
|
+
// If a tabindex attribute was not rendered after invoking its setter, it means the
|
|
4212
|
+
// component is taking control. Do nothing.
|
|
4213
|
+
if (isFalse(currHasAttr)) {
|
|
4214
|
+
return;
|
|
4215
|
+
}
|
|
4216
|
+
// If the tabindex attribute is initially rendered, we can assume that this setter has
|
|
4217
|
+
// previously executed and a listener has been added. If the tabindex attribute is still
|
|
4218
|
+
// rendered after invoking the setter AND the tabIndex property value has not changed,
|
|
4219
|
+
// we don't need to do any work.
|
|
4220
|
+
if (prevHasAttr && currHasAttr && isFalse(didValueChange)) {
|
|
4221
|
+
return;
|
|
4222
|
+
}
|
|
4223
|
+
// At this point we know that a tabindex attribute was rendered after invoking the
|
|
4224
|
+
// setter and that either:
|
|
4225
|
+
// 1) This is the first time this setter is being invoked.
|
|
4226
|
+
// 2) This is not the first time this setter is being invoked and the value is changing.
|
|
4227
|
+
// We need to add the appropriate listeners in either case.
|
|
4228
|
+
if (currValue === -1) {
|
|
4229
|
+
// Add the magic to skip the shadow tree
|
|
4230
|
+
handleFocusIn(this);
|
|
4231
|
+
}
|
|
4232
|
+
if (currValue === 0 && delegatesFocus) {
|
|
4233
|
+
// Add the magic to skip the host element
|
|
4234
|
+
handleFocus(this);
|
|
4425
4235
|
}
|
|
4426
|
-
}
|
|
4427
|
-
// If a tabindex attribute was not rendered after invoking its setter, it means the
|
|
4428
|
-
// component is taking control. Do nothing.
|
|
4429
|
-
if (isFalse(currHasAttr)) {
|
|
4430
|
-
return;
|
|
4431
|
-
}
|
|
4432
|
-
// If the tabindex attribute is initially rendered, we can assume that this setter has
|
|
4433
|
-
// previously executed and a listener has been added. If the tabindex attribute is still
|
|
4434
|
-
// rendered after invoking the setter AND the tabIndex property value has not changed,
|
|
4435
|
-
// we don't need to do any work.
|
|
4436
|
-
if (prevHasAttr && currHasAttr && isFalse(didValueChange)) {
|
|
4437
|
-
return;
|
|
4438
|
-
}
|
|
4439
|
-
// At this point we know that a tabindex attribute was rendered after invoking the
|
|
4440
|
-
// setter and that either:
|
|
4441
|
-
// 1) This is the first time this setter is being invoked.
|
|
4442
|
-
// 2) This is not the first time this setter is being invoked and the value is changing.
|
|
4443
|
-
// We need to add the appropriate listeners in either case.
|
|
4444
|
-
if (currValue === -1) {
|
|
4445
|
-
// Add the magic to skip the shadow tree
|
|
4446
|
-
handleFocusIn(this);
|
|
4447
|
-
}
|
|
4448
|
-
if (currValue === 0 && delegatesFocus) {
|
|
4449
|
-
// Add the magic to skip the host element
|
|
4450
|
-
handleFocus(this);
|
|
4451
|
-
}
|
|
4452
4236
|
}
|
|
4453
4237
|
/**
|
|
4454
4238
|
* This method only applies to elements with a shadow attached to them
|
|
4455
4239
|
*/
|
|
4456
4240
|
function blurPatched() {
|
|
4457
|
-
|
|
4458
|
-
|
|
4459
|
-
|
|
4460
|
-
|
|
4461
|
-
|
|
4462
|
-
|
|
4241
|
+
if (isDelegatingFocus(this)) {
|
|
4242
|
+
const currentActiveElement = getActiveElement(this);
|
|
4243
|
+
if (!isNull(currentActiveElement)) {
|
|
4244
|
+
// if there is an active element, blur it (intentionally using the dot notation in case the user defines the blur routine)
|
|
4245
|
+
currentActiveElement.blur();
|
|
4246
|
+
return;
|
|
4247
|
+
}
|
|
4463
4248
|
}
|
|
4464
|
-
|
|
4465
|
-
return blur.call(this);
|
|
4249
|
+
return blur.call(this);
|
|
4466
4250
|
}
|
|
4467
4251
|
function focusPatched() {
|
|
4468
|
-
|
|
4469
|
-
|
|
4470
|
-
|
|
4471
|
-
|
|
4472
|
-
|
|
4473
|
-
|
|
4474
|
-
|
|
4475
|
-
|
|
4476
|
-
|
|
4477
|
-
|
|
4478
|
-
|
|
4479
|
-
|
|
4480
|
-
|
|
4481
|
-
|
|
4482
|
-
|
|
4483
|
-
|
|
4484
|
-
|
|
4252
|
+
// Save enabled state
|
|
4253
|
+
const originallyEnabled = isKeyboardFocusNavigationRoutineEnabled();
|
|
4254
|
+
// Change state by disabling if originally enabled
|
|
4255
|
+
if (originallyEnabled) {
|
|
4256
|
+
disableKeyboardFocusNavigationRoutines();
|
|
4257
|
+
}
|
|
4258
|
+
if (isSyntheticShadowHost(this) && isDelegatingFocus(this)) {
|
|
4259
|
+
hostElementFocus.call(this);
|
|
4260
|
+
return;
|
|
4261
|
+
}
|
|
4262
|
+
// Typescript does not like it when you treat the `arguments` object as an array
|
|
4263
|
+
// @ts-ignore type-mismatch
|
|
4264
|
+
focus.apply(this, arguments);
|
|
4265
|
+
// Restore state by enabling if originally enabled
|
|
4266
|
+
if (originallyEnabled) {
|
|
4267
|
+
enableKeyboardFocusNavigationRoutines();
|
|
4268
|
+
}
|
|
4485
4269
|
}
|
|
4486
4270
|
// Non-deep-traversing patches: this descriptor map includes all descriptors that
|
|
4487
4271
|
// do not five access to nodes beyond the immediate children.
|
|
4488
4272
|
defineProperties(HTMLElement.prototype, {
|
|
4489
|
-
|
|
4490
|
-
|
|
4491
|
-
|
|
4492
|
-
|
|
4493
|
-
|
|
4494
|
-
|
|
4495
|
-
|
|
4496
|
-
|
|
4497
|
-
|
|
4498
|
-
|
|
4499
|
-
|
|
4500
|
-
|
|
4273
|
+
tabIndex: {
|
|
4274
|
+
get() {
|
|
4275
|
+
if (isSyntheticShadowHost(this)) {
|
|
4276
|
+
return tabIndexGetterPatched.call(this);
|
|
4277
|
+
}
|
|
4278
|
+
return tabIndexGetter.call(this);
|
|
4279
|
+
},
|
|
4280
|
+
set(v) {
|
|
4281
|
+
if (isSyntheticShadowHost(this)) {
|
|
4282
|
+
return tabIndexSetterPatched.call(this, v);
|
|
4283
|
+
}
|
|
4284
|
+
return tabIndexSetter.call(this, v);
|
|
4285
|
+
},
|
|
4286
|
+
enumerable: true,
|
|
4287
|
+
configurable: true,
|
|
4501
4288
|
},
|
|
4502
|
-
|
|
4503
|
-
|
|
4504
|
-
|
|
4505
|
-
|
|
4506
|
-
|
|
4507
|
-
|
|
4508
|
-
|
|
4509
|
-
|
|
4510
|
-
|
|
4289
|
+
blur: {
|
|
4290
|
+
value() {
|
|
4291
|
+
if (isSyntheticShadowHost(this)) {
|
|
4292
|
+
return blurPatched.call(this);
|
|
4293
|
+
}
|
|
4294
|
+
blur.call(this);
|
|
4295
|
+
},
|
|
4296
|
+
enumerable: true,
|
|
4297
|
+
writable: true,
|
|
4298
|
+
configurable: true,
|
|
4511
4299
|
},
|
|
4512
|
-
|
|
4513
|
-
|
|
4514
|
-
|
|
4515
|
-
|
|
4516
|
-
|
|
4517
|
-
|
|
4518
|
-
|
|
4519
|
-
|
|
4520
|
-
|
|
4300
|
+
focus: {
|
|
4301
|
+
value() {
|
|
4302
|
+
// Typescript does not like it when you treat the `arguments` object as an array
|
|
4303
|
+
// @ts-ignore type-mismatch
|
|
4304
|
+
focusPatched.apply(this, arguments);
|
|
4305
|
+
},
|
|
4306
|
+
enumerable: true,
|
|
4307
|
+
writable: true,
|
|
4308
|
+
configurable: true,
|
|
4521
4309
|
},
|
|
4522
|
-
enumerable: true,
|
|
4523
|
-
writable: true,
|
|
4524
|
-
configurable: true
|
|
4525
|
-
}
|
|
4526
4310
|
});
|
|
4527
4311
|
// Note: In JSDOM innerText is not implemented: https://github.com/jsdom/jsdom/issues/1245
|
|
4528
4312
|
if (innerTextGetter !== null && innerTextSetter !== null) {
|
|
4529
|
-
|
|
4530
|
-
|
|
4531
|
-
|
|
4532
|
-
|
|
4533
|
-
|
|
4534
|
-
|
|
4535
|
-
|
|
4536
|
-
|
|
4537
|
-
}
|
|
4538
|
-
|
|
4539
|
-
|
|
4540
|
-
|
|
4541
|
-
if (isGlobalPatchingSkipped(this)) {
|
|
4542
|
-
return innerTextGetter.call(this);
|
|
4543
|
-
}
|
|
4544
|
-
return getInnerText(this);
|
|
4545
|
-
},
|
|
4546
|
-
set(v) {
|
|
4547
|
-
innerTextSetter.call(this, v);
|
|
4548
|
-
},
|
|
4549
|
-
enumerable: true,
|
|
4550
|
-
configurable: true
|
|
4551
|
-
});
|
|
4313
|
+
defineProperty(HTMLElement.prototype, 'innerText', {
|
|
4314
|
+
get() {
|
|
4315
|
+
// Note: we deviate from native shadow here, but are not fixing
|
|
4316
|
+
// due to backwards compat: https://github.com/salesforce/lwc/pull/3103
|
|
4317
|
+
return innerTextGetter.call(this);
|
|
4318
|
+
},
|
|
4319
|
+
set(v) {
|
|
4320
|
+
innerTextSetter.call(this, v);
|
|
4321
|
+
},
|
|
4322
|
+
enumerable: true,
|
|
4323
|
+
configurable: true,
|
|
4324
|
+
});
|
|
4552
4325
|
}
|
|
4553
4326
|
// Note: Firefox does not have outerText, https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/outerText
|
|
4554
4327
|
if (outerTextGetter !== null && outerTextSetter !== null) {
|
|
4555
|
-
|
|
4556
|
-
|
|
4557
|
-
|
|
4558
|
-
|
|
4559
|
-
|
|
4560
|
-
|
|
4561
|
-
|
|
4562
|
-
|
|
4563
|
-
|
|
4564
|
-
|
|
4565
|
-
|
|
4566
|
-
|
|
4567
|
-
|
|
4568
|
-
|
|
4569
|
-
|
|
4570
|
-
|
|
4571
|
-
|
|
4572
|
-
|
|
4573
|
-
return getInnerText(this);
|
|
4574
|
-
},
|
|
4575
|
-
set(v) {
|
|
4576
|
-
// Invoking the `outerText` setter on a host element should trigger its disconnection, but until we merge node reactions, it will not work.
|
|
4577
|
-
// We could reimplement the outerText setter in JavaScript ([blink implementation](https://source.chromium.org/chromium/chromium/src/+/master:third_party/blink/renderer/core/html/html_element.cc;l=841-879;drc=6e8b402a6231405b753919029c9027404325ea00;bpv=0;bpt=1))
|
|
4578
|
-
// but the benefits don't worth the efforts.
|
|
4579
|
-
outerTextSetter.call(this, v);
|
|
4580
|
-
},
|
|
4581
|
-
enumerable: true,
|
|
4582
|
-
configurable: true
|
|
4583
|
-
});
|
|
4328
|
+
// From https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/outerText :
|
|
4329
|
+
// HTMLElement.outerText is a non-standard property. As a getter, it returns the same value as Node.innerText.
|
|
4330
|
+
// As a setter, it removes the current node and replaces it with the given text.
|
|
4331
|
+
defineProperty(HTMLElement.prototype, 'outerText', {
|
|
4332
|
+
get() {
|
|
4333
|
+
// Note: we deviate from native shadow here, but are not fixing
|
|
4334
|
+
// due to backwards compat: https://github.com/salesforce/lwc/pull/3103
|
|
4335
|
+
return outerTextGetter.call(this);
|
|
4336
|
+
},
|
|
4337
|
+
set(v) {
|
|
4338
|
+
// Invoking the `outerText` setter on a host element should trigger its disconnection, but until we merge node reactions, it will not work.
|
|
4339
|
+
// We could reimplement the outerText setter in JavaScript ([blink implementation](https://source.chromium.org/chromium/chromium/src/+/master:third_party/blink/renderer/core/html/html_element.cc;l=841-879;drc=6e8b402a6231405b753919029c9027404325ea00;bpv=0;bpt=1))
|
|
4340
|
+
// but the benefits don't worth the efforts.
|
|
4341
|
+
outerTextSetter.call(this, v);
|
|
4342
|
+
},
|
|
4343
|
+
enumerable: true,
|
|
4344
|
+
configurable: true,
|
|
4345
|
+
});
|
|
4584
4346
|
}
|
|
4585
4347
|
|
|
4586
4348
|
/*
|
|
@@ -4756,6 +4518,6 @@
|
|
|
4756
4518
|
},
|
|
4757
4519
|
configurable: true,
|
|
4758
4520
|
});
|
|
4759
|
-
/** version: 2.
|
|
4521
|
+
/** version: 2.32.1 */
|
|
4760
4522
|
|
|
4761
4523
|
})();
|