lwc 2.29.0 → 2.30.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/engine-dom/esm/es2017/engine-dom.js +319 -683
- package/dist/engine-dom/iife/es2017/engine-dom.js +319 -683
- package/dist/engine-dom/iife/es2017/engine-dom.min.js +1 -1
- package/dist/engine-dom/iife/es2017/engine-dom_debug.js +201 -624
- package/dist/engine-dom/iife/es5/engine-dom.js +1138 -2843
- package/dist/engine-dom/iife/es5/engine-dom.min.js +1 -1
- package/dist/engine-dom/iife/es5/engine-dom_debug.js +892 -2428
- package/dist/engine-dom/umd/es2017/engine-dom.js +319 -683
- package/dist/engine-dom/umd/es2017/engine-dom.min.js +1 -1
- package/dist/engine-dom/umd/es2017/engine-dom_debug.js +201 -624
- package/dist/engine-dom/umd/es5/engine-dom.js +1138 -2843
- package/dist/engine-dom/umd/es5/engine-dom.min.js +1 -1
- package/dist/engine-dom/umd/es5/engine-dom_debug.js +892 -2428
- package/dist/engine-server/commonjs/es2017/engine-server.js +204 -584
- package/dist/engine-server/commonjs/es2017/engine-server.min.js +1 -1
- package/dist/engine-server/esm/es2017/engine-server.js +204 -584
- package/dist/synthetic-shadow/esm/es2017/synthetic-shadow.js +99 -323
- package/dist/synthetic-shadow/iife/es2017/synthetic-shadow.js +99 -323
- package/dist/synthetic-shadow/iife/es2017/synthetic-shadow_debug.js +98 -316
- package/dist/synthetic-shadow/iife/es5/synthetic-shadow.js +483 -1220
- package/dist/synthetic-shadow/iife/es5/synthetic-shadow_debug.js +470 -1187
- package/dist/synthetic-shadow/umd/es2017/synthetic-shadow.js +99 -323
- package/dist/synthetic-shadow/umd/es2017/synthetic-shadow_debug.js +98 -316
- package/dist/synthetic-shadow/umd/es5/synthetic-shadow.js +483 -1220
- package/dist/synthetic-shadow/umd/es5/synthetic-shadow_debug.js +470 -1187
- package/dist/wire-service/esm/es2017/wire-service.js +2 -2
- package/dist/wire-service/iife/es2017/wire-service.js +2 -2
- package/dist/wire-service/iife/es2017/wire-service.min.js +1 -1
- package/dist/wire-service/iife/es2017/wire-service_debug.js +2 -2
- package/dist/wire-service/iife/es5/wire-service.js +13 -68
- package/dist/wire-service/iife/es5/wire-service_debug.js +13 -68
- package/dist/wire-service/umd/es2017/wire-service.js +2 -2
- package/dist/wire-service/umd/es2017/wire-service.min.js +1 -1
- package/dist/wire-service/umd/es2017/wire-service_debug.js +2 -2
- package/dist/wire-service/umd/es5/wire-service.js +13 -68
- package/dist/wire-service/umd/es5/wire-service_debug.js +13 -68
- package/package.json +7 -7
|
@@ -4,68 +4,58 @@
|
|
|
4
4
|
})((function () { 'use strict';
|
|
5
5
|
|
|
6
6
|
var _create, _create2;
|
|
7
|
-
|
|
8
7
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
9
|
-
|
|
10
8
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
11
|
-
|
|
12
9
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
13
|
-
|
|
14
10
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
15
|
-
|
|
16
11
|
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
12
|
+
|
|
17
13
|
/*
|
|
18
14
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
19
15
|
* All rights reserved.
|
|
20
16
|
* SPDX-License-Identifier: MIT
|
|
21
17
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
22
18
|
*/
|
|
23
|
-
|
|
24
19
|
var assign = Object.assign,
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
20
|
+
create = Object.create,
|
|
21
|
+
defineProperties = Object.defineProperties,
|
|
22
|
+
defineProperty = Object.defineProperty,
|
|
23
|
+
getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor,
|
|
24
|
+
getPrototypeOf = Object.getPrototypeOf,
|
|
25
|
+
hasOwnProperty = Object.hasOwnProperty,
|
|
26
|
+
setPrototypeOf = Object.setPrototypeOf;
|
|
32
27
|
var _Array$prototype = Array.prototype,
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
28
|
+
ArrayFilter = _Array$prototype.filter,
|
|
29
|
+
ArrayFind = _Array$prototype.find,
|
|
30
|
+
ArrayIndexOf = _Array$prototype.indexOf,
|
|
31
|
+
ArrayMap = _Array$prototype.map,
|
|
32
|
+
ArrayPush = _Array$prototype.push,
|
|
33
|
+
ArrayReduce = _Array$prototype.reduce,
|
|
34
|
+
ArrayReverse = _Array$prototype.reverse,
|
|
35
|
+
ArraySlice = _Array$prototype.slice,
|
|
36
|
+
ArraySplice = _Array$prototype.splice,
|
|
37
|
+
forEach = _Array$prototype.forEach;
|
|
43
38
|
var _String$prototype = String.prototype,
|
|
44
|
-
|
|
45
|
-
|
|
39
|
+
StringCharCodeAt = _String$prototype.charCodeAt;
|
|
46
40
|
function isUndefined(obj) {
|
|
47
41
|
return obj === undefined;
|
|
48
42
|
}
|
|
49
|
-
|
|
50
43
|
function isNull(obj) {
|
|
51
44
|
return obj === null;
|
|
52
45
|
}
|
|
53
|
-
|
|
54
46
|
function isTrue(obj) {
|
|
55
47
|
return obj === true;
|
|
56
48
|
}
|
|
57
|
-
|
|
58
49
|
function isFalse(obj) {
|
|
59
50
|
return obj === false;
|
|
60
51
|
}
|
|
61
|
-
|
|
62
52
|
function isFunction(obj) {
|
|
63
53
|
return typeof obj === 'function';
|
|
64
54
|
}
|
|
65
|
-
|
|
66
55
|
function isObject(obj) {
|
|
67
56
|
return _typeof(obj) === 'object';
|
|
68
57
|
}
|
|
58
|
+
|
|
69
59
|
/*
|
|
70
60
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
71
61
|
* All rights reserved.
|
|
@@ -73,16 +63,12 @@
|
|
|
73
63
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
74
64
|
*/
|
|
75
65
|
// Inspired from: https://mathiasbynens.be/notes/globalthis
|
|
76
|
-
|
|
77
|
-
|
|
78
66
|
var _globalThis = /*@__PURE__*/function () {
|
|
79
67
|
// On recent browsers, `globalThis` is already defined. In this case return it directly.
|
|
80
68
|
if ((typeof globalThis === "undefined" ? "undefined" : _typeof(globalThis)) === 'object') {
|
|
81
69
|
return globalThis;
|
|
82
70
|
}
|
|
83
|
-
|
|
84
71
|
var _globalThis;
|
|
85
|
-
|
|
86
72
|
try {
|
|
87
73
|
// eslint-disable-next-line no-extend-native
|
|
88
74
|
Object.defineProperty(Object.prototype, '__magic__', {
|
|
@@ -90,14 +76,15 @@
|
|
|
90
76
|
return this;
|
|
91
77
|
},
|
|
92
78
|
configurable: true
|
|
93
|
-
});
|
|
79
|
+
});
|
|
80
|
+
// __magic__ is undefined in Safari 10 and IE10 and older.
|
|
94
81
|
// @ts-ignore
|
|
95
82
|
// eslint-disable-next-line no-undef
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
83
|
+
_globalThis = __magic__;
|
|
84
|
+
// @ts-ignore
|
|
99
85
|
delete Object.prototype.__magic__;
|
|
100
|
-
} catch (ex) {
|
|
86
|
+
} catch (ex) {
|
|
87
|
+
// In IE8, Object.defineProperty only works on DOM objects.
|
|
101
88
|
} finally {
|
|
102
89
|
// If the magic above fails for some reason we assume that we are in a legacy browser.
|
|
103
90
|
// Assume `window` exists in this case.
|
|
@@ -106,17 +93,15 @@
|
|
|
106
93
|
_globalThis = window;
|
|
107
94
|
}
|
|
108
95
|
}
|
|
109
|
-
|
|
110
96
|
return _globalThis;
|
|
111
97
|
}();
|
|
98
|
+
|
|
112
99
|
/*
|
|
113
100
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
114
101
|
* All rights reserved.
|
|
115
102
|
* SPDX-License-Identifier: MIT
|
|
116
103
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
117
104
|
*/
|
|
118
|
-
|
|
119
|
-
|
|
120
105
|
var KEY__IS_NATIVE_SHADOW_ROOT_DEFINED = '$isNativeShadowRootDefined$';
|
|
121
106
|
var KEY__SHADOW_RESOLVER = '$shadowResolver$';
|
|
122
107
|
var KEY__SHADOW_RESOLVER_PRIVATE = '$$ShadowResolverKey$$';
|
|
@@ -125,7 +110,7 @@
|
|
|
125
110
|
var KEY__SHADOW_TOKEN = '$shadowToken$';
|
|
126
111
|
var KEY__SHADOW_TOKEN_PRIVATE = '$$ShadowTokenKey$$';
|
|
127
112
|
var KEY__SYNTHETIC_MODE = '$$lwc-synthetic-mode';
|
|
128
|
-
/** version: 2.
|
|
113
|
+
/** version: 2.30.0 */
|
|
129
114
|
|
|
130
115
|
/*
|
|
131
116
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
@@ -135,25 +120,23 @@
|
|
|
135
120
|
*/
|
|
136
121
|
// TODO [#2472]: Remove this workaround when appropriate.
|
|
137
122
|
// eslint-disable-next-line @lwc/lwc-internal/no-global-node
|
|
138
|
-
|
|
139
|
-
|
|
140
123
|
var _Node = Node;
|
|
141
124
|
var nodePrototype = _Node.prototype;
|
|
142
125
|
var DOCUMENT_POSITION_CONTAINED_BY = _Node.DOCUMENT_POSITION_CONTAINED_BY,
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
126
|
+
DOCUMENT_POSITION_PRECEDING = _Node.DOCUMENT_POSITION_PRECEDING,
|
|
127
|
+
DOCUMENT_POSITION_FOLLOWING = _Node.DOCUMENT_POSITION_FOLLOWING,
|
|
128
|
+
ELEMENT_NODE = _Node.ELEMENT_NODE,
|
|
129
|
+
TEXT_NODE = _Node.TEXT_NODE,
|
|
130
|
+
CDATA_SECTION_NODE = _Node.CDATA_SECTION_NODE,
|
|
131
|
+
PROCESSING_INSTRUCTION_NODE = _Node.PROCESSING_INSTRUCTION_NODE,
|
|
132
|
+
COMMENT_NODE = _Node.COMMENT_NODE;
|
|
150
133
|
var appendChild = nodePrototype.appendChild,
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
134
|
+
cloneNode = nodePrototype.cloneNode,
|
|
135
|
+
compareDocumentPosition = nodePrototype.compareDocumentPosition,
|
|
136
|
+
insertBefore = nodePrototype.insertBefore,
|
|
137
|
+
removeChild = nodePrototype.removeChild,
|
|
138
|
+
replaceChild = nodePrototype.replaceChild,
|
|
139
|
+
hasChildNodes = nodePrototype.hasChildNodes;
|
|
157
140
|
var contains = HTMLElement.prototype.contains;
|
|
158
141
|
var firstChildGetter = getOwnPropertyDescriptor(nodePrototype, 'firstChild').get;
|
|
159
142
|
var lastChildGetter = getOwnPropertyDescriptor(nodePrototype, 'lastChild').get;
|
|
@@ -161,35 +144,34 @@
|
|
|
161
144
|
var parentNodeGetter = getOwnPropertyDescriptor(nodePrototype, 'parentNode').get;
|
|
162
145
|
var ownerDocumentGetter = getOwnPropertyDescriptor(nodePrototype, 'ownerDocument').get;
|
|
163
146
|
var parentElementGetter = hasOwnProperty.call(nodePrototype, 'parentElement') ? getOwnPropertyDescriptor(nodePrototype, 'parentElement').get : getOwnPropertyDescriptor(HTMLElement.prototype, 'parentElement').get; // IE11
|
|
164
|
-
|
|
165
147
|
var textContextSetter = getOwnPropertyDescriptor(nodePrototype, 'textContent').set;
|
|
166
148
|
var childNodesGetter = hasOwnProperty.call(nodePrototype, 'childNodes') ? getOwnPropertyDescriptor(nodePrototype, 'childNodes').get : getOwnPropertyDescriptor(HTMLElement.prototype, 'childNodes').get; // IE11
|
|
167
|
-
|
|
168
149
|
var isConnected = hasOwnProperty.call(nodePrototype, 'isConnected') ? getOwnPropertyDescriptor(nodePrototype, 'isConnected').get : function () {
|
|
169
|
-
var doc = ownerDocumentGetter.call(this);
|
|
170
|
-
|
|
171
|
-
return (
|
|
150
|
+
var doc = ownerDocumentGetter.call(this);
|
|
151
|
+
// IE11
|
|
152
|
+
return (
|
|
153
|
+
// if doc is null, it means `this` is actually a document instance which
|
|
172
154
|
// is always connected
|
|
173
155
|
doc === null || (compareDocumentPosition.call(doc, this) & DOCUMENT_POSITION_CONTAINED_BY) !== 0
|
|
174
156
|
);
|
|
175
157
|
};
|
|
158
|
+
|
|
176
159
|
/*
|
|
177
160
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
178
161
|
* All rights reserved.
|
|
179
162
|
* SPDX-License-Identifier: MIT
|
|
180
163
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
181
164
|
*/
|
|
182
|
-
|
|
183
165
|
var _Element$prototype = Element.prototype,
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
166
|
+
getAttribute = _Element$prototype.getAttribute,
|
|
167
|
+
getBoundingClientRect = _Element$prototype.getBoundingClientRect,
|
|
168
|
+
getElementsByTagName$1 = _Element$prototype.getElementsByTagName,
|
|
169
|
+
getElementsByTagNameNS$1 = _Element$prototype.getElementsByTagNameNS,
|
|
170
|
+
hasAttribute = _Element$prototype.hasAttribute,
|
|
171
|
+
querySelector = _Element$prototype.querySelector,
|
|
172
|
+
querySelectorAll$1 = _Element$prototype.querySelectorAll,
|
|
173
|
+
removeAttribute = _Element$prototype.removeAttribute,
|
|
174
|
+
setAttribute = _Element$prototype.setAttribute;
|
|
193
175
|
var attachShadow$1 = hasOwnProperty.call(Element.prototype, 'attachShadow') ? Element.prototype.attachShadow : function () {
|
|
194
176
|
throw new TypeError('attachShadow() is not supported in current browser. Load the @lwc/synthetic-shadow polyfill and use Lightning Web Components');
|
|
195
177
|
};
|
|
@@ -198,17 +180,15 @@
|
|
|
198
180
|
var lastElementChildGetter = getOwnPropertyDescriptor(Element.prototype, 'lastElementChild').get;
|
|
199
181
|
var innerTextDescriptor = getOwnPropertyDescriptor(HTMLElement.prototype, 'innerText');
|
|
200
182
|
var innerTextGetter = innerTextDescriptor ? innerTextDescriptor.get : null;
|
|
201
|
-
var innerTextSetter = innerTextDescriptor ? innerTextDescriptor.set : null;
|
|
202
|
-
|
|
183
|
+
var innerTextSetter = innerTextDescriptor ? innerTextDescriptor.set : null;
|
|
184
|
+
// Note: Firefox does not have outerText, https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/outerText
|
|
203
185
|
var outerTextDescriptor = getOwnPropertyDescriptor(HTMLElement.prototype, 'outerText');
|
|
204
186
|
var outerTextGetter = outerTextDescriptor ? outerTextDescriptor.get : null;
|
|
205
187
|
var outerTextSetter = outerTextDescriptor ? outerTextDescriptor.set : null;
|
|
206
188
|
var innerHTMLDescriptor = hasOwnProperty.call(Element.prototype, 'innerHTML') ? getOwnPropertyDescriptor(Element.prototype, 'innerHTML') : getOwnPropertyDescriptor(HTMLElement.prototype, 'innerHTML'); // IE11
|
|
207
|
-
|
|
208
189
|
var innerHTMLGetter = innerHTMLDescriptor.get;
|
|
209
190
|
var innerHTMLSetter = innerHTMLDescriptor.set;
|
|
210
191
|
var outerHTMLDescriptor = hasOwnProperty.call(Element.prototype, 'outerHTML') ? getOwnPropertyDescriptor(Element.prototype, 'outerHTML') : getOwnPropertyDescriptor(HTMLElement.prototype, 'outerHTML'); // IE11
|
|
211
|
-
|
|
212
192
|
var outerHTMLGetter = outerHTMLDescriptor.get;
|
|
213
193
|
var outerHTMLSetter = outerHTMLDescriptor.set;
|
|
214
194
|
var tagNameGetter = getOwnPropertyDescriptor(Element.prototype, 'tagName').get;
|
|
@@ -216,11 +196,9 @@
|
|
|
216
196
|
var tabIndexGetter = tabIndexDescriptor.get;
|
|
217
197
|
var tabIndexSetter = tabIndexDescriptor.set;
|
|
218
198
|
var matches = hasOwnProperty.call(Element.prototype, 'matches') ? Element.prototype.matches : Element.prototype.msMatchesSelector; // IE11
|
|
219
|
-
|
|
220
199
|
var childrenGetter = hasOwnProperty.call(Element.prototype, 'children') ? getOwnPropertyDescriptor(Element.prototype, 'children').get : getOwnPropertyDescriptor(HTMLElement.prototype, 'children').get; // IE11
|
|
221
200
|
// for IE11, access from HTMLElement
|
|
222
201
|
// for all other browsers access the method from the parent Element interface
|
|
223
|
-
|
|
224
202
|
var getElementsByClassName$1 = HTMLElement.prototype.getElementsByClassName;
|
|
225
203
|
var shadowRootGetter = hasOwnProperty.call(Element.prototype, 'shadowRoot') ? getOwnPropertyDescriptor(Element.prototype, 'shadowRoot').get : function () {
|
|
226
204
|
return null;
|
|
@@ -228,15 +206,14 @@
|
|
|
228
206
|
var assignedSlotGetter$1 = hasOwnProperty.call(Element.prototype, 'assignedSlot') ? getOwnPropertyDescriptor(Element.prototype, 'assignedSlot').get : function () {
|
|
229
207
|
return null;
|
|
230
208
|
};
|
|
209
|
+
|
|
231
210
|
/*
|
|
232
211
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
233
212
|
* All rights reserved.
|
|
234
213
|
* SPDX-License-Identifier: MIT
|
|
235
214
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
236
215
|
*/
|
|
237
|
-
|
|
238
216
|
var assignedNodes, assignedElements;
|
|
239
|
-
|
|
240
217
|
if (typeof HTMLSlotElement !== 'undefined') {
|
|
241
218
|
assignedNodes = HTMLSlotElement.prototype.assignedNodes;
|
|
242
219
|
assignedElements = HTMLSlotElement.prototype.assignedElements;
|
|
@@ -244,64 +221,61 @@
|
|
|
244
221
|
assignedNodes = function assignedNodes() {
|
|
245
222
|
throw new TypeError("assignedNodes() is not supported in current browser. Load the @lwc/synthetic-shadow polyfill to start using <slot> elements in your Lightning Web Component's template");
|
|
246
223
|
};
|
|
247
|
-
|
|
248
224
|
assignedElements = function assignedElements() {
|
|
249
225
|
throw new TypeError("assignedElements() is not supported in current browser. Load the @lwc/synthetic-shadow polyfill to start using <slot> elements in your Lightning Web Component's template");
|
|
250
226
|
};
|
|
251
227
|
}
|
|
228
|
+
|
|
252
229
|
/*
|
|
253
230
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
254
231
|
* All rights reserved.
|
|
255
232
|
* SPDX-License-Identifier: MIT
|
|
256
233
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
257
234
|
*/
|
|
258
|
-
|
|
259
|
-
|
|
260
235
|
var eventTargetGetter = getOwnPropertyDescriptor(Event.prototype, 'target').get;
|
|
261
236
|
var eventCurrentTargetGetter = getOwnPropertyDescriptor(Event.prototype, 'currentTarget').get;
|
|
262
|
-
var focusEventRelatedTargetGetter = getOwnPropertyDescriptor(FocusEvent.prototype, 'relatedTarget').get;
|
|
237
|
+
var focusEventRelatedTargetGetter = getOwnPropertyDescriptor(FocusEvent.prototype, 'relatedTarget').get;
|
|
238
|
+
// IE does not implement composedPath() but that's ok because we only use this instead of our
|
|
263
239
|
// composedPath() polyfill when dealing with native shadow DOM components in mixed mode. Defaulting
|
|
264
240
|
// to a NOOP just to be safe, even though this is almost guaranteed to be defined such a scenario.
|
|
265
|
-
|
|
266
241
|
var composedPath = hasOwnProperty.call(Event.prototype, 'composedPath') ? Event.prototype.composedPath : function () {
|
|
267
242
|
return [];
|
|
268
243
|
};
|
|
244
|
+
|
|
269
245
|
/*
|
|
270
246
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
271
247
|
* All rights reserved.
|
|
272
248
|
* SPDX-License-Identifier: MIT
|
|
273
249
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
274
250
|
*/
|
|
275
|
-
|
|
276
251
|
var DocumentPrototypeActiveElement = getOwnPropertyDescriptor(Document.prototype, 'activeElement').get;
|
|
277
252
|
var elementFromPoint = hasOwnProperty.call(Document.prototype, 'elementFromPoint') ? Document.prototype.elementFromPoint : Document.prototype.msElementFromPoint; // IE11
|
|
278
|
-
|
|
279
253
|
var elementsFromPoint = hasOwnProperty.call(Document.prototype, 'elementsFromPoint') ? Document.prototype.elementsFromPoint : Document.prototype.msElementsFromPoint; // IE11
|
|
280
254
|
// defaultView can be null when a document has no browsing context. For example, the owner document
|
|
281
255
|
// of a node in a template doesn't have a default view: https://jsfiddle.net/hv9z0q5a/
|
|
282
|
-
|
|
283
256
|
var defaultViewGetter = getOwnPropertyDescriptor(Document.prototype, 'defaultView').get;
|
|
284
257
|
var _Document$prototype = Document.prototype,
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
258
|
+
querySelectorAll = _Document$prototype.querySelectorAll,
|
|
259
|
+
getElementById = _Document$prototype.getElementById,
|
|
260
|
+
getElementsByClassName = _Document$prototype.getElementsByClassName,
|
|
261
|
+
getElementsByTagName = _Document$prototype.getElementsByTagName,
|
|
262
|
+
getElementsByTagNameNS = _Document$prototype.getElementsByTagNameNS;
|
|
263
|
+
// In Firefox v57 and lower, getElementsByName is defined on HTMLDocument.prototype
|
|
290
264
|
// In all other browsers have the method on Document.prototype
|
|
291
|
-
|
|
292
265
|
var getElementsByName = HTMLDocument.prototype.getElementsByName;
|
|
266
|
+
|
|
293
267
|
/*
|
|
294
268
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
295
269
|
* All rights reserved.
|
|
296
270
|
* SPDX-License-Identifier: MIT
|
|
297
271
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
298
272
|
*/
|
|
299
|
-
|
|
300
273
|
var _window = window,
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
274
|
+
windowAddEventListener = _window.addEventListener,
|
|
275
|
+
windowRemoveEventListener = _window.removeEventListener,
|
|
276
|
+
windowGetComputedStyle = _window.getComputedStyle,
|
|
277
|
+
windowGetSelection = _window.getSelection;
|
|
278
|
+
|
|
305
279
|
/*
|
|
306
280
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
307
281
|
* All rights reserved.
|
|
@@ -311,91 +285,82 @@
|
|
|
311
285
|
// There is code in the polyfills that requires access to the unpatched
|
|
312
286
|
// Mutation Observer constructor, this the code for that.
|
|
313
287
|
// Eventually, the polyfill should uses the patched version, and this file can be removed.
|
|
314
|
-
|
|
315
288
|
var MO = MutationObserver;
|
|
316
289
|
var MutationObserverObserve = MO.prototype.observe;
|
|
290
|
+
|
|
317
291
|
/*
|
|
318
292
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
319
293
|
* All rights reserved.
|
|
320
294
|
* SPDX-License-Identifier: MIT
|
|
321
295
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
322
296
|
*/
|
|
323
|
-
|
|
324
297
|
var NativeShadowRoot = null;
|
|
325
|
-
|
|
326
298
|
if (typeof ShadowRoot !== 'undefined') {
|
|
327
299
|
NativeShadowRoot = ShadowRoot;
|
|
328
300
|
}
|
|
329
|
-
|
|
330
301
|
var isNativeShadowRootDefined = !isNull(NativeShadowRoot);
|
|
331
302
|
var isInstanceOfNativeShadowRoot = isNull(NativeShadowRoot) ? function () {
|
|
332
303
|
return false;
|
|
333
304
|
} : function (node) {
|
|
334
305
|
return node instanceof NativeShadowRoot;
|
|
335
306
|
};
|
|
307
|
+
|
|
336
308
|
/*
|
|
337
309
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
338
310
|
* All rights reserved.
|
|
339
311
|
* SPDX-License-Identifier: MIT
|
|
340
312
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
341
313
|
*/
|
|
342
|
-
|
|
343
314
|
function detect$4() {
|
|
344
315
|
return typeof HTMLSlotElement === 'undefined';
|
|
345
316
|
}
|
|
317
|
+
|
|
346
318
|
/*
|
|
347
319
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
348
320
|
* All rights reserved.
|
|
349
321
|
* SPDX-License-Identifier: MIT
|
|
350
322
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
351
323
|
*/
|
|
352
|
-
|
|
353
|
-
|
|
354
324
|
var createElement = Document.prototype.createElement;
|
|
355
325
|
var CHAR_S = 115;
|
|
356
326
|
var CHAR_L = 108;
|
|
357
327
|
var CHAR_O = 111;
|
|
358
328
|
var CHAR_T = 116;
|
|
359
|
-
|
|
360
329
|
function apply$4() {
|
|
361
330
|
// IE11 does not have this element definition
|
|
362
331
|
// we don't care much about the construction phase, just the prototype
|
|
363
332
|
var HTMLSlotElement = /*#__PURE__*/_createClass(function HTMLSlotElement() {
|
|
364
333
|
_classCallCheck(this, HTMLSlotElement);
|
|
365
334
|
}); // prototype inheritance dance
|
|
366
|
-
|
|
367
|
-
|
|
368
335
|
setPrototypeOf(HTMLSlotElement, HTMLElement.constructor);
|
|
369
336
|
setPrototypeOf(HTMLSlotElement.prototype, HTMLElement.prototype);
|
|
370
|
-
Window.prototype.HTMLSlotElement = HTMLSlotElement;
|
|
337
|
+
Window.prototype.HTMLSlotElement = HTMLSlotElement;
|
|
338
|
+
// IE11 doesn't have HTMLSlotElement, in which case we
|
|
371
339
|
// need to patch Document.prototype.createElement to remap `slot`
|
|
372
340
|
// elements to the right prototype
|
|
373
|
-
|
|
374
341
|
defineProperty(Document.prototype, 'createElement', {
|
|
375
342
|
value: function value(tagName, _options) {
|
|
376
343
|
var elm = createElement.apply(this, ArraySlice.call(arguments));
|
|
377
|
-
|
|
378
344
|
if (tagName.length === 4 && StringCharCodeAt.call(tagName, 0) === CHAR_S && StringCharCodeAt.call(tagName, 1) === CHAR_L && StringCharCodeAt.call(tagName, 2) === CHAR_O && StringCharCodeAt.call(tagName, 3) === CHAR_T) {
|
|
379
345
|
// the new element is the `slot`, resetting the proto chain
|
|
380
346
|
// the new newly created global HTMLSlotElement.prototype
|
|
381
347
|
setPrototypeOf(elm, HTMLSlotElement.prototype);
|
|
382
348
|
}
|
|
383
|
-
|
|
384
349
|
return elm;
|
|
385
350
|
}
|
|
386
351
|
});
|
|
387
352
|
}
|
|
353
|
+
|
|
388
354
|
/*
|
|
389
355
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
390
356
|
* All rights reserved.
|
|
391
357
|
* SPDX-License-Identifier: MIT
|
|
392
358
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
393
359
|
*/
|
|
394
|
-
|
|
395
|
-
|
|
396
360
|
if (detect$4()) {
|
|
397
361
|
apply$4();
|
|
398
362
|
}
|
|
363
|
+
|
|
399
364
|
/*
|
|
400
365
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
401
366
|
* All rights reserved.
|
|
@@ -403,29 +368,23 @@
|
|
|
403
368
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
404
369
|
*/
|
|
405
370
|
// Helpful for tests running with jsdom
|
|
406
|
-
|
|
407
|
-
|
|
408
371
|
function getOwnerDocument(node) {
|
|
409
|
-
var doc = ownerDocumentGetter.call(node);
|
|
410
|
-
|
|
372
|
+
var doc = ownerDocumentGetter.call(node);
|
|
373
|
+
// if doc is null, it means `this` is actually a document instance
|
|
411
374
|
return doc === null ? node : doc;
|
|
412
375
|
}
|
|
413
|
-
|
|
414
376
|
function getOwnerWindow(node) {
|
|
415
377
|
var doc = getOwnerDocument(node);
|
|
416
378
|
var win = defaultViewGetter.call(doc);
|
|
417
|
-
|
|
418
379
|
if (win === null) {
|
|
419
380
|
// this method should never be called with a node that is not part
|
|
420
381
|
// of a qualifying connected node.
|
|
421
382
|
throw new TypeError();
|
|
422
383
|
}
|
|
423
|
-
|
|
424
384
|
return win;
|
|
425
385
|
}
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
386
|
+
var skipGlobalPatching;
|
|
387
|
+
// TODO [#1222]: remove global bypass
|
|
429
388
|
function isGlobalPatchingSkipped(node) {
|
|
430
389
|
// we lazily compute this value instead of doing it during evaluation, this helps
|
|
431
390
|
// for apps that are setting this after the engine code is evaluated.
|
|
@@ -433,46 +392,40 @@
|
|
|
433
392
|
var ownerDocument = getOwnerDocument(node);
|
|
434
393
|
skipGlobalPatching = ownerDocument.body && getAttribute.call(ownerDocument.body, 'data-global-patching-bypass') === 'temporary-bypass';
|
|
435
394
|
}
|
|
436
|
-
|
|
437
395
|
return isTrue(skipGlobalPatching);
|
|
438
396
|
}
|
|
439
|
-
|
|
440
397
|
function arrayFromCollection(collection) {
|
|
441
398
|
var size = collection.length;
|
|
442
399
|
var cloned = [];
|
|
443
|
-
|
|
444
400
|
if (size > 0) {
|
|
445
401
|
for (var i = 0; i < size; i++) {
|
|
446
402
|
cloned[i] = collection[i];
|
|
447
403
|
}
|
|
448
404
|
}
|
|
449
|
-
|
|
450
405
|
return cloned;
|
|
451
406
|
}
|
|
407
|
+
|
|
452
408
|
/*
|
|
453
409
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
454
410
|
* All rights reserved.
|
|
455
411
|
* SPDX-License-Identifier: MIT
|
|
456
412
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
457
413
|
*/
|
|
458
|
-
|
|
459
|
-
|
|
460
414
|
var eventTargetPrototype = typeof EventTarget !== 'undefined' ? EventTarget.prototype : _Node.prototype;
|
|
461
415
|
var addEventListener = eventTargetPrototype.addEventListener,
|
|
462
|
-
|
|
463
|
-
|
|
416
|
+
dispatchEvent = eventTargetPrototype.dispatchEvent,
|
|
417
|
+
removeEventListener = eventTargetPrototype.removeEventListener;
|
|
418
|
+
|
|
464
419
|
/**
|
|
465
420
|
* Copyright (C) 2018 salesforce.com, inc.
|
|
466
421
|
*/
|
|
467
|
-
|
|
468
422
|
if (!_globalThis.lwcRuntimeFlags) {
|
|
469
423
|
Object.defineProperty(_globalThis, 'lwcRuntimeFlags', {
|
|
470
424
|
value: create(null)
|
|
471
425
|
});
|
|
472
426
|
}
|
|
473
|
-
|
|
474
427
|
var lwcRuntimeFlags = _globalThis.lwcRuntimeFlags;
|
|
475
|
-
/** version: 2.
|
|
428
|
+
/** version: 2.30.0 */
|
|
476
429
|
|
|
477
430
|
/*
|
|
478
431
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
@@ -480,51 +433,42 @@
|
|
|
480
433
|
* SPDX-License-Identifier: MIT
|
|
481
434
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
482
435
|
*/
|
|
483
|
-
|
|
436
|
+
// Used as a back reference to identify the host element
|
|
484
437
|
var HostElementKey = '$$HostElementKey$$';
|
|
485
438
|
var ShadowedNodeKey = '$$ShadowedNodeKey$$';
|
|
486
|
-
|
|
487
439
|
function fastDefineProperty(node, propName, config) {
|
|
488
440
|
var shadowedNode = node;
|
|
489
|
-
|
|
490
441
|
{
|
|
491
|
-
var value = config.value;
|
|
492
|
-
|
|
442
|
+
var value = config.value;
|
|
443
|
+
// in prod, we prioritize performance
|
|
493
444
|
shadowedNode[propName] = value;
|
|
494
445
|
}
|
|
495
446
|
}
|
|
496
|
-
|
|
497
447
|
function setNodeOwnerKey(node, value) {
|
|
498
448
|
fastDefineProperty(node, HostElementKey, {
|
|
499
449
|
value: value,
|
|
500
450
|
configurable: true
|
|
501
451
|
});
|
|
502
452
|
}
|
|
503
|
-
|
|
504
453
|
function setNodeKey(node, value) {
|
|
505
454
|
fastDefineProperty(node, ShadowedNodeKey, {
|
|
506
455
|
value: value
|
|
507
456
|
});
|
|
508
457
|
}
|
|
509
|
-
|
|
510
458
|
function getNodeOwnerKey(node) {
|
|
511
459
|
return node[HostElementKey];
|
|
512
460
|
}
|
|
513
|
-
|
|
514
461
|
function getNodeNearestOwnerKey(node) {
|
|
515
462
|
var host = node;
|
|
516
|
-
var hostKey;
|
|
463
|
+
var hostKey;
|
|
464
|
+
// search for the first element with owner identity
|
|
517
465
|
// in case of manually inserted elements and elements slotted from Light DOM
|
|
518
|
-
|
|
519
466
|
while (!isNull(host)) {
|
|
520
467
|
hostKey = getNodeOwnerKey(host);
|
|
521
|
-
|
|
522
468
|
if (!isUndefined(hostKey)) {
|
|
523
469
|
return hostKey;
|
|
524
470
|
}
|
|
525
|
-
|
|
526
471
|
host = parentNodeGetter.call(host);
|
|
527
|
-
|
|
528
472
|
if (lwcRuntimeFlags.ENABLE_LIGHT_GET_ROOT_NODE_PATCH) {
|
|
529
473
|
if (!isNull(host) && isSyntheticSlotElement(host)) {
|
|
530
474
|
return undefined;
|
|
@@ -532,7 +476,6 @@
|
|
|
532
476
|
}
|
|
533
477
|
}
|
|
534
478
|
}
|
|
535
|
-
|
|
536
479
|
function getNodeKey(node) {
|
|
537
480
|
return node[ShadowedNodeKey];
|
|
538
481
|
}
|
|
@@ -541,42 +484,34 @@
|
|
|
541
484
|
* cases. If we need to traverse up and verify those nodes that don't have owner key, use
|
|
542
485
|
* isNodeDeepShadowed instead.
|
|
543
486
|
*/
|
|
544
|
-
|
|
545
|
-
|
|
546
487
|
function isNodeShadowed(node) {
|
|
547
488
|
return !isUndefined(getNodeOwnerKey(node));
|
|
548
489
|
}
|
|
490
|
+
|
|
549
491
|
/*
|
|
550
492
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
551
493
|
* All rights reserved.
|
|
552
494
|
* SPDX-License-Identifier: MIT
|
|
553
495
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
554
496
|
*/
|
|
497
|
+
// when finding a slot in the DOM, we can fold it if it is contained
|
|
555
498
|
// inside another slot.
|
|
556
|
-
|
|
557
|
-
|
|
558
499
|
function foldSlotElement(slot) {
|
|
559
500
|
var parent = parentElementGetter.call(slot);
|
|
560
|
-
|
|
561
501
|
while (!isNull(parent) && isSlotElement(parent)) {
|
|
562
502
|
slot = parent;
|
|
563
503
|
parent = parentElementGetter.call(slot);
|
|
564
504
|
}
|
|
565
|
-
|
|
566
505
|
return slot;
|
|
567
506
|
}
|
|
568
|
-
|
|
569
507
|
function isNodeSlotted(host, node) {
|
|
570
|
-
|
|
571
|
-
|
|
508
|
+
var hostKey = getNodeKey(host);
|
|
509
|
+
// this routine assumes that the node is coming from a different shadow (it is not owned by the host)
|
|
572
510
|
// just in case the provided node is not an element
|
|
573
|
-
|
|
574
511
|
var currentElement = node instanceof Element ? node : parentElementGetter.call(node);
|
|
575
|
-
|
|
576
512
|
while (!isNull(currentElement) && currentElement !== host) {
|
|
577
513
|
var elmOwnerKey = getNodeNearestOwnerKey(currentElement);
|
|
578
514
|
var parent = parentElementGetter.call(currentElement);
|
|
579
|
-
|
|
580
515
|
if (elmOwnerKey === hostKey) {
|
|
581
516
|
// we have reached an element inside the host's template, and only if
|
|
582
517
|
// that element is an slot, then the node is considered slotted
|
|
@@ -602,7 +537,6 @@
|
|
|
602
537
|
* most outer slot parent before jumping into its corresponding host.
|
|
603
538
|
*/
|
|
604
539
|
currentElement = getNodeOwner(foldSlotElement(parent));
|
|
605
|
-
|
|
606
540
|
if (!isNull(currentElement)) {
|
|
607
541
|
if (currentElement === host) {
|
|
608
542
|
// the slot element is a top level element inside the shadow
|
|
@@ -621,197 +555,156 @@
|
|
|
621
555
|
currentElement = parent;
|
|
622
556
|
}
|
|
623
557
|
}
|
|
624
|
-
|
|
625
558
|
return false;
|
|
626
559
|
}
|
|
627
|
-
|
|
628
560
|
function getNodeOwner(node) {
|
|
629
561
|
if (!(node instanceof _Node)) {
|
|
630
562
|
return null;
|
|
631
563
|
}
|
|
632
|
-
|
|
633
564
|
var ownerKey = getNodeNearestOwnerKey(node);
|
|
634
|
-
|
|
635
565
|
if (isUndefined(ownerKey)) {
|
|
636
566
|
return null;
|
|
637
567
|
}
|
|
638
|
-
|
|
639
|
-
|
|
568
|
+
var nodeOwner = node;
|
|
569
|
+
// At this point, node is a valid node with owner identity, now we need to find the owner node
|
|
640
570
|
// search for a custom element with a VM that owns the first element with owner identity attached to it
|
|
641
|
-
|
|
642
571
|
while (!isNull(nodeOwner) && getNodeKey(nodeOwner) !== ownerKey) {
|
|
643
572
|
nodeOwner = parentNodeGetter.call(nodeOwner);
|
|
644
573
|
}
|
|
645
|
-
|
|
646
574
|
if (isNull(nodeOwner)) {
|
|
647
575
|
return null;
|
|
648
576
|
}
|
|
649
|
-
|
|
650
577
|
return nodeOwner;
|
|
651
578
|
}
|
|
652
|
-
|
|
653
579
|
function isSyntheticSlotElement(node) {
|
|
654
580
|
return isSlotElement(node) && isNodeShadowed(node);
|
|
655
581
|
}
|
|
656
|
-
|
|
657
582
|
function isSlotElement(node) {
|
|
658
583
|
return node instanceof HTMLSlotElement;
|
|
659
584
|
}
|
|
660
|
-
|
|
661
585
|
function isNodeOwnedBy(owner, node) {
|
|
662
|
-
|
|
663
586
|
var ownerKey = getNodeNearestOwnerKey(node);
|
|
664
|
-
|
|
665
587
|
if (isUndefined(ownerKey)) {
|
|
666
588
|
if (lwcRuntimeFlags.ENABLE_LIGHT_GET_ROOT_NODE_PATCH) {
|
|
667
589
|
// in case of root level light DOM element slotting into a synthetic shadow
|
|
668
590
|
var host = parentNodeGetter.call(node);
|
|
669
|
-
|
|
670
591
|
if (!isNull(host) && isSyntheticSlotElement(host)) {
|
|
671
592
|
return false;
|
|
672
593
|
}
|
|
673
|
-
}
|
|
674
|
-
|
|
675
|
-
|
|
594
|
+
}
|
|
595
|
+
// in case of manually inserted elements
|
|
676
596
|
return true;
|
|
677
597
|
}
|
|
678
|
-
|
|
679
598
|
return getNodeKey(owner) === ownerKey;
|
|
680
599
|
}
|
|
681
|
-
|
|
682
600
|
function shadowRootChildNodes(root) {
|
|
683
601
|
var elm = getHost(root);
|
|
684
602
|
return getAllMatches(elm, arrayFromCollection(childNodesGetter.call(elm)));
|
|
685
603
|
}
|
|
686
|
-
|
|
687
604
|
function getAllSlottedMatches(host, nodeList) {
|
|
688
605
|
var filteredAndPatched = [];
|
|
689
|
-
|
|
690
606
|
for (var i = 0, len = nodeList.length; i < len; i += 1) {
|
|
691
607
|
var node = nodeList[i];
|
|
692
|
-
|
|
693
608
|
if (!isNodeOwnedBy(host, node) && isNodeSlotted(host, node)) {
|
|
694
609
|
ArrayPush.call(filteredAndPatched, node);
|
|
695
610
|
}
|
|
696
611
|
}
|
|
697
|
-
|
|
698
612
|
return filteredAndPatched;
|
|
699
613
|
}
|
|
700
|
-
|
|
701
614
|
function getFirstSlottedMatch(host, nodeList) {
|
|
702
615
|
for (var i = 0, len = nodeList.length; i < len; i += 1) {
|
|
703
616
|
var node = nodeList[i];
|
|
704
|
-
|
|
705
617
|
if (!isNodeOwnedBy(host, node) && isNodeSlotted(host, node)) {
|
|
706
618
|
return node;
|
|
707
619
|
}
|
|
708
620
|
}
|
|
709
|
-
|
|
710
621
|
return null;
|
|
711
622
|
}
|
|
712
|
-
|
|
713
623
|
function getAllMatches(owner, nodeList) {
|
|
714
624
|
var filteredAndPatched = [];
|
|
715
|
-
|
|
716
625
|
for (var i = 0, len = nodeList.length; i < len; i += 1) {
|
|
717
626
|
var node = nodeList[i];
|
|
718
627
|
var isOwned = isNodeOwnedBy(owner, node);
|
|
719
|
-
|
|
720
628
|
if (isOwned) {
|
|
721
629
|
// Patch querySelector, querySelectorAll, etc
|
|
722
630
|
// if element is owned by VM
|
|
723
631
|
ArrayPush.call(filteredAndPatched, node);
|
|
724
632
|
}
|
|
725
633
|
}
|
|
726
|
-
|
|
727
634
|
return filteredAndPatched;
|
|
728
635
|
}
|
|
729
|
-
|
|
730
636
|
function getFirstMatch(owner, nodeList) {
|
|
731
637
|
for (var i = 0, len = nodeList.length; i < len; i += 1) {
|
|
732
638
|
if (isNodeOwnedBy(owner, nodeList[i])) {
|
|
733
639
|
return nodeList[i];
|
|
734
640
|
}
|
|
735
641
|
}
|
|
736
|
-
|
|
737
642
|
return null;
|
|
738
643
|
}
|
|
739
|
-
|
|
740
644
|
function shadowRootQuerySelector(root, selector) {
|
|
741
645
|
var elm = getHost(root);
|
|
742
646
|
var nodeList = arrayFromCollection(querySelectorAll$1.call(elm, selector));
|
|
743
647
|
return getFirstMatch(elm, nodeList);
|
|
744
648
|
}
|
|
745
|
-
|
|
746
649
|
function shadowRootQuerySelectorAll(root, selector) {
|
|
747
650
|
var elm = getHost(root);
|
|
748
651
|
var nodeList = querySelectorAll$1.call(elm, selector);
|
|
749
652
|
return getAllMatches(elm, arrayFromCollection(nodeList));
|
|
750
653
|
}
|
|
751
|
-
|
|
752
654
|
function getFilteredChildNodes(node) {
|
|
753
655
|
if (!isSyntheticShadowHost(node) && !isSlotElement(node)) {
|
|
754
656
|
// regular element - fast path
|
|
755
657
|
var children = childNodesGetter.call(node);
|
|
756
658
|
return arrayFromCollection(children);
|
|
757
659
|
}
|
|
758
|
-
|
|
759
660
|
if (isSyntheticShadowHost(node)) {
|
|
760
661
|
// we need to get only the nodes that were slotted
|
|
761
662
|
var slots = arrayFromCollection(querySelectorAll$1.call(node, 'slot'));
|
|
762
|
-
var resolver = getShadowRootResolver(getShadowRoot(node));
|
|
663
|
+
var resolver = getShadowRootResolver(getShadowRoot(node));
|
|
664
|
+
// Typescript is inferring the wrong function type for this particular
|
|
763
665
|
// overloaded method: https://github.com/Microsoft/TypeScript/issues/27972
|
|
764
666
|
// @ts-ignore type-mismatch
|
|
765
|
-
|
|
766
667
|
return ArrayReduce.call(slots, function (seed, slot) {
|
|
767
668
|
if (resolver === getShadowRootResolver(slot)) {
|
|
768
669
|
ArrayPush.apply(seed, getFilteredSlotAssignedNodes(slot));
|
|
769
670
|
}
|
|
770
|
-
|
|
771
671
|
return seed;
|
|
772
672
|
}, []);
|
|
773
673
|
} else {
|
|
774
674
|
// slot element
|
|
775
675
|
var _children = arrayFromCollection(childNodesGetter.call(node));
|
|
776
|
-
|
|
777
676
|
var _resolver = getShadowRootResolver(node);
|
|
778
|
-
|
|
779
677
|
return ArrayFilter.call(_children, function (child) {
|
|
780
678
|
return _resolver === getShadowRootResolver(child);
|
|
781
679
|
});
|
|
782
680
|
}
|
|
783
681
|
}
|
|
784
|
-
|
|
785
682
|
function getFilteredSlotAssignedNodes(slot) {
|
|
786
683
|
var owner = getNodeOwner(slot);
|
|
787
|
-
|
|
788
684
|
if (isNull(owner)) {
|
|
789
685
|
return [];
|
|
790
686
|
}
|
|
791
|
-
|
|
792
687
|
var childNodes = arrayFromCollection(childNodesGetter.call(slot));
|
|
793
688
|
return ArrayFilter.call(childNodes, function (child) {
|
|
794
689
|
return !isNodeShadowed(child) || !isNodeOwnedBy(owner, child);
|
|
795
690
|
});
|
|
796
691
|
}
|
|
692
|
+
|
|
797
693
|
/*
|
|
798
694
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
799
695
|
* All rights reserved.
|
|
800
696
|
* SPDX-License-Identifier: MIT
|
|
801
697
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
802
698
|
*/
|
|
803
|
-
|
|
804
|
-
|
|
805
699
|
function getInnerHTML(node) {
|
|
806
700
|
var s = '';
|
|
807
701
|
var childNodes = getFilteredChildNodes(node);
|
|
808
|
-
|
|
809
702
|
for (var i = 0, len = childNodes.length; i < len; i += 1) {
|
|
810
703
|
s += getOuterHTML(childNodes[i]);
|
|
811
704
|
}
|
|
812
|
-
|
|
813
705
|
return s;
|
|
814
706
|
}
|
|
707
|
+
|
|
815
708
|
/*
|
|
816
709
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
817
710
|
* All rights reserved.
|
|
@@ -819,48 +712,36 @@
|
|
|
819
712
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
820
713
|
*/
|
|
821
714
|
// http://www.whatwg.org/specs/web-apps/current-work/multipage/the-end.html#escapingString
|
|
822
|
-
|
|
823
|
-
|
|
824
715
|
var escapeAttrRegExp = /[&\u00A0"]/g;
|
|
825
716
|
var escapeDataRegExp = /[&\u00A0<>]/g;
|
|
826
717
|
var _String$prototype2 = String.prototype,
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
718
|
+
replace = _String$prototype2.replace,
|
|
719
|
+
toLowerCase = _String$prototype2.toLowerCase;
|
|
830
720
|
function escapeReplace(c) {
|
|
831
721
|
switch (c) {
|
|
832
722
|
case '&':
|
|
833
723
|
return '&';
|
|
834
|
-
|
|
835
724
|
case '<':
|
|
836
725
|
return '<';
|
|
837
|
-
|
|
838
726
|
case '>':
|
|
839
727
|
return '>';
|
|
840
|
-
|
|
841
728
|
case '"':
|
|
842
729
|
return '"';
|
|
843
|
-
|
|
844
730
|
case "\xA0":
|
|
845
731
|
return ' ';
|
|
846
|
-
|
|
847
732
|
default:
|
|
848
733
|
return '';
|
|
849
734
|
}
|
|
850
735
|
}
|
|
851
|
-
|
|
852
736
|
function escapeAttr(s) {
|
|
853
737
|
return replace.call(s, escapeAttrRegExp, escapeReplace);
|
|
854
738
|
}
|
|
855
|
-
|
|
856
739
|
function escapeData(s) {
|
|
857
740
|
return replace.call(s, escapeDataRegExp, escapeReplace);
|
|
858
|
-
}
|
|
859
|
-
|
|
860
|
-
|
|
741
|
+
}
|
|
742
|
+
// http://www.whatwg.org/specs/web-apps/current-work/#void-elements
|
|
861
743
|
var voidElements = new Set(['AREA', 'BASE', 'BR', 'COL', 'COMMAND', 'EMBED', 'HR', 'IMG', 'INPUT', 'KEYGEN', 'LINK', 'META', 'PARAM', 'SOURCE', 'TRACK', 'WBR']);
|
|
862
744
|
var plaintextParents = new Set(['STYLE', 'SCRIPT', 'XMP', 'IFRAME', 'NOEMBED', 'NOFRAMES', 'PLAINTEXT', 'NOSCRIPT']);
|
|
863
|
-
|
|
864
745
|
function getOuterHTML(node) {
|
|
865
746
|
switch (node.nodeType) {
|
|
866
747
|
case ELEMENT_NODE:
|
|
@@ -868,47 +749,36 @@
|
|
|
868
749
|
var attrs = node.attributes;
|
|
869
750
|
var tagName = tagNameGetter.call(node);
|
|
870
751
|
var s = '<' + toLowerCase.call(tagName);
|
|
871
|
-
|
|
872
752
|
for (var i = 0, attr; attr = attrs[i]; i++) {
|
|
873
753
|
s += ' ' + attr.name + '="' + escapeAttr(attr.value) + '"';
|
|
874
754
|
}
|
|
875
|
-
|
|
876
755
|
s += '>';
|
|
877
|
-
|
|
878
756
|
if (voidElements.has(tagName)) {
|
|
879
757
|
return s;
|
|
880
758
|
}
|
|
881
|
-
|
|
882
759
|
return s + getInnerHTML(node) + '</' + toLowerCase.call(tagName) + '>';
|
|
883
760
|
}
|
|
884
|
-
|
|
885
761
|
case TEXT_NODE:
|
|
886
762
|
{
|
|
887
763
|
var data = node.data,
|
|
888
|
-
|
|
889
|
-
|
|
764
|
+
parentNode = node.parentNode;
|
|
890
765
|
if (parentNode instanceof Element && plaintextParents.has(tagNameGetter.call(parentNode))) {
|
|
891
766
|
return data;
|
|
892
767
|
}
|
|
893
|
-
|
|
894
768
|
return escapeData(data);
|
|
895
769
|
}
|
|
896
|
-
|
|
897
770
|
case CDATA_SECTION_NODE:
|
|
898
771
|
{
|
|
899
772
|
return "<!CDATA[[".concat(node.data, "]]>");
|
|
900
773
|
}
|
|
901
|
-
|
|
902
774
|
case PROCESSING_INSTRUCTION_NODE:
|
|
903
775
|
{
|
|
904
776
|
return "<?".concat(node.target, " ").concat(node.data, "?>");
|
|
905
777
|
}
|
|
906
|
-
|
|
907
778
|
case COMMENT_NODE:
|
|
908
779
|
{
|
|
909
780
|
return "<!--".concat(node.data, "-->");
|
|
910
781
|
}
|
|
911
|
-
|
|
912
782
|
default:
|
|
913
783
|
{
|
|
914
784
|
// intentionally ignoring unknown node types
|
|
@@ -918,50 +788,42 @@
|
|
|
918
788
|
}
|
|
919
789
|
}
|
|
920
790
|
}
|
|
791
|
+
|
|
921
792
|
/*
|
|
922
793
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
923
794
|
* All rights reserved.
|
|
924
795
|
* SPDX-License-Identifier: MIT
|
|
925
796
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
926
797
|
*/
|
|
927
|
-
|
|
928
|
-
|
|
929
798
|
function getTextContent(node) {
|
|
930
799
|
switch (node.nodeType) {
|
|
931
800
|
case ELEMENT_NODE:
|
|
932
801
|
{
|
|
933
802
|
var childNodes = getFilteredChildNodes(node);
|
|
934
803
|
var content = '';
|
|
935
|
-
|
|
936
804
|
for (var i = 0, len = childNodes.length; i < len; i += 1) {
|
|
937
805
|
var currentNode = childNodes[i];
|
|
938
|
-
|
|
939
806
|
if (currentNode.nodeType !== COMMENT_NODE) {
|
|
940
807
|
content += getTextContent(currentNode);
|
|
941
808
|
}
|
|
942
809
|
}
|
|
943
|
-
|
|
944
810
|
return content;
|
|
945
811
|
}
|
|
946
|
-
|
|
947
812
|
default:
|
|
948
813
|
return node.nodeValue;
|
|
949
814
|
}
|
|
950
815
|
}
|
|
816
|
+
|
|
951
817
|
/*
|
|
952
818
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
953
819
|
* All rights reserved.
|
|
954
820
|
* SPDX-License-Identifier: MIT
|
|
955
821
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
956
822
|
*/
|
|
957
|
-
|
|
958
|
-
|
|
959
823
|
var Items$1 = new WeakMap();
|
|
960
|
-
|
|
961
824
|
function StaticNodeList() {
|
|
962
825
|
throw new TypeError('Illegal constructor');
|
|
963
826
|
}
|
|
964
|
-
|
|
965
827
|
StaticNodeList.prototype = create(NodeList.prototype, (_create = {
|
|
966
828
|
constructor: {
|
|
967
829
|
writable: true,
|
|
@@ -1025,7 +887,6 @@
|
|
|
1025
887
|
configurable: true,
|
|
1026
888
|
value: function value() {
|
|
1027
889
|
var _this = this;
|
|
1028
|
-
|
|
1029
890
|
var nextIndex = 0;
|
|
1030
891
|
return {
|
|
1031
892
|
next: function next() {
|
|
@@ -1050,14 +911,13 @@
|
|
|
1050
911
|
value: function value() {
|
|
1051
912
|
return '[object NodeList]';
|
|
1052
913
|
}
|
|
1053
|
-
}), _create));
|
|
1054
|
-
|
|
914
|
+
}), _create));
|
|
915
|
+
// prototype inheritance dance
|
|
1055
916
|
setPrototypeOf(StaticNodeList, NodeList);
|
|
1056
|
-
|
|
1057
917
|
function createStaticNodeList(items) {
|
|
1058
918
|
var nodeList = create(StaticNodeList.prototype);
|
|
1059
|
-
Items$1.set(nodeList, items);
|
|
1060
|
-
|
|
919
|
+
Items$1.set(nodeList, items);
|
|
920
|
+
// setting static indexes
|
|
1061
921
|
forEach.call(items, function (item, index) {
|
|
1062
922
|
defineProperty(nodeList, index, {
|
|
1063
923
|
value: item,
|
|
@@ -1067,6 +927,7 @@
|
|
|
1067
927
|
});
|
|
1068
928
|
return nodeList;
|
|
1069
929
|
}
|
|
930
|
+
|
|
1070
931
|
/*
|
|
1071
932
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
1072
933
|
* All rights reserved.
|
|
@@ -1074,91 +935,72 @@
|
|
|
1074
935
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
1075
936
|
*/
|
|
1076
937
|
// Walk up the DOM tree, collecting all shadow roots plus the document root
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
938
|
function getAllRootNodes(node) {
|
|
1080
939
|
var _a;
|
|
1081
|
-
|
|
1082
940
|
var rootNodes = [];
|
|
1083
941
|
var currentRootNode = node.getRootNode();
|
|
1084
|
-
|
|
1085
942
|
while (!isUndefined(currentRootNode)) {
|
|
1086
943
|
rootNodes.push(currentRootNode);
|
|
1087
944
|
currentRootNode = (_a = currentRootNode.host) === null || _a === void 0 ? void 0 : _a.getRootNode();
|
|
1088
945
|
}
|
|
1089
|
-
|
|
1090
946
|
return rootNodes;
|
|
1091
|
-
}
|
|
1092
|
-
|
|
1093
|
-
|
|
947
|
+
}
|
|
948
|
+
// Keep searching up the host tree until we find an element that is within the immediate shadow root
|
|
1094
949
|
var findAncestorHostInImmediateShadowRoot = function findAncestorHostInImmediateShadowRoot(rootNode, targetRootNode) {
|
|
1095
950
|
var host;
|
|
1096
|
-
|
|
1097
951
|
while (!isUndefined(host = rootNode.host)) {
|
|
1098
952
|
var thisRootNode = host.getRootNode();
|
|
1099
|
-
|
|
1100
953
|
if (thisRootNode === targetRootNode) {
|
|
1101
954
|
return host;
|
|
1102
955
|
}
|
|
1103
|
-
|
|
1104
956
|
rootNode = thisRootNode;
|
|
1105
957
|
}
|
|
1106
958
|
};
|
|
1107
|
-
|
|
1108
959
|
function fauxElementsFromPoint(context, doc, left, top) {
|
|
1109
960
|
var elements = elementsFromPoint.call(doc, left, top);
|
|
1110
961
|
var result = [];
|
|
1111
|
-
var rootNodes = getAllRootNodes(context);
|
|
962
|
+
var rootNodes = getAllRootNodes(context);
|
|
963
|
+
// Filter the elements array to only include those elements that are in this shadow root or in one of its
|
|
1112
964
|
// ancestor roots. This matches Chrome and Safari's implementation (but not Firefox's, which only includes
|
|
1113
965
|
// elements in the immediate shadow root: https://crbug.com/1207863#c4).
|
|
1114
|
-
|
|
1115
966
|
if (!isNull(elements)) {
|
|
1116
967
|
// can be null in IE https://developer.mozilla.org/en-US/docs/Web/API/Document/elementsFromPoint#browser_compatibility
|
|
1117
968
|
for (var i = 0; i < elements.length; i++) {
|
|
1118
969
|
var element = elements[i];
|
|
1119
|
-
|
|
1120
970
|
if (isSyntheticSlotElement(element)) {
|
|
1121
971
|
continue;
|
|
1122
972
|
}
|
|
1123
|
-
|
|
1124
973
|
var elementRootNode = element.getRootNode();
|
|
1125
|
-
|
|
1126
974
|
if (ArrayIndexOf.call(rootNodes, elementRootNode) !== -1) {
|
|
1127
975
|
ArrayPush.call(result, element);
|
|
1128
976
|
continue;
|
|
1129
|
-
}
|
|
977
|
+
}
|
|
978
|
+
// In cases where the host element is not visible but its shadow descendants are, then
|
|
1130
979
|
// we may get the shadow descendant instead of the host element here. (The
|
|
1131
980
|
// browser doesn't know the difference in synthetic shadow DOM.)
|
|
1132
981
|
// In native shadow DOM, however, elementsFromPoint would return the host but not
|
|
1133
982
|
// the child. So we need to detect if this shadow element's host is accessible from
|
|
1134
983
|
// the context's shadow root. Note we also need to be careful not to add the host
|
|
1135
984
|
// multiple times.
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
985
|
var ancestorHost = findAncestorHostInImmediateShadowRoot(elementRootNode, rootNodes[0]);
|
|
1139
|
-
|
|
1140
986
|
if (!isUndefined(ancestorHost) && ArrayIndexOf.call(elements, ancestorHost) === -1 && ArrayIndexOf.call(result, ancestorHost) === -1) {
|
|
1141
987
|
ArrayPush.call(result, ancestorHost);
|
|
1142
988
|
}
|
|
1143
989
|
}
|
|
1144
990
|
}
|
|
1145
|
-
|
|
1146
991
|
return result;
|
|
1147
992
|
}
|
|
993
|
+
|
|
1148
994
|
/*
|
|
1149
995
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
1150
996
|
* All rights reserved.
|
|
1151
997
|
* SPDX-License-Identifier: MIT
|
|
1152
998
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
1153
999
|
*/
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
1000
|
var Items = new WeakMap();
|
|
1157
|
-
|
|
1158
1001
|
function StaticHTMLCollection() {
|
|
1159
1002
|
throw new TypeError('Illegal constructor');
|
|
1160
1003
|
}
|
|
1161
|
-
|
|
1162
1004
|
StaticHTMLCollection.prototype = create(HTMLCollection.prototype, (_create2 = {
|
|
1163
1005
|
constructor: {
|
|
1164
1006
|
writable: true,
|
|
@@ -1189,17 +1031,13 @@
|
|
|
1189
1031
|
if (name === '') {
|
|
1190
1032
|
return null;
|
|
1191
1033
|
}
|
|
1192
|
-
|
|
1193
1034
|
var items = Items.get(this);
|
|
1194
|
-
|
|
1195
1035
|
for (var i = 0, len = items.length; i < len; i++) {
|
|
1196
1036
|
var item = items[len];
|
|
1197
|
-
|
|
1198
1037
|
if (name === getAttribute.call(item, 'id') || name === getAttribute.call(item, 'name')) {
|
|
1199
1038
|
return item;
|
|
1200
1039
|
}
|
|
1201
1040
|
}
|
|
1202
|
-
|
|
1203
1041
|
return null;
|
|
1204
1042
|
}
|
|
1205
1043
|
}
|
|
@@ -1214,14 +1052,13 @@
|
|
|
1214
1052
|
value: function value() {
|
|
1215
1053
|
return '[object HTMLCollection]';
|
|
1216
1054
|
}
|
|
1217
|
-
}), _create2));
|
|
1218
|
-
|
|
1055
|
+
}), _create2));
|
|
1056
|
+
// prototype inheritance dance
|
|
1219
1057
|
setPrototypeOf(StaticHTMLCollection, HTMLCollection);
|
|
1220
|
-
|
|
1221
1058
|
function createStaticHTMLCollection(items) {
|
|
1222
1059
|
var collection = create(StaticHTMLCollection.prototype);
|
|
1223
|
-
Items.set(collection, items);
|
|
1224
|
-
|
|
1060
|
+
Items.set(collection, items);
|
|
1061
|
+
// setting static indexes
|
|
1225
1062
|
forEach.call(items, function (item, index) {
|
|
1226
1063
|
defineProperty(collection, index, {
|
|
1227
1064
|
value: item,
|
|
@@ -1231,28 +1068,24 @@
|
|
|
1231
1068
|
});
|
|
1232
1069
|
return collection;
|
|
1233
1070
|
}
|
|
1071
|
+
|
|
1234
1072
|
/*
|
|
1235
1073
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
1236
1074
|
* All rights reserved.
|
|
1237
1075
|
* SPDX-License-Identifier: MIT
|
|
1238
1076
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
1239
1077
|
*/
|
|
1240
|
-
|
|
1241
1078
|
/**
|
|
1242
1079
|
* This method checks whether or not the content of the node is computed
|
|
1243
1080
|
* based on the light-dom slotting mechanism. This applies to synthetic slot elements
|
|
1244
1081
|
* and elements with shadow dom attached to them. It doesn't apply to native slot elements
|
|
1245
1082
|
* because we don't want to patch the children getters for those elements.
|
|
1246
1083
|
*/
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
1084
|
function hasMountedChildren(node) {
|
|
1250
1085
|
return isSyntheticSlotElement(node) || isSyntheticShadowHost(node);
|
|
1251
1086
|
}
|
|
1252
|
-
|
|
1253
1087
|
function getShadowParent(node, value) {
|
|
1254
1088
|
var owner = getNodeOwner(node);
|
|
1255
|
-
|
|
1256
1089
|
if (value === owner) {
|
|
1257
1090
|
// walking up via parent chain might end up in the shadow root element
|
|
1258
1091
|
return getShadowRoot(owner);
|
|
@@ -1265,64 +1098,50 @@
|
|
|
1265
1098
|
// where they slotted into, but its shadowed parent is always the
|
|
1266
1099
|
// owner of the slot.
|
|
1267
1100
|
var slotOwner = getNodeOwner(value);
|
|
1268
|
-
|
|
1269
1101
|
if (!isNull(slotOwner) && isNodeOwnedBy(owner, slotOwner)) {
|
|
1270
1102
|
// it is a slotted element, and therefore its parent is always going to be the host of the slot
|
|
1271
1103
|
return slotOwner;
|
|
1272
1104
|
}
|
|
1273
1105
|
}
|
|
1274
1106
|
}
|
|
1275
|
-
|
|
1276
1107
|
return null;
|
|
1277
1108
|
}
|
|
1278
|
-
|
|
1279
1109
|
function hasChildNodesPatched() {
|
|
1280
1110
|
return getInternalChildNodes(this).length > 0;
|
|
1281
1111
|
}
|
|
1282
|
-
|
|
1283
1112
|
function firstChildGetterPatched() {
|
|
1284
1113
|
var childNodes = getInternalChildNodes(this);
|
|
1285
1114
|
return childNodes[0] || null;
|
|
1286
1115
|
}
|
|
1287
|
-
|
|
1288
1116
|
function lastChildGetterPatched() {
|
|
1289
1117
|
var childNodes = getInternalChildNodes(this);
|
|
1290
1118
|
return childNodes[childNodes.length - 1] || null;
|
|
1291
1119
|
}
|
|
1292
|
-
|
|
1293
1120
|
function textContentGetterPatched() {
|
|
1294
1121
|
return getTextContent(this);
|
|
1295
1122
|
}
|
|
1296
|
-
|
|
1297
1123
|
function textContentSetterPatched(value) {
|
|
1298
1124
|
textContextSetter.call(this, value);
|
|
1299
1125
|
}
|
|
1300
|
-
|
|
1301
1126
|
function parentNodeGetterPatched() {
|
|
1302
1127
|
var value = parentNodeGetter.call(this);
|
|
1303
|
-
|
|
1304
1128
|
if (isNull(value)) {
|
|
1305
1129
|
return value;
|
|
1306
|
-
}
|
|
1307
|
-
|
|
1308
|
-
|
|
1130
|
+
}
|
|
1131
|
+
// TODO [#1635]: this needs optimization, maybe implementing it based on this.assignedSlot
|
|
1309
1132
|
return getShadowParent(this, value);
|
|
1310
1133
|
}
|
|
1311
|
-
|
|
1312
1134
|
function parentElementGetterPatched() {
|
|
1313
1135
|
var value = parentNodeGetter.call(this);
|
|
1314
|
-
|
|
1315
1136
|
if (isNull(value)) {
|
|
1316
1137
|
return null;
|
|
1317
1138
|
}
|
|
1318
|
-
|
|
1319
|
-
|
|
1139
|
+
var parentNode = getShadowParent(this, value);
|
|
1140
|
+
// it could be that the parentNode is the shadowRoot, in which case
|
|
1320
1141
|
// we need to return null.
|
|
1321
1142
|
// TODO [#1635]: this needs optimization, maybe implementing it based on this.assignedSlot
|
|
1322
|
-
|
|
1323
1143
|
return parentNode instanceof Element ? parentNode : null;
|
|
1324
1144
|
}
|
|
1325
|
-
|
|
1326
1145
|
function compareDocumentPositionPatched(otherNode) {
|
|
1327
1146
|
if (this === otherNode) {
|
|
1328
1147
|
return 0;
|
|
@@ -1332,71 +1151,56 @@
|
|
|
1332
1151
|
} else if (getNodeOwnerKey(this) !== getNodeOwnerKey(otherNode)) {
|
|
1333
1152
|
// "this" and "otherNode" belongs to 2 different shadow tree.
|
|
1334
1153
|
return 35; // Node.DOCUMENT_POSITION_DISCONNECTED | Node.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC | Node.DOCUMENT_POSITION_PRECEDING
|
|
1335
|
-
}
|
|
1154
|
+
}
|
|
1155
|
+
// Since "this" and "otherNode" are part of the same shadow tree we can safely rely to the native
|
|
1336
1156
|
// Node.compareDocumentPosition implementation.
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
1157
|
return compareDocumentPosition.call(this, otherNode);
|
|
1340
1158
|
}
|
|
1341
|
-
|
|
1342
1159
|
function containsPatched(otherNode) {
|
|
1343
1160
|
if (otherNode == null || getNodeOwnerKey(this) !== getNodeOwnerKey(otherNode)) {
|
|
1344
1161
|
// it is from another shadow
|
|
1345
1162
|
return false;
|
|
1346
1163
|
}
|
|
1347
|
-
|
|
1348
1164
|
return (compareDocumentPosition.call(this, otherNode) & DOCUMENT_POSITION_CONTAINED_BY) !== 0;
|
|
1349
1165
|
}
|
|
1350
|
-
|
|
1351
1166
|
function cloneNodePatched(deep) {
|
|
1352
|
-
var clone = cloneNode.call(this, false);
|
|
1167
|
+
var clone = cloneNode.call(this, false);
|
|
1168
|
+
// Per spec, browsers only care about truthy values
|
|
1353
1169
|
// Not strict true or false
|
|
1354
|
-
|
|
1355
1170
|
if (!deep) {
|
|
1356
1171
|
return clone;
|
|
1357
1172
|
}
|
|
1358
|
-
|
|
1359
1173
|
var childNodes = getInternalChildNodes(this);
|
|
1360
|
-
|
|
1361
1174
|
for (var i = 0, len = childNodes.length; i < len; i += 1) {
|
|
1362
1175
|
clone.appendChild(childNodes[i].cloneNode(true));
|
|
1363
1176
|
}
|
|
1364
|
-
|
|
1365
1177
|
return clone;
|
|
1366
1178
|
}
|
|
1367
1179
|
/**
|
|
1368
1180
|
* This method only applies to elements with a shadow or slots
|
|
1369
1181
|
*/
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
1182
|
function childNodesGetterPatched() {
|
|
1373
1183
|
if (isSyntheticShadowHost(this)) {
|
|
1374
1184
|
var owner = getNodeOwner(this);
|
|
1375
1185
|
var childNodes = isNull(owner) ? [] : getAllMatches(owner, getFilteredChildNodes(this));
|
|
1376
|
-
|
|
1377
1186
|
return createStaticNodeList(childNodes);
|
|
1378
|
-
}
|
|
1187
|
+
}
|
|
1188
|
+
// nothing to do here since this does not have a synthetic shadow attached to it
|
|
1379
1189
|
// TODO [#1636]: what about slot elements?
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
1190
|
return childNodesGetter.call(this);
|
|
1383
1191
|
}
|
|
1384
|
-
|
|
1385
1192
|
var nativeGetRootNode = _Node.prototype.getRootNode;
|
|
1386
1193
|
/**
|
|
1387
1194
|
* Get the root by climbing up the dom tree, beyond the shadow root
|
|
1388
1195
|
* If Node.prototype.getRootNode is supported, use it
|
|
1389
1196
|
* else, assume we are working in non-native shadow mode and climb using parentNode
|
|
1390
1197
|
*/
|
|
1391
|
-
|
|
1392
1198
|
var getDocumentOrRootNode = !isUndefined(nativeGetRootNode) ? nativeGetRootNode : function () {
|
|
1393
1199
|
var node = this;
|
|
1394
1200
|
var nodeParent;
|
|
1395
|
-
|
|
1396
1201
|
while (!isNull(nodeParent = parentNodeGetter.call(node))) {
|
|
1397
1202
|
node = nodeParent;
|
|
1398
1203
|
}
|
|
1399
|
-
|
|
1400
1204
|
return node;
|
|
1401
1205
|
};
|
|
1402
1206
|
/**
|
|
@@ -1408,15 +1212,12 @@
|
|
|
1408
1212
|
* of a native shadow or the synthetic shadow.
|
|
1409
1213
|
* @param {Node} node
|
|
1410
1214
|
*/
|
|
1411
|
-
|
|
1412
1215
|
function getNearestRoot(node) {
|
|
1413
1216
|
var ownerNode = getNodeOwner(node);
|
|
1414
|
-
|
|
1415
1217
|
if (isNull(ownerNode)) {
|
|
1416
1218
|
// we hit a wall, either we are in native shadow mode or the node is not in lwc boundary.
|
|
1417
1219
|
return getDocumentOrRootNode.call(node);
|
|
1418
1220
|
}
|
|
1419
|
-
|
|
1420
1221
|
return getShadowRoot(ownerNode);
|
|
1421
1222
|
}
|
|
1422
1223
|
/**
|
|
@@ -1438,22 +1239,18 @@
|
|
|
1438
1239
|
* _Spec_: https://dom.spec.whatwg.org/#dom-node-getrootnode
|
|
1439
1240
|
*
|
|
1440
1241
|
**/
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
1242
|
function getRootNodePatched(options) {
|
|
1444
1243
|
var composed = isUndefined(options) ? false : !!options.composed;
|
|
1445
1244
|
return isTrue(composed) ? getDocumentOrRootNode.call(this, options) : getNearestRoot(this);
|
|
1446
|
-
}
|
|
1245
|
+
}
|
|
1246
|
+
// Non-deep-traversing patches: this descriptor map includes all descriptors that
|
|
1447
1247
|
// do not give access to nodes beyond the immediate children.
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
1248
|
defineProperties(_Node.prototype, {
|
|
1451
1249
|
firstChild: {
|
|
1452
1250
|
get: function get() {
|
|
1453
1251
|
if (hasMountedChildren(this)) {
|
|
1454
1252
|
return firstChildGetterPatched.call(this);
|
|
1455
1253
|
}
|
|
1456
|
-
|
|
1457
1254
|
return firstChildGetter.call(this);
|
|
1458
1255
|
},
|
|
1459
1256
|
enumerable: true,
|
|
@@ -1464,7 +1261,6 @@
|
|
|
1464
1261
|
if (hasMountedChildren(this)) {
|
|
1465
1262
|
return lastChildGetterPatched.call(this);
|
|
1466
1263
|
}
|
|
1467
|
-
|
|
1468
1264
|
return lastChildGetter.call(this);
|
|
1469
1265
|
},
|
|
1470
1266
|
enumerable: true,
|
|
@@ -1476,15 +1272,12 @@
|
|
|
1476
1272
|
if (isNodeShadowed(this) || isSyntheticShadowHost(this)) {
|
|
1477
1273
|
return textContentGetterPatched.call(this);
|
|
1478
1274
|
}
|
|
1479
|
-
|
|
1480
1275
|
return textContentGetter.call(this);
|
|
1481
|
-
}
|
|
1482
|
-
|
|
1483
|
-
|
|
1276
|
+
}
|
|
1277
|
+
// TODO [#1222]: remove global bypass
|
|
1484
1278
|
if (isGlobalPatchingSkipped(this)) {
|
|
1485
1279
|
return textContentGetter.call(this);
|
|
1486
1280
|
}
|
|
1487
|
-
|
|
1488
1281
|
return textContentGetterPatched.call(this);
|
|
1489
1282
|
},
|
|
1490
1283
|
set: textContentSetterPatched,
|
|
@@ -1496,14 +1289,12 @@
|
|
|
1496
1289
|
if (isNodeShadowed(this)) {
|
|
1497
1290
|
return parentNodeGetterPatched.call(this);
|
|
1498
1291
|
}
|
|
1499
|
-
|
|
1500
|
-
|
|
1292
|
+
var parentNode = parentNodeGetter.call(this);
|
|
1293
|
+
// Handle the case where a top level light DOM element is slotted into a synthetic
|
|
1501
1294
|
// shadow slot.
|
|
1502
|
-
|
|
1503
1295
|
if (!isNull(parentNode) && isSyntheticSlotElement(parentNode)) {
|
|
1504
1296
|
return getNodeOwner(parentNode);
|
|
1505
1297
|
}
|
|
1506
|
-
|
|
1507
1298
|
return parentNode;
|
|
1508
1299
|
},
|
|
1509
1300
|
enumerable: true,
|
|
@@ -1514,14 +1305,12 @@
|
|
|
1514
1305
|
if (isNodeShadowed(this)) {
|
|
1515
1306
|
return parentElementGetterPatched.call(this);
|
|
1516
1307
|
}
|
|
1517
|
-
|
|
1518
|
-
|
|
1308
|
+
var parentElement = parentElementGetter.call(this);
|
|
1309
|
+
// Handle the case where a top level light DOM element is slotted into a synthetic
|
|
1519
1310
|
// shadow slot.
|
|
1520
|
-
|
|
1521
1311
|
if (!isNull(parentElement) && isSyntheticSlotElement(parentElement)) {
|
|
1522
1312
|
return getNodeOwner(parentElement);
|
|
1523
1313
|
}
|
|
1524
|
-
|
|
1525
1314
|
return parentElement;
|
|
1526
1315
|
},
|
|
1527
1316
|
enumerable: true,
|
|
@@ -1532,7 +1321,6 @@
|
|
|
1532
1321
|
if (hasMountedChildren(this)) {
|
|
1533
1322
|
return childNodesGetterPatched.call(this);
|
|
1534
1323
|
}
|
|
1535
|
-
|
|
1536
1324
|
return childNodesGetter.call(this);
|
|
1537
1325
|
},
|
|
1538
1326
|
enumerable: true,
|
|
@@ -1543,7 +1331,6 @@
|
|
|
1543
1331
|
if (hasMountedChildren(this)) {
|
|
1544
1332
|
return hasChildNodesPatched.call(this);
|
|
1545
1333
|
}
|
|
1546
|
-
|
|
1547
1334
|
return hasChildNodes.call(this);
|
|
1548
1335
|
},
|
|
1549
1336
|
enumerable: true,
|
|
@@ -1556,7 +1343,6 @@
|
|
|
1556
1343
|
if (isGlobalPatchingSkipped(this)) {
|
|
1557
1344
|
return compareDocumentPosition.call(this, otherNode);
|
|
1558
1345
|
}
|
|
1559
|
-
|
|
1560
1346
|
return compareDocumentPositionPatched.call(this, otherNode);
|
|
1561
1347
|
},
|
|
1562
1348
|
enumerable: true,
|
|
@@ -1572,24 +1358,19 @@
|
|
|
1572
1358
|
if (this === otherNode) {
|
|
1573
1359
|
return true;
|
|
1574
1360
|
}
|
|
1575
|
-
|
|
1576
1361
|
if (!lwcRuntimeFlags.ENABLE_NODE_PATCH) {
|
|
1577
1362
|
if (otherNode == null) {
|
|
1578
1363
|
return false;
|
|
1579
1364
|
}
|
|
1580
|
-
|
|
1581
1365
|
if (isNodeShadowed(this) || isSyntheticShadowHost(this)) {
|
|
1582
1366
|
return containsPatched.call(this, otherNode);
|
|
1583
1367
|
}
|
|
1584
|
-
|
|
1585
1368
|
return contains.call(this, otherNode);
|
|
1586
|
-
}
|
|
1587
|
-
|
|
1588
|
-
|
|
1369
|
+
}
|
|
1370
|
+
// TODO [#1222]: remove global bypass
|
|
1589
1371
|
if (isGlobalPatchingSkipped(this)) {
|
|
1590
1372
|
return contains.call(this, otherNode);
|
|
1591
1373
|
}
|
|
1592
|
-
|
|
1593
1374
|
return containsPatched.call(this, otherNode);
|
|
1594
1375
|
},
|
|
1595
1376
|
enumerable: true,
|
|
@@ -1602,19 +1383,15 @@
|
|
|
1602
1383
|
if (isNodeShadowed(this) || isSyntheticShadowHost(this)) {
|
|
1603
1384
|
return cloneNodePatched.call(this, deep);
|
|
1604
1385
|
}
|
|
1605
|
-
|
|
1606
1386
|
return cloneNode.call(this, deep);
|
|
1607
1387
|
}
|
|
1608
|
-
|
|
1609
1388
|
if (isTrue(deep)) {
|
|
1610
1389
|
// TODO [#1222]: remove global bypass
|
|
1611
1390
|
if (isGlobalPatchingSkipped(this)) {
|
|
1612
1391
|
return cloneNode.call(this, deep);
|
|
1613
1392
|
}
|
|
1614
|
-
|
|
1615
1393
|
return cloneNodePatched.call(this, deep);
|
|
1616
1394
|
}
|
|
1617
|
-
|
|
1618
1395
|
return cloneNode.call(this, deep);
|
|
1619
1396
|
},
|
|
1620
1397
|
enumerable: true,
|
|
@@ -1635,33 +1412,28 @@
|
|
|
1635
1412
|
}
|
|
1636
1413
|
}
|
|
1637
1414
|
});
|
|
1638
|
-
|
|
1639
1415
|
var getInternalChildNodes = function (node) {
|
|
1640
1416
|
return node.childNodes;
|
|
1641
|
-
};
|
|
1642
|
-
|
|
1417
|
+
};
|
|
1418
|
+
// IE11 extra patches for wrong prototypes
|
|
1643
1419
|
if (hasOwnProperty.call(HTMLElement.prototype, 'contains')) {
|
|
1644
1420
|
defineProperty(HTMLElement.prototype, 'contains', getOwnPropertyDescriptor(_Node.prototype, 'contains'));
|
|
1645
1421
|
}
|
|
1646
|
-
|
|
1647
1422
|
if (hasOwnProperty.call(HTMLElement.prototype, 'parentElement')) {
|
|
1648
1423
|
defineProperty(HTMLElement.prototype, 'parentElement', getOwnPropertyDescriptor(_Node.prototype, 'parentElement'));
|
|
1649
1424
|
}
|
|
1425
|
+
|
|
1650
1426
|
/*
|
|
1651
1427
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
1652
1428
|
* All rights reserved.
|
|
1653
1429
|
* SPDX-License-Identifier: MIT
|
|
1654
1430
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
1655
1431
|
*/
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
1432
|
var EventListenerMap = new WeakMap();
|
|
1659
1433
|
var ComposedPathMap = new WeakMap();
|
|
1660
|
-
|
|
1661
1434
|
function isEventListenerOrEventListenerObject(fnOrObj) {
|
|
1662
1435
|
return isFunction(fnOrObj) || isObject(fnOrObj) && !isNull(fnOrObj) && isFunction(fnOrObj.handleEvent);
|
|
1663
1436
|
}
|
|
1664
|
-
|
|
1665
1437
|
function shouldInvokeListener(event, target, currentTarget) {
|
|
1666
1438
|
// Subsequent logic assumes that `currentTarget` must be contained in the composed path for the listener to be
|
|
1667
1439
|
// invoked, but this is not always the case. `composedPath()` will sometimes return an empty array, even when the
|
|
@@ -1669,62 +1441,47 @@
|
|
|
1669
1441
|
if (target === currentTarget) {
|
|
1670
1442
|
return true;
|
|
1671
1443
|
}
|
|
1672
|
-
|
|
1673
1444
|
var composedPath = ComposedPathMap.get(event);
|
|
1674
|
-
|
|
1675
1445
|
if (isUndefined(composedPath)) {
|
|
1676
1446
|
composedPath = event.composedPath();
|
|
1677
1447
|
ComposedPathMap.set(event, composedPath);
|
|
1678
1448
|
}
|
|
1679
|
-
|
|
1680
1449
|
return composedPath.includes(currentTarget);
|
|
1681
1450
|
}
|
|
1682
|
-
|
|
1683
1451
|
function getEventListenerWrapper(fnOrObj) {
|
|
1684
1452
|
if (!isEventListenerOrEventListenerObject(fnOrObj)) {
|
|
1685
1453
|
return fnOrObj;
|
|
1686
1454
|
}
|
|
1687
|
-
|
|
1688
1455
|
var wrapperFn = EventListenerMap.get(fnOrObj);
|
|
1689
|
-
|
|
1690
1456
|
if (isUndefined(wrapperFn)) {
|
|
1691
1457
|
wrapperFn = function wrapperFn(event) {
|
|
1692
1458
|
// This function is invoked from an event listener and currentTarget is always defined.
|
|
1693
1459
|
var currentTarget = eventCurrentTargetGetter.call(event);
|
|
1694
|
-
|
|
1695
1460
|
var actualTarget = getActualTarget(event);
|
|
1696
|
-
|
|
1697
1461
|
if (!shouldInvokeListener(event, actualTarget, currentTarget)) {
|
|
1698
1462
|
return;
|
|
1699
1463
|
}
|
|
1700
|
-
|
|
1701
1464
|
return isFunction(fnOrObj) ? fnOrObj.call(this, event) : fnOrObj.handleEvent && fnOrObj.handleEvent(event);
|
|
1702
1465
|
};
|
|
1703
|
-
|
|
1704
1466
|
EventListenerMap.set(fnOrObj, wrapperFn);
|
|
1705
1467
|
}
|
|
1706
|
-
|
|
1707
1468
|
return wrapperFn;
|
|
1708
1469
|
}
|
|
1470
|
+
|
|
1709
1471
|
/*
|
|
1710
1472
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
1711
1473
|
* All rights reserved.
|
|
1712
1474
|
* SPDX-License-Identifier: MIT
|
|
1713
1475
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
1714
1476
|
*/
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
1477
|
var eventToContextMap = new WeakMap();
|
|
1718
1478
|
var customElementToWrappedListeners = new WeakMap();
|
|
1719
|
-
|
|
1720
1479
|
function getEventMap(elm) {
|
|
1721
1480
|
var listenerInfo = customElementToWrappedListeners.get(elm);
|
|
1722
|
-
|
|
1723
1481
|
if (isUndefined(listenerInfo)) {
|
|
1724
1482
|
listenerInfo = create(null);
|
|
1725
1483
|
customElementToWrappedListeners.set(elm, listenerInfo);
|
|
1726
1484
|
}
|
|
1727
|
-
|
|
1728
1485
|
return listenerInfo;
|
|
1729
1486
|
}
|
|
1730
1487
|
/**
|
|
@@ -1732,89 +1489,67 @@
|
|
|
1732
1489
|
* property of events dispatched on shadow roots always resolve to their host. This function understands this
|
|
1733
1490
|
* abstraction and properly returns a reference to the shadow root when appropriate.
|
|
1734
1491
|
*/
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
1492
|
function getActualTarget(event) {
|
|
1738
1493
|
var _a;
|
|
1739
|
-
|
|
1740
1494
|
return (_a = eventToShadowRootMap.get(event)) !== null && _a !== void 0 ? _a : eventTargetGetter.call(event);
|
|
1741
1495
|
}
|
|
1742
|
-
|
|
1743
1496
|
var shadowRootEventListenerMap = new WeakMap();
|
|
1744
|
-
|
|
1745
1497
|
function getWrappedShadowRootListener(listener) {
|
|
1746
1498
|
if (!isFunction(listener)) {
|
|
1747
1499
|
throw new TypeError(); // avoiding problems with non-valid listeners
|
|
1748
1500
|
}
|
|
1749
1501
|
|
|
1750
1502
|
var shadowRootWrappedListener = shadowRootEventListenerMap.get(listener);
|
|
1751
|
-
|
|
1752
1503
|
if (isUndefined(shadowRootWrappedListener)) {
|
|
1753
1504
|
shadowRootWrappedListener = function shadowRootWrappedListener(event) {
|
|
1754
1505
|
// currentTarget is always defined inside an event listener
|
|
1755
|
-
var currentTarget = eventCurrentTargetGetter.call(event);
|
|
1506
|
+
var currentTarget = eventCurrentTargetGetter.call(event);
|
|
1507
|
+
// If currentTarget is not an instance of a native shadow root then we're dealing with a
|
|
1756
1508
|
// host element whose synthetic shadow root must be accessed via getShadowRoot().
|
|
1757
|
-
|
|
1758
1509
|
if (!isInstanceOfNativeShadowRoot(currentTarget)) {
|
|
1759
1510
|
currentTarget = getShadowRoot(currentTarget);
|
|
1760
1511
|
}
|
|
1761
|
-
|
|
1762
1512
|
var actualTarget = getActualTarget(event);
|
|
1763
|
-
|
|
1764
1513
|
if (shouldInvokeListener(event, actualTarget, currentTarget)) {
|
|
1765
1514
|
listener.call(currentTarget, event);
|
|
1766
1515
|
}
|
|
1767
1516
|
};
|
|
1768
|
-
|
|
1769
|
-
shadowRootWrappedListener.placement = 1
|
|
1770
|
-
/* EventListenerContext.SHADOW_ROOT_LISTENER */
|
|
1771
|
-
;
|
|
1517
|
+
shadowRootWrappedListener.placement = 1 /* EventListenerContext.SHADOW_ROOT_LISTENER */;
|
|
1772
1518
|
shadowRootEventListenerMap.set(listener, shadowRootWrappedListener);
|
|
1773
1519
|
}
|
|
1774
|
-
|
|
1775
1520
|
return shadowRootWrappedListener;
|
|
1776
1521
|
}
|
|
1777
|
-
|
|
1778
1522
|
var customElementEventListenerMap = new WeakMap();
|
|
1779
|
-
|
|
1780
1523
|
function getWrappedCustomElementListener(listener) {
|
|
1781
1524
|
if (!isFunction(listener)) {
|
|
1782
1525
|
throw new TypeError(); // avoiding problems with non-valid listeners
|
|
1783
1526
|
}
|
|
1784
1527
|
|
|
1785
1528
|
var customElementWrappedListener = customElementEventListenerMap.get(listener);
|
|
1786
|
-
|
|
1787
1529
|
if (isUndefined(customElementWrappedListener)) {
|
|
1788
1530
|
customElementWrappedListener = function customElementWrappedListener(event) {
|
|
1789
1531
|
// currentTarget is always defined inside an event listener
|
|
1790
1532
|
var currentTarget = eventCurrentTargetGetter.call(event);
|
|
1791
1533
|
var actualTarget = getActualTarget(event);
|
|
1792
|
-
|
|
1793
1534
|
if (shouldInvokeListener(event, actualTarget, currentTarget)) {
|
|
1794
1535
|
listener.call(currentTarget, event);
|
|
1795
1536
|
}
|
|
1796
1537
|
};
|
|
1797
|
-
|
|
1798
|
-
customElementWrappedListener.placement = 0
|
|
1799
|
-
/* EventListenerContext.CUSTOM_ELEMENT_LISTENER */
|
|
1800
|
-
;
|
|
1538
|
+
customElementWrappedListener.placement = 0 /* EventListenerContext.CUSTOM_ELEMENT_LISTENER */;
|
|
1801
1539
|
customElementEventListenerMap.set(listener, customElementWrappedListener);
|
|
1802
1540
|
}
|
|
1803
|
-
|
|
1804
1541
|
return customElementWrappedListener;
|
|
1805
1542
|
}
|
|
1806
|
-
|
|
1807
1543
|
function domListener(evt) {
|
|
1808
1544
|
var immediatePropagationStopped = false;
|
|
1809
1545
|
var propagationStopped = false;
|
|
1810
1546
|
var type = evt.type,
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1547
|
+
stopImmediatePropagation = evt.stopImmediatePropagation,
|
|
1548
|
+
stopPropagation = evt.stopPropagation;
|
|
1549
|
+
// currentTarget is always defined
|
|
1814
1550
|
var currentTarget = eventCurrentTargetGetter.call(evt);
|
|
1815
1551
|
var listenerMap = getEventMap(currentTarget);
|
|
1816
1552
|
var listeners = listenerMap[type]; // it must have listeners at this point
|
|
1817
|
-
|
|
1818
1553
|
defineProperty(evt, 'stopImmediatePropagation', {
|
|
1819
1554
|
value: function value() {
|
|
1820
1555
|
immediatePropagationStopped = true;
|
|
@@ -1832,10 +1567,9 @@
|
|
|
1832
1567
|
writable: true,
|
|
1833
1568
|
enumerable: true,
|
|
1834
1569
|
configurable: true
|
|
1835
|
-
});
|
|
1836
|
-
|
|
1570
|
+
});
|
|
1571
|
+
// in case a listener adds or removes other listeners during invocation
|
|
1837
1572
|
var bookkeeping = ArraySlice.call(listeners);
|
|
1838
|
-
|
|
1839
1573
|
function invokeListenersByPlacement(placement) {
|
|
1840
1574
|
forEach.call(bookkeeping, function (listener) {
|
|
1841
1575
|
if (isFalse(immediatePropagationStopped) && listener.placement === placement) {
|
|
@@ -1847,75 +1581,54 @@
|
|
|
1847
1581
|
}
|
|
1848
1582
|
});
|
|
1849
1583
|
}
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
/* EventListenerContext.SHADOW_ROOT_LISTENER */
|
|
1853
|
-
);
|
|
1854
|
-
invokeListenersByPlacement(1
|
|
1855
|
-
/* EventListenerContext.SHADOW_ROOT_LISTENER */
|
|
1856
|
-
);
|
|
1857
|
-
|
|
1584
|
+
eventToContextMap.set(evt, 1 /* EventListenerContext.SHADOW_ROOT_LISTENER */);
|
|
1585
|
+
invokeListenersByPlacement(1 /* EventListenerContext.SHADOW_ROOT_LISTENER */);
|
|
1858
1586
|
if (isFalse(immediatePropagationStopped) && isFalse(propagationStopped)) {
|
|
1859
1587
|
// doing the second iteration only if the first one didn't interrupt the event propagation
|
|
1860
|
-
eventToContextMap.set(evt, 0
|
|
1861
|
-
/* EventListenerContext.CUSTOM_ELEMENT_LISTENER */
|
|
1862
|
-
);
|
|
1863
|
-
invokeListenersByPlacement(0
|
|
1864
|
-
/* EventListenerContext.CUSTOM_ELEMENT_LISTENER */
|
|
1865
|
-
);
|
|
1588
|
+
eventToContextMap.set(evt, 0 /* EventListenerContext.CUSTOM_ELEMENT_LISTENER */);
|
|
1589
|
+
invokeListenersByPlacement(0 /* EventListenerContext.CUSTOM_ELEMENT_LISTENER */);
|
|
1866
1590
|
}
|
|
1867
1591
|
|
|
1868
|
-
eventToContextMap.set(evt, 2
|
|
1869
|
-
/* EventListenerContext.UNKNOWN_LISTENER */
|
|
1870
|
-
);
|
|
1592
|
+
eventToContextMap.set(evt, 2 /* EventListenerContext.UNKNOWN_LISTENER */);
|
|
1871
1593
|
}
|
|
1872
1594
|
|
|
1873
1595
|
function attachDOMListener(elm, type, wrappedListener) {
|
|
1874
1596
|
var listenerMap = getEventMap(elm);
|
|
1875
1597
|
var cmpEventHandlers = listenerMap[type];
|
|
1876
|
-
|
|
1877
1598
|
if (isUndefined(cmpEventHandlers)) {
|
|
1878
1599
|
cmpEventHandlers = listenerMap[type] = [];
|
|
1879
|
-
}
|
|
1600
|
+
}
|
|
1601
|
+
// Prevent identical listeners from subscribing to the same event type.
|
|
1880
1602
|
// TODO [#1824]: Options will also play a factor when we introduce support for them (#1824).
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
1603
|
if (ArrayIndexOf.call(cmpEventHandlers, wrappedListener) !== -1) {
|
|
1884
1604
|
return;
|
|
1885
|
-
}
|
|
1886
|
-
|
|
1887
|
-
|
|
1605
|
+
}
|
|
1606
|
+
// only add to DOM if there is no other listener on the same placement yet
|
|
1888
1607
|
if (cmpEventHandlers.length === 0) {
|
|
1889
1608
|
// super.addEventListener() - this will not work on
|
|
1890
1609
|
addEventListener.call(elm, type, domListener);
|
|
1891
1610
|
}
|
|
1892
|
-
|
|
1893
1611
|
ArrayPush.call(cmpEventHandlers, wrappedListener);
|
|
1894
1612
|
}
|
|
1895
|
-
|
|
1896
1613
|
function detachDOMListener(elm, type, wrappedListener) {
|
|
1897
1614
|
var listenerMap = getEventMap(elm);
|
|
1898
1615
|
var p;
|
|
1899
1616
|
var listeners;
|
|
1900
|
-
|
|
1901
1617
|
if (!isUndefined(listeners = listenerMap[type]) && (p = ArrayIndexOf.call(listeners, wrappedListener)) !== -1) {
|
|
1902
|
-
ArraySplice.call(listeners, p, 1);
|
|
1903
|
-
|
|
1618
|
+
ArraySplice.call(listeners, p, 1);
|
|
1619
|
+
// only remove from DOM if there is no other listener on the same placement
|
|
1904
1620
|
if (listeners.length === 0) {
|
|
1905
1621
|
removeEventListener.call(elm, type, domListener);
|
|
1906
1622
|
}
|
|
1907
1623
|
}
|
|
1908
1624
|
}
|
|
1909
|
-
|
|
1910
1625
|
function addCustomElementEventListener(type, listener, _options) {
|
|
1911
|
-
|
|
1912
|
-
|
|
1626
|
+
// TODO [#1824]: Lift this restriction on the option parameter
|
|
1913
1627
|
if (isFunction(listener)) {
|
|
1914
1628
|
var wrappedListener = getWrappedCustomElementListener(listener);
|
|
1915
1629
|
attachDOMListener(this, type, wrappedListener);
|
|
1916
1630
|
}
|
|
1917
1631
|
}
|
|
1918
|
-
|
|
1919
1632
|
function removeCustomElementEventListener(type, listener, _options) {
|
|
1920
1633
|
// TODO [#1824]: Lift this restriction on the option parameter
|
|
1921
1634
|
if (isFunction(listener)) {
|
|
@@ -1923,17 +1636,14 @@
|
|
|
1923
1636
|
detachDOMListener(this, type, wrappedListener);
|
|
1924
1637
|
}
|
|
1925
1638
|
}
|
|
1926
|
-
|
|
1927
1639
|
function addShadowRootEventListener(sr, type, listener, _options) {
|
|
1928
|
-
|
|
1929
|
-
|
|
1640
|
+
// TODO [#1824]: Lift this restriction on the option parameter
|
|
1930
1641
|
if (isFunction(listener)) {
|
|
1931
1642
|
var elm = getHost(sr);
|
|
1932
1643
|
var wrappedListener = getWrappedShadowRootListener(listener);
|
|
1933
1644
|
attachDOMListener(elm, type, wrappedListener);
|
|
1934
1645
|
}
|
|
1935
1646
|
}
|
|
1936
|
-
|
|
1937
1647
|
function removeShadowRootEventListener(sr, type, listener, _options) {
|
|
1938
1648
|
// TODO [#1824]: Lift this restriction on the option parameter
|
|
1939
1649
|
if (isFunction(listener)) {
|
|
@@ -1942,37 +1652,31 @@
|
|
|
1942
1652
|
detachDOMListener(elm, type, wrappedListener);
|
|
1943
1653
|
}
|
|
1944
1654
|
}
|
|
1655
|
+
|
|
1945
1656
|
/*
|
|
1946
1657
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
1947
1658
|
* All rights reserved.
|
|
1948
1659
|
* SPDX-License-Identifier: MIT
|
|
1949
1660
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
1950
1661
|
*/
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
1662
|
var InternalSlot = new WeakMap();
|
|
1954
1663
|
var _document = document,
|
|
1955
|
-
|
|
1956
|
-
|
|
1664
|
+
createDocumentFragment = _document.createDocumentFragment;
|
|
1957
1665
|
function hasInternalSlot(root) {
|
|
1958
1666
|
return InternalSlot.has(root);
|
|
1959
1667
|
}
|
|
1960
|
-
|
|
1961
1668
|
function getInternalSlot(root) {
|
|
1962
1669
|
var record = InternalSlot.get(root);
|
|
1963
|
-
|
|
1964
1670
|
if (isUndefined(record)) {
|
|
1965
1671
|
throw new TypeError();
|
|
1966
1672
|
}
|
|
1967
|
-
|
|
1968
1673
|
return record;
|
|
1969
1674
|
}
|
|
1970
|
-
|
|
1971
1675
|
defineProperty(_Node.prototype, KEY__SHADOW_RESOLVER, {
|
|
1972
1676
|
set: function set(fn) {
|
|
1973
1677
|
if (isUndefined(fn)) return;
|
|
1974
|
-
this[KEY__SHADOW_RESOLVER_PRIVATE] = fn;
|
|
1975
|
-
|
|
1678
|
+
this[KEY__SHADOW_RESOLVER_PRIVATE] = fn;
|
|
1679
|
+
// TODO [#1164]: temporary propagation of the key
|
|
1976
1680
|
setNodeOwnerKey(this, fn.nodeKey);
|
|
1977
1681
|
},
|
|
1978
1682
|
get: function get() {
|
|
@@ -1984,52 +1688,42 @@
|
|
|
1984
1688
|
defineProperty(_globalThis, KEY__IS_NATIVE_SHADOW_ROOT_DEFINED, {
|
|
1985
1689
|
value: isNativeShadowRootDefined
|
|
1986
1690
|
});
|
|
1987
|
-
|
|
1988
1691
|
function getShadowRootResolver(node) {
|
|
1989
1692
|
return node[KEY__SHADOW_RESOLVER];
|
|
1990
1693
|
}
|
|
1991
|
-
|
|
1992
1694
|
function setShadowRootResolver(node, fn) {
|
|
1993
1695
|
node[KEY__SHADOW_RESOLVER] = fn;
|
|
1994
1696
|
}
|
|
1995
|
-
|
|
1996
1697
|
function isDelegatingFocus(host) {
|
|
1997
1698
|
return getInternalSlot(host).delegatesFocus;
|
|
1998
1699
|
}
|
|
1999
|
-
|
|
2000
1700
|
function getHost(root) {
|
|
2001
1701
|
return getInternalSlot(root).host;
|
|
2002
1702
|
}
|
|
2003
|
-
|
|
2004
1703
|
function getShadowRoot(elm) {
|
|
2005
1704
|
return getInternalSlot(elm).shadowRoot;
|
|
2006
|
-
}
|
|
1705
|
+
}
|
|
1706
|
+
// Intentionally adding `Node` here in addition to `Element` since this check is harmless for nodes
|
|
2007
1707
|
// and we can avoid having to cast the type before calling this method in a few places.
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
1708
|
function isSyntheticShadowHost(node) {
|
|
2011
1709
|
var shadowRootRecord = InternalSlot.get(node);
|
|
2012
1710
|
return !isUndefined(shadowRootRecord) && node === shadowRootRecord.host;
|
|
2013
1711
|
}
|
|
2014
|
-
|
|
2015
1712
|
function isSyntheticShadowRoot(node) {
|
|
2016
1713
|
var shadowRootRecord = InternalSlot.get(node);
|
|
2017
1714
|
return !isUndefined(shadowRootRecord) && node === shadowRootRecord.shadowRoot;
|
|
2018
1715
|
}
|
|
2019
|
-
|
|
2020
1716
|
var uid = 0;
|
|
2021
|
-
|
|
2022
1717
|
function attachShadow(elm, options) {
|
|
2023
1718
|
if (InternalSlot.has(elm)) {
|
|
2024
1719
|
throw new Error("Failed to execute 'attachShadow' on 'Element': Shadow root cannot be created on a host which already hosts a shadow tree.");
|
|
2025
1720
|
}
|
|
2026
|
-
|
|
2027
1721
|
var mode = options.mode,
|
|
2028
|
-
|
|
2029
|
-
|
|
1722
|
+
delegatesFocus = options.delegatesFocus;
|
|
1723
|
+
// creating a real fragment for shadowRoot instance
|
|
2030
1724
|
var doc = getOwnerDocument(elm);
|
|
2031
|
-
var sr = createDocumentFragment.call(doc);
|
|
2032
|
-
|
|
1725
|
+
var sr = createDocumentFragment.call(doc);
|
|
1726
|
+
// creating shadow internal record
|
|
2033
1727
|
var record = {
|
|
2034
1728
|
mode: mode,
|
|
2035
1729
|
delegatesFocus: !!delegatesFocus,
|
|
@@ -2038,19 +1732,16 @@
|
|
|
2038
1732
|
};
|
|
2039
1733
|
InternalSlot.set(sr, record);
|
|
2040
1734
|
InternalSlot.set(elm, record);
|
|
2041
|
-
|
|
2042
1735
|
var shadowResolver = function shadowResolver() {
|
|
2043
1736
|
return sr;
|
|
2044
1737
|
};
|
|
2045
|
-
|
|
2046
1738
|
var x = shadowResolver.nodeKey = uid++;
|
|
2047
1739
|
setNodeKey(elm, x);
|
|
2048
|
-
setShadowRootResolver(sr, shadowResolver);
|
|
2049
|
-
|
|
1740
|
+
setShadowRootResolver(sr, shadowResolver);
|
|
1741
|
+
// correcting the proto chain
|
|
2050
1742
|
setPrototypeOf(sr, SyntheticShadowRoot.prototype);
|
|
2051
1743
|
return sr;
|
|
2052
1744
|
}
|
|
2053
|
-
|
|
2054
1745
|
var SyntheticShadowRootDescriptors = {
|
|
2055
1746
|
constructor: {
|
|
2056
1747
|
writable: true,
|
|
@@ -2079,31 +1770,25 @@
|
|
|
2079
1770
|
var host = getHost(this);
|
|
2080
1771
|
var doc = getOwnerDocument(host);
|
|
2081
1772
|
var activeElement = DocumentPrototypeActiveElement.call(doc);
|
|
2082
|
-
|
|
2083
1773
|
if (isNull(activeElement)) {
|
|
2084
1774
|
return activeElement;
|
|
2085
1775
|
}
|
|
2086
|
-
|
|
2087
1776
|
if ((compareDocumentPosition.call(host, activeElement) & DOCUMENT_POSITION_CONTAINED_BY) === 0) {
|
|
2088
1777
|
return null;
|
|
2089
|
-
}
|
|
2090
|
-
|
|
2091
|
-
|
|
1778
|
+
}
|
|
1779
|
+
// activeElement must be child of the host and owned by it
|
|
2092
1780
|
var node = activeElement;
|
|
2093
|
-
|
|
2094
1781
|
while (!isNodeOwnedBy(host, node)) {
|
|
2095
1782
|
// parentElement is always an element because we are talking up the tree knowing
|
|
2096
1783
|
// that it is a child of the host.
|
|
2097
1784
|
node = parentElementGetter.call(node);
|
|
2098
|
-
}
|
|
1785
|
+
}
|
|
1786
|
+
// If we have a slot element here that means that we were dealing
|
|
2099
1787
|
// with an element that was passed to one of our slots. In this
|
|
2100
1788
|
// case, activeElement returns null.
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
1789
|
if (isSlotElement(node)) {
|
|
2104
1790
|
return null;
|
|
2105
1791
|
}
|
|
2106
|
-
|
|
2107
1792
|
return node;
|
|
2108
1793
|
}
|
|
2109
1794
|
},
|
|
@@ -2213,9 +1898,9 @@
|
|
|
2213
1898
|
enumerable: true,
|
|
2214
1899
|
configurable: true,
|
|
2215
1900
|
value: function value(evt) {
|
|
2216
|
-
eventToShadowRootMap.set(evt, this);
|
|
1901
|
+
eventToShadowRootMap.set(evt, this);
|
|
1902
|
+
// Typescript does not like it when you treat the `arguments` object as an array
|
|
2217
1903
|
// @ts-ignore type-mismatch
|
|
2218
|
-
|
|
2219
1904
|
return dispatchEvent.apply(getHost(this), arguments);
|
|
2220
1905
|
}
|
|
2221
1906
|
},
|
|
@@ -2255,7 +1940,6 @@
|
|
|
2255
1940
|
configurable: true,
|
|
2256
1941
|
value: function value(otherNode) {
|
|
2257
1942
|
var host = getHost(this);
|
|
2258
|
-
|
|
2259
1943
|
if (this === otherNode) {
|
|
2260
1944
|
// "this" and "otherNode" are the same shadow root.
|
|
2261
1945
|
return 0;
|
|
@@ -2271,6 +1955,7 @@
|
|
|
2271
1955
|
}
|
|
2272
1956
|
}
|
|
2273
1957
|
},
|
|
1958
|
+
|
|
2274
1959
|
contains: {
|
|
2275
1960
|
writable: true,
|
|
2276
1961
|
enumerable: true,
|
|
@@ -2279,9 +1964,8 @@
|
|
|
2279
1964
|
if (this === otherNode) {
|
|
2280
1965
|
return true;
|
|
2281
1966
|
}
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
|
|
1967
|
+
var host = getHost(this);
|
|
1968
|
+
// must be child of the host and owned by it.
|
|
2285
1969
|
return (compareDocumentPosition.call(host, otherNode) & DOCUMENT_POSITION_CONTAINED_BY) !== 0 && isNodeOwnedBy(host, otherNode);
|
|
2286
1970
|
}
|
|
2287
1971
|
},
|
|
@@ -2345,6 +2029,7 @@
|
|
|
2345
2029
|
return 11; // Node.DOCUMENT_FRAGMENT_NODE
|
|
2346
2030
|
}
|
|
2347
2031
|
},
|
|
2032
|
+
|
|
2348
2033
|
nodeValue: {
|
|
2349
2034
|
enumerable: true,
|
|
2350
2035
|
configurable: true,
|
|
@@ -2379,15 +2064,12 @@
|
|
|
2379
2064
|
get: function get() {
|
|
2380
2065
|
var childNodes = getInternalChildNodes(this);
|
|
2381
2066
|
var textContent = '';
|
|
2382
|
-
|
|
2383
2067
|
for (var i = 0, len = childNodes.length; i < len; i += 1) {
|
|
2384
2068
|
var currentNode = childNodes[i];
|
|
2385
|
-
|
|
2386
2069
|
if (currentNode.nodeType !== COMMENT_NODE) {
|
|
2387
2070
|
textContent += getTextContent(currentNode);
|
|
2388
2071
|
}
|
|
2389
2072
|
}
|
|
2390
|
-
|
|
2391
2073
|
return textContent;
|
|
2392
2074
|
},
|
|
2393
2075
|
set: function set(v) {
|
|
@@ -2412,11 +2094,9 @@
|
|
|
2412
2094
|
get: function get() {
|
|
2413
2095
|
var childNodes = getInternalChildNodes(this);
|
|
2414
2096
|
var innerHTML = '';
|
|
2415
|
-
|
|
2416
2097
|
for (var i = 0, len = childNodes.length; i < len; i += 1) {
|
|
2417
2098
|
innerHTML += getOuterHTML(childNodes[i]);
|
|
2418
2099
|
}
|
|
2419
|
-
|
|
2420
2100
|
return innerHTML;
|
|
2421
2101
|
},
|
|
2422
2102
|
set: function set(v) {
|
|
@@ -2483,13 +2163,11 @@
|
|
|
2483
2163
|
}
|
|
2484
2164
|
};
|
|
2485
2165
|
assign(SyntheticShadowRootDescriptors, NodePatchDescriptors, ParentNodePatchDescriptors, ElementPatchDescriptors, ShadowRootDescriptors);
|
|
2486
|
-
|
|
2487
2166
|
function SyntheticShadowRoot() {
|
|
2488
2167
|
throw new TypeError('Illegal constructor');
|
|
2489
2168
|
}
|
|
2490
|
-
|
|
2491
|
-
|
|
2492
|
-
|
|
2169
|
+
SyntheticShadowRoot.prototype = create(DocumentFragment.prototype, SyntheticShadowRootDescriptors);
|
|
2170
|
+
// `this.shadowRoot instanceof ShadowRoot` should evaluate to true even for synthetic shadow
|
|
2493
2171
|
defineProperty(SyntheticShadowRoot, Symbol.hasInstance, {
|
|
2494
2172
|
value: function value(object) {
|
|
2495
2173
|
// Technically we should walk up the entire prototype chain, but with SyntheticShadowRoot
|
|
@@ -2497,18 +2175,16 @@
|
|
|
2497
2175
|
return isObject(object) && !isNull(object) && (isInstanceOfNativeShadowRoot(object) || getPrototypeOf(object) === SyntheticShadowRoot.prototype);
|
|
2498
2176
|
}
|
|
2499
2177
|
});
|
|
2178
|
+
|
|
2500
2179
|
/*
|
|
2501
2180
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
2502
2181
|
* All rights reserved.
|
|
2503
2182
|
* SPDX-License-Identifier: MIT
|
|
2504
2183
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
2505
2184
|
*/
|
|
2506
|
-
|
|
2507
|
-
|
|
2508
2185
|
function pathComposer(startNode, composed) {
|
|
2509
2186
|
var composedPath = [];
|
|
2510
2187
|
var startRoot;
|
|
2511
|
-
|
|
2512
2188
|
if (startNode instanceof Window) {
|
|
2513
2189
|
startRoot = startNode;
|
|
2514
2190
|
} else if (startNode instanceof _Node) {
|
|
@@ -2516,15 +2192,11 @@
|
|
|
2516
2192
|
} else {
|
|
2517
2193
|
return composedPath;
|
|
2518
2194
|
}
|
|
2519
|
-
|
|
2520
2195
|
var current = startNode;
|
|
2521
|
-
|
|
2522
2196
|
while (!isNull(current)) {
|
|
2523
2197
|
composedPath.push(current);
|
|
2524
|
-
|
|
2525
2198
|
if (current instanceof Element || current instanceof Text) {
|
|
2526
2199
|
var assignedSlot = current.assignedSlot;
|
|
2527
|
-
|
|
2528
2200
|
if (!isNull(assignedSlot)) {
|
|
2529
2201
|
current = assignedSlot;
|
|
2530
2202
|
} else {
|
|
@@ -2539,29 +2211,25 @@
|
|
|
2539
2211
|
current = null;
|
|
2540
2212
|
}
|
|
2541
2213
|
}
|
|
2542
|
-
|
|
2543
2214
|
var doc;
|
|
2544
|
-
|
|
2545
2215
|
if (startNode instanceof Window) {
|
|
2546
2216
|
doc = startNode.document;
|
|
2547
2217
|
} else {
|
|
2548
2218
|
doc = getOwnerDocument(startNode);
|
|
2549
|
-
}
|
|
2550
|
-
|
|
2551
|
-
|
|
2219
|
+
}
|
|
2220
|
+
// event composedPath includes window when startNode's ownerRoot is document
|
|
2552
2221
|
if (composedPath[composedPath.length - 1] === doc) {
|
|
2553
2222
|
composedPath.push(window);
|
|
2554
2223
|
}
|
|
2555
|
-
|
|
2556
2224
|
return composedPath;
|
|
2557
2225
|
}
|
|
2226
|
+
|
|
2558
2227
|
/*
|
|
2559
2228
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
2560
2229
|
* All rights reserved.
|
|
2561
2230
|
* SPDX-License-Identifier: MIT
|
|
2562
2231
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
2563
2232
|
*/
|
|
2564
|
-
|
|
2565
2233
|
/**
|
|
2566
2234
|
@license
|
|
2567
2235
|
Copyright (c) 2016 The Polymer Project Authors. All rights reserved.
|
|
@@ -2571,97 +2239,79 @@
|
|
|
2571
2239
|
Code distributed by Google as part of the polymer project is also
|
|
2572
2240
|
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
|
|
2573
2241
|
*/
|
|
2574
|
-
|
|
2575
|
-
|
|
2576
2242
|
function retarget(refNode, path) {
|
|
2577
2243
|
if (isNull(refNode)) {
|
|
2578
2244
|
return null;
|
|
2579
|
-
}
|
|
2245
|
+
}
|
|
2246
|
+
// If ANCESTOR's root is not a shadow root or ANCESTOR's root is BASE's
|
|
2580
2247
|
// shadow-including inclusive ancestor, return ANCESTOR.
|
|
2581
|
-
|
|
2582
|
-
|
|
2583
2248
|
var refNodePath = pathComposer(refNode, true);
|
|
2584
2249
|
var p$ = path;
|
|
2585
|
-
|
|
2586
2250
|
for (var i = 0, ancestor, lastRoot, root, rootIdx; i < p$.length; i++) {
|
|
2587
2251
|
ancestor = p$[i];
|
|
2588
2252
|
root = ancestor instanceof Window ? ancestor : ancestor.getRootNode();
|
|
2589
|
-
|
|
2590
2253
|
if (root !== lastRoot) {
|
|
2591
2254
|
rootIdx = refNodePath.indexOf(root);
|
|
2592
2255
|
lastRoot = root;
|
|
2593
2256
|
}
|
|
2594
|
-
|
|
2595
2257
|
if (!isSyntheticShadowRoot(root) || !isUndefined(rootIdx) && rootIdx > -1) {
|
|
2596
2258
|
return ancestor;
|
|
2597
2259
|
}
|
|
2598
2260
|
}
|
|
2599
|
-
|
|
2600
2261
|
return null;
|
|
2601
2262
|
}
|
|
2263
|
+
|
|
2602
2264
|
/*
|
|
2603
2265
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
2604
2266
|
* All rights reserved.
|
|
2605
2267
|
* SPDX-License-Identifier: MIT
|
|
2606
2268
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
2607
2269
|
*/
|
|
2608
|
-
|
|
2609
|
-
|
|
2610
2270
|
function fauxElementFromPoint(context, doc, left, top) {
|
|
2611
2271
|
var element = elementFromPoint.call(doc, left, top);
|
|
2612
|
-
|
|
2613
2272
|
if (isNull(element)) {
|
|
2614
2273
|
return element;
|
|
2615
2274
|
}
|
|
2616
|
-
|
|
2617
2275
|
return retarget(context, pathComposer(element, true));
|
|
2618
2276
|
}
|
|
2277
|
+
|
|
2619
2278
|
/*
|
|
2620
2279
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
2621
2280
|
* All rights reserved.
|
|
2622
2281
|
* SPDX-License-Identifier: MIT
|
|
2623
2282
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
2624
2283
|
*/
|
|
2625
|
-
|
|
2626
|
-
|
|
2627
2284
|
function elemFromPoint(left, top) {
|
|
2628
2285
|
return fauxElementFromPoint(this, this, left, top);
|
|
2629
2286
|
}
|
|
2630
|
-
|
|
2631
2287
|
Document.prototype.elementFromPoint = elemFromPoint;
|
|
2632
|
-
|
|
2633
2288
|
function elemsFromPoint(left, top) {
|
|
2634
2289
|
return fauxElementsFromPoint(this, this, left, top);
|
|
2635
2290
|
}
|
|
2636
|
-
|
|
2637
|
-
|
|
2638
|
-
|
|
2291
|
+
Document.prototype.elementsFromPoint = elemsFromPoint;
|
|
2292
|
+
// Go until we reach to top of the LWC tree
|
|
2639
2293
|
defineProperty(Document.prototype, 'activeElement', {
|
|
2640
2294
|
get: function get() {
|
|
2641
2295
|
var node = DocumentPrototypeActiveElement.call(this);
|
|
2642
|
-
|
|
2643
2296
|
if (isNull(node)) {
|
|
2644
2297
|
return node;
|
|
2645
2298
|
}
|
|
2646
|
-
|
|
2647
2299
|
while (!isUndefined(getNodeOwnerKey(node))) {
|
|
2648
2300
|
node = parentElementGetter.call(node);
|
|
2649
|
-
|
|
2650
2301
|
if (isNull(node)) {
|
|
2651
2302
|
return null;
|
|
2652
2303
|
}
|
|
2653
2304
|
}
|
|
2654
|
-
|
|
2655
2305
|
if (node.tagName === 'HTML') {
|
|
2656
2306
|
// IE 11. Active element should never be html element
|
|
2657
2307
|
node = this.body;
|
|
2658
2308
|
}
|
|
2659
|
-
|
|
2660
2309
|
return node;
|
|
2661
2310
|
},
|
|
2662
2311
|
enumerable: true,
|
|
2663
2312
|
configurable: true
|
|
2664
|
-
});
|
|
2313
|
+
});
|
|
2314
|
+
// The following patched methods hide shadowed elements from global
|
|
2665
2315
|
// traversing mechanisms. They are simplified for performance reasons to
|
|
2666
2316
|
// filter by ownership and do not account for slotted elements. This
|
|
2667
2317
|
// compromise is fine for our synthetic shadow dom because root elements
|
|
@@ -2670,16 +2320,13 @@
|
|
|
2670
2320
|
// static HTMLCollection or static NodeList. We decided that this compromise
|
|
2671
2321
|
// is not a big problem considering the amount of code that is relying on
|
|
2672
2322
|
// the liveliness of these results are rare.
|
|
2673
|
-
|
|
2674
2323
|
defineProperty(Document.prototype, 'getElementById', {
|
|
2675
2324
|
value: function value() {
|
|
2676
2325
|
var elm = getElementById.apply(this, ArraySlice.call(arguments));
|
|
2677
|
-
|
|
2678
2326
|
if (isNull(elm)) {
|
|
2679
2327
|
return null;
|
|
2680
|
-
}
|
|
2681
|
-
|
|
2682
|
-
|
|
2328
|
+
}
|
|
2329
|
+
// TODO [#1222]: remove global bypass
|
|
2683
2330
|
return isUndefined(getNodeOwnerKey(elm)) || isGlobalPatchingSkipped(elm) ? elm : null;
|
|
2684
2331
|
},
|
|
2685
2332
|
writable: true,
|
|
@@ -2689,7 +2336,8 @@
|
|
|
2689
2336
|
defineProperty(Document.prototype, 'querySelector', {
|
|
2690
2337
|
value: function value() {
|
|
2691
2338
|
var elements = arrayFromCollection(querySelectorAll.apply(this, ArraySlice.call(arguments)));
|
|
2692
|
-
var filtered = ArrayFind.call(elements,
|
|
2339
|
+
var filtered = ArrayFind.call(elements,
|
|
2340
|
+
// TODO [#1222]: remove global bypass
|
|
2693
2341
|
function (elm) {
|
|
2694
2342
|
return isUndefined(getNodeOwnerKey(elm)) || isGlobalPatchingSkipped(elm);
|
|
2695
2343
|
});
|
|
@@ -2702,7 +2350,8 @@
|
|
|
2702
2350
|
defineProperty(Document.prototype, 'querySelectorAll', {
|
|
2703
2351
|
value: function value() {
|
|
2704
2352
|
var elements = arrayFromCollection(querySelectorAll.apply(this, ArraySlice.call(arguments)));
|
|
2705
|
-
var filtered = ArrayFilter.call(elements,
|
|
2353
|
+
var filtered = ArrayFilter.call(elements,
|
|
2354
|
+
// TODO [#1222]: remove global bypass
|
|
2706
2355
|
function (elm) {
|
|
2707
2356
|
return isUndefined(getNodeOwnerKey(elm)) || isGlobalPatchingSkipped(elm);
|
|
2708
2357
|
});
|
|
@@ -2715,7 +2364,8 @@
|
|
|
2715
2364
|
defineProperty(Document.prototype, 'getElementsByClassName', {
|
|
2716
2365
|
value: function value() {
|
|
2717
2366
|
var elements = arrayFromCollection(getElementsByClassName.apply(this, ArraySlice.call(arguments)));
|
|
2718
|
-
var filtered = ArrayFilter.call(elements,
|
|
2367
|
+
var filtered = ArrayFilter.call(elements,
|
|
2368
|
+
// TODO [#1222]: remove global bypass
|
|
2719
2369
|
function (elm) {
|
|
2720
2370
|
return isUndefined(getNodeOwnerKey(elm)) || isGlobalPatchingSkipped(elm);
|
|
2721
2371
|
});
|
|
@@ -2728,7 +2378,8 @@
|
|
|
2728
2378
|
defineProperty(Document.prototype, 'getElementsByTagName', {
|
|
2729
2379
|
value: function value() {
|
|
2730
2380
|
var elements = arrayFromCollection(getElementsByTagName.apply(this, ArraySlice.call(arguments)));
|
|
2731
|
-
var filtered = ArrayFilter.call(elements,
|
|
2381
|
+
var filtered = ArrayFilter.call(elements,
|
|
2382
|
+
// TODO [#1222]: remove global bypass
|
|
2732
2383
|
function (elm) {
|
|
2733
2384
|
return isUndefined(getNodeOwnerKey(elm)) || isGlobalPatchingSkipped(elm);
|
|
2734
2385
|
});
|
|
@@ -2741,7 +2392,8 @@
|
|
|
2741
2392
|
defineProperty(Document.prototype, 'getElementsByTagNameNS', {
|
|
2742
2393
|
value: function value() {
|
|
2743
2394
|
var elements = arrayFromCollection(getElementsByTagNameNS.apply(this, ArraySlice.call(arguments)));
|
|
2744
|
-
var filtered = ArrayFilter.call(elements,
|
|
2395
|
+
var filtered = ArrayFilter.call(elements,
|
|
2396
|
+
// TODO [#1222]: remove global bypass
|
|
2745
2397
|
function (elm) {
|
|
2746
2398
|
return isUndefined(getNodeOwnerKey(elm)) || isGlobalPatchingSkipped(elm);
|
|
2747
2399
|
});
|
|
@@ -2751,11 +2403,13 @@
|
|
|
2751
2403
|
enumerable: true,
|
|
2752
2404
|
configurable: true
|
|
2753
2405
|
});
|
|
2754
|
-
defineProperty(
|
|
2406
|
+
defineProperty(
|
|
2407
|
+
// In Firefox v57 and lower, getElementsByName is defined on HTMLDocument.prototype
|
|
2755
2408
|
getOwnPropertyDescriptor(HTMLDocument.prototype, 'getElementsByName') ? HTMLDocument.prototype : Document.prototype, 'getElementsByName', {
|
|
2756
2409
|
value: function value() {
|
|
2757
2410
|
var elements = arrayFromCollection(getElementsByName.apply(this, ArraySlice.call(arguments)));
|
|
2758
|
-
var filtered = ArrayFilter.call(elements,
|
|
2411
|
+
var filtered = ArrayFilter.call(elements,
|
|
2412
|
+
// TODO [#1222]: remove global bypass
|
|
2759
2413
|
function (elm) {
|
|
2760
2414
|
return isUndefined(getNodeOwnerKey(elm)) || isGlobalPatchingSkipped(elm);
|
|
2761
2415
|
});
|
|
@@ -2765,37 +2419,35 @@
|
|
|
2765
2419
|
enumerable: true,
|
|
2766
2420
|
configurable: true
|
|
2767
2421
|
});
|
|
2422
|
+
|
|
2768
2423
|
/*
|
|
2769
2424
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
2770
2425
|
* All rights reserved.
|
|
2771
2426
|
* SPDX-License-Identifier: MIT
|
|
2772
2427
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
2773
2428
|
*/
|
|
2774
|
-
|
|
2775
2429
|
Object.defineProperty(window, 'ShadowRoot', {
|
|
2776
2430
|
value: SyntheticShadowRoot,
|
|
2777
2431
|
configurable: true,
|
|
2778
2432
|
writable: true
|
|
2779
2433
|
});
|
|
2434
|
+
|
|
2780
2435
|
/*
|
|
2781
2436
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
2782
2437
|
* All rights reserved.
|
|
2783
2438
|
* SPDX-License-Identifier: MIT
|
|
2784
2439
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
2785
2440
|
*/
|
|
2786
|
-
|
|
2787
2441
|
var composedDescriptor = Object.getOwnPropertyDescriptor(Event.prototype, 'composed');
|
|
2788
|
-
|
|
2789
2442
|
function detect$3() {
|
|
2790
2443
|
if (!composedDescriptor) {
|
|
2791
2444
|
// No need to apply this polyfill if this client completely lacks
|
|
2792
2445
|
// support for the composed property.
|
|
2793
2446
|
return false;
|
|
2794
|
-
}
|
|
2447
|
+
}
|
|
2448
|
+
// Assigning a throwaway click event here to suppress a ts error when we
|
|
2795
2449
|
// pass clickEvent into the composed getter below. The error is:
|
|
2796
2450
|
// [ts] Variable 'clickEvent' is used before being assigned.
|
|
2797
|
-
|
|
2798
|
-
|
|
2799
2451
|
var clickEvent = new Event('click');
|
|
2800
2452
|
var button = document.createElement('button');
|
|
2801
2453
|
button.addEventListener('click', function (event) {
|
|
@@ -2804,16 +2456,14 @@
|
|
|
2804
2456
|
button.click();
|
|
2805
2457
|
return !composedDescriptor.get.call(clickEvent);
|
|
2806
2458
|
}
|
|
2459
|
+
|
|
2807
2460
|
/*
|
|
2808
2461
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
2809
2462
|
* All rights reserved.
|
|
2810
2463
|
* SPDX-License-Identifier: MIT
|
|
2811
2464
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
2812
2465
|
*/
|
|
2813
|
-
|
|
2814
|
-
|
|
2815
2466
|
var originalClickDescriptor = Object.getOwnPropertyDescriptor(HTMLElement.prototype, 'click');
|
|
2816
|
-
|
|
2817
2467
|
function handleClick(event) {
|
|
2818
2468
|
Object.defineProperty(event, 'composed', {
|
|
2819
2469
|
configurable: true,
|
|
@@ -2823,11 +2473,9 @@
|
|
|
2823
2473
|
}
|
|
2824
2474
|
});
|
|
2825
2475
|
}
|
|
2826
|
-
|
|
2827
2476
|
function apply$3() {
|
|
2828
2477
|
HTMLElement.prototype.click = function () {
|
|
2829
2478
|
addEventListener.call(this, 'click', handleClick);
|
|
2830
|
-
|
|
2831
2479
|
try {
|
|
2832
2480
|
originalClickDescriptor.value.call(this);
|
|
2833
2481
|
} finally {
|
|
@@ -2835,38 +2483,35 @@
|
|
|
2835
2483
|
}
|
|
2836
2484
|
};
|
|
2837
2485
|
}
|
|
2486
|
+
|
|
2838
2487
|
/*
|
|
2839
2488
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
2840
2489
|
* All rights reserved.
|
|
2841
2490
|
* SPDX-License-Identifier: MIT
|
|
2842
2491
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
2843
2492
|
*/
|
|
2844
|
-
|
|
2845
|
-
|
|
2846
2493
|
if (detect$3()) {
|
|
2847
2494
|
apply$3();
|
|
2848
2495
|
}
|
|
2496
|
+
|
|
2849
2497
|
/*
|
|
2850
2498
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
2851
2499
|
* All rights reserved.
|
|
2852
2500
|
* SPDX-License-Identifier: MIT
|
|
2853
2501
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
2854
2502
|
*/
|
|
2855
|
-
|
|
2856
|
-
|
|
2857
2503
|
function detect$2() {
|
|
2858
2504
|
return new Event('test', {
|
|
2859
2505
|
composed: true
|
|
2860
2506
|
}).composed !== true;
|
|
2861
2507
|
}
|
|
2508
|
+
|
|
2862
2509
|
/*
|
|
2863
2510
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
2864
2511
|
* All rights reserved.
|
|
2865
2512
|
* SPDX-License-Identifier: MIT
|
|
2866
2513
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
2867
2514
|
*/
|
|
2868
|
-
|
|
2869
|
-
|
|
2870
2515
|
function apply$2() {
|
|
2871
2516
|
// https://github.com/w3c/webcomponents/issues/513#issuecomment-224183937
|
|
2872
2517
|
var composedEvents = assign(create(null), {
|
|
@@ -2920,8 +2565,8 @@
|
|
|
2920
2565
|
touchstart: 1,
|
|
2921
2566
|
wheel: 1
|
|
2922
2567
|
});
|
|
2923
|
-
var EventConstructor = Event;
|
|
2924
|
-
|
|
2568
|
+
var EventConstructor = Event;
|
|
2569
|
+
// Patch Event constructor to add the composed property on events created via new Event.
|
|
2925
2570
|
function PatchedEvent(type, eventInitDict) {
|
|
2926
2571
|
var event = new EventConstructor(type, eventInitDict);
|
|
2927
2572
|
var isComposed = !!(eventInitDict && eventInitDict.composed);
|
|
@@ -2936,14 +2581,13 @@
|
|
|
2936
2581
|
});
|
|
2937
2582
|
return event;
|
|
2938
2583
|
}
|
|
2939
|
-
|
|
2940
2584
|
PatchedEvent.prototype = EventConstructor.prototype;
|
|
2941
2585
|
PatchedEvent.AT_TARGET = EventConstructor.AT_TARGET;
|
|
2942
2586
|
PatchedEvent.BUBBLING_PHASE = EventConstructor.BUBBLING_PHASE;
|
|
2943
2587
|
PatchedEvent.CAPTURING_PHASE = EventConstructor.CAPTURING_PHASE;
|
|
2944
2588
|
PatchedEvent.NONE = EventConstructor.NONE;
|
|
2945
|
-
window.Event = PatchedEvent;
|
|
2946
|
-
|
|
2589
|
+
window.Event = PatchedEvent;
|
|
2590
|
+
// Patch the Event prototype to add the composed property on user agent dispatched event.
|
|
2947
2591
|
Object.defineProperties(Event.prototype, {
|
|
2948
2592
|
composed: {
|
|
2949
2593
|
get: function get() {
|
|
@@ -2955,27 +2599,24 @@
|
|
|
2955
2599
|
}
|
|
2956
2600
|
});
|
|
2957
2601
|
}
|
|
2602
|
+
|
|
2958
2603
|
/*
|
|
2959
2604
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
2960
2605
|
* All rights reserved.
|
|
2961
2606
|
* SPDX-License-Identifier: MIT
|
|
2962
2607
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
2963
2608
|
*/
|
|
2964
|
-
|
|
2965
|
-
|
|
2966
2609
|
if (detect$2()) {
|
|
2967
2610
|
apply$2();
|
|
2968
2611
|
}
|
|
2612
|
+
|
|
2969
2613
|
/*
|
|
2970
2614
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
2971
2615
|
* All rights reserved.
|
|
2972
2616
|
* SPDX-License-Identifier: MIT
|
|
2973
2617
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
2974
2618
|
*/
|
|
2975
|
-
|
|
2976
|
-
|
|
2977
2619
|
var CustomEventConstructor = CustomEvent;
|
|
2978
|
-
|
|
2979
2620
|
function PatchedCustomEvent(type, eventInitDict) {
|
|
2980
2621
|
var event = new CustomEventConstructor(type, eventInitDict);
|
|
2981
2622
|
var isComposed = !!(eventInitDict && eventInitDict.composed);
|
|
@@ -2990,23 +2631,22 @@
|
|
|
2990
2631
|
});
|
|
2991
2632
|
return event;
|
|
2992
2633
|
}
|
|
2993
|
-
|
|
2994
2634
|
PatchedCustomEvent.prototype = CustomEventConstructor.prototype;
|
|
2995
2635
|
window.CustomEvent = PatchedCustomEvent;
|
|
2636
|
+
|
|
2996
2637
|
/*
|
|
2997
2638
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
2998
2639
|
* All rights reserved.
|
|
2999
2640
|
* SPDX-License-Identifier: MIT
|
|
3000
2641
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
3001
2642
|
*/
|
|
3002
|
-
|
|
3003
2643
|
if (typeof ClipboardEvent !== 'undefined') {
|
|
3004
2644
|
var isComposedType = assign(create(null), {
|
|
3005
2645
|
copy: 1,
|
|
3006
2646
|
cut: 1,
|
|
3007
2647
|
paste: 1
|
|
3008
|
-
});
|
|
3009
|
-
|
|
2648
|
+
});
|
|
2649
|
+
// Patch the prototype to override the composed property on user-agent dispatched events
|
|
3010
2650
|
defineProperties(ClipboardEvent.prototype, {
|
|
3011
2651
|
composed: {
|
|
3012
2652
|
get: function get() {
|
|
@@ -3018,50 +2658,44 @@
|
|
|
3018
2658
|
}
|
|
3019
2659
|
});
|
|
3020
2660
|
}
|
|
2661
|
+
|
|
3021
2662
|
/*
|
|
3022
2663
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
3023
2664
|
* All rights reserved.
|
|
3024
2665
|
* SPDX-License-Identifier: MIT
|
|
3025
2666
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
3026
2667
|
*/
|
|
3027
|
-
|
|
3028
|
-
|
|
3029
2668
|
function detect$1() {
|
|
3030
2669
|
// Note: when using this in mobile apps, we might have a DOM that does not support iframes.
|
|
3031
2670
|
return typeof HTMLIFrameElement !== 'undefined';
|
|
3032
2671
|
}
|
|
2672
|
+
|
|
3033
2673
|
/*
|
|
3034
2674
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
3035
2675
|
* All rights reserved.
|
|
3036
2676
|
* SPDX-License-Identifier: MIT
|
|
3037
2677
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
3038
2678
|
*/
|
|
3039
|
-
|
|
3040
|
-
|
|
3041
2679
|
function apply$1() {
|
|
3042
2680
|
// the iframe property descriptor for `contentWindow` should always be available, otherwise this method should never be called
|
|
3043
2681
|
var desc = getOwnPropertyDescriptor(HTMLIFrameElement.prototype, 'contentWindow');
|
|
3044
2682
|
var originalGetter = desc.get;
|
|
3045
|
-
|
|
3046
2683
|
desc.get = function () {
|
|
3047
|
-
var original = originalGetter.call(this);
|
|
3048
|
-
|
|
2684
|
+
var original = originalGetter.call(this);
|
|
2685
|
+
// If the original iframe element is not a keyed node, then do not wrap it
|
|
3049
2686
|
if (isNull(original) || isUndefined(getNodeOwnerKey(this))) {
|
|
3050
2687
|
return original;
|
|
3051
|
-
}
|
|
2688
|
+
}
|
|
2689
|
+
// only if the element is an iframe inside a shadowRoot, we care about this problem
|
|
3052
2690
|
// because in that case, the code that is accessing the iframe, is very likely code
|
|
3053
2691
|
// compiled with proxy-compat transformation. It is true that other code without those
|
|
3054
2692
|
// transformations might also access an iframe from within a shadowRoot, but in that,
|
|
3055
2693
|
// case, which is more rare, we still return the wrapper, and it should work the same,
|
|
3056
2694
|
// this part is just an optimization.
|
|
3057
|
-
|
|
3058
|
-
|
|
3059
2695
|
return wrapIframeWindow(original);
|
|
3060
2696
|
};
|
|
3061
|
-
|
|
3062
2697
|
defineProperty(HTMLIFrameElement.prototype, 'contentWindow', desc);
|
|
3063
2698
|
}
|
|
3064
|
-
|
|
3065
2699
|
function wrapIframeWindow(win) {
|
|
3066
2700
|
return {
|
|
3067
2701
|
addEventListener: function addEventListener() {
|
|
@@ -3094,82 +2728,67 @@
|
|
|
3094
2728
|
// @ts-ignore type-mismatch
|
|
3095
2729
|
return win.removeEventListener.apply(win, arguments);
|
|
3096
2730
|
},
|
|
3097
|
-
|
|
3098
2731
|
get closed() {
|
|
3099
2732
|
return win.closed;
|
|
3100
2733
|
},
|
|
3101
|
-
|
|
3102
2734
|
get frames() {
|
|
3103
2735
|
return win.frames;
|
|
3104
2736
|
},
|
|
3105
|
-
|
|
3106
2737
|
get length() {
|
|
3107
2738
|
return win.length;
|
|
3108
2739
|
},
|
|
3109
|
-
|
|
3110
2740
|
get location() {
|
|
3111
2741
|
return win.location;
|
|
3112
2742
|
},
|
|
3113
|
-
|
|
3114
2743
|
set location(value) {
|
|
3115
2744
|
win.location = value;
|
|
3116
2745
|
},
|
|
3117
|
-
|
|
3118
2746
|
get opener() {
|
|
3119
2747
|
return win.opener;
|
|
3120
2748
|
},
|
|
3121
|
-
|
|
3122
2749
|
get parent() {
|
|
3123
2750
|
return win.parent;
|
|
3124
2751
|
},
|
|
3125
|
-
|
|
3126
2752
|
get self() {
|
|
3127
2753
|
return win.self;
|
|
3128
2754
|
},
|
|
3129
|
-
|
|
3130
2755
|
get top() {
|
|
3131
2756
|
return win.top;
|
|
3132
2757
|
},
|
|
3133
|
-
|
|
3134
2758
|
get window() {
|
|
3135
2759
|
return win.window;
|
|
3136
2760
|
}
|
|
3137
|
-
|
|
3138
2761
|
}; // this is limited
|
|
3139
2762
|
}
|
|
2763
|
+
|
|
3140
2764
|
/*
|
|
3141
2765
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
3142
2766
|
* All rights reserved.
|
|
3143
2767
|
* SPDX-License-Identifier: MIT
|
|
3144
2768
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
3145
2769
|
*/
|
|
3146
|
-
|
|
3147
|
-
|
|
3148
2770
|
if (detect$1()) {
|
|
3149
2771
|
apply$1();
|
|
3150
2772
|
}
|
|
2773
|
+
|
|
3151
2774
|
/*
|
|
3152
2775
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
3153
2776
|
* All rights reserved.
|
|
3154
2777
|
* SPDX-License-Identifier: MIT
|
|
3155
2778
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
3156
2779
|
*/
|
|
3157
|
-
|
|
3158
|
-
|
|
3159
2780
|
var OriginalMutationObserver = MutationObserver;
|
|
3160
2781
|
var _OriginalMutationObse = OriginalMutationObserver.prototype,
|
|
3161
|
-
|
|
3162
|
-
|
|
3163
|
-
|
|
3164
|
-
|
|
2782
|
+
originalDisconnect = _OriginalMutationObse.disconnect,
|
|
2783
|
+
originalObserve = _OriginalMutationObse.observe,
|
|
2784
|
+
originalTakeRecords = _OriginalMutationObse.takeRecords;
|
|
2785
|
+
// Internal fields to maintain relationships
|
|
3165
2786
|
var wrapperLookupField = '$$lwcObserverCallbackWrapper$$';
|
|
3166
2787
|
var observerLookupField = '$$lwcNodeObservers$$';
|
|
3167
2788
|
var observerToNodesMap = new WeakMap();
|
|
3168
|
-
|
|
3169
2789
|
function getNodeObservers(node) {
|
|
3170
2790
|
return node[observerLookupField];
|
|
3171
2791
|
}
|
|
3172
|
-
|
|
3173
2792
|
function setNodeObservers(node, observers) {
|
|
3174
2793
|
node[observerLookupField] = observers;
|
|
3175
2794
|
}
|
|
@@ -3177,13 +2796,11 @@
|
|
|
3177
2796
|
* Retarget the mutation record's target value to its shadowRoot
|
|
3178
2797
|
* @param {MutationRecord} originalRecord
|
|
3179
2798
|
*/
|
|
3180
|
-
|
|
3181
|
-
|
|
3182
2799
|
function retargetMutationRecord(originalRecord) {
|
|
3183
2800
|
var addedNodes = originalRecord.addedNodes,
|
|
3184
|
-
|
|
3185
|
-
|
|
3186
|
-
|
|
2801
|
+
removedNodes = originalRecord.removedNodes,
|
|
2802
|
+
target = originalRecord.target,
|
|
2803
|
+
type = originalRecord.type;
|
|
3187
2804
|
var retargetedRecord = create(MutationRecord.prototype);
|
|
3188
2805
|
defineProperties(retargetedRecord, {
|
|
3189
2806
|
addedNodes: {
|
|
@@ -3223,22 +2840,17 @@
|
|
|
3223
2840
|
* @param {MutationObserver} observer
|
|
3224
2841
|
* @param {Node} target
|
|
3225
2842
|
*/
|
|
3226
|
-
|
|
3227
|
-
|
|
3228
2843
|
function isQualifiedObserver(observer, target) {
|
|
3229
2844
|
var parentNode = target;
|
|
3230
|
-
|
|
3231
2845
|
while (!isNull(parentNode)) {
|
|
3232
2846
|
var parentNodeObservers = getNodeObservers(parentNode);
|
|
3233
|
-
|
|
3234
|
-
|
|
2847
|
+
if (!isUndefined(parentNodeObservers) && (parentNodeObservers[0] === observer ||
|
|
2848
|
+
// perf optimization to check for the first item is a match
|
|
3235
2849
|
ArrayIndexOf.call(parentNodeObservers, observer) !== -1)) {
|
|
3236
2850
|
return true;
|
|
3237
2851
|
}
|
|
3238
|
-
|
|
3239
2852
|
parentNode = parentNode.parentNode;
|
|
3240
2853
|
}
|
|
3241
|
-
|
|
3242
2854
|
return false;
|
|
3243
2855
|
}
|
|
3244
2856
|
/**
|
|
@@ -3250,30 +2862,26 @@
|
|
|
3250
2862
|
* @param {MutationRecords[]} mutations
|
|
3251
2863
|
* @param {MutationObserver} observer
|
|
3252
2864
|
*/
|
|
3253
|
-
|
|
3254
|
-
|
|
3255
2865
|
function filterMutationRecords(mutations, observer) {
|
|
3256
2866
|
return ArrayReduce.call(mutations, function (filteredSet, record) {
|
|
3257
2867
|
var target = record.target,
|
|
3258
|
-
|
|
3259
|
-
|
|
3260
|
-
|
|
2868
|
+
addedNodes = record.addedNodes,
|
|
2869
|
+
removedNodes = record.removedNodes,
|
|
2870
|
+
type = record.type;
|
|
2871
|
+
// If target is an lwc host,
|
|
3261
2872
|
// Determine if the mutations affected the host or the shadowRoot
|
|
3262
2873
|
// Mutations affecting host: changes to slot content
|
|
3263
2874
|
// Mutations affecting shadowRoot: changes to template content
|
|
3264
|
-
|
|
3265
2875
|
if (type === 'childList' && !isUndefined(getNodeKey(target))) {
|
|
3266
2876
|
// In case of added nodes, we can climb up the tree and determine eligibility
|
|
3267
2877
|
if (addedNodes.length > 0) {
|
|
3268
2878
|
// Optimization: Peek in and test one node to decide if the MutationRecord qualifies
|
|
3269
2879
|
// The remaining nodes in this MutationRecord will have the same ownerKey
|
|
3270
2880
|
var sampleNode = addedNodes[0];
|
|
3271
|
-
|
|
3272
2881
|
if (isQualifiedObserver(observer, sampleNode)) {
|
|
3273
2882
|
// If the target was being observed, then return record as-is
|
|
3274
2883
|
// this will be the case for slot content
|
|
3275
2884
|
var nodeObservers = getNodeObservers(target);
|
|
3276
|
-
|
|
3277
2885
|
if (nodeObservers && (nodeObservers[0] === observer || ArrayIndexOf.call(nodeObservers, observer) !== -1)) {
|
|
3278
2886
|
ArrayPush.call(filteredSet, record);
|
|
3279
2887
|
} else {
|
|
@@ -3286,14 +2894,13 @@
|
|
|
3286
2894
|
// We can only check if either the host or shadow root was observed and qualify the record
|
|
3287
2895
|
var shadowRoot = target.shadowRoot;
|
|
3288
2896
|
var _sampleNode = removedNodes[0];
|
|
3289
|
-
|
|
3290
|
-
|
|
2897
|
+
if (getNodeNearestOwnerKey(target) === getNodeNearestOwnerKey(_sampleNode) &&
|
|
2898
|
+
// trickery: sampleNode is slot content
|
|
3291
2899
|
isQualifiedObserver(observer, target) // use target as a close enough reference to climb up
|
|
3292
2900
|
) {
|
|
3293
2901
|
ArrayPush.call(filteredSet, record);
|
|
3294
2902
|
} else if (shadowRoot) {
|
|
3295
2903
|
var shadowRootObservers = getNodeObservers(shadowRoot);
|
|
3296
|
-
|
|
3297
2904
|
if (shadowRootObservers && (shadowRootObservers[0] === observer || ArrayIndexOf.call(shadowRootObservers, observer) !== -1)) {
|
|
3298
2905
|
ArrayPush.call(filteredSet, retargetMutationRecord(record));
|
|
3299
2906
|
}
|
|
@@ -3306,27 +2913,22 @@
|
|
|
3306
2913
|
ArrayPush.call(filteredSet, record);
|
|
3307
2914
|
}
|
|
3308
2915
|
}
|
|
3309
|
-
|
|
3310
2916
|
return filteredSet;
|
|
3311
2917
|
}, []);
|
|
3312
2918
|
}
|
|
3313
|
-
|
|
3314
2919
|
function getWrappedCallback(callback) {
|
|
3315
2920
|
var wrappedCallback = callback[wrapperLookupField];
|
|
3316
|
-
|
|
3317
2921
|
if (isUndefined(wrappedCallback)) {
|
|
3318
2922
|
wrappedCallback = callback[wrapperLookupField] = function (mutations, observer) {
|
|
3319
2923
|
// Filter mutation records
|
|
3320
|
-
var filteredRecords = filterMutationRecords(mutations, observer);
|
|
3321
|
-
|
|
2924
|
+
var filteredRecords = filterMutationRecords(mutations, observer);
|
|
2925
|
+
// If not records are eligible for the observer, do not invoke callback
|
|
3322
2926
|
if (filteredRecords.length === 0) {
|
|
3323
2927
|
return;
|
|
3324
2928
|
}
|
|
3325
|
-
|
|
3326
2929
|
callback.call(observer, filteredRecords, observer);
|
|
3327
2930
|
};
|
|
3328
2931
|
}
|
|
3329
|
-
|
|
3330
2932
|
return wrappedCallback;
|
|
3331
2933
|
}
|
|
3332
2934
|
/**
|
|
@@ -3335,28 +2937,21 @@
|
|
|
3335
2937
|
* 2. Add a property field to track all observed targets of the observer instance
|
|
3336
2938
|
* @param {MutationCallback} callback
|
|
3337
2939
|
*/
|
|
3338
|
-
|
|
3339
|
-
|
|
3340
2940
|
function PatchedMutationObserver(callback) {
|
|
3341
2941
|
var wrappedCallback = getWrappedCallback(callback);
|
|
3342
2942
|
var observer = new OriginalMutationObserver(wrappedCallback);
|
|
3343
2943
|
return observer;
|
|
3344
2944
|
}
|
|
3345
|
-
|
|
3346
2945
|
function patchedDisconnect() {
|
|
3347
2946
|
var _this2 = this;
|
|
3348
|
-
|
|
3349
|
-
|
|
3350
|
-
|
|
2947
|
+
originalDisconnect.call(this);
|
|
2948
|
+
// Clear the node to observer reference which is a strong references
|
|
3351
2949
|
var observedNodes = observerToNodesMap.get(this);
|
|
3352
|
-
|
|
3353
2950
|
if (!isUndefined(observedNodes)) {
|
|
3354
2951
|
forEach.call(observedNodes, function (observedNode) {
|
|
3355
2952
|
var observers = observedNode[observerLookupField];
|
|
3356
|
-
|
|
3357
2953
|
if (!isUndefined(observers)) {
|
|
3358
2954
|
var index = ArrayIndexOf.call(observers, _this2);
|
|
3359
|
-
|
|
3360
2955
|
if (index !== -1) {
|
|
3361
2956
|
ArraySplice.call(observers, index, 1);
|
|
3362
2957
|
}
|
|
@@ -3371,49 +2966,38 @@
|
|
|
3371
2966
|
* @param {Node} target
|
|
3372
2967
|
* @param {Object} options
|
|
3373
2968
|
*/
|
|
3374
|
-
|
|
3375
|
-
|
|
3376
2969
|
function patchedObserve(target, options) {
|
|
3377
|
-
var targetObservers = getNodeObservers(target);
|
|
3378
|
-
|
|
2970
|
+
var targetObservers = getNodeObservers(target);
|
|
2971
|
+
// Maintain a list of all observers that want to observe a node
|
|
3379
2972
|
if (isUndefined(targetObservers)) {
|
|
3380
2973
|
targetObservers = [];
|
|
3381
2974
|
setNodeObservers(target, targetObservers);
|
|
3382
|
-
}
|
|
3383
|
-
|
|
3384
|
-
|
|
2975
|
+
}
|
|
2976
|
+
// Same observer trying to observe the same node
|
|
3385
2977
|
if (ArrayIndexOf.call(targetObservers, this) === -1) {
|
|
3386
2978
|
ArrayPush.call(targetObservers, this);
|
|
3387
2979
|
} // else There is more bookkeeping to do here https://dom.spec.whatwg.org/#dom-mutationobserver-observe Step #7
|
|
3388
2980
|
// SyntheticShadowRoot instances are not actually a part of the DOM so observe the host instead.
|
|
3389
|
-
|
|
3390
|
-
|
|
3391
2981
|
if (isSyntheticShadowRoot(target)) {
|
|
3392
2982
|
target = target.host;
|
|
3393
|
-
}
|
|
3394
|
-
|
|
3395
|
-
|
|
2983
|
+
}
|
|
2984
|
+
// maintain a list of all nodes observed by this observer
|
|
3396
2985
|
if (observerToNodesMap.has(this)) {
|
|
3397
2986
|
var observedNodes = observerToNodesMap.get(this);
|
|
3398
|
-
|
|
3399
2987
|
if (ArrayIndexOf.call(observedNodes, target) === -1) {
|
|
3400
2988
|
ArrayPush.call(observedNodes, target);
|
|
3401
2989
|
}
|
|
3402
2990
|
} else {
|
|
3403
2991
|
observerToNodesMap.set(this, [target]);
|
|
3404
2992
|
}
|
|
3405
|
-
|
|
3406
2993
|
return originalObserve.call(this, target, options);
|
|
3407
2994
|
}
|
|
3408
2995
|
/**
|
|
3409
2996
|
* Patch the takeRecords() api to filter MutationRecords based on the observed targets
|
|
3410
2997
|
*/
|
|
3411
|
-
|
|
3412
|
-
|
|
3413
2998
|
function patchedTakeRecords() {
|
|
3414
2999
|
return filterMutationRecords(originalTakeRecords.call(this), this);
|
|
3415
3000
|
}
|
|
3416
|
-
|
|
3417
3001
|
PatchedMutationObserver.prototype = OriginalMutationObserver.prototype;
|
|
3418
3002
|
PatchedMutationObserver.prototype.disconnect = patchedDisconnect;
|
|
3419
3003
|
PatchedMutationObserver.prototype.observe = patchedObserve;
|
|
@@ -3423,63 +3007,54 @@
|
|
|
3423
3007
|
configurable: true,
|
|
3424
3008
|
writable: true
|
|
3425
3009
|
});
|
|
3010
|
+
|
|
3426
3011
|
/*
|
|
3427
3012
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
3428
3013
|
* All rights reserved.
|
|
3429
3014
|
* SPDX-License-Identifier: MIT
|
|
3430
3015
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
3431
3016
|
*/
|
|
3432
|
-
|
|
3433
3017
|
function patchedAddEventListener$1(type, listener, optionsOrCapture) {
|
|
3434
3018
|
if (isSyntheticShadowHost(this)) {
|
|
3435
3019
|
// Typescript does not like it when you treat the `arguments` object as an array
|
|
3436
3020
|
// @ts-ignore type-mismatch
|
|
3437
3021
|
return addCustomElementEventListener.apply(this, arguments);
|
|
3438
3022
|
}
|
|
3439
|
-
|
|
3440
3023
|
if (arguments.length < 2) {
|
|
3441
3024
|
// Slow path, unlikely to be called frequently. We expect modern browsers to throw:
|
|
3442
3025
|
// https://googlechrome.github.io/samples/event-listeners-mandatory-arguments/
|
|
3443
3026
|
var args = ArraySlice.call(arguments);
|
|
3444
|
-
|
|
3445
3027
|
if (args.length > 1) {
|
|
3446
3028
|
args[1] = getEventListenerWrapper(args[1]);
|
|
3447
|
-
}
|
|
3029
|
+
}
|
|
3030
|
+
// Ignore types because we're passing through to native method
|
|
3448
3031
|
// @ts-ignore type-mismatch
|
|
3449
|
-
|
|
3450
|
-
|
|
3451
3032
|
return addEventListener.apply(this, args);
|
|
3452
|
-
}
|
|
3033
|
+
}
|
|
3034
|
+
// Fast path. This function is optimized to avoid ArraySlice because addEventListener is called
|
|
3453
3035
|
// very frequently, and it provides a measurable perf boost to avoid so much array cloning.
|
|
3454
|
-
|
|
3455
|
-
|
|
3456
|
-
var wrappedListener = getEventListenerWrapper(listener); // The third argument is optional, so passing in `undefined` for `optionsOrCapture` gives capture=false
|
|
3457
|
-
|
|
3036
|
+
var wrappedListener = getEventListenerWrapper(listener);
|
|
3037
|
+
// The third argument is optional, so passing in `undefined` for `optionsOrCapture` gives capture=false
|
|
3458
3038
|
return addEventListener.call(this, type, wrappedListener, optionsOrCapture);
|
|
3459
3039
|
}
|
|
3460
|
-
|
|
3461
3040
|
function patchedRemoveEventListener$1(_type, _listener, _optionsOrCapture) {
|
|
3462
3041
|
if (isSyntheticShadowHost(this)) {
|
|
3463
3042
|
// Typescript does not like it when you treat the `arguments` object as an array
|
|
3464
3043
|
// @ts-ignore type-mismatch
|
|
3465
3044
|
return removeCustomElementEventListener.apply(this, arguments);
|
|
3466
3045
|
}
|
|
3467
|
-
|
|
3468
3046
|
var args = ArraySlice.call(arguments);
|
|
3469
|
-
|
|
3470
3047
|
if (arguments.length > 1) {
|
|
3471
3048
|
args[1] = getEventListenerWrapper(args[1]);
|
|
3472
|
-
}
|
|
3049
|
+
}
|
|
3050
|
+
// Ignore types because we're passing through to native method
|
|
3473
3051
|
// @ts-ignore type-mismatch
|
|
3474
|
-
|
|
3475
|
-
|
|
3476
|
-
removeEventListener.apply(this, args); // Account for listeners that were added before this polyfill was applied
|
|
3052
|
+
removeEventListener.apply(this, args);
|
|
3053
|
+
// Account for listeners that were added before this polyfill was applied
|
|
3477
3054
|
// Typescript does not like it when you treat the `arguments` object as an array
|
|
3478
3055
|
// @ts-ignore type-mismatch
|
|
3479
|
-
|
|
3480
3056
|
removeEventListener.apply(this, arguments);
|
|
3481
3057
|
}
|
|
3482
|
-
|
|
3483
3058
|
defineProperties(eventTargetPrototype, {
|
|
3484
3059
|
addEventListener: {
|
|
3485
3060
|
value: patchedAddEventListener$1,
|
|
@@ -3494,53 +3069,48 @@
|
|
|
3494
3069
|
configurable: true
|
|
3495
3070
|
}
|
|
3496
3071
|
});
|
|
3072
|
+
|
|
3497
3073
|
/*
|
|
3498
3074
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
3499
3075
|
* All rights reserved.
|
|
3500
3076
|
* SPDX-License-Identifier: MIT
|
|
3501
3077
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
3502
3078
|
*/
|
|
3503
|
-
|
|
3504
3079
|
function detect() {
|
|
3505
3080
|
return typeof EventTarget === 'undefined';
|
|
3506
3081
|
}
|
|
3082
|
+
|
|
3507
3083
|
/*
|
|
3508
3084
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
3509
3085
|
* All rights reserved.
|
|
3510
3086
|
* SPDX-License-Identifier: MIT
|
|
3511
3087
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
3512
3088
|
*/
|
|
3513
|
-
|
|
3514
|
-
|
|
3515
3089
|
function patchedAddEventListener(_type, _listener, _options) {
|
|
3516
3090
|
if (arguments.length > 1) {
|
|
3517
3091
|
var args = ArraySlice.call(arguments);
|
|
3518
|
-
args[1] = getEventListenerWrapper(args[1]);
|
|
3092
|
+
args[1] = getEventListenerWrapper(args[1]);
|
|
3093
|
+
// Ignore types because we're passing through to native method
|
|
3519
3094
|
// @ts-ignore type-mismatch
|
|
3520
|
-
|
|
3521
3095
|
return windowAddEventListener.apply(this, args);
|
|
3522
|
-
}
|
|
3096
|
+
}
|
|
3097
|
+
// Typescript does not like it when you treat the `arguments` object as an array
|
|
3523
3098
|
// @ts-ignore type-mismatch
|
|
3524
|
-
|
|
3525
|
-
|
|
3526
3099
|
return windowAddEventListener.apply(this, arguments);
|
|
3527
3100
|
}
|
|
3528
|
-
|
|
3529
3101
|
function patchedRemoveEventListener(_type, _listener, _options) {
|
|
3530
3102
|
if (arguments.length > 1) {
|
|
3531
3103
|
var args = ArraySlice.call(arguments);
|
|
3532
|
-
args[1] = getEventListenerWrapper(args[1]);
|
|
3104
|
+
args[1] = getEventListenerWrapper(args[1]);
|
|
3105
|
+
// Ignore types because we're passing through to native method
|
|
3533
3106
|
// @ts-ignore type-mismatch
|
|
3534
|
-
|
|
3535
3107
|
windowRemoveEventListener.apply(this, args);
|
|
3536
|
-
}
|
|
3108
|
+
}
|
|
3109
|
+
// Account for listeners that were added before this polyfill was applied
|
|
3537
3110
|
// Typescript does not like it when you treat the `arguments` object as an array
|
|
3538
3111
|
// @ts-ignore type-mismatch
|
|
3539
|
-
|
|
3540
|
-
|
|
3541
3112
|
windowRemoveEventListener.apply(this, arguments);
|
|
3542
3113
|
}
|
|
3543
|
-
|
|
3544
3114
|
function apply() {
|
|
3545
3115
|
defineProperties(Window.prototype, {
|
|
3546
3116
|
addEventListener: {
|
|
@@ -3557,60 +3127,49 @@
|
|
|
3557
3127
|
}
|
|
3558
3128
|
});
|
|
3559
3129
|
}
|
|
3130
|
+
|
|
3560
3131
|
/*
|
|
3561
3132
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
3562
3133
|
* All rights reserved.
|
|
3563
3134
|
* SPDX-License-Identifier: MIT
|
|
3564
3135
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
3565
3136
|
*/
|
|
3566
|
-
|
|
3567
|
-
|
|
3568
3137
|
if (detect()) {
|
|
3569
3138
|
apply();
|
|
3570
3139
|
}
|
|
3140
|
+
|
|
3571
3141
|
/*
|
|
3572
3142
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
3573
3143
|
* All rights reserved.
|
|
3574
3144
|
* SPDX-License-Identifier: MIT
|
|
3575
3145
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
3576
3146
|
*/
|
|
3577
|
-
|
|
3578
|
-
|
|
3579
3147
|
function patchedCurrentTargetGetter() {
|
|
3580
3148
|
var currentTarget = eventCurrentTargetGetter.call(this);
|
|
3581
|
-
|
|
3582
3149
|
if (isNull(currentTarget)) {
|
|
3583
3150
|
return null;
|
|
3584
3151
|
}
|
|
3585
|
-
|
|
3586
|
-
if (eventToContextMap.get(this) === 1
|
|
3587
|
-
/* EventListenerContext.SHADOW_ROOT_LISTENER */
|
|
3588
|
-
) {
|
|
3152
|
+
if (eventToContextMap.get(this) === 1 /* EventListenerContext.SHADOW_ROOT_LISTENER */) {
|
|
3589
3153
|
return getShadowRoot(currentTarget);
|
|
3590
3154
|
}
|
|
3591
|
-
|
|
3592
3155
|
return currentTarget;
|
|
3593
3156
|
}
|
|
3594
|
-
|
|
3595
3157
|
function patchedTargetGetter() {
|
|
3596
3158
|
var originalTarget = eventTargetGetter.call(this);
|
|
3597
|
-
|
|
3598
3159
|
if (!(originalTarget instanceof _Node)) {
|
|
3599
3160
|
return originalTarget;
|
|
3600
3161
|
}
|
|
3601
|
-
|
|
3602
3162
|
var doc = getOwnerDocument(originalTarget);
|
|
3603
3163
|
var composedPath = pathComposer(originalTarget, this.composed);
|
|
3604
|
-
var originalCurrentTarget = eventCurrentTargetGetter.call(this);
|
|
3164
|
+
var originalCurrentTarget = eventCurrentTargetGetter.call(this);
|
|
3165
|
+
// Handle cases where the currentTarget is null (for async events), and when an event has been
|
|
3605
3166
|
// added to Window
|
|
3606
|
-
|
|
3607
3167
|
if (!(originalCurrentTarget instanceof _Node)) {
|
|
3608
3168
|
// TODO [#1511]: Special escape hatch to support legacy behavior. Should be fixed.
|
|
3609
3169
|
// If the event's target is being accessed async and originalTarget is not a keyed element, do not retarget
|
|
3610
3170
|
if (isNull(originalCurrentTarget) && isUndefined(getNodeOwnerKey(originalTarget))) {
|
|
3611
3171
|
return originalTarget;
|
|
3612
3172
|
}
|
|
3613
|
-
|
|
3614
3173
|
return retarget(doc, composedPath);
|
|
3615
3174
|
} else if (originalCurrentTarget === doc || originalCurrentTarget === doc.body) {
|
|
3616
3175
|
// TODO [#1530]: If currentTarget is document or document.body (Third party libraries that have global event listeners)
|
|
@@ -3618,68 +3177,53 @@
|
|
|
3618
3177
|
if (isUndefined(getNodeOwnerKey(originalTarget))) {
|
|
3619
3178
|
return originalTarget;
|
|
3620
3179
|
}
|
|
3621
|
-
|
|
3622
3180
|
return retarget(doc, composedPath);
|
|
3623
3181
|
}
|
|
3624
|
-
|
|
3625
3182
|
var actualCurrentTarget = originalCurrentTarget;
|
|
3626
|
-
var actualPath = composedPath;
|
|
3627
|
-
|
|
3183
|
+
var actualPath = composedPath;
|
|
3184
|
+
// Address the possibility that `currentTarget` is a shadow root
|
|
3628
3185
|
if (isSyntheticShadowHost(originalCurrentTarget)) {
|
|
3629
3186
|
var context = eventToContextMap.get(this);
|
|
3630
|
-
|
|
3631
|
-
if (context === 1
|
|
3632
|
-
/* EventListenerContext.SHADOW_ROOT_LISTENER */
|
|
3633
|
-
) {
|
|
3187
|
+
if (context === 1 /* EventListenerContext.SHADOW_ROOT_LISTENER */) {
|
|
3634
3188
|
actualCurrentTarget = getShadowRoot(originalCurrentTarget);
|
|
3635
3189
|
}
|
|
3636
|
-
}
|
|
3637
|
-
|
|
3638
|
-
|
|
3190
|
+
}
|
|
3191
|
+
// Address the possibility that `target` is a shadow root
|
|
3639
3192
|
if (isSyntheticShadowHost(originalTarget) && eventToShadowRootMap.has(this)) {
|
|
3640
3193
|
actualPath = pathComposer(getShadowRoot(originalTarget), this.composed);
|
|
3641
3194
|
}
|
|
3642
|
-
|
|
3643
3195
|
return retarget(actualCurrentTarget, actualPath);
|
|
3644
3196
|
}
|
|
3645
|
-
|
|
3646
3197
|
function patchedComposedPathValue() {
|
|
3647
|
-
var originalTarget = eventTargetGetter.call(this);
|
|
3198
|
+
var originalTarget = eventTargetGetter.call(this);
|
|
3199
|
+
// Account for events with targets that are not instances of Node (e.g., when a readystatechange
|
|
3648
3200
|
// handler is listening on an instance of XMLHttpRequest).
|
|
3649
|
-
|
|
3650
3201
|
if (!(originalTarget instanceof _Node)) {
|
|
3651
3202
|
return [];
|
|
3652
|
-
}
|
|
3203
|
+
}
|
|
3204
|
+
// If the original target is inside a native shadow root, then just call the native
|
|
3653
3205
|
// composePath() method. The event is already retargeted and this causes our composedPath()
|
|
3654
3206
|
// polyfill to compute the wrong value. This is only an issue when you have a native web
|
|
3655
3207
|
// component inside an LWC component (see test in same commit) but this scenario is unlikely
|
|
3656
3208
|
// because we don't yet support that. Workaround specifically for W-9846457. Mixed mode solution
|
|
3657
3209
|
// will likely be more involved.
|
|
3658
|
-
|
|
3659
|
-
|
|
3660
3210
|
var hasShadowRoot = Boolean(originalTarget.shadowRoot);
|
|
3661
3211
|
var hasSyntheticShadowRootAttached = hasInternalSlot(originalTarget);
|
|
3662
|
-
|
|
3663
3212
|
if (hasShadowRoot && !hasSyntheticShadowRootAttached) {
|
|
3664
3213
|
return composedPath.call(this);
|
|
3665
3214
|
}
|
|
3666
|
-
|
|
3667
|
-
|
|
3668
|
-
|
|
3215
|
+
var originalCurrentTarget = eventCurrentTargetGetter.call(this);
|
|
3216
|
+
// If the event has completed propagation, the composedPath should be an empty array.
|
|
3669
3217
|
if (isNull(originalCurrentTarget)) {
|
|
3670
3218
|
return [];
|
|
3671
|
-
}
|
|
3672
|
-
|
|
3673
|
-
|
|
3219
|
+
}
|
|
3220
|
+
// Address the possibility that `target` is a shadow root
|
|
3674
3221
|
var actualTarget = originalTarget;
|
|
3675
|
-
|
|
3676
3222
|
if (isSyntheticShadowHost(originalTarget) && eventToShadowRootMap.has(this)) {
|
|
3677
3223
|
actualTarget = getShadowRoot(originalTarget);
|
|
3678
3224
|
}
|
|
3679
|
-
|
|
3680
3225
|
return pathComposer(actualTarget, this.composed);
|
|
3681
3226
|
}
|
|
3682
|
-
|
|
3683
3227
|
defineProperties(Event.prototype, {
|
|
3684
3228
|
target: {
|
|
3685
3229
|
get: patchedTargetGetter,
|
|
@@ -3711,66 +3255,61 @@
|
|
|
3711
3255
|
configurable: true
|
|
3712
3256
|
}
|
|
3713
3257
|
});
|
|
3258
|
+
|
|
3714
3259
|
/*
|
|
3715
3260
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
3716
3261
|
* All rights reserved.
|
|
3717
3262
|
* SPDX-License-Identifier: MIT
|
|
3718
3263
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
3719
3264
|
*/
|
|
3720
|
-
|
|
3721
3265
|
function retargetRelatedTarget(Ctor) {
|
|
3722
3266
|
var relatedTargetGetter = getOwnPropertyDescriptor(Ctor.prototype, 'relatedTarget').get;
|
|
3723
3267
|
defineProperty(Ctor.prototype, 'relatedTarget', {
|
|
3724
3268
|
get: function get() {
|
|
3725
3269
|
var relatedTarget = relatedTargetGetter.call(this);
|
|
3726
|
-
|
|
3727
3270
|
if (isNull(relatedTarget)) {
|
|
3728
3271
|
return null;
|
|
3729
3272
|
}
|
|
3730
|
-
|
|
3731
3273
|
if (!(relatedTarget instanceof _Node) || !isNodeShadowed(relatedTarget)) {
|
|
3732
3274
|
return relatedTarget;
|
|
3733
3275
|
}
|
|
3734
|
-
|
|
3735
3276
|
var pointOfReference = eventCurrentTargetGetter.call(this);
|
|
3736
|
-
|
|
3737
3277
|
if (isNull(pointOfReference)) {
|
|
3738
3278
|
pointOfReference = getOwnerDocument(relatedTarget);
|
|
3739
3279
|
}
|
|
3740
|
-
|
|
3741
3280
|
return retarget(pointOfReference, pathComposer(relatedTarget, true));
|
|
3742
3281
|
},
|
|
3743
3282
|
enumerable: true,
|
|
3744
3283
|
configurable: true
|
|
3745
3284
|
});
|
|
3746
3285
|
}
|
|
3286
|
+
|
|
3747
3287
|
/*
|
|
3748
3288
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
3749
3289
|
* All rights reserved.
|
|
3750
3290
|
* SPDX-License-Identifier: MIT
|
|
3751
3291
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
3752
3292
|
*/
|
|
3753
|
-
|
|
3754
|
-
|
|
3755
3293
|
retargetRelatedTarget(FocusEvent);
|
|
3294
|
+
|
|
3756
3295
|
/*
|
|
3757
3296
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
3758
3297
|
* All rights reserved.
|
|
3759
3298
|
* SPDX-License-Identifier: MIT
|
|
3760
3299
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
3761
3300
|
*/
|
|
3762
|
-
|
|
3763
3301
|
retargetRelatedTarget(MouseEvent);
|
|
3302
|
+
|
|
3764
3303
|
/*
|
|
3765
3304
|
* Copyright (c) 2021, salesforce.com, inc.
|
|
3766
3305
|
* All rights reserved.
|
|
3767
3306
|
* SPDX-License-Identifier: MIT
|
|
3768
3307
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
3769
3308
|
*/
|
|
3770
|
-
|
|
3771
3309
|
var assignedSlotGetter = hasOwnProperty.call(Text.prototype, 'assignedSlot') ? getOwnPropertyDescriptor(Text.prototype, 'assignedSlot').get : function () {
|
|
3772
3310
|
return null;
|
|
3773
3311
|
};
|
|
3312
|
+
|
|
3774
3313
|
/*
|
|
3775
3314
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
3776
3315
|
* All rights reserved.
|
|
@@ -3781,20 +3320,16 @@
|
|
|
3781
3320
|
// "Registered observers in a node’s registered observer list have a weak
|
|
3782
3321
|
// reference to the node."
|
|
3783
3322
|
// https://dom.spec.whatwg.org/#garbage-collection
|
|
3784
|
-
|
|
3785
3323
|
var observer;
|
|
3786
3324
|
var observerConfig = {
|
|
3787
3325
|
childList: true
|
|
3788
3326
|
};
|
|
3789
3327
|
var SlotChangeKey = new WeakMap();
|
|
3790
|
-
|
|
3791
3328
|
function initSlotObserver() {
|
|
3792
3329
|
return new MO(function (mutations) {
|
|
3793
3330
|
var slots = [];
|
|
3794
3331
|
forEach.call(mutations, function (mutation) {
|
|
3795
|
-
|
|
3796
3332
|
var slot = mutation.target;
|
|
3797
|
-
|
|
3798
3333
|
if (ArrayIndexOf.call(slots, slot) === -1) {
|
|
3799
3334
|
ArrayPush.call(slots, slot);
|
|
3800
3335
|
dispatchEvent.call(slot, new CustomEvent('slotchange'));
|
|
@@ -3802,34 +3337,29 @@
|
|
|
3802
3337
|
});
|
|
3803
3338
|
});
|
|
3804
3339
|
}
|
|
3805
|
-
|
|
3806
3340
|
function getFilteredSlotFlattenNodes(slot) {
|
|
3807
|
-
var childNodes = arrayFromCollection(childNodesGetter.call(slot));
|
|
3341
|
+
var childNodes = arrayFromCollection(childNodesGetter.call(slot));
|
|
3342
|
+
// Typescript is inferring the wrong function type for this particular
|
|
3808
3343
|
// overloaded method: https://github.com/Microsoft/TypeScript/issues/27972
|
|
3809
3344
|
// @ts-ignore type-mismatch
|
|
3810
|
-
|
|
3811
3345
|
return ArrayReduce.call(childNodes, function (seed, child) {
|
|
3812
3346
|
if (child instanceof Element && isSlotElement(child)) {
|
|
3813
3347
|
ArrayPush.apply(seed, getFilteredSlotFlattenNodes(child));
|
|
3814
3348
|
} else {
|
|
3815
3349
|
ArrayPush.call(seed, child);
|
|
3816
3350
|
}
|
|
3817
|
-
|
|
3818
3351
|
return seed;
|
|
3819
3352
|
}, []);
|
|
3820
3353
|
}
|
|
3821
|
-
|
|
3822
3354
|
function assignedSlotGetterPatched() {
|
|
3823
|
-
var parentNode = parentNodeGetter.call(this);
|
|
3824
|
-
|
|
3355
|
+
var parentNode = parentNodeGetter.call(this);
|
|
3356
|
+
// use original assignedSlot if parent has a native shdow root
|
|
3825
3357
|
if (parentNode instanceof Element) {
|
|
3826
3358
|
var sr = shadowRootGetter.call(parentNode);
|
|
3827
|
-
|
|
3828
3359
|
if (isInstanceOfNativeShadowRoot(sr)) {
|
|
3829
3360
|
if (this instanceof Text) {
|
|
3830
3361
|
return assignedSlotGetter.call(this);
|
|
3831
3362
|
}
|
|
3832
|
-
|
|
3833
3363
|
return assignedSlotGetter$1.call(this);
|
|
3834
3364
|
}
|
|
3835
3365
|
}
|
|
@@ -3843,28 +3373,21 @@
|
|
|
3843
3373
|
* the light DOM node doesn't have an owner key and therefor the slot owner key will be
|
|
3844
3374
|
* different than the node owner key (always `undefined`).
|
|
3845
3375
|
*/
|
|
3846
|
-
|
|
3847
|
-
|
|
3848
3376
|
if (!isNull(parentNode) && isSlotElement(parentNode) && getNodeOwnerKey(parentNode) !== getNodeOwnerKey(this)) {
|
|
3849
3377
|
return parentNode;
|
|
3850
3378
|
}
|
|
3851
|
-
|
|
3852
3379
|
return null;
|
|
3853
3380
|
}
|
|
3854
|
-
|
|
3855
3381
|
defineProperties(HTMLSlotElement.prototype, {
|
|
3856
3382
|
addEventListener: {
|
|
3857
3383
|
value: function value(type, listener, options) {
|
|
3858
3384
|
// super.addEventListener - but that doesn't work with typescript
|
|
3859
3385
|
HTMLElement.prototype.addEventListener.call(this, type, listener, options);
|
|
3860
|
-
|
|
3861
3386
|
if (type === 'slotchange' && !SlotChangeKey.get(this)) {
|
|
3862
3387
|
SlotChangeKey.set(this, true);
|
|
3863
|
-
|
|
3864
3388
|
if (!observer) {
|
|
3865
3389
|
observer = initSlotObserver();
|
|
3866
3390
|
}
|
|
3867
|
-
|
|
3868
3391
|
MutationObserverObserve.call(observer, this, observerConfig);
|
|
3869
3392
|
}
|
|
3870
3393
|
},
|
|
@@ -3919,13 +3442,13 @@
|
|
|
3919
3442
|
var childNodes = isNull(owner) ? [] : getAllMatches(owner, getFilteredChildNodes(this));
|
|
3920
3443
|
return createStaticNodeList(childNodes);
|
|
3921
3444
|
}
|
|
3922
|
-
|
|
3923
3445
|
return childNodesGetter.call(this);
|
|
3924
3446
|
},
|
|
3925
3447
|
enumerable: true,
|
|
3926
3448
|
configurable: true
|
|
3927
3449
|
}
|
|
3928
3450
|
});
|
|
3451
|
+
|
|
3929
3452
|
/*
|
|
3930
3453
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
3931
3454
|
* All rights reserved.
|
|
@@ -3934,7 +3457,6 @@
|
|
|
3934
3457
|
*/
|
|
3935
3458
|
// Non-deep-traversing patches: this descriptor map includes all descriptors that
|
|
3936
3459
|
// do not five access to nodes beyond the immediate children.
|
|
3937
|
-
|
|
3938
3460
|
defineProperties(Text.prototype, {
|
|
3939
3461
|
assignedSlot: {
|
|
3940
3462
|
get: assignedSlotGetterPatched,
|
|
@@ -3942,27 +3464,25 @@
|
|
|
3942
3464
|
configurable: true
|
|
3943
3465
|
}
|
|
3944
3466
|
});
|
|
3467
|
+
|
|
3945
3468
|
/*
|
|
3946
3469
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
3947
3470
|
* All rights reserved.
|
|
3948
3471
|
* SPDX-License-Identifier: MIT
|
|
3949
3472
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
3950
3473
|
*/
|
|
3951
|
-
|
|
3952
3474
|
/**
|
|
3953
3475
|
* This methods filters out elements that are not in the same shadow root of context.
|
|
3954
3476
|
* It does not enforce shadow dom semantics if $context is not managed by LWC
|
|
3955
3477
|
*/
|
|
3956
|
-
|
|
3957
3478
|
function getNonPatchedFilteredArrayOfNodes(context, unfilteredNodes) {
|
|
3958
3479
|
var filtered;
|
|
3959
|
-
var ownerKey = getNodeOwnerKey(context);
|
|
3960
|
-
|
|
3480
|
+
var ownerKey = getNodeOwnerKey(context);
|
|
3481
|
+
// a node inside a shadow.
|
|
3961
3482
|
if (!isUndefined(ownerKey)) {
|
|
3962
3483
|
if (isSyntheticShadowHost(context)) {
|
|
3963
3484
|
// element with shadowRoot attached
|
|
3964
3485
|
var owner = getNodeOwner(context);
|
|
3965
|
-
|
|
3966
3486
|
if (isNull(owner)) {
|
|
3967
3487
|
filtered = [];
|
|
3968
3488
|
} else if (getNodeKey(context)) {
|
|
@@ -3980,7 +3500,8 @@
|
|
|
3980
3500
|
}
|
|
3981
3501
|
} else if (context instanceof HTMLBodyElement) {
|
|
3982
3502
|
// `context` is document.body which is already patched.
|
|
3983
|
-
filtered = ArrayFilter.call(unfilteredNodes,
|
|
3503
|
+
filtered = ArrayFilter.call(unfilteredNodes,
|
|
3504
|
+
// TODO [#1222]: remove global bypass
|
|
3984
3505
|
function (elm) {
|
|
3985
3506
|
return isUndefined(getNodeOwnerKey(elm)) || isGlobalPatchingSkipped(context);
|
|
3986
3507
|
});
|
|
@@ -3988,53 +3509,42 @@
|
|
|
3988
3509
|
// `context` is outside the lwc boundary, return unfiltered list.
|
|
3989
3510
|
filtered = ArraySlice.call(unfilteredNodes);
|
|
3990
3511
|
}
|
|
3991
|
-
|
|
3992
3512
|
return filtered;
|
|
3993
3513
|
}
|
|
3514
|
+
|
|
3994
3515
|
/*
|
|
3995
3516
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
3996
3517
|
* All rights reserved.
|
|
3997
3518
|
* SPDX-License-Identifier: MIT
|
|
3998
3519
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
3999
3520
|
*/
|
|
4000
|
-
|
|
4001
|
-
|
|
4002
3521
|
function innerHTMLGetterPatched() {
|
|
4003
3522
|
var childNodes = getInternalChildNodes(this);
|
|
4004
3523
|
var innerHTML = '';
|
|
4005
|
-
|
|
4006
3524
|
for (var i = 0, len = childNodes.length; i < len; i += 1) {
|
|
4007
3525
|
innerHTML += getOuterHTML(childNodes[i]);
|
|
4008
3526
|
}
|
|
4009
|
-
|
|
4010
3527
|
return innerHTML;
|
|
4011
3528
|
}
|
|
4012
|
-
|
|
4013
3529
|
function outerHTMLGetterPatched() {
|
|
4014
3530
|
return getOuterHTML(this);
|
|
4015
3531
|
}
|
|
4016
|
-
|
|
4017
3532
|
function attachShadowPatched(options) {
|
|
4018
3533
|
// To retain native behavior of the API, provide synthetic shadowRoot only when specified
|
|
4019
3534
|
if (options[KEY__SYNTHETIC_MODE]) {
|
|
4020
3535
|
return attachShadow(this, options);
|
|
4021
3536
|
}
|
|
4022
|
-
|
|
4023
3537
|
return attachShadow$1.call(this, options);
|
|
4024
3538
|
}
|
|
4025
|
-
|
|
4026
3539
|
function shadowRootGetterPatched() {
|
|
4027
3540
|
if (isSyntheticShadowHost(this)) {
|
|
4028
3541
|
var shadow = getShadowRoot(this);
|
|
4029
|
-
|
|
4030
3542
|
if (shadow.mode === 'open') {
|
|
4031
3543
|
return shadow;
|
|
4032
3544
|
}
|
|
4033
3545
|
}
|
|
4034
|
-
|
|
4035
3546
|
return shadowRootGetter.call(this);
|
|
4036
3547
|
}
|
|
4037
|
-
|
|
4038
3548
|
function childrenGetterPatched() {
|
|
4039
3549
|
var owner = getNodeOwner(this);
|
|
4040
3550
|
var childNodes = isNull(owner) ? [] : getAllMatches(owner, getFilteredChildNodes(this));
|
|
@@ -4042,22 +3552,18 @@
|
|
|
4042
3552
|
return node instanceof Element;
|
|
4043
3553
|
}));
|
|
4044
3554
|
}
|
|
4045
|
-
|
|
4046
3555
|
function childElementCountGetterPatched() {
|
|
4047
3556
|
return this.children.length;
|
|
4048
3557
|
}
|
|
4049
|
-
|
|
4050
3558
|
function firstElementChildGetterPatched() {
|
|
4051
3559
|
return this.children[0] || null;
|
|
4052
3560
|
}
|
|
4053
|
-
|
|
4054
3561
|
function lastElementChildGetterPatched() {
|
|
4055
3562
|
var children = this.children;
|
|
4056
3563
|
return children.item(children.length - 1) || null;
|
|
4057
|
-
}
|
|
3564
|
+
}
|
|
3565
|
+
// Non-deep-traversing patches: this descriptor map includes all descriptors that
|
|
4058
3566
|
// do not five access to nodes beyond the immediate children.
|
|
4059
|
-
|
|
4060
|
-
|
|
4061
3567
|
defineProperties(Element.prototype, {
|
|
4062
3568
|
innerHTML: {
|
|
4063
3569
|
get: function get() {
|
|
@@ -4065,15 +3571,12 @@
|
|
|
4065
3571
|
if (isNodeShadowed(this) || isSyntheticShadowHost(this)) {
|
|
4066
3572
|
return innerHTMLGetterPatched.call(this);
|
|
4067
3573
|
}
|
|
4068
|
-
|
|
4069
3574
|
return innerHTMLGetter.call(this);
|
|
4070
|
-
}
|
|
4071
|
-
|
|
4072
|
-
|
|
3575
|
+
}
|
|
3576
|
+
// TODO [#1222]: remove global bypass
|
|
4073
3577
|
if (isGlobalPatchingSkipped(this)) {
|
|
4074
3578
|
return innerHTMLGetter.call(this);
|
|
4075
3579
|
}
|
|
4076
|
-
|
|
4077
3580
|
return innerHTMLGetterPatched.call(this);
|
|
4078
3581
|
},
|
|
4079
3582
|
set: function set(v) {
|
|
@@ -4088,15 +3591,12 @@
|
|
|
4088
3591
|
if (isNodeShadowed(this) || isSyntheticShadowHost(this)) {
|
|
4089
3592
|
return outerHTMLGetterPatched.call(this);
|
|
4090
3593
|
}
|
|
4091
|
-
|
|
4092
3594
|
return outerHTMLGetter.call(this);
|
|
4093
|
-
}
|
|
4094
|
-
|
|
4095
|
-
|
|
3595
|
+
}
|
|
3596
|
+
// TODO [#1222]: remove global bypass
|
|
4096
3597
|
if (isGlobalPatchingSkipped(this)) {
|
|
4097
3598
|
return outerHTMLGetter.call(this);
|
|
4098
3599
|
}
|
|
4099
|
-
|
|
4100
3600
|
return outerHTMLGetterPatched.call(this);
|
|
4101
3601
|
},
|
|
4102
3602
|
set: function set(v) {
|
|
@@ -4122,7 +3622,6 @@
|
|
|
4122
3622
|
if (hasMountedChildren(this)) {
|
|
4123
3623
|
return childrenGetterPatched.call(this);
|
|
4124
3624
|
}
|
|
4125
|
-
|
|
4126
3625
|
return childrenGetter.call(this);
|
|
4127
3626
|
},
|
|
4128
3627
|
enumerable: true,
|
|
@@ -4133,7 +3632,6 @@
|
|
|
4133
3632
|
if (hasMountedChildren(this)) {
|
|
4134
3633
|
return childElementCountGetterPatched.call(this);
|
|
4135
3634
|
}
|
|
4136
|
-
|
|
4137
3635
|
return childElementCountGetter.call(this);
|
|
4138
3636
|
},
|
|
4139
3637
|
enumerable: true,
|
|
@@ -4144,7 +3642,6 @@
|
|
|
4144
3642
|
if (hasMountedChildren(this)) {
|
|
4145
3643
|
return firstElementChildGetterPatched.call(this);
|
|
4146
3644
|
}
|
|
4147
|
-
|
|
4148
3645
|
return firstElementChildGetter.call(this);
|
|
4149
3646
|
},
|
|
4150
3647
|
enumerable: true,
|
|
@@ -4155,7 +3652,6 @@
|
|
|
4155
3652
|
if (hasMountedChildren(this)) {
|
|
4156
3653
|
return lastElementChildGetterPatched.call(this);
|
|
4157
3654
|
}
|
|
4158
|
-
|
|
4159
3655
|
return lastElementChildGetter.call(this);
|
|
4160
3656
|
},
|
|
4161
3657
|
enumerable: true,
|
|
@@ -4166,30 +3662,24 @@
|
|
|
4166
3662
|
enumerable: true,
|
|
4167
3663
|
configurable: true
|
|
4168
3664
|
}
|
|
4169
|
-
});
|
|
4170
|
-
|
|
3665
|
+
});
|
|
3666
|
+
// IE11 extra patches for wrong prototypes
|
|
4171
3667
|
if (hasOwnProperty.call(HTMLElement.prototype, 'innerHTML')) {
|
|
4172
3668
|
defineProperty(HTMLElement.prototype, 'innerHTML', getOwnPropertyDescriptor(Element.prototype, 'innerHTML'));
|
|
4173
3669
|
}
|
|
4174
|
-
|
|
4175
3670
|
if (hasOwnProperty.call(HTMLElement.prototype, 'outerHTML')) {
|
|
4176
3671
|
defineProperty(HTMLElement.prototype, 'outerHTML', getOwnPropertyDescriptor(Element.prototype, 'outerHTML'));
|
|
4177
3672
|
}
|
|
4178
|
-
|
|
4179
3673
|
if (hasOwnProperty.call(HTMLElement.prototype, 'children')) {
|
|
4180
3674
|
defineProperty(HTMLElement.prototype, 'children', getOwnPropertyDescriptor(Element.prototype, 'children'));
|
|
4181
|
-
}
|
|
4182
|
-
|
|
4183
|
-
|
|
3675
|
+
}
|
|
3676
|
+
// Deep-traversing patches from this point on:
|
|
4184
3677
|
function querySelectorPatched() {
|
|
4185
3678
|
var _this3 = this;
|
|
4186
|
-
|
|
4187
3679
|
var nodeList = arrayFromCollection(querySelectorAll$1.apply(this, ArraySlice.call(arguments)));
|
|
4188
|
-
|
|
4189
3680
|
if (isSyntheticShadowHost(this)) {
|
|
4190
3681
|
// element with shadowRoot attached
|
|
4191
3682
|
var owner = getNodeOwner(this);
|
|
4192
|
-
|
|
4193
3683
|
if (!isUndefined(getNodeKey(this))) {
|
|
4194
3684
|
// it is a custom element, and we should then filter by slotted elements
|
|
4195
3685
|
return getFirstSlottedMatch(this, nodeList);
|
|
@@ -4202,7 +3692,6 @@
|
|
|
4202
3692
|
} else if (isNodeShadowed(this)) {
|
|
4203
3693
|
// element inside a shadowRoot
|
|
4204
3694
|
var ownerKey = getNodeOwnerKey(this);
|
|
4205
|
-
|
|
4206
3695
|
if (!isUndefined(ownerKey)) {
|
|
4207
3696
|
// `this` is handled by lwc, using getNodeNearestOwnerKey to include manually inserted elements in the same shadow.
|
|
4208
3697
|
var elm = ArrayFind.call(nodeList, function (elm) {
|
|
@@ -4213,16 +3702,13 @@
|
|
|
4213
3702
|
if (!lwcRuntimeFlags.ENABLE_NODE_LIST_PATCH) {
|
|
4214
3703
|
// `this` is a manually inserted element inside a shadowRoot, return the first element.
|
|
4215
3704
|
return nodeList.length === 0 ? null : nodeList[0];
|
|
4216
|
-
}
|
|
3705
|
+
}
|
|
3706
|
+
// Element is inside a shadow but we dont know which one. Use the
|
|
4217
3707
|
// "nearest" owner key to filter by ownership.
|
|
4218
|
-
|
|
4219
|
-
|
|
4220
3708
|
var contextNearestOwnerKey = getNodeNearestOwnerKey(this);
|
|
4221
|
-
|
|
4222
3709
|
var _elm = ArrayFind.call(nodeList, function (elm) {
|
|
4223
3710
|
return getNodeNearestOwnerKey(elm) === contextNearestOwnerKey;
|
|
4224
3711
|
});
|
|
4225
|
-
|
|
4226
3712
|
return isUndefined(_elm) ? null : _elm;
|
|
4227
3713
|
}
|
|
4228
3714
|
} else {
|
|
@@ -4231,25 +3717,21 @@
|
|
|
4231
3717
|
var _elm3 = nodeList[0];
|
|
4232
3718
|
return isUndefined(_elm3) ? null : _elm3;
|
|
4233
3719
|
}
|
|
4234
|
-
}
|
|
4235
|
-
|
|
4236
|
-
|
|
4237
|
-
|
|
3720
|
+
}
|
|
3721
|
+
// element belonging to the document
|
|
3722
|
+
var _elm2 = ArrayFind.call(nodeList,
|
|
3723
|
+
// TODO [#1222]: remove global bypass
|
|
4238
3724
|
function (elm) {
|
|
4239
3725
|
return isUndefined(getNodeOwnerKey(elm)) || isGlobalPatchingSkipped(_this3);
|
|
4240
3726
|
});
|
|
4241
|
-
|
|
4242
3727
|
return isUndefined(_elm2) ? null : _elm2;
|
|
4243
3728
|
}
|
|
4244
3729
|
}
|
|
4245
|
-
|
|
4246
3730
|
function getFilteredArrayOfNodes(context, unfilteredNodes, shadowDomSemantic) {
|
|
4247
3731
|
var filtered;
|
|
4248
|
-
|
|
4249
3732
|
if (isSyntheticShadowHost(context)) {
|
|
4250
3733
|
// element with shadowRoot attached
|
|
4251
3734
|
var owner = getNodeOwner(context);
|
|
4252
|
-
|
|
4253
3735
|
if (!isUndefined(getNodeKey(context))) {
|
|
4254
3736
|
// it is a custom element, and we should then filter by slotted elements
|
|
4255
3737
|
filtered = getAllSlottedMatches(context, unfilteredNodes);
|
|
@@ -4262,15 +3744,12 @@
|
|
|
4262
3744
|
} else if (isNodeShadowed(context)) {
|
|
4263
3745
|
// element inside a shadowRoot
|
|
4264
3746
|
var ownerKey = getNodeOwnerKey(context);
|
|
4265
|
-
|
|
4266
3747
|
if (!isUndefined(ownerKey)) {
|
|
4267
3748
|
// context is handled by lwc, using getNodeNearestOwnerKey to include manually inserted elements in the same shadow.
|
|
4268
3749
|
filtered = ArrayFilter.call(unfilteredNodes, function (elm) {
|
|
4269
3750
|
return getNodeNearestOwnerKey(elm) === ownerKey;
|
|
4270
3751
|
});
|
|
4271
|
-
} else if (shadowDomSemantic === 1
|
|
4272
|
-
/* ShadowDomSemantic.Enabled */
|
|
4273
|
-
) {
|
|
3752
|
+
} else if (shadowDomSemantic === 1 /* ShadowDomSemantic.Enabled */) {
|
|
4274
3753
|
// context is inside a shadow, we dont know which one.
|
|
4275
3754
|
var contextNearestOwnerKey = getNodeNearestOwnerKey(context);
|
|
4276
3755
|
filtered = ArrayFilter.call(unfilteredNodes, function (elm) {
|
|
@@ -4281,11 +3760,10 @@
|
|
|
4281
3760
|
filtered = ArraySlice.call(unfilteredNodes);
|
|
4282
3761
|
}
|
|
4283
3762
|
} else {
|
|
4284
|
-
if (context instanceof HTMLBodyElement || shadowDomSemantic === 1
|
|
4285
|
-
/* ShadowDomSemantic.Enabled */
|
|
4286
|
-
) {
|
|
3763
|
+
if (context instanceof HTMLBodyElement || shadowDomSemantic === 1 /* ShadowDomSemantic.Enabled */) {
|
|
4287
3764
|
// `context` is document.body or element belonging to the document with the patch enabled
|
|
4288
|
-
filtered = ArrayFilter.call(unfilteredNodes,
|
|
3765
|
+
filtered = ArrayFilter.call(unfilteredNodes,
|
|
3766
|
+
// TODO [#1222]: remove global bypass
|
|
4289
3767
|
function (elm) {
|
|
4290
3768
|
return isUndefined(getNodeOwnerKey(elm)) || isGlobalPatchingSkipped(context);
|
|
4291
3769
|
});
|
|
@@ -4294,9 +3772,9 @@
|
|
|
4294
3772
|
filtered = ArraySlice.call(unfilteredNodes);
|
|
4295
3773
|
}
|
|
4296
3774
|
}
|
|
4297
|
-
|
|
4298
3775
|
return filtered;
|
|
4299
|
-
}
|
|
3776
|
+
}
|
|
3777
|
+
// The following patched methods hide shadowed elements from global
|
|
4300
3778
|
// traversing mechanisms. They are simplified for performance reasons to
|
|
4301
3779
|
// filter by ownership and do not account for slotted elements. This
|
|
4302
3780
|
// compromise is fine for our synthetic shadow dom because root elements
|
|
@@ -4305,8 +3783,6 @@
|
|
|
4305
3783
|
// static HTMLCollection or static NodeList. We decided that this compromise
|
|
4306
3784
|
// is not a big problem considering the amount of code that is relying on
|
|
4307
3785
|
// the liveliness of these results are rare.
|
|
4308
|
-
|
|
4309
|
-
|
|
4310
3786
|
defineProperties(Element.prototype, {
|
|
4311
3787
|
querySelector: {
|
|
4312
3788
|
value: querySelectorPatched,
|
|
@@ -4317,37 +3793,28 @@
|
|
|
4317
3793
|
querySelectorAll: {
|
|
4318
3794
|
value: function value() {
|
|
4319
3795
|
var nodeList = arrayFromCollection(querySelectorAll$1.apply(this, ArraySlice.call(arguments)));
|
|
4320
|
-
|
|
4321
3796
|
if (!lwcRuntimeFlags.ENABLE_NODE_LIST_PATCH) {
|
|
4322
|
-
var filteredResults = getFilteredArrayOfNodes(this, nodeList, 0
|
|
4323
|
-
/* ShadowDomSemantic.Disabled */
|
|
4324
|
-
);
|
|
3797
|
+
var filteredResults = getFilteredArrayOfNodes(this, nodeList, 0 /* ShadowDomSemantic.Disabled */);
|
|
4325
3798
|
return createStaticNodeList(filteredResults);
|
|
4326
3799
|
}
|
|
4327
|
-
|
|
4328
|
-
return createStaticNodeList(getFilteredArrayOfNodes(this, nodeList, 1
|
|
4329
|
-
/* ShadowDomSemantic.Enabled */
|
|
4330
|
-
));
|
|
3800
|
+
return createStaticNodeList(getFilteredArrayOfNodes(this, nodeList, 1 /* ShadowDomSemantic.Enabled */));
|
|
4331
3801
|
},
|
|
3802
|
+
|
|
4332
3803
|
writable: true,
|
|
4333
3804
|
enumerable: true,
|
|
4334
3805
|
configurable: true
|
|
4335
3806
|
}
|
|
4336
|
-
});
|
|
4337
|
-
|
|
3807
|
+
});
|
|
3808
|
+
// The following APIs are used directly by Jest internally so we avoid patching them during testing.
|
|
4338
3809
|
{
|
|
4339
3810
|
defineProperties(Element.prototype, {
|
|
4340
3811
|
getElementsByClassName: {
|
|
4341
3812
|
value: function value() {
|
|
4342
3813
|
var elements = arrayFromCollection(getElementsByClassName$1.apply(this, ArraySlice.call(arguments)));
|
|
4343
|
-
|
|
4344
3814
|
if (!lwcRuntimeFlags.ENABLE_HTML_COLLECTIONS_PATCH) {
|
|
4345
3815
|
return createStaticHTMLCollection(getNonPatchedFilteredArrayOfNodes(this, elements));
|
|
4346
3816
|
}
|
|
4347
|
-
|
|
4348
|
-
var filteredResults = getFilteredArrayOfNodes(this, elements, 1
|
|
4349
|
-
/* ShadowDomSemantic.Enabled */
|
|
4350
|
-
);
|
|
3817
|
+
var filteredResults = getFilteredArrayOfNodes(this, elements, 1 /* ShadowDomSemantic.Enabled */);
|
|
4351
3818
|
return createStaticHTMLCollection(filteredResults);
|
|
4352
3819
|
},
|
|
4353
3820
|
writable: true,
|
|
@@ -4357,14 +3824,10 @@
|
|
|
4357
3824
|
getElementsByTagName: {
|
|
4358
3825
|
value: function value() {
|
|
4359
3826
|
var elements = arrayFromCollection(getElementsByTagName$1.apply(this, ArraySlice.call(arguments)));
|
|
4360
|
-
|
|
4361
3827
|
if (!lwcRuntimeFlags.ENABLE_HTML_COLLECTIONS_PATCH) {
|
|
4362
3828
|
return createStaticHTMLCollection(getNonPatchedFilteredArrayOfNodes(this, elements));
|
|
4363
3829
|
}
|
|
4364
|
-
|
|
4365
|
-
var filteredResults = getFilteredArrayOfNodes(this, elements, 1
|
|
4366
|
-
/* ShadowDomSemantic.Enabled */
|
|
4367
|
-
);
|
|
3830
|
+
var filteredResults = getFilteredArrayOfNodes(this, elements, 1 /* ShadowDomSemantic.Enabled */);
|
|
4368
3831
|
return createStaticHTMLCollection(filteredResults);
|
|
4369
3832
|
},
|
|
4370
3833
|
writable: true,
|
|
@@ -4374,14 +3837,10 @@
|
|
|
4374
3837
|
getElementsByTagNameNS: {
|
|
4375
3838
|
value: function value() {
|
|
4376
3839
|
var elements = arrayFromCollection(getElementsByTagNameNS$1.apply(this, ArraySlice.call(arguments)));
|
|
4377
|
-
|
|
4378
3840
|
if (!lwcRuntimeFlags.ENABLE_HTML_COLLECTIONS_PATCH) {
|
|
4379
3841
|
return createStaticHTMLCollection(getNonPatchedFilteredArrayOfNodes(this, elements));
|
|
4380
3842
|
}
|
|
4381
|
-
|
|
4382
|
-
var filteredResults = getFilteredArrayOfNodes(this, elements, 1
|
|
4383
|
-
/* ShadowDomSemantic.Enabled */
|
|
4384
|
-
);
|
|
3843
|
+
var filteredResults = getFilteredArrayOfNodes(this, elements, 1 /* ShadowDomSemantic.Enabled */);
|
|
4385
3844
|
return createStaticHTMLCollection(filteredResults);
|
|
4386
3845
|
},
|
|
4387
3846
|
writable: true,
|
|
@@ -4389,48 +3848,39 @@
|
|
|
4389
3848
|
configurable: true
|
|
4390
3849
|
}
|
|
4391
3850
|
});
|
|
4392
|
-
}
|
|
4393
|
-
|
|
4394
|
-
|
|
3851
|
+
}
|
|
3852
|
+
// IE11 extra patches for wrong prototypes
|
|
4395
3853
|
if (hasOwnProperty.call(HTMLElement.prototype, 'getElementsByClassName')) {
|
|
4396
3854
|
defineProperty(HTMLElement.prototype, 'getElementsByClassName', getOwnPropertyDescriptor(Element.prototype, 'getElementsByClassName'));
|
|
4397
3855
|
}
|
|
3856
|
+
|
|
4398
3857
|
/*
|
|
4399
3858
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
4400
3859
|
* All rights reserved.
|
|
4401
3860
|
* SPDX-License-Identifier: MIT
|
|
4402
3861
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
4403
3862
|
*/
|
|
4404
|
-
|
|
4405
|
-
|
|
4406
3863
|
function getElementComputedStyle(element) {
|
|
4407
3864
|
var win = getOwnerWindow(element);
|
|
4408
3865
|
return windowGetComputedStyle.call(win, element);
|
|
4409
3866
|
}
|
|
4410
|
-
|
|
4411
3867
|
function getWindowSelection(node) {
|
|
4412
3868
|
var win = getOwnerWindow(node);
|
|
4413
3869
|
return windowGetSelection.call(win);
|
|
4414
3870
|
}
|
|
4415
|
-
|
|
4416
3871
|
function nodeIsBeingRendered(nodeComputedStyle) {
|
|
4417
3872
|
return nodeComputedStyle.visibility === 'visible' && nodeComputedStyle.display !== 'none';
|
|
4418
3873
|
}
|
|
4419
|
-
|
|
4420
3874
|
function getSelectionState(element) {
|
|
4421
3875
|
var win = getOwnerWindow(element);
|
|
4422
3876
|
var selection = getWindowSelection(element);
|
|
4423
|
-
|
|
4424
3877
|
if (selection === null) {
|
|
4425
3878
|
return null;
|
|
4426
3879
|
}
|
|
4427
|
-
|
|
4428
3880
|
var ranges = [];
|
|
4429
|
-
|
|
4430
3881
|
for (var i = 0; i < selection.rangeCount; i++) {
|
|
4431
3882
|
ranges.push(selection.getRangeAt(i));
|
|
4432
3883
|
}
|
|
4433
|
-
|
|
4434
3884
|
var state = {
|
|
4435
3885
|
element: element,
|
|
4436
3886
|
onselect: win.onselect,
|
|
@@ -4443,25 +3893,21 @@
|
|
|
4443
3893
|
win.onselectionchange = null;
|
|
4444
3894
|
return state;
|
|
4445
3895
|
}
|
|
4446
|
-
|
|
4447
3896
|
function restoreSelectionState(state) {
|
|
4448
3897
|
if (state === null) {
|
|
4449
3898
|
return;
|
|
4450
3899
|
}
|
|
4451
|
-
|
|
4452
3900
|
var element = state.element,
|
|
4453
|
-
|
|
4454
|
-
|
|
4455
|
-
|
|
4456
|
-
|
|
3901
|
+
onselect = state.onselect,
|
|
3902
|
+
onselectstart = state.onselectstart,
|
|
3903
|
+
onselectionchange = state.onselectionchange,
|
|
3904
|
+
ranges = state.ranges;
|
|
4457
3905
|
var win = getOwnerWindow(element);
|
|
4458
3906
|
var selection = getWindowSelection(element);
|
|
4459
3907
|
selection.removeAllRanges();
|
|
4460
|
-
|
|
4461
3908
|
for (var i = 0; i < ranges.length; i++) {
|
|
4462
3909
|
selection.addRange(ranges[i]);
|
|
4463
3910
|
}
|
|
4464
|
-
|
|
4465
3911
|
win.onselect = onselect;
|
|
4466
3912
|
win.onselectstart = onselectstart;
|
|
4467
3913
|
win.onselectionchange = onselectionchange;
|
|
@@ -4472,37 +3918,29 @@
|
|
|
4472
3918
|
* NOTE: For performance reasons, since this function will be called multiple times while calculating the innerText of
|
|
4473
3919
|
* an element, it does not restore the current selection.
|
|
4474
3920
|
*/
|
|
4475
|
-
|
|
4476
|
-
|
|
4477
3921
|
function getTextNodeInnerText(textNode) {
|
|
4478
3922
|
var selection = getWindowSelection(textNode);
|
|
4479
|
-
|
|
4480
3923
|
if (selection === null) {
|
|
4481
3924
|
return textNode.textContent || '';
|
|
4482
3925
|
}
|
|
4483
|
-
|
|
4484
3926
|
var range = document.createRange();
|
|
4485
3927
|
range.selectNodeContents(textNode);
|
|
4486
3928
|
var domRect = range.getBoundingClientRect();
|
|
4487
|
-
|
|
4488
3929
|
if (domRect.height <= 0 || domRect.width <= 0) {
|
|
4489
3930
|
// the text node is not rendered
|
|
4490
3931
|
return '';
|
|
4491
|
-
}
|
|
4492
|
-
|
|
4493
|
-
|
|
3932
|
+
}
|
|
3933
|
+
// Needed to remove non rendered characters from the text node.
|
|
4494
3934
|
selection.removeAllRanges();
|
|
4495
3935
|
selection.addRange(range);
|
|
4496
|
-
var selectionText = selection.toString();
|
|
3936
|
+
var selectionText = selection.toString();
|
|
3937
|
+
// The textNode is visible, but it may not be selectable. When the text is not selectable,
|
|
4497
3938
|
// textContent is the nearest approximation to innerText.
|
|
4498
|
-
|
|
4499
3939
|
return selectionText ? selectionText : textNode.textContent || '';
|
|
4500
3940
|
}
|
|
4501
|
-
|
|
4502
3941
|
var nodeIsElement = function nodeIsElement(node) {
|
|
4503
3942
|
return node.nodeType === ELEMENT_NODE;
|
|
4504
3943
|
};
|
|
4505
|
-
|
|
4506
3944
|
var nodeIsText = function nodeIsText(node) {
|
|
4507
3945
|
return node.nodeType === TEXT_NODE;
|
|
4508
3946
|
};
|
|
@@ -4510,15 +3948,11 @@
|
|
|
4510
3948
|
* Spec: https://html.spec.whatwg.org/multipage/dom.html#inner-text-collection-steps
|
|
4511
3949
|
* One spec implementation: https://github.com/servo/servo/blob/721271dcd3c20db5ca8cf146e2b5907647afb4d6/components/layout/query.rs#L1132
|
|
4512
3950
|
*/
|
|
4513
|
-
|
|
4514
|
-
|
|
4515
3951
|
function innerTextCollectionSteps(node) {
|
|
4516
3952
|
var items = [];
|
|
4517
|
-
|
|
4518
3953
|
if (nodeIsElement(node)) {
|
|
4519
3954
|
var tagName = node.tagName;
|
|
4520
3955
|
var computedStyle = getElementComputedStyle(node);
|
|
4521
|
-
|
|
4522
3956
|
if (tagName === 'OPTION') {
|
|
4523
3957
|
// For options, is hard to get the "rendered" text, let's use the original getter.
|
|
4524
3958
|
return [1, innerTextGetter.call(node), 1];
|
|
@@ -4526,49 +3960,37 @@
|
|
|
4526
3960
|
return [];
|
|
4527
3961
|
} else {
|
|
4528
3962
|
var childNodes = node.childNodes;
|
|
4529
|
-
|
|
4530
3963
|
for (var i = 0, n = childNodes.length; i < n; i++) {
|
|
4531
3964
|
ArrayPush.apply(items, innerTextCollectionSteps(childNodes[i]));
|
|
4532
3965
|
}
|
|
4533
3966
|
}
|
|
4534
|
-
|
|
4535
3967
|
if (!nodeIsBeingRendered(computedStyle)) {
|
|
4536
3968
|
if (tagName === 'SELECT' || tagName === 'DATALIST') {
|
|
4537
3969
|
// the select is either: .visibility != 'visible' or .display === hidden, therefore this select should
|
|
4538
3970
|
// not display any value.
|
|
4539
3971
|
return [];
|
|
4540
3972
|
}
|
|
4541
|
-
|
|
4542
3973
|
return items;
|
|
4543
3974
|
}
|
|
4544
|
-
|
|
4545
3975
|
if (tagName === 'BR') {
|
|
4546
|
-
items.push("\n"
|
|
4547
|
-
/* line feed */
|
|
4548
|
-
);
|
|
3976
|
+
items.push("\n" /* line feed */);
|
|
4549
3977
|
}
|
|
4550
3978
|
|
|
4551
3979
|
var display = computedStyle.display;
|
|
4552
|
-
|
|
4553
3980
|
if (display === 'table-cell') {
|
|
4554
3981
|
// omitting case: and node's CSS box is not the last 'table-cell' box of its enclosing 'table-row' box
|
|
4555
|
-
items.push("\t"
|
|
4556
|
-
/* tab */
|
|
4557
|
-
);
|
|
3982
|
+
items.push("\t" /* tab */);
|
|
4558
3983
|
}
|
|
4559
3984
|
|
|
4560
3985
|
if (display === 'table-row') {
|
|
4561
3986
|
// omitting case: and node's CSS box is not the last 'table-row' box of the nearest ancestor 'table' box
|
|
4562
|
-
items.push("\n"
|
|
4563
|
-
/* line feed */
|
|
4564
|
-
);
|
|
3987
|
+
items.push("\n" /* line feed */);
|
|
4565
3988
|
}
|
|
4566
3989
|
|
|
4567
3990
|
if (tagName === 'P') {
|
|
4568
3991
|
items.unshift(2);
|
|
4569
3992
|
items.push(2);
|
|
4570
3993
|
}
|
|
4571
|
-
|
|
4572
3994
|
if (display === 'block' || display === 'table-caption' || display === 'flex' || display === 'table') {
|
|
4573
3995
|
items.unshift(1);
|
|
4574
3996
|
items.push(1);
|
|
@@ -4576,7 +3998,6 @@
|
|
|
4576
3998
|
} else if (nodeIsText(node)) {
|
|
4577
3999
|
items.push(getTextNodeInnerText(node));
|
|
4578
4000
|
}
|
|
4579
|
-
|
|
4580
4001
|
return items;
|
|
4581
4002
|
}
|
|
4582
4003
|
/**
|
|
@@ -4584,39 +4005,29 @@
|
|
|
4584
4005
|
*
|
|
4585
4006
|
* One spec implementation: https://github.com/servo/servo/blob/721271dcd3c20db5ca8cf146e2b5907647afb4d6/components/layout/query.rs#L1087
|
|
4586
4007
|
*/
|
|
4587
|
-
|
|
4588
|
-
|
|
4589
4008
|
function getInnerText(element) {
|
|
4590
4009
|
var thisComputedStyle = getElementComputedStyle(element);
|
|
4591
|
-
|
|
4592
4010
|
if (!nodeIsBeingRendered(thisComputedStyle)) {
|
|
4593
4011
|
return getTextContent(element) || '';
|
|
4594
4012
|
}
|
|
4595
|
-
|
|
4596
4013
|
var selectionState = getSelectionState(element);
|
|
4597
4014
|
var results = [];
|
|
4598
4015
|
var childNodes = element.childNodes;
|
|
4599
|
-
|
|
4600
4016
|
for (var i = 0, n = childNodes.length; i < n; i++) {
|
|
4601
4017
|
ArrayPush.apply(results, innerTextCollectionSteps(childNodes[i]));
|
|
4602
4018
|
}
|
|
4603
|
-
|
|
4604
4019
|
restoreSelectionState(selectionState);
|
|
4605
4020
|
var elementInnerText = '';
|
|
4606
4021
|
var maxReqLineBreakCount = 0;
|
|
4607
|
-
|
|
4608
4022
|
for (var _i = 0, _n = results.length; _i < _n; _i++) {
|
|
4609
4023
|
var item = results[_i];
|
|
4610
|
-
|
|
4611
4024
|
if (typeof item === 'string') {
|
|
4612
4025
|
if (maxReqLineBreakCount > 0) {
|
|
4613
4026
|
for (var j = 0; j < maxReqLineBreakCount; j++) {
|
|
4614
4027
|
elementInnerText += "\n";
|
|
4615
4028
|
}
|
|
4616
|
-
|
|
4617
4029
|
maxReqLineBreakCount = 0;
|
|
4618
4030
|
}
|
|
4619
|
-
|
|
4620
4031
|
if (item.length > 0) {
|
|
4621
4032
|
elementInnerText += item;
|
|
4622
4033
|
}
|
|
@@ -4624,30 +4035,26 @@
|
|
|
4624
4035
|
if (elementInnerText.length == 0) {
|
|
4625
4036
|
// Remove required line break count at the start.
|
|
4626
4037
|
continue;
|
|
4627
|
-
}
|
|
4038
|
+
}
|
|
4039
|
+
// Store the count if it's the max of this run,
|
|
4628
4040
|
// but it may be ignored if no text item is found afterwards,
|
|
4629
4041
|
// which means that these are consecutive line breaks at the end.
|
|
4630
|
-
|
|
4631
|
-
|
|
4632
4042
|
if (item > maxReqLineBreakCount) {
|
|
4633
4043
|
maxReqLineBreakCount = item;
|
|
4634
4044
|
}
|
|
4635
4045
|
}
|
|
4636
4046
|
}
|
|
4637
|
-
|
|
4638
4047
|
return elementInnerText;
|
|
4639
4048
|
}
|
|
4049
|
+
|
|
4640
4050
|
/*
|
|
4641
4051
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
4642
4052
|
* All rights reserved.
|
|
4643
4053
|
* SPDX-License-Identifier: MIT
|
|
4644
4054
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
4645
4055
|
*/
|
|
4646
|
-
|
|
4647
|
-
|
|
4648
4056
|
var FocusableSelector = "\n [contenteditable],\n [tabindex],\n a[href],\n area[href],\n audio[controls],\n button,\n iframe,\n input,\n select,\n textarea,\n video[controls]\n";
|
|
4649
4057
|
var formElementTagNames = new Set(['BUTTON', 'INPUT', 'SELECT', 'TEXTAREA']);
|
|
4650
|
-
|
|
4651
4058
|
function filterSequentiallyFocusableElements(elements) {
|
|
4652
4059
|
return elements.filter(function (element) {
|
|
4653
4060
|
if (hasAttribute.call(element, 'tabindex')) {
|
|
@@ -4656,97 +4063,78 @@
|
|
|
4656
4063
|
// than filtering out elements based on tabindex="-1".
|
|
4657
4064
|
return getAttribute.call(element, 'tabindex') === '0';
|
|
4658
4065
|
}
|
|
4659
|
-
|
|
4660
4066
|
if (formElementTagNames.has(tagNameGetter.call(element))) {
|
|
4661
4067
|
return !hasAttribute.call(element, 'disabled');
|
|
4662
4068
|
}
|
|
4663
|
-
|
|
4664
4069
|
return true;
|
|
4665
4070
|
});
|
|
4666
4071
|
}
|
|
4667
|
-
|
|
4668
|
-
|
|
4072
|
+
var DidAddMouseEventListeners = new WeakMap();
|
|
4073
|
+
// Due to browser differences, it is impossible to know what is focusable until
|
|
4669
4074
|
// we actually try to focus it. We need to refactor our focus delegation logic
|
|
4670
4075
|
// to verify whether or not the target was actually focused instead of trying
|
|
4671
4076
|
// to predict focusability like we do here.
|
|
4672
|
-
|
|
4673
4077
|
function isVisible(element) {
|
|
4674
4078
|
var _getBoundingClientRec = getBoundingClientRect.call(element),
|
|
4675
|
-
|
|
4676
|
-
|
|
4677
|
-
|
|
4678
|
-
|
|
4079
|
+
width = _getBoundingClientRec.width,
|
|
4080
|
+
height = _getBoundingClientRec.height;
|
|
4081
|
+
var noZeroSize = width > 0 || height > 0;
|
|
4082
|
+
// The area element can be 0x0 and focusable. Hardcoding this is not ideal
|
|
4679
4083
|
// but it will minimize changes in the current behavior.
|
|
4680
|
-
|
|
4681
4084
|
var isAreaElement = element.tagName === 'AREA';
|
|
4682
4085
|
return (noZeroSize || isAreaElement) && getComputedStyle(element).visibility !== 'hidden';
|
|
4683
|
-
}
|
|
4086
|
+
}
|
|
4087
|
+
// This function based on https://allyjs.io/data-tables/focusable.html
|
|
4684
4088
|
// It won't catch everything, but should be good enough
|
|
4685
4089
|
// There are a lot of edge cases here that we can't realistically handle
|
|
4686
4090
|
// Determines if a particular element is tabbable, as opposed to simply focusable
|
|
4687
|
-
|
|
4688
|
-
|
|
4689
4091
|
function isTabbable(element) {
|
|
4690
4092
|
if (isSyntheticShadowHost(element) && isDelegatingFocus(element)) {
|
|
4691
4093
|
return false;
|
|
4692
4094
|
}
|
|
4693
|
-
|
|
4694
4095
|
return matches.call(element, FocusableSelector) && isVisible(element);
|
|
4695
4096
|
}
|
|
4696
|
-
|
|
4697
4097
|
function hostElementFocus() {
|
|
4698
4098
|
var _rootNode = this.getRootNode();
|
|
4699
|
-
|
|
4700
4099
|
if (_rootNode === this) {
|
|
4701
4100
|
// We invoke the focus() method even if the host is disconnected in order to eliminate
|
|
4702
4101
|
// observable differences for component authors between synthetic and native.
|
|
4703
4102
|
var focusable = querySelector.call(this, FocusableSelector);
|
|
4704
|
-
|
|
4705
4103
|
if (!isNull(focusable)) {
|
|
4706
4104
|
// @ts-ignore type-mismatch
|
|
4707
4105
|
focusable.focus.apply(focusable, arguments);
|
|
4708
4106
|
}
|
|
4709
|
-
|
|
4710
4107
|
return;
|
|
4711
|
-
}
|
|
4712
|
-
|
|
4713
|
-
|
|
4108
|
+
}
|
|
4109
|
+
// If the root node is not the host element then it's either the document or a shadow root.
|
|
4714
4110
|
var rootNode = _rootNode;
|
|
4715
|
-
|
|
4716
4111
|
if (rootNode.activeElement === this) {
|
|
4717
4112
|
// The focused element should not change if the focus method is invoked
|
|
4718
4113
|
// on the shadow-including ancestor of the currently focused element.
|
|
4719
4114
|
return;
|
|
4720
4115
|
}
|
|
4721
|
-
|
|
4722
4116
|
var focusables = arrayFromCollection(querySelectorAll$1.call(this, FocusableSelector));
|
|
4723
4117
|
var didFocus = false;
|
|
4724
|
-
|
|
4725
4118
|
while (!didFocus && focusables.length !== 0) {
|
|
4726
|
-
var _focusable = focusables.shift();
|
|
4727
|
-
|
|
4728
|
-
|
|
4729
|
-
|
|
4730
|
-
|
|
4731
|
-
|
|
4119
|
+
var _focusable = focusables.shift();
|
|
4120
|
+
// @ts-ignore type-mismatch
|
|
4121
|
+
_focusable.focus.apply(_focusable, arguments);
|
|
4122
|
+
// Get the root node of the current focusable in case it was slotted.
|
|
4732
4123
|
var currentRootNode = _focusable.getRootNode();
|
|
4733
|
-
|
|
4734
4124
|
didFocus = currentRootNode.activeElement === _focusable;
|
|
4735
4125
|
}
|
|
4736
4126
|
}
|
|
4737
|
-
|
|
4738
4127
|
function getTabbableSegments(host) {
|
|
4739
4128
|
var doc = getOwnerDocument(host);
|
|
4740
4129
|
var all = filterSequentiallyFocusableElements(arrayFromCollection(querySelectorAll.call(doc, FocusableSelector)));
|
|
4741
4130
|
var inner = filterSequentiallyFocusableElements(arrayFromCollection(querySelectorAll$1.call(host, FocusableSelector)));
|
|
4742
|
-
|
|
4743
4131
|
var firstChild = inner[0];
|
|
4744
4132
|
var lastChild = inner[inner.length - 1];
|
|
4745
|
-
var hostIndex = ArrayIndexOf.call(all, host);
|
|
4133
|
+
var hostIndex = ArrayIndexOf.call(all, host);
|
|
4134
|
+
// Host element can show up in our "previous" section if its tabindex is 0
|
|
4746
4135
|
// We want to filter that out here
|
|
4747
|
-
|
|
4748
|
-
|
|
4749
|
-
|
|
4136
|
+
var firstChildIndex = hostIndex > -1 ? hostIndex : ArrayIndexOf.call(all, firstChild);
|
|
4137
|
+
// Account for an empty inner list
|
|
4750
4138
|
var lastChildIndex = inner.length === 0 ? firstChildIndex + 1 : ArrayIndexOf.call(all, lastChild) + 1;
|
|
4751
4139
|
var prev = ArraySlice.call(all, 0, firstChildIndex);
|
|
4752
4140
|
var next = ArraySlice.call(all, lastChildIndex);
|
|
@@ -4756,23 +4144,18 @@
|
|
|
4756
4144
|
next: next
|
|
4757
4145
|
};
|
|
4758
4146
|
}
|
|
4759
|
-
|
|
4760
4147
|
function getActiveElement(host) {
|
|
4761
4148
|
var doc = getOwnerDocument(host);
|
|
4762
4149
|
var activeElement = DocumentPrototypeActiveElement.call(doc);
|
|
4763
|
-
|
|
4764
4150
|
if (isNull(activeElement)) {
|
|
4765
4151
|
return activeElement;
|
|
4766
|
-
}
|
|
4767
|
-
|
|
4768
|
-
|
|
4152
|
+
}
|
|
4153
|
+
// activeElement must be child of the host and owned by it
|
|
4769
4154
|
return (compareDocumentPosition.call(host, activeElement) & DOCUMENT_POSITION_CONTAINED_BY) !== 0 ? activeElement : null;
|
|
4770
4155
|
}
|
|
4771
|
-
|
|
4772
4156
|
function relatedTargetPosition(host, relatedTarget) {
|
|
4773
4157
|
// assert: target must be child of host
|
|
4774
4158
|
var pos = compareDocumentPosition.call(host, relatedTarget);
|
|
4775
|
-
|
|
4776
4159
|
if (pos & DOCUMENT_POSITION_CONTAINED_BY) {
|
|
4777
4160
|
// focus remains inside the host
|
|
4778
4161
|
return 0;
|
|
@@ -4782,17 +4165,14 @@
|
|
|
4782
4165
|
} else if (pos & DOCUMENT_POSITION_FOLLOWING) {
|
|
4783
4166
|
// focus is coming from below
|
|
4784
4167
|
return 2;
|
|
4785
|
-
}
|
|
4786
|
-
|
|
4787
|
-
|
|
4168
|
+
}
|
|
4169
|
+
// we don't know what's going on.
|
|
4788
4170
|
return -1;
|
|
4789
4171
|
}
|
|
4790
|
-
|
|
4791
4172
|
function muteEvent(event) {
|
|
4792
4173
|
event.preventDefault();
|
|
4793
4174
|
event.stopPropagation();
|
|
4794
4175
|
}
|
|
4795
|
-
|
|
4796
4176
|
function muteFocusEventsDuringExecution(win, func) {
|
|
4797
4177
|
windowAddEventListener.call(win, 'focusin', muteEvent, true);
|
|
4798
4178
|
windowAddEventListener.call(win, 'focusout', muteEvent, true);
|
|
@@ -4800,11 +4180,9 @@
|
|
|
4800
4180
|
windowRemoveEventListener.call(win, 'focusin', muteEvent, true);
|
|
4801
4181
|
windowRemoveEventListener.call(win, 'focusout', muteEvent, true);
|
|
4802
4182
|
}
|
|
4803
|
-
|
|
4804
4183
|
function focusOnNextOrBlur(segment, target, relatedTarget) {
|
|
4805
4184
|
var win = getOwnerWindow(relatedTarget);
|
|
4806
4185
|
var next = getNextTabbable(segment, relatedTarget);
|
|
4807
|
-
|
|
4808
4186
|
if (isNull(next)) {
|
|
4809
4187
|
// nothing to focus on, blur to invalidate the operation
|
|
4810
4188
|
muteFocusEventsDuringExecution(win, function () {
|
|
@@ -4816,38 +4194,30 @@
|
|
|
4816
4194
|
});
|
|
4817
4195
|
}
|
|
4818
4196
|
}
|
|
4819
|
-
|
|
4820
4197
|
var letBrowserHandleFocus = false;
|
|
4821
|
-
|
|
4822
4198
|
function disableKeyboardFocusNavigationRoutines() {
|
|
4823
4199
|
letBrowserHandleFocus = true;
|
|
4824
4200
|
}
|
|
4825
|
-
|
|
4826
4201
|
function enableKeyboardFocusNavigationRoutines() {
|
|
4827
4202
|
letBrowserHandleFocus = false;
|
|
4828
4203
|
}
|
|
4829
|
-
|
|
4830
4204
|
function isKeyboardFocusNavigationRoutineEnabled() {
|
|
4831
4205
|
return !letBrowserHandleFocus;
|
|
4832
4206
|
}
|
|
4833
|
-
|
|
4834
4207
|
function skipHostHandler(event) {
|
|
4835
4208
|
if (letBrowserHandleFocus) {
|
|
4836
4209
|
return;
|
|
4837
4210
|
}
|
|
4838
|
-
|
|
4839
4211
|
var host = eventCurrentTargetGetter.call(event);
|
|
4840
|
-
var target = eventTargetGetter.call(event);
|
|
4212
|
+
var target = eventTargetGetter.call(event);
|
|
4213
|
+
// If the host delegating focus with tabindex=0 is not the target, we know
|
|
4841
4214
|
// that the event was dispatched on a descendant node of the host. This
|
|
4842
4215
|
// means the focus is coming from below and we don't need to do anything.
|
|
4843
|
-
|
|
4844
4216
|
if (host !== target) {
|
|
4845
4217
|
// Focus is coming from above
|
|
4846
4218
|
return;
|
|
4847
4219
|
}
|
|
4848
|
-
|
|
4849
4220
|
var relatedTarget = focusEventRelatedTargetGetter.call(event);
|
|
4850
|
-
|
|
4851
4221
|
if (isNull(relatedTarget)) {
|
|
4852
4222
|
// If relatedTarget is null, the user is most likely tabbing into the document from the
|
|
4853
4223
|
// browser chrome. We could probably deduce whether focus is coming in from the top or the
|
|
@@ -4856,15 +4226,12 @@
|
|
|
4856
4226
|
// document.
|
|
4857
4227
|
return;
|
|
4858
4228
|
}
|
|
4859
|
-
|
|
4860
4229
|
var segments = getTabbableSegments(host);
|
|
4861
4230
|
var position = relatedTargetPosition(host, relatedTarget);
|
|
4862
|
-
|
|
4863
4231
|
if (position === 1) {
|
|
4864
4232
|
// Focus is coming from above
|
|
4865
4233
|
var findTabbableElms = isTabbableFrom.bind(null, host.getRootNode());
|
|
4866
4234
|
var first = ArrayFind.call(segments.inner, findTabbableElms);
|
|
4867
|
-
|
|
4868
4235
|
if (!isUndefined(first)) {
|
|
4869
4236
|
var win = getOwnerWindow(first);
|
|
4870
4237
|
muteFocusEventsDuringExecution(win, function () {
|
|
@@ -4878,14 +4245,11 @@
|
|
|
4878
4245
|
focusOnNextOrBlur(ArrayReverse.call(segments.prev), target, relatedTarget);
|
|
4879
4246
|
}
|
|
4880
4247
|
}
|
|
4881
|
-
|
|
4882
4248
|
function skipShadowHandler(event) {
|
|
4883
4249
|
if (letBrowserHandleFocus) {
|
|
4884
4250
|
return;
|
|
4885
4251
|
}
|
|
4886
|
-
|
|
4887
4252
|
var relatedTarget = focusEventRelatedTargetGetter.call(event);
|
|
4888
|
-
|
|
4889
4253
|
if (isNull(relatedTarget)) {
|
|
4890
4254
|
// If relatedTarget is null, the user is most likely tabbing into the document from the
|
|
4891
4255
|
// browser chrome. We could probably deduce whether focus is coming in from the top or the
|
|
@@ -4894,87 +4258,67 @@
|
|
|
4894
4258
|
// document.
|
|
4895
4259
|
return;
|
|
4896
4260
|
}
|
|
4897
|
-
|
|
4898
4261
|
var host = eventCurrentTargetGetter.call(event);
|
|
4899
4262
|
var segments = getTabbableSegments(host);
|
|
4900
|
-
|
|
4901
4263
|
if (ArrayIndexOf.call(segments.inner, relatedTarget) !== -1) {
|
|
4902
4264
|
// If relatedTarget is contained by the host's subtree we can assume that the user is
|
|
4903
4265
|
// tabbing between elements inside of the shadow. Do nothing.
|
|
4904
4266
|
return;
|
|
4905
4267
|
}
|
|
4906
|
-
|
|
4907
|
-
|
|
4908
|
-
|
|
4268
|
+
var target = eventTargetGetter.call(event);
|
|
4269
|
+
// Determine where the focus is coming from (Tab or Shift+Tab)
|
|
4909
4270
|
var position = relatedTargetPosition(host, relatedTarget);
|
|
4910
|
-
|
|
4911
4271
|
if (position === 1) {
|
|
4912
4272
|
// Focus is coming from above
|
|
4913
4273
|
focusOnNextOrBlur(segments.next, target, relatedTarget);
|
|
4914
4274
|
}
|
|
4915
|
-
|
|
4916
4275
|
if (position === 2) {
|
|
4917
4276
|
// Focus is coming from below
|
|
4918
4277
|
focusOnNextOrBlur(ArrayReverse.call(segments.prev), target, relatedTarget);
|
|
4919
4278
|
}
|
|
4920
|
-
}
|
|
4279
|
+
}
|
|
4280
|
+
// Use this function to determine whether you can start from one root and end up
|
|
4921
4281
|
// at another element via tabbing.
|
|
4922
|
-
|
|
4923
|
-
|
|
4924
4282
|
function isTabbableFrom(fromRoot, toElm) {
|
|
4925
4283
|
if (!isTabbable(toElm)) {
|
|
4926
4284
|
return false;
|
|
4927
4285
|
}
|
|
4928
|
-
|
|
4929
4286
|
var ownerDocument = getOwnerDocument(toElm);
|
|
4930
4287
|
var root = toElm.getRootNode();
|
|
4931
|
-
|
|
4932
4288
|
while (root !== ownerDocument && root !== fromRoot) {
|
|
4933
4289
|
var sr = root;
|
|
4934
4290
|
var host = sr.host;
|
|
4935
|
-
|
|
4936
4291
|
if (getAttribute.call(host, 'tabindex') === '-1') {
|
|
4937
4292
|
return false;
|
|
4938
4293
|
}
|
|
4939
|
-
|
|
4940
4294
|
root = host && host.getRootNode();
|
|
4941
4295
|
}
|
|
4942
|
-
|
|
4943
4296
|
return true;
|
|
4944
4297
|
}
|
|
4945
|
-
|
|
4946
4298
|
function getNextTabbable(tabbables, relatedTarget) {
|
|
4947
4299
|
var len = tabbables.length;
|
|
4948
|
-
|
|
4949
4300
|
if (len > 0) {
|
|
4950
4301
|
for (var i = 0; i < len; i += 1) {
|
|
4951
4302
|
var next = tabbables[i];
|
|
4952
|
-
|
|
4953
4303
|
if (isTabbableFrom(relatedTarget.getRootNode(), next)) {
|
|
4954
4304
|
return next;
|
|
4955
4305
|
}
|
|
4956
4306
|
}
|
|
4957
4307
|
}
|
|
4958
|
-
|
|
4959
4308
|
return null;
|
|
4960
|
-
}
|
|
4961
|
-
|
|
4962
|
-
|
|
4309
|
+
}
|
|
4310
|
+
// Skips the host element
|
|
4963
4311
|
function handleFocus(elm) {
|
|
4964
|
-
|
|
4965
|
-
|
|
4966
|
-
|
|
4312
|
+
bindDocumentMousedownMouseupHandlers(elm);
|
|
4313
|
+
// Unbind any focusin listeners we may have going on
|
|
4967
4314
|
ignoreFocusIn(elm);
|
|
4968
4315
|
addEventListener.call(elm, 'focusin', skipHostHandler, true);
|
|
4969
4316
|
}
|
|
4970
|
-
|
|
4971
4317
|
function ignoreFocus(elm) {
|
|
4972
4318
|
removeEventListener.call(elm, 'focusin', skipHostHandler, true);
|
|
4973
4319
|
}
|
|
4974
|
-
|
|
4975
4320
|
function bindDocumentMousedownMouseupHandlers(elm) {
|
|
4976
4321
|
var ownerDocument = getOwnerDocument(elm);
|
|
4977
|
-
|
|
4978
4322
|
if (!DidAddMouseEventListeners.get(ownerDocument)) {
|
|
4979
4323
|
DidAddMouseEventListeners.set(ownerDocument, true);
|
|
4980
4324
|
addEventListener.call(ownerDocument, 'mousedown', disableKeyboardFocusNavigationRoutines, true);
|
|
@@ -4991,63 +4335,55 @@
|
|
|
4991
4335
|
// mouseup | FOCUSIN
|
|
4992
4336
|
// mouseup-setTimeout | mouseup-setTimeout
|
|
4993
4337
|
setTimeout(enableKeyboardFocusNavigationRoutines);
|
|
4994
|
-
}, true);
|
|
4338
|
+
}, true);
|
|
4339
|
+
// [W-7824445] If the element is draggable, the mousedown event is dispatched before the
|
|
4995
4340
|
// element is starting to be dragged, which disable the keyboard focus navigation routine.
|
|
4996
4341
|
// But by specification, the mouseup event is never dispatched once the element is dropped.
|
|
4997
4342
|
//
|
|
4998
4343
|
// For all draggable element, we need to add an event listener to re-enable the keyboard
|
|
4999
4344
|
// navigation routine after dragging starts.
|
|
5000
|
-
|
|
5001
4345
|
addEventListener.call(ownerDocument, 'dragstart', enableKeyboardFocusNavigationRoutines, true);
|
|
5002
4346
|
}
|
|
5003
|
-
}
|
|
5004
|
-
|
|
5005
|
-
|
|
4347
|
+
}
|
|
4348
|
+
// Skips the shadow tree
|
|
5006
4349
|
function handleFocusIn(elm) {
|
|
5007
|
-
|
|
5008
|
-
|
|
5009
|
-
|
|
5010
|
-
|
|
4350
|
+
bindDocumentMousedownMouseupHandlers(elm);
|
|
4351
|
+
// Unbind any focus listeners we may have going on
|
|
4352
|
+
ignoreFocus(elm);
|
|
4353
|
+
// This focusin listener is to catch focusin events from keyboard interactions
|
|
5011
4354
|
// A better solution would perhaps be to listen for keydown events, but
|
|
5012
4355
|
// the keydown event happens on whatever element already has focus (or no element
|
|
5013
4356
|
// at all in the case of the location bar. So, instead we have to assume that focusin
|
|
5014
4357
|
// without a mousedown means keyboard navigation
|
|
5015
|
-
|
|
5016
4358
|
addEventListener.call(elm, 'focusin', skipShadowHandler, true);
|
|
5017
4359
|
}
|
|
5018
|
-
|
|
5019
4360
|
function ignoreFocusIn(elm) {
|
|
5020
4361
|
removeEventListener.call(elm, 'focusin', skipShadowHandler, true);
|
|
5021
4362
|
}
|
|
4363
|
+
|
|
5022
4364
|
/*
|
|
5023
4365
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
5024
4366
|
* All rights reserved.
|
|
5025
4367
|
* SPDX-License-Identifier: MIT
|
|
5026
4368
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
5027
4369
|
*/
|
|
5028
|
-
|
|
5029
|
-
|
|
5030
4370
|
var _HTMLElement$prototyp = HTMLElement.prototype,
|
|
5031
|
-
|
|
5032
|
-
|
|
4371
|
+
blur = _HTMLElement$prototyp.blur,
|
|
4372
|
+
focus = _HTMLElement$prototyp.focus;
|
|
5033
4373
|
/**
|
|
5034
4374
|
* This method only applies to elements with a shadow attached to them
|
|
5035
4375
|
*/
|
|
5036
|
-
|
|
5037
4376
|
function tabIndexGetterPatched() {
|
|
5038
4377
|
if (isDelegatingFocus(this) && isFalse(hasAttribute.call(this, 'tabindex'))) {
|
|
5039
4378
|
// this covers the case where the default tabindex should be 0 because the
|
|
5040
4379
|
// custom element is delegating its focus
|
|
5041
4380
|
return 0;
|
|
5042
4381
|
}
|
|
5043
|
-
|
|
5044
4382
|
return tabIndexGetter.call(this);
|
|
5045
4383
|
}
|
|
5046
4384
|
/**
|
|
5047
4385
|
* This method only applies to elements with a shadow attached to them
|
|
5048
4386
|
*/
|
|
5049
|
-
|
|
5050
|
-
|
|
5051
4387
|
function tabIndexSetterPatched(value) {
|
|
5052
4388
|
// This tabIndex setter might be confusing unless it is understood that HTML
|
|
5053
4389
|
// elements have default tabIndex property values. Natively focusable elements have
|
|
@@ -5055,53 +4391,48 @@
|
|
|
5055
4391
|
// value of -1. For example, the tabIndex property value is -1 for both <x-foo> and
|
|
5056
4392
|
// <x-foo tabindex="-1">, but our delegatesFocus polyfill should only kick in for
|
|
5057
4393
|
// the latter case when the value of the tabindex attribute is -1.
|
|
5058
|
-
var delegatesFocus = isDelegatingFocus(this);
|
|
5059
|
-
|
|
4394
|
+
var delegatesFocus = isDelegatingFocus(this);
|
|
4395
|
+
// Record the state of things before invoking component setter.
|
|
5060
4396
|
var prevValue = tabIndexGetter.call(this);
|
|
5061
4397
|
var prevHasAttr = hasAttribute.call(this, 'tabindex');
|
|
5062
|
-
tabIndexSetter.call(this, value);
|
|
5063
|
-
|
|
4398
|
+
tabIndexSetter.call(this, value);
|
|
4399
|
+
// Record the state of things after invoking component setter.
|
|
5064
4400
|
var currValue = tabIndexGetter.call(this);
|
|
5065
4401
|
var currHasAttr = hasAttribute.call(this, 'tabindex');
|
|
5066
|
-
var didValueChange = prevValue !== currValue;
|
|
4402
|
+
var didValueChange = prevValue !== currValue;
|
|
4403
|
+
// If the tabindex attribute is initially rendered, we can assume that this setter has
|
|
5067
4404
|
// previously executed and a listener has been added. We must remove that listener if
|
|
5068
4405
|
// the tabIndex property value has changed or if the component no longer renders a
|
|
5069
4406
|
// tabindex attribute.
|
|
5070
|
-
|
|
5071
4407
|
if (prevHasAttr && (didValueChange || isFalse(currHasAttr))) {
|
|
5072
4408
|
if (prevValue === -1) {
|
|
5073
4409
|
ignoreFocusIn(this);
|
|
5074
4410
|
}
|
|
5075
|
-
|
|
5076
4411
|
if (prevValue === 0 && delegatesFocus) {
|
|
5077
4412
|
ignoreFocus(this);
|
|
5078
4413
|
}
|
|
5079
|
-
}
|
|
4414
|
+
}
|
|
4415
|
+
// If a tabindex attribute was not rendered after invoking its setter, it means the
|
|
5080
4416
|
// component is taking control. Do nothing.
|
|
5081
|
-
|
|
5082
|
-
|
|
5083
4417
|
if (isFalse(currHasAttr)) {
|
|
5084
4418
|
return;
|
|
5085
|
-
}
|
|
4419
|
+
}
|
|
4420
|
+
// If the tabindex attribute is initially rendered, we can assume that this setter has
|
|
5086
4421
|
// previously executed and a listener has been added. If the tabindex attribute is still
|
|
5087
4422
|
// rendered after invoking the setter AND the tabIndex property value has not changed,
|
|
5088
4423
|
// we don't need to do any work.
|
|
5089
|
-
|
|
5090
|
-
|
|
5091
4424
|
if (prevHasAttr && currHasAttr && isFalse(didValueChange)) {
|
|
5092
4425
|
return;
|
|
5093
|
-
}
|
|
4426
|
+
}
|
|
4427
|
+
// At this point we know that a tabindex attribute was rendered after invoking the
|
|
5094
4428
|
// setter and that either:
|
|
5095
4429
|
// 1) This is the first time this setter is being invoked.
|
|
5096
4430
|
// 2) This is not the first time this setter is being invoked and the value is changing.
|
|
5097
4431
|
// We need to add the appropriate listeners in either case.
|
|
5098
|
-
|
|
5099
|
-
|
|
5100
4432
|
if (currValue === -1) {
|
|
5101
4433
|
// Add the magic to skip the shadow tree
|
|
5102
4434
|
handleFocusIn(this);
|
|
5103
4435
|
}
|
|
5104
|
-
|
|
5105
4436
|
if (currValue === 0 && delegatesFocus) {
|
|
5106
4437
|
// Add the magic to skip the host element
|
|
5107
4438
|
handleFocus(this);
|
|
@@ -5110,60 +4441,50 @@
|
|
|
5110
4441
|
/**
|
|
5111
4442
|
* This method only applies to elements with a shadow attached to them
|
|
5112
4443
|
*/
|
|
5113
|
-
|
|
5114
|
-
|
|
5115
4444
|
function blurPatched() {
|
|
5116
4445
|
if (isDelegatingFocus(this)) {
|
|
5117
4446
|
var currentActiveElement = getActiveElement(this);
|
|
5118
|
-
|
|
5119
4447
|
if (!isNull(currentActiveElement)) {
|
|
5120
4448
|
// if there is an active element, blur it (intentionally using the dot notation in case the user defines the blur routine)
|
|
5121
4449
|
currentActiveElement.blur();
|
|
5122
4450
|
return;
|
|
5123
4451
|
}
|
|
5124
4452
|
}
|
|
5125
|
-
|
|
5126
4453
|
return blur.call(this);
|
|
5127
4454
|
}
|
|
5128
|
-
|
|
5129
4455
|
function focusPatched() {
|
|
5130
4456
|
// Save enabled state
|
|
5131
|
-
var originallyEnabled = isKeyboardFocusNavigationRoutineEnabled();
|
|
5132
|
-
|
|
4457
|
+
var originallyEnabled = isKeyboardFocusNavigationRoutineEnabled();
|
|
4458
|
+
// Change state by disabling if originally enabled
|
|
5133
4459
|
if (originallyEnabled) {
|
|
5134
4460
|
disableKeyboardFocusNavigationRoutines();
|
|
5135
4461
|
}
|
|
5136
|
-
|
|
5137
4462
|
if (isSyntheticShadowHost(this) && isDelegatingFocus(this)) {
|
|
5138
4463
|
hostElementFocus.call(this);
|
|
5139
4464
|
return;
|
|
5140
|
-
}
|
|
4465
|
+
}
|
|
4466
|
+
// Typescript does not like it when you treat the `arguments` object as an array
|
|
5141
4467
|
// @ts-ignore type-mismatch
|
|
5142
|
-
|
|
5143
|
-
|
|
5144
|
-
focus.apply(this, arguments); // Restore state by enabling if originally enabled
|
|
5145
|
-
|
|
4468
|
+
focus.apply(this, arguments);
|
|
4469
|
+
// Restore state by enabling if originally enabled
|
|
5146
4470
|
if (originallyEnabled) {
|
|
5147
4471
|
enableKeyboardFocusNavigationRoutines();
|
|
5148
4472
|
}
|
|
5149
|
-
}
|
|
4473
|
+
}
|
|
4474
|
+
// Non-deep-traversing patches: this descriptor map includes all descriptors that
|
|
5150
4475
|
// do not five access to nodes beyond the immediate children.
|
|
5151
|
-
|
|
5152
|
-
|
|
5153
4476
|
defineProperties(HTMLElement.prototype, {
|
|
5154
4477
|
tabIndex: {
|
|
5155
4478
|
get: function get() {
|
|
5156
4479
|
if (isSyntheticShadowHost(this)) {
|
|
5157
4480
|
return tabIndexGetterPatched.call(this);
|
|
5158
4481
|
}
|
|
5159
|
-
|
|
5160
4482
|
return tabIndexGetter.call(this);
|
|
5161
4483
|
},
|
|
5162
4484
|
set: function set(v) {
|
|
5163
4485
|
if (isSyntheticShadowHost(this)) {
|
|
5164
4486
|
return tabIndexSetterPatched.call(this, v);
|
|
5165
4487
|
}
|
|
5166
|
-
|
|
5167
4488
|
return tabIndexSetter.call(this, v);
|
|
5168
4489
|
},
|
|
5169
4490
|
enumerable: true,
|
|
@@ -5174,7 +4495,6 @@
|
|
|
5174
4495
|
if (isSyntheticShadowHost(this)) {
|
|
5175
4496
|
return blurPatched.call(this);
|
|
5176
4497
|
}
|
|
5177
|
-
|
|
5178
4498
|
blur.call(this);
|
|
5179
4499
|
},
|
|
5180
4500
|
enumerable: true,
|
|
@@ -5191,28 +4511,24 @@
|
|
|
5191
4511
|
writable: true,
|
|
5192
4512
|
configurable: true
|
|
5193
4513
|
}
|
|
5194
|
-
});
|
|
5195
|
-
|
|
4514
|
+
});
|
|
4515
|
+
// Note: In JSDOM innerText is not implemented: https://github.com/jsdom/jsdom/issues/1245
|
|
5196
4516
|
if (innerTextGetter !== null && innerTextSetter !== null) {
|
|
5197
4517
|
defineProperty(HTMLElement.prototype, 'innerText', {
|
|
5198
4518
|
get: function get() {
|
|
5199
4519
|
if (!lwcRuntimeFlags.ENABLE_INNER_OUTER_TEXT_PATCH) {
|
|
5200
4520
|
return innerTextGetter.call(this);
|
|
5201
4521
|
}
|
|
5202
|
-
|
|
5203
4522
|
if (!lwcRuntimeFlags.ENABLE_ELEMENT_PATCH) {
|
|
5204
4523
|
if (isNodeShadowed(this) || isSyntheticShadowHost(this)) {
|
|
5205
4524
|
return getInnerText(this);
|
|
5206
4525
|
}
|
|
5207
|
-
|
|
5208
4526
|
return innerTextGetter.call(this);
|
|
5209
|
-
}
|
|
5210
|
-
|
|
5211
|
-
|
|
4527
|
+
}
|
|
4528
|
+
// TODO [#1222]: remove global bypass
|
|
5212
4529
|
if (isGlobalPatchingSkipped(this)) {
|
|
5213
4530
|
return innerTextGetter.call(this);
|
|
5214
4531
|
}
|
|
5215
|
-
|
|
5216
4532
|
return getInnerText(this);
|
|
5217
4533
|
},
|
|
5218
4534
|
set: function set(v) {
|
|
@@ -5221,9 +4537,8 @@
|
|
|
5221
4537
|
enumerable: true,
|
|
5222
4538
|
configurable: true
|
|
5223
4539
|
});
|
|
5224
|
-
}
|
|
5225
|
-
|
|
5226
|
-
|
|
4540
|
+
}
|
|
4541
|
+
// Note: Firefox does not have outerText, https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/outerText
|
|
5227
4542
|
if (outerTextGetter !== null && outerTextSetter !== null) {
|
|
5228
4543
|
// From https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/outerText :
|
|
5229
4544
|
// HTMLElement.outerText is a non-standard property. As a getter, it returns the same value as Node.innerText.
|
|
@@ -5233,20 +4548,16 @@
|
|
|
5233
4548
|
if (!lwcRuntimeFlags.ENABLE_INNER_OUTER_TEXT_PATCH) {
|
|
5234
4549
|
return outerTextGetter.call(this);
|
|
5235
4550
|
}
|
|
5236
|
-
|
|
5237
4551
|
if (!lwcRuntimeFlags.ENABLE_ELEMENT_PATCH) {
|
|
5238
4552
|
if (isNodeShadowed(this) || isSyntheticShadowHost(this)) {
|
|
5239
4553
|
return getInnerText(this);
|
|
5240
4554
|
}
|
|
5241
|
-
|
|
5242
4555
|
return outerTextGetter.call(this);
|
|
5243
|
-
}
|
|
5244
|
-
|
|
5245
|
-
|
|
4556
|
+
}
|
|
4557
|
+
// TODO [#1222]: remove global bypass
|
|
5246
4558
|
if (isGlobalPatchingSkipped(this)) {
|
|
5247
4559
|
return outerTextGetter.call(this);
|
|
5248
4560
|
}
|
|
5249
|
-
|
|
5250
4561
|
return getInnerText(this);
|
|
5251
4562
|
},
|
|
5252
4563
|
set: function set(v) {
|
|
@@ -5259,18 +4570,16 @@
|
|
|
5259
4570
|
configurable: true
|
|
5260
4571
|
});
|
|
5261
4572
|
}
|
|
4573
|
+
|
|
5262
4574
|
/*
|
|
5263
4575
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
5264
4576
|
* All rights reserved.
|
|
5265
4577
|
* SPDX-License-Identifier: MIT
|
|
5266
4578
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
5267
4579
|
*/
|
|
5268
|
-
|
|
5269
|
-
|
|
5270
4580
|
function getShadowToken(node) {
|
|
5271
4581
|
return node[KEY__SHADOW_TOKEN];
|
|
5272
4582
|
}
|
|
5273
|
-
|
|
5274
4583
|
function setShadowToken(node, shadowToken) {
|
|
5275
4584
|
node[KEY__SHADOW_TOKEN] = shadowToken;
|
|
5276
4585
|
}
|
|
@@ -5283,20 +4592,15 @@
|
|
|
5283
4592
|
* - this custom attribute must be unique.
|
|
5284
4593
|
*
|
|
5285
4594
|
**/
|
|
5286
|
-
|
|
5287
|
-
|
|
5288
4595
|
defineProperty(Element.prototype, KEY__SHADOW_TOKEN, {
|
|
5289
4596
|
set: function set(shadowToken) {
|
|
5290
4597
|
var oldShadowToken = this[KEY__SHADOW_TOKEN_PRIVATE];
|
|
5291
|
-
|
|
5292
4598
|
if (!isUndefined(oldShadowToken) && oldShadowToken !== shadowToken) {
|
|
5293
4599
|
removeAttribute.call(this, oldShadowToken);
|
|
5294
4600
|
}
|
|
5295
|
-
|
|
5296
4601
|
if (!isUndefined(shadowToken)) {
|
|
5297
4602
|
setAttribute.call(this, shadowToken, '');
|
|
5298
4603
|
}
|
|
5299
|
-
|
|
5300
4604
|
this[KEY__SHADOW_TOKEN_PRIVATE] = shadowToken;
|
|
5301
4605
|
},
|
|
5302
4606
|
get: function get() {
|
|
@@ -5304,16 +4608,13 @@
|
|
|
5304
4608
|
},
|
|
5305
4609
|
configurable: true
|
|
5306
4610
|
});
|
|
5307
|
-
|
|
5308
4611
|
function recursivelySetShadowResolver(node, fn) {
|
|
5309
4612
|
node[KEY__SHADOW_RESOLVER] = fn;
|
|
5310
4613
|
var childNodes = childNodesGetter.call(node);
|
|
5311
|
-
|
|
5312
4614
|
for (var i = 0, n = childNodes.length; i < n; i++) {
|
|
5313
4615
|
recursivelySetShadowResolver(childNodes[i], fn);
|
|
5314
4616
|
}
|
|
5315
4617
|
}
|
|
5316
|
-
|
|
5317
4618
|
defineProperty(Element.prototype, KEY__SHADOW_STATIC, {
|
|
5318
4619
|
set: function set(v) {
|
|
5319
4620
|
// Marking an element as static will propagate the shadow resolver to the children.
|
|
@@ -5321,7 +4622,6 @@
|
|
|
5321
4622
|
var fn = this[KEY__SHADOW_RESOLVER];
|
|
5322
4623
|
recursivelySetShadowResolver(this, fn);
|
|
5323
4624
|
}
|
|
5324
|
-
|
|
5325
4625
|
this[KEY__SHADOW_STATIC_PRIVATE] = v;
|
|
5326
4626
|
},
|
|
5327
4627
|
get: function get() {
|
|
@@ -5329,57 +4629,48 @@
|
|
|
5329
4629
|
},
|
|
5330
4630
|
configurable: true
|
|
5331
4631
|
});
|
|
4632
|
+
|
|
5332
4633
|
/*
|
|
5333
4634
|
* Copyright (c) 2018, salesforce.com, inc.
|
|
5334
4635
|
* All rights reserved.
|
|
5335
4636
|
* SPDX-License-Identifier: MIT
|
|
5336
4637
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
5337
4638
|
*/
|
|
5338
|
-
|
|
5339
|
-
|
|
5340
|
-
|
|
5341
|
-
|
|
4639
|
+
var DomManualPrivateKey = '$$DomManualKey$$';
|
|
4640
|
+
// Resolver function used when a node is removed from within a portal
|
|
4641
|
+
var DocumentResolverFn = function DocumentResolverFn() {};
|
|
4642
|
+
// We can use a single observer without having to worry about leaking because
|
|
5342
4643
|
// "Registered observers in a node’s registered observer list have a weak
|
|
5343
4644
|
// reference to the node."
|
|
5344
4645
|
// https://dom.spec.whatwg.org/#garbage-collection
|
|
5345
|
-
|
|
5346
|
-
|
|
5347
4646
|
var portalObserver;
|
|
5348
4647
|
var portalObserverConfig = {
|
|
5349
4648
|
childList: true
|
|
5350
4649
|
};
|
|
5351
|
-
|
|
5352
4650
|
function adoptChildNode(node, fn, shadowToken) {
|
|
5353
4651
|
var previousNodeShadowResolver = getShadowRootResolver(node);
|
|
5354
|
-
|
|
5355
4652
|
if (previousNodeShadowResolver === fn) {
|
|
5356
4653
|
return; // nothing to do here, it is already correctly patched
|
|
5357
4654
|
}
|
|
5358
4655
|
|
|
5359
4656
|
setShadowRootResolver(node, fn);
|
|
5360
|
-
|
|
5361
4657
|
if (node instanceof Element) {
|
|
5362
4658
|
setShadowToken(node, shadowToken);
|
|
5363
|
-
|
|
5364
4659
|
if (isSyntheticShadowHost(node)) {
|
|
5365
4660
|
// Root LWC elements can't get content slotted into them, therefore we don't observe their children.
|
|
5366
4661
|
return;
|
|
5367
4662
|
}
|
|
5368
|
-
|
|
5369
4663
|
if (isUndefined(previousNodeShadowResolver)) {
|
|
5370
4664
|
// we only care about Element without shadowResolver (no MO.observe has been called)
|
|
5371
4665
|
MutationObserverObserve.call(portalObserver, node, portalObserverConfig);
|
|
5372
|
-
}
|
|
5373
|
-
|
|
5374
|
-
|
|
4666
|
+
}
|
|
4667
|
+
// recursively patching all children as well
|
|
5375
4668
|
var childNodes = childNodesGetter.call(node);
|
|
5376
|
-
|
|
5377
4669
|
for (var i = 0, len = childNodes.length; i < len; i += 1) {
|
|
5378
4670
|
adoptChildNode(childNodes[i], fn, shadowToken);
|
|
5379
4671
|
}
|
|
5380
4672
|
}
|
|
5381
4673
|
}
|
|
5382
|
-
|
|
5383
4674
|
function initPortalObserver() {
|
|
5384
4675
|
return new MO(function (mutations) {
|
|
5385
4676
|
forEach.call(mutations, function (mutation) {
|
|
@@ -5394,23 +4685,20 @@
|
|
|
5394
4685
|
* (or not in the case of removal) by the element.
|
|
5395
4686
|
*/
|
|
5396
4687
|
var elm = mutation.target,
|
|
5397
|
-
|
|
5398
|
-
|
|
5399
|
-
|
|
4688
|
+
addedNodes = mutation.addedNodes,
|
|
4689
|
+
removedNodes = mutation.removedNodes;
|
|
4690
|
+
// the target of the mutation should always have a ShadowRootResolver attached to it
|
|
5400
4691
|
var fn = getShadowRootResolver(elm);
|
|
5401
|
-
var shadowToken = getShadowToken(elm);
|
|
5402
|
-
|
|
4692
|
+
var shadowToken = getShadowToken(elm);
|
|
4693
|
+
// Process removals first to handle the case where an element is removed and reinserted
|
|
5403
4694
|
for (var i = 0, len = removedNodes.length; i < len; i += 1) {
|
|
5404
4695
|
var node = removedNodes[i];
|
|
5405
|
-
|
|
5406
4696
|
if (!(compareDocumentPosition.call(elm, node) & _Node.DOCUMENT_POSITION_CONTAINED_BY)) {
|
|
5407
4697
|
adoptChildNode(node, DocumentResolverFn, undefined);
|
|
5408
4698
|
}
|
|
5409
4699
|
}
|
|
5410
|
-
|
|
5411
4700
|
for (var _i2 = 0, _len = addedNodes.length; _i2 < _len; _i2 += 1) {
|
|
5412
4701
|
var _node = addedNodes[_i2];
|
|
5413
|
-
|
|
5414
4702
|
if (compareDocumentPosition.call(elm, _node) & _Node.DOCUMENT_POSITION_CONTAINED_BY) {
|
|
5415
4703
|
adoptChildNode(_node, fn, shadowToken);
|
|
5416
4704
|
}
|
|
@@ -5418,19 +4706,17 @@
|
|
|
5418
4706
|
});
|
|
5419
4707
|
});
|
|
5420
4708
|
}
|
|
5421
|
-
|
|
5422
4709
|
function markElementAsPortal(elm) {
|
|
5423
4710
|
if (isUndefined(portalObserver)) {
|
|
5424
4711
|
portalObserver = initPortalObserver();
|
|
5425
4712
|
}
|
|
5426
|
-
|
|
5427
4713
|
if (isUndefined(getShadowRootResolver(elm))) {
|
|
5428
4714
|
// only an element from a within a shadowRoot should be used here
|
|
5429
4715
|
throw new Error("Invalid Element");
|
|
5430
|
-
}
|
|
5431
|
-
|
|
5432
|
-
|
|
5433
|
-
|
|
4716
|
+
}
|
|
4717
|
+
// install mutation observer for portals
|
|
4718
|
+
MutationObserverObserve.call(portalObserver, elm, portalObserverConfig);
|
|
4719
|
+
// TODO [#1253]: optimization to synchronously adopt new child nodes added
|
|
5434
4720
|
// to this elm, we can do that by patching the most common operations
|
|
5435
4721
|
// on the node itself
|
|
5436
4722
|
}
|
|
@@ -5449,12 +4735,9 @@
|
|
|
5449
4735
|
*
|
|
5450
4736
|
**/
|
|
5451
4737
|
// TODO [#1306]: rename this to $observerConnection$
|
|
5452
|
-
|
|
5453
|
-
|
|
5454
4738
|
defineProperty(Element.prototype, '$domManual$', {
|
|
5455
4739
|
set: function set(v) {
|
|
5456
4740
|
this[DomManualPrivateKey] = v;
|
|
5457
|
-
|
|
5458
4741
|
if (isTrue(v)) {
|
|
5459
4742
|
markElementAsPortal(this);
|
|
5460
4743
|
}
|
|
@@ -5464,6 +4747,6 @@
|
|
|
5464
4747
|
},
|
|
5465
4748
|
configurable: true
|
|
5466
4749
|
});
|
|
5467
|
-
/** version: 2.
|
|
4750
|
+
/** version: 2.30.0 */
|
|
5468
4751
|
|
|
5469
4752
|
}));
|