@blueking/bk-weweb 0.0.21 → 0.0.22
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/collect-source.js +10 -1
- package/dist/collect-source.js.map +1 -1
- package/dist/index.esm.js +10 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
package/dist/collect-source.js
CHANGED
|
@@ -191,6 +191,7 @@ const isJsonpUrl = (url) => {
|
|
|
191
191
|
*/
|
|
192
192
|
const { document: document$1 } = window;
|
|
193
193
|
const { createElement, getElementById, getElementsByClassName, getElementsByName, getElementsByTagName, querySelector, querySelectorAll, } = Document.prototype;
|
|
194
|
+
const { querySelector: bodyQuerySelector } = HTMLBodyElement.prototype;
|
|
194
195
|
const SPECIAL_ELEMENT_TAG = ['body', 'html', 'head'];
|
|
195
196
|
let hasRewrite$1 = false;
|
|
196
197
|
function rewriteDocumentPrototypeMethods() {
|
|
@@ -220,17 +221,23 @@ function rewriteDocumentPrototypeMethods() {
|
|
|
220
221
|
*/
|
|
221
222
|
function querySelectorNew(selectors) {
|
|
222
223
|
const app = getCurrentRunningApp();
|
|
224
|
+
if (selectors.includes('data-bk-mask-uid'))
|
|
225
|
+
debugger;
|
|
223
226
|
// 如果选择器是特殊元素标签
|
|
224
227
|
if (SPECIAL_ELEMENT_TAG.includes(selectors)) {
|
|
225
228
|
// 如果当前应用程序容器是 ShadowRoot 类型
|
|
226
229
|
if (app?.container instanceof ShadowRoot) {
|
|
227
230
|
return app?.container;
|
|
228
231
|
}
|
|
232
|
+
if (this instanceof HTMLBodyElement)
|
|
233
|
+
return bodyQuerySelector.call(this, selectors);
|
|
229
234
|
// 否则调用原始的 querySelector 方法
|
|
230
235
|
return querySelector.call(this, selectors);
|
|
231
236
|
}
|
|
232
237
|
// 如果没有当前应用程序或选择器为空或文档不是当前文档
|
|
233
|
-
if (!app || !selectors || document$1
|
|
238
|
+
if (!app || !selectors || ![document$1, document$1.body].includes(this)) {
|
|
239
|
+
if (this instanceof HTMLBodyElement)
|
|
240
|
+
return bodyQuerySelector.call(this, selectors);
|
|
234
241
|
// 调用原始的 querySelector 方法
|
|
235
242
|
return querySelector.call(this, selectors);
|
|
236
243
|
}
|
|
@@ -260,6 +267,7 @@ function rewriteDocumentPrototypeMethods() {
|
|
|
260
267
|
}
|
|
261
268
|
Document.prototype.querySelector = querySelectorNew;
|
|
262
269
|
Document.prototype.querySelectorAll = querySelectorAllNew;
|
|
270
|
+
HTMLBodyElement.prototype.querySelector = querySelectorNew;
|
|
263
271
|
Document.prototype.getElementById = function getElementByIdNew(key) {
|
|
264
272
|
return getCurrentRunningApp() ? querySelectorNew.call(this, `#${key}`) : getElementById.call(this, key);
|
|
265
273
|
};
|
|
@@ -281,6 +289,7 @@ function rewriteDocumentPrototypeMethods() {
|
|
|
281
289
|
function resetDocumentPrototypeMethods() {
|
|
282
290
|
Document.prototype.createElement = createElement;
|
|
283
291
|
Document.prototype.querySelector = querySelector;
|
|
292
|
+
HTMLBodyElement.prototype.querySelector = bodyQuerySelector;
|
|
284
293
|
Document.prototype.querySelectorAll = querySelectorAll;
|
|
285
294
|
Document.prototype.getElementById = getElementById;
|
|
286
295
|
Document.prototype.getElementsByClassName = getElementsByClassName;
|