@stencil/mock-doc 5.0.0-next.0 → 5.0.0-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +133 -0
- package/dist/index.d.mts +163 -52
- package/dist/index.mjs +1824 -1338
- package/package.json +22 -15
- /package/{LICENSE.md → LICENSE} +0 -0
package/dist/index.mjs
CHANGED
|
@@ -1,47 +1,50 @@
|
|
|
1
1
|
import { parse, parseFragment } from "parse5";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
2
|
+
//#region \0rolldown/runtime.js
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
12
|
+
key = keys[i];
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
14
|
+
get: ((k) => from[k]).bind(null, key),
|
|
15
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", {
|
|
21
|
+
value: mod,
|
|
22
|
+
enumerable: true
|
|
23
|
+
}) : target, mod));
|
|
10
24
|
const XML_NS = "http://www.w3.org/XML/1998/namespace";
|
|
11
25
|
const XMLNS_NS = "http://www.w3.org/2000/xmlns/";
|
|
12
26
|
/**
|
|
13
27
|
* Get the standard prefix for a namespace URI.
|
|
14
28
|
* Returns null if namespace has no standard prefix.
|
|
29
|
+
*
|
|
30
|
+
* @param namespaceURI - the namespace URI to look up
|
|
31
|
+
* @returns the standard prefix or null if not found
|
|
15
32
|
*/
|
|
16
33
|
function getPrefixForNamespace(namespaceURI) {
|
|
17
|
-
if (namespaceURI ===
|
|
34
|
+
if (namespaceURI === "http://www.w3.org/1999/xlink") return "xlink";
|
|
18
35
|
if (namespaceURI === XML_NS) return "xml";
|
|
19
36
|
if (namespaceURI === XMLNS_NS) return "xmlns";
|
|
20
37
|
return null;
|
|
21
38
|
}
|
|
22
39
|
let NODE_TYPES = /* @__PURE__ */ function(NODE_TYPES) {
|
|
23
40
|
NODE_TYPES[NODE_TYPES["ELEMENT_NODE"] = 1] = "ELEMENT_NODE";
|
|
24
|
-
NODE_TYPES[NODE_TYPES["ATTRIBUTE_NODE"] = 2] = "ATTRIBUTE_NODE";
|
|
25
41
|
NODE_TYPES[NODE_TYPES["TEXT_NODE"] = 3] = "TEXT_NODE";
|
|
26
|
-
NODE_TYPES[NODE_TYPES["CDATA_SECTION_NODE"] = 4] = "CDATA_SECTION_NODE";
|
|
27
|
-
NODE_TYPES[NODE_TYPES["ENTITY_REFERENCE_NODE"] = 5] = "ENTITY_REFERENCE_NODE";
|
|
28
|
-
NODE_TYPES[NODE_TYPES["ENTITY_NODE"] = 6] = "ENTITY_NODE";
|
|
29
|
-
NODE_TYPES[NODE_TYPES["PROCESSING_INSTRUCTION_NODE"] = 7] = "PROCESSING_INSTRUCTION_NODE";
|
|
30
42
|
NODE_TYPES[NODE_TYPES["COMMENT_NODE"] = 8] = "COMMENT_NODE";
|
|
31
43
|
NODE_TYPES[NODE_TYPES["DOCUMENT_NODE"] = 9] = "DOCUMENT_NODE";
|
|
32
44
|
NODE_TYPES[NODE_TYPES["DOCUMENT_TYPE_NODE"] = 10] = "DOCUMENT_TYPE_NODE";
|
|
33
45
|
NODE_TYPES[NODE_TYPES["DOCUMENT_FRAGMENT_NODE"] = 11] = "DOCUMENT_FRAGMENT_NODE";
|
|
34
|
-
NODE_TYPES[NODE_TYPES["NOTATION_NODE"] = 12] = "NOTATION_NODE";
|
|
35
46
|
return NODE_TYPES;
|
|
36
47
|
}({});
|
|
37
|
-
let NODE_NAMES = /* @__PURE__ */ function(NODE_NAMES) {
|
|
38
|
-
NODE_NAMES["COMMENT_NODE"] = "#comment";
|
|
39
|
-
NODE_NAMES["DOCUMENT_NODE"] = "#document";
|
|
40
|
-
NODE_NAMES["DOCUMENT_FRAGMENT_NODE"] = "#document-fragment";
|
|
41
|
-
NODE_NAMES["TEXT_NODE"] = "#text";
|
|
42
|
-
return NODE_NAMES;
|
|
43
|
-
}({});
|
|
44
|
-
|
|
45
48
|
//#endregion
|
|
46
49
|
//#region src/attribute.ts
|
|
47
50
|
const attrHandler = { get(obj, prop) {
|
|
@@ -50,6 +53,7 @@ const attrHandler = { get(obj, prop) {
|
|
|
50
53
|
} };
|
|
51
54
|
const createAttributeProxy = (caseInsensitive) => new Proxy(new MockAttributeMap(caseInsensitive), attrHandler);
|
|
52
55
|
var MockAttributeMap = class {
|
|
56
|
+
caseInsensitive;
|
|
53
57
|
__items = [];
|
|
54
58
|
constructor(caseInsensitive = false) {
|
|
55
59
|
this.caseInsensitive = caseInsensitive;
|
|
@@ -99,7 +103,7 @@ var MockAttributeMap = class {
|
|
|
99
103
|
}
|
|
100
104
|
};
|
|
101
105
|
function getNamespaceURI(namespaceURI) {
|
|
102
|
-
return namespaceURI ===
|
|
106
|
+
return namespaceURI === "http://www.w3.org/1999/xlink" ? null : namespaceURI;
|
|
103
107
|
}
|
|
104
108
|
function cloneAttributes(srcAttrs, sortByName = false) {
|
|
105
109
|
const dstAttrs = createAttributeProxy(srcAttrs.caseInsensitive);
|
|
@@ -198,7 +202,6 @@ var MockAttr = class {
|
|
|
198
202
|
this._namespaceURI = namespaceURI;
|
|
199
203
|
}
|
|
200
204
|
};
|
|
201
|
-
|
|
202
205
|
//#endregion
|
|
203
206
|
//#region src/css-style-declaration.ts
|
|
204
207
|
var MockCSSStyleDeclaration = class {
|
|
@@ -270,10 +273,10 @@ function jsCaseToCssCase(str) {
|
|
|
270
273
|
if (str.length > 1 && str.includes("-") === false && /[A-Z]/.test(str) === true) str = str.replace(/([A-Z])/g, (g) => " " + g[0]).trim().replace(/ /g, "-").toLowerCase();
|
|
271
274
|
return str;
|
|
272
275
|
}
|
|
273
|
-
|
|
274
276
|
//#endregion
|
|
275
277
|
//#region src/custom-element-registry.ts
|
|
276
278
|
var MockCustomElementRegistry = class {
|
|
279
|
+
win;
|
|
277
280
|
__registry;
|
|
278
281
|
__whenDefined;
|
|
279
282
|
constructor(win) {
|
|
@@ -319,9 +322,13 @@ var MockCustomElementRegistry = class {
|
|
|
319
322
|
}
|
|
320
323
|
}
|
|
321
324
|
getName(cstr) {
|
|
322
|
-
|
|
325
|
+
if (this.__registry != null) {
|
|
326
|
+
for (const [tagName, def] of this.__registry.entries()) if (def.cstr === cstr) return tagName;
|
|
327
|
+
}
|
|
328
|
+
return null;
|
|
323
329
|
}
|
|
324
330
|
upgrade(_rootNode) {}
|
|
331
|
+
initialize(_root) {}
|
|
325
332
|
clear() {
|
|
326
333
|
if (this.__registry != null) this.__registry.clear();
|
|
327
334
|
if (this.__whenDefined != null) this.__whenDefined.clear();
|
|
@@ -351,12 +358,12 @@ function createCustomElement(customElements, ownerDocument, tagName) {
|
|
|
351
358
|
const host = new Proxy({}, {
|
|
352
359
|
get(obj, prop) {
|
|
353
360
|
const elm = proxyElements.get(host);
|
|
354
|
-
if (elm != null) return elm
|
|
361
|
+
if (elm != null) return Reflect.get(elm, prop, host);
|
|
355
362
|
return obj[prop];
|
|
356
363
|
},
|
|
357
364
|
set(obj, prop, val) {
|
|
358
365
|
const elm = proxyElements.get(host);
|
|
359
|
-
if (elm != null) elm
|
|
366
|
+
if (elm != null) Reflect.set(elm, prop, val, host);
|
|
360
367
|
else obj[prop] = val;
|
|
361
368
|
return true;
|
|
362
369
|
},
|
|
@@ -364,6 +371,26 @@ function createCustomElement(customElements, ownerDocument, tagName) {
|
|
|
364
371
|
if (prop in proxyElements.get(host)) return true;
|
|
365
372
|
if (prop in obj) return true;
|
|
366
373
|
return false;
|
|
374
|
+
},
|
|
375
|
+
defineProperty(obj, prop, descriptor) {
|
|
376
|
+
const elm = proxyElements.get(host);
|
|
377
|
+
return Reflect.defineProperty(elm != null ? elm : obj, prop, descriptor);
|
|
378
|
+
},
|
|
379
|
+
deleteProperty(obj, prop) {
|
|
380
|
+
const elm = proxyElements.get(host);
|
|
381
|
+
return Reflect.deleteProperty(elm != null ? elm : obj, prop);
|
|
382
|
+
},
|
|
383
|
+
getOwnPropertyDescriptor(obj, prop) {
|
|
384
|
+
const elm = proxyElements.get(host);
|
|
385
|
+
return Reflect.getOwnPropertyDescriptor(elm != null ? elm : obj, prop);
|
|
386
|
+
},
|
|
387
|
+
ownKeys(obj) {
|
|
388
|
+
const elm = proxyElements.get(host);
|
|
389
|
+
return Reflect.ownKeys(elm != null ? elm : obj);
|
|
390
|
+
},
|
|
391
|
+
getPrototypeOf(obj) {
|
|
392
|
+
const elm = proxyElements.get(host);
|
|
393
|
+
return Reflect.getPrototypeOf(elm != null ? elm : obj);
|
|
367
394
|
}
|
|
368
395
|
});
|
|
369
396
|
const elm = new MockHTMLElement(ownerDocument, tagName);
|
|
@@ -374,7 +401,7 @@ const proxyElements = /* @__PURE__ */ new WeakMap();
|
|
|
374
401
|
const upgradedElements = /* @__PURE__ */ new WeakSet();
|
|
375
402
|
function connectNode(ownerDocument, node) {
|
|
376
403
|
node.ownerDocument = ownerDocument;
|
|
377
|
-
if (node.nodeType ===
|
|
404
|
+
if (node.nodeType === 1) {
|
|
378
405
|
if (ownerDocument != null && node.nodeName.includes("-")) {
|
|
379
406
|
if (ownerDocument.defaultView != null && typeof node.connectedCallback === "function" && node.isConnected) fireConnectedCallback(node);
|
|
380
407
|
const shadowRoot = node.shadowRoot;
|
|
@@ -399,7 +426,7 @@ function fireConnectedCallback(node) {
|
|
|
399
426
|
}
|
|
400
427
|
}
|
|
401
428
|
function disconnectNode(node) {
|
|
402
|
-
if (node.nodeType ===
|
|
429
|
+
if (node.nodeType === 1) {
|
|
403
430
|
if (node.nodeName.includes("-") === true && typeof node.disconnectedCallback === "function") {
|
|
404
431
|
if (tempDisableCallbacks.has(node.ownerDocument) === false) try {
|
|
405
432
|
node.disconnectedCallback();
|
|
@@ -423,7 +450,6 @@ function checkAttributeChanged(node) {
|
|
|
423
450
|
return node.nodeName.includes("-") === true && typeof node.attributeChangedCallback === "function";
|
|
424
451
|
}
|
|
425
452
|
const tempDisableCallbacks = /* @__PURE__ */ new Set();
|
|
426
|
-
|
|
427
453
|
//#endregion
|
|
428
454
|
//#region src/dataset.ts
|
|
429
455
|
function dataset(elm) {
|
|
@@ -456,7 +482,6 @@ function dashToPascalCase(str) {
|
|
|
456
482
|
return segment.charAt(0).toUpperCase() + segment.slice(1);
|
|
457
483
|
}).join("");
|
|
458
484
|
}
|
|
459
|
-
|
|
460
485
|
//#endregion
|
|
461
486
|
//#region src/event.ts
|
|
462
487
|
var MockEvent = class {
|
|
@@ -486,7 +511,8 @@ var MockEvent = class {
|
|
|
486
511
|
this.cancelBubble = true;
|
|
487
512
|
}
|
|
488
513
|
/**
|
|
489
|
-
*
|
|
514
|
+
* Get the composed path of event propagation.
|
|
515
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/Event/composedPath
|
|
490
516
|
* @returns a composed path of the event
|
|
491
517
|
*/
|
|
492
518
|
composedPath() {
|
|
@@ -494,7 +520,7 @@ var MockEvent = class {
|
|
|
494
520
|
let currentElement = this.target;
|
|
495
521
|
while (currentElement) {
|
|
496
522
|
composedPath.push(currentElement);
|
|
497
|
-
if (!currentElement.parentElement && currentElement.nodeName ===
|
|
523
|
+
if (!currentElement.parentElement && currentElement.nodeName === "#document") {
|
|
498
524
|
composedPath.push(currentElement.defaultView);
|
|
499
525
|
break;
|
|
500
526
|
}
|
|
@@ -565,34 +591,72 @@ var MockFocusEvent = class extends MockUIEvent {
|
|
|
565
591
|
var MockEventListener = class {
|
|
566
592
|
type;
|
|
567
593
|
handler;
|
|
568
|
-
|
|
594
|
+
capture;
|
|
595
|
+
once;
|
|
596
|
+
constructor(type, handler, options) {
|
|
569
597
|
this.type = type;
|
|
570
598
|
this.handler = handler;
|
|
599
|
+
if (typeof options === "boolean") {
|
|
600
|
+
this.capture = options;
|
|
601
|
+
this.once = false;
|
|
602
|
+
} else {
|
|
603
|
+
this.capture = options?.capture ?? false;
|
|
604
|
+
this.once = options?.once ?? false;
|
|
605
|
+
}
|
|
571
606
|
}
|
|
572
607
|
};
|
|
573
|
-
|
|
608
|
+
/**
|
|
609
|
+
* Add an event listener to an element.
|
|
610
|
+
*
|
|
611
|
+
* @param elm - the element to add the listener to
|
|
612
|
+
* @param type - the event type to listen for
|
|
613
|
+
* @param handler - the event handler function
|
|
614
|
+
* @param options - `capture` and `once` are supported; `passive` and `signal` are accepted but not implemented
|
|
615
|
+
*/
|
|
616
|
+
function addEventListener(elm, type, handler, options) {
|
|
574
617
|
const target = elm;
|
|
575
618
|
if (target.__listeners == null) target.__listeners = [];
|
|
576
|
-
target.__listeners.push(new MockEventListener(type, handler));
|
|
619
|
+
target.__listeners.push(new MockEventListener(type, handler, options));
|
|
577
620
|
}
|
|
578
|
-
|
|
621
|
+
/**
|
|
622
|
+
* Remove an event listener from an element.
|
|
623
|
+
*
|
|
624
|
+
* @param elm - the element to remove the listener from
|
|
625
|
+
* @param type - the event type to remove
|
|
626
|
+
* @param handler - the event handler function to remove
|
|
627
|
+
* @param options - only `capture` is relevant here, since listeners are keyed by type + handler + capture
|
|
628
|
+
*/
|
|
629
|
+
function removeEventListener(elm, type, handler, options) {
|
|
579
630
|
const target = elm;
|
|
631
|
+
const capture = typeof options === "boolean" ? options : options?.capture ?? false;
|
|
580
632
|
if (target != null && Array.isArray(target.__listeners) === true) {
|
|
581
|
-
const elmListener = target.__listeners.find((e) => e.type === type && e.handler === handler);
|
|
633
|
+
const elmListener = target.__listeners.find((e) => e.type === type && e.handler === handler && e.capture === capture);
|
|
582
634
|
if (elmListener != null) {
|
|
583
635
|
const index = target.__listeners.indexOf(elmListener);
|
|
584
636
|
target.__listeners.splice(index, 1);
|
|
585
637
|
}
|
|
586
638
|
}
|
|
587
639
|
}
|
|
640
|
+
/**
|
|
641
|
+
* Reset all event listeners on a target.
|
|
642
|
+
*
|
|
643
|
+
* @param target - the target to reset listeners on
|
|
644
|
+
*/
|
|
588
645
|
function resetEventListeners(target) {
|
|
589
646
|
if (target != null && target.__listeners != null) target.__listeners = null;
|
|
590
647
|
}
|
|
648
|
+
/**
|
|
649
|
+
* Trigger an event on an element and bubble through the DOM tree.
|
|
650
|
+
*
|
|
651
|
+
* @param elm - the element to trigger the event on
|
|
652
|
+
* @param ev - the mock event to trigger
|
|
653
|
+
*/
|
|
591
654
|
function triggerEventListener(elm, ev) {
|
|
592
655
|
if (elm == null || ev.cancelBubble === true) return;
|
|
593
656
|
const target = elm;
|
|
594
657
|
ev.currentTarget = elm;
|
|
595
658
|
if (Array.isArray(target.__listeners) === true) target.__listeners.filter((e) => e.type === ev.type).forEach((listener) => {
|
|
659
|
+
if (listener.once) removeEventListener(target, listener.type, listener.handler, { capture: listener.capture });
|
|
596
660
|
try {
|
|
597
661
|
listener.handler.call(target, ev);
|
|
598
662
|
} catch (err) {
|
|
@@ -600,22 +664,35 @@ function triggerEventListener(elm, ev) {
|
|
|
600
664
|
}
|
|
601
665
|
});
|
|
602
666
|
if (ev.bubbles === false) return;
|
|
603
|
-
if (elm.nodeName ===
|
|
667
|
+
if (elm.nodeName === "#document") triggerEventListener(elm.defaultView, ev);
|
|
604
668
|
else if (elm.parentElement == null && elm.tagName === "HTML") triggerEventListener(elm.ownerDocument, ev);
|
|
605
669
|
else triggerEventListener(getNextEventTarget(elm, ev), ev);
|
|
606
670
|
}
|
|
671
|
+
/**
|
|
672
|
+
* Get the next event target for event bubbling.
|
|
673
|
+
*
|
|
674
|
+
* @param elm - the current element
|
|
675
|
+
* @param ev - the mock event being bubbled
|
|
676
|
+
* @returns the next target element or null
|
|
677
|
+
*/
|
|
607
678
|
function getNextEventTarget(elm, ev) {
|
|
608
679
|
if (elm.parentElement) return elm.parentElement;
|
|
609
680
|
if (elm.host && ev.composed) return elm.host;
|
|
610
681
|
if (ev.composed && elm.parentNode && elm.parentNode.host) return elm.parentNode.host;
|
|
611
682
|
return null;
|
|
612
683
|
}
|
|
684
|
+
/**
|
|
685
|
+
* Dispatch an event on a target element.
|
|
686
|
+
*
|
|
687
|
+
* @param currentTarget - the element to dispatch the event on
|
|
688
|
+
* @param ev - the mock event to dispatch
|
|
689
|
+
* @returns true (always returns true for compatibility)
|
|
690
|
+
*/
|
|
613
691
|
function dispatchEvent(currentTarget, ev) {
|
|
614
692
|
ev.target = currentTarget;
|
|
615
693
|
triggerEventListener(currentTarget, ev);
|
|
616
694
|
return true;
|
|
617
695
|
}
|
|
618
|
-
|
|
619
696
|
//#endregion
|
|
620
697
|
//#region src/parse-util.ts
|
|
621
698
|
const docParser = /* @__PURE__ */ new WeakMap();
|
|
@@ -636,7 +713,7 @@ function getParser(ownerDocument) {
|
|
|
636
713
|
if (parseOptions != null) return parseOptions;
|
|
637
714
|
parseOptions = { treeAdapter: {
|
|
638
715
|
createDocument() {
|
|
639
|
-
const doc = ownerDocument.createElement(
|
|
716
|
+
const doc = ownerDocument.createElement("#document");
|
|
640
717
|
doc["x-mode"] = "no-quirks";
|
|
641
718
|
return doc;
|
|
642
719
|
},
|
|
@@ -675,7 +752,7 @@ function getParser(ownerDocument) {
|
|
|
675
752
|
return templateElement.content;
|
|
676
753
|
},
|
|
677
754
|
setDocumentType(doc, name, publicId, systemId) {
|
|
678
|
-
let doctypeNode = doc.childNodes.find((n) => n.nodeType ===
|
|
755
|
+
let doctypeNode = doc.childNodes.find((n) => n.nodeType === 10);
|
|
679
756
|
if (doctypeNode == null) {
|
|
680
757
|
doctypeNode = ownerDocument.createDocumentTypeNode();
|
|
681
758
|
doc.insertBefore(doctypeNode, doc.firstChild);
|
|
@@ -696,12 +773,12 @@ function getParser(ownerDocument) {
|
|
|
696
773
|
},
|
|
697
774
|
insertText(parentNode, text) {
|
|
698
775
|
const lastChild = parentNode.lastChild;
|
|
699
|
-
if (lastChild != null && lastChild.nodeType ===
|
|
776
|
+
if (lastChild != null && lastChild.nodeType === 3) lastChild.nodeValue += text;
|
|
700
777
|
else parentNode.appendChild(ownerDocument.createTextNode(text));
|
|
701
778
|
},
|
|
702
779
|
insertTextBefore(parentNode, text, referenceNode) {
|
|
703
780
|
const prevNode = parentNode.childNodes[parentNode.childNodes.indexOf(referenceNode) - 1];
|
|
704
|
-
if (prevNode != null && prevNode.nodeType ===
|
|
781
|
+
if (prevNode != null && prevNode.nodeType === 3) prevNode.nodeValue += text;
|
|
705
782
|
else parentNode.insertBefore(ownerDocument.createTextNode(text), referenceNode);
|
|
706
783
|
},
|
|
707
784
|
adoptAttributes(recipient, attrs) {
|
|
@@ -753,1085 +830,21 @@ function getParser(ownerDocument) {
|
|
|
753
830
|
return doctypeNode["x-systemId"];
|
|
754
831
|
},
|
|
755
832
|
isTextNode(node) {
|
|
756
|
-
return node.nodeType ===
|
|
833
|
+
return node.nodeType === 3;
|
|
757
834
|
},
|
|
758
835
|
isCommentNode(node) {
|
|
759
|
-
return node.nodeType ===
|
|
836
|
+
return node.nodeType === 8;
|
|
760
837
|
},
|
|
761
838
|
isDocumentTypeNode(node) {
|
|
762
|
-
return node.nodeType ===
|
|
839
|
+
return node.nodeType === 10;
|
|
763
840
|
},
|
|
764
841
|
isElementNode(node) {
|
|
765
|
-
return node.nodeType ===
|
|
842
|
+
return node.nodeType === 1;
|
|
766
843
|
}
|
|
767
844
|
} };
|
|
768
845
|
docParser.set(ownerDocument, parseOptions);
|
|
769
846
|
return parseOptions;
|
|
770
847
|
}
|
|
771
|
-
|
|
772
|
-
//#endregion
|
|
773
|
-
//#region src/third-party/jquery.ts
|
|
774
|
-
/**
|
|
775
|
-
* ATTENTION: DO NOT MODIFY THIS FILE
|
|
776
|
-
*
|
|
777
|
-
* This file is generated by "scripts/updateSelectorEngine.ts" and can be overwritten
|
|
778
|
-
* at any time. Don't make changes in here as they will get lost!
|
|
779
|
-
*/
|
|
780
|
-
var jquery_default = (function(global, factory) {
|
|
781
|
-
"use strict";
|
|
782
|
-
return factory(global, true);
|
|
783
|
-
})({ document: {
|
|
784
|
-
createElement() {
|
|
785
|
-
return {};
|
|
786
|
-
},
|
|
787
|
-
nodeType: 9,
|
|
788
|
-
documentElement: {
|
|
789
|
-
nodeType: 1,
|
|
790
|
-
nodeName: "HTML"
|
|
791
|
-
}
|
|
792
|
-
} }, function(window, noGlobal) {
|
|
793
|
-
"use strict";
|
|
794
|
-
if (!window.document) throw new Error("jQuery requires a window with a document");
|
|
795
|
-
var arr = [];
|
|
796
|
-
var getProto = Object.getPrototypeOf;
|
|
797
|
-
var slice = arr.slice;
|
|
798
|
-
var flat = arr.flat ? function(array) {
|
|
799
|
-
return arr.flat.call(array);
|
|
800
|
-
} : function(array) {
|
|
801
|
-
return arr.concat.apply([], array);
|
|
802
|
-
};
|
|
803
|
-
var push = arr.push;
|
|
804
|
-
var indexOf = arr.indexOf;
|
|
805
|
-
var class2type = {};
|
|
806
|
-
var toString = class2type.toString;
|
|
807
|
-
var hasOwn = class2type.hasOwnProperty;
|
|
808
|
-
var fnToString = hasOwn.toString;
|
|
809
|
-
var ObjectFunctionString = fnToString.call(Object);
|
|
810
|
-
var support = {};
|
|
811
|
-
function toType(obj) {
|
|
812
|
-
if (obj == null) return obj + "";
|
|
813
|
-
return typeof obj === "object" ? class2type[toString.call(obj)] || "object" : typeof obj;
|
|
814
|
-
}
|
|
815
|
-
function isWindow(obj) {
|
|
816
|
-
return obj != null && obj === obj.window;
|
|
817
|
-
}
|
|
818
|
-
function isArrayLike(obj) {
|
|
819
|
-
var length = !!obj && obj.length, type = toType(obj);
|
|
820
|
-
if (typeof obj === "function" || isWindow(obj)) return false;
|
|
821
|
-
return type === "array" || length === 0 || typeof length === "number" && length > 0 && length - 1 in obj;
|
|
822
|
-
}
|
|
823
|
-
var document = window.document;
|
|
824
|
-
var preservedScriptAttributes = {
|
|
825
|
-
type: true,
|
|
826
|
-
src: true,
|
|
827
|
-
nonce: true,
|
|
828
|
-
noModule: true
|
|
829
|
-
};
|
|
830
|
-
function DOMEval(code, node, doc) {
|
|
831
|
-
doc = doc || document;
|
|
832
|
-
var i, script = doc.createElement("script");
|
|
833
|
-
script.text = code;
|
|
834
|
-
if (node) {
|
|
835
|
-
for (i in preservedScriptAttributes) if (node[i]) script[i] = node[i];
|
|
836
|
-
}
|
|
837
|
-
doc.head.appendChild(script).parentNode.removeChild(script);
|
|
838
|
-
}
|
|
839
|
-
const jQuery = {};
|
|
840
|
-
var version = "4.0.0-pre+9352011a7.dirty +selector", rhtmlSuffix = /HTML$/i;
|
|
841
|
-
jQuery.fn = jQuery.prototype = {
|
|
842
|
-
jquery: version,
|
|
843
|
-
constructor: jQuery,
|
|
844
|
-
length: 0,
|
|
845
|
-
toArray: function() {
|
|
846
|
-
return slice.call(this);
|
|
847
|
-
},
|
|
848
|
-
get: function(num) {
|
|
849
|
-
if (num == null) return slice.call(this);
|
|
850
|
-
return num < 0 ? this[num + this.length] : this[num];
|
|
851
|
-
},
|
|
852
|
-
pushStack: function(elems) {
|
|
853
|
-
var ret = jQuery.merge(this.constructor(), elems);
|
|
854
|
-
ret.prevObject = this;
|
|
855
|
-
return ret;
|
|
856
|
-
},
|
|
857
|
-
each: function(callback) {
|
|
858
|
-
return jQuery.each(this, callback);
|
|
859
|
-
},
|
|
860
|
-
map: function(callback) {
|
|
861
|
-
return this.pushStack(jQuery.map(this, function(elem, i) {
|
|
862
|
-
return callback.call(elem, i, elem);
|
|
863
|
-
}));
|
|
864
|
-
},
|
|
865
|
-
slice: function() {
|
|
866
|
-
return this.pushStack(slice.apply(this, arguments));
|
|
867
|
-
},
|
|
868
|
-
first: function() {
|
|
869
|
-
return this.eq(0);
|
|
870
|
-
},
|
|
871
|
-
last: function() {
|
|
872
|
-
return this.eq(-1);
|
|
873
|
-
},
|
|
874
|
-
even: function() {
|
|
875
|
-
return this.pushStack(jQuery.grep(this, function(_elem, i) {
|
|
876
|
-
return (i + 1) % 2;
|
|
877
|
-
}));
|
|
878
|
-
},
|
|
879
|
-
odd: function() {
|
|
880
|
-
return this.pushStack(jQuery.grep(this, function(_elem, i) {
|
|
881
|
-
return i % 2;
|
|
882
|
-
}));
|
|
883
|
-
},
|
|
884
|
-
eq: function(i) {
|
|
885
|
-
var len = this.length, j = +i + (i < 0 ? len : 0);
|
|
886
|
-
return this.pushStack(j >= 0 && j < len ? [this[j]] : []);
|
|
887
|
-
},
|
|
888
|
-
end: function() {
|
|
889
|
-
return this.prevObject || this.constructor();
|
|
890
|
-
}
|
|
891
|
-
};
|
|
892
|
-
jQuery.extend = jQuery.fn.extend = function() {
|
|
893
|
-
var options, name, src, copy, copyIsArray, clone, target = arguments[0] || {}, i = 1, length = arguments.length, deep = false;
|
|
894
|
-
if (typeof target === "boolean") {
|
|
895
|
-
deep = target;
|
|
896
|
-
target = arguments[i] || {};
|
|
897
|
-
i++;
|
|
898
|
-
}
|
|
899
|
-
if (typeof target !== "object" && typeof target !== "function") target = {};
|
|
900
|
-
if (i === length) {
|
|
901
|
-
target = this;
|
|
902
|
-
i--;
|
|
903
|
-
}
|
|
904
|
-
for (; i < length; i++) if ((options = arguments[i]) != null) for (name in options) {
|
|
905
|
-
copy = options[name];
|
|
906
|
-
if (name === "__proto__" || target === copy) continue;
|
|
907
|
-
if (deep && copy && (jQuery.isPlainObject(copy) || (copyIsArray = Array.isArray(copy)))) {
|
|
908
|
-
src = target[name];
|
|
909
|
-
if (copyIsArray && !Array.isArray(src)) clone = [];
|
|
910
|
-
else if (!copyIsArray && !jQuery.isPlainObject(src)) clone = {};
|
|
911
|
-
else clone = src;
|
|
912
|
-
copyIsArray = false;
|
|
913
|
-
target[name] = jQuery.extend(deep, clone, copy);
|
|
914
|
-
} else if (copy !== void 0) target[name] = copy;
|
|
915
|
-
}
|
|
916
|
-
return target;
|
|
917
|
-
};
|
|
918
|
-
jQuery.extend({
|
|
919
|
-
expando: "jQuery" + (version + Math.random()).replace(/\D/g, ""),
|
|
920
|
-
isReady: true,
|
|
921
|
-
error: function(msg) {
|
|
922
|
-
throw new Error(msg);
|
|
923
|
-
},
|
|
924
|
-
noop: function() {},
|
|
925
|
-
isPlainObject: function(obj) {
|
|
926
|
-
var proto, Ctor;
|
|
927
|
-
if (!obj || toString.call(obj) !== "[object Object]") return false;
|
|
928
|
-
proto = getProto(obj);
|
|
929
|
-
if (!proto) return true;
|
|
930
|
-
Ctor = hasOwn.call(proto, "constructor") && proto.constructor;
|
|
931
|
-
return typeof Ctor === "function" && fnToString.call(Ctor) === ObjectFunctionString;
|
|
932
|
-
},
|
|
933
|
-
isEmptyObject: function(obj) {
|
|
934
|
-
var name;
|
|
935
|
-
for (name in obj) return false;
|
|
936
|
-
return true;
|
|
937
|
-
},
|
|
938
|
-
globalEval: function(code, options, doc) {
|
|
939
|
-
DOMEval(code, { nonce: options && options.nonce }, doc);
|
|
940
|
-
},
|
|
941
|
-
each: function(obj, callback) {
|
|
942
|
-
var length, i = 0;
|
|
943
|
-
if (isArrayLike(obj)) {
|
|
944
|
-
length = obj.length;
|
|
945
|
-
for (; i < length; i++) if (callback.call(obj[i], i, obj[i]) === false) break;
|
|
946
|
-
} else for (i in obj) if (callback.call(obj[i], i, obj[i]) === false) break;
|
|
947
|
-
return obj;
|
|
948
|
-
},
|
|
949
|
-
text: function(elem) {
|
|
950
|
-
var node, ret = "", i = 0, nodeType = elem.nodeType;
|
|
951
|
-
if (!nodeType) while (node = elem[i++]) ret += jQuery.text(node);
|
|
952
|
-
if (nodeType === 1 || nodeType === 11) return elem.textContent;
|
|
953
|
-
if (nodeType === 9) return elem.documentElement.textContent;
|
|
954
|
-
if (nodeType === 3 || nodeType === 4) return elem.nodeValue;
|
|
955
|
-
return ret;
|
|
956
|
-
},
|
|
957
|
-
makeArray: function(arr, results) {
|
|
958
|
-
var ret = results || [];
|
|
959
|
-
if (arr != null) if (isArrayLike(Object(arr))) jQuery.merge(ret, typeof arr === "string" ? [arr] : arr);
|
|
960
|
-
else push.call(ret, arr);
|
|
961
|
-
return ret;
|
|
962
|
-
},
|
|
963
|
-
inArray: function(elem, arr, i) {
|
|
964
|
-
return arr == null ? -1 : indexOf.call(arr, elem, i);
|
|
965
|
-
},
|
|
966
|
-
isXMLDoc: function(elem) {
|
|
967
|
-
var namespace = elem && elem.namespaceURI, docElem = elem && (elem.ownerDocument || elem).documentElement;
|
|
968
|
-
return !rhtmlSuffix.test(namespace || docElem && docElem.nodeName || "HTML");
|
|
969
|
-
},
|
|
970
|
-
contains: function(a, b) {
|
|
971
|
-
var bup = b && b.parentNode;
|
|
972
|
-
return a === bup || !!(bup && bup.nodeType === 1 && (a.contains ? a.contains(bup) : a.compareDocumentPosition && a.compareDocumentPosition(bup) & 16));
|
|
973
|
-
},
|
|
974
|
-
merge: function(first, second) {
|
|
975
|
-
var len = +second.length, j = 0, i = first.length;
|
|
976
|
-
for (; j < len; j++) first[i++] = second[j];
|
|
977
|
-
first.length = i;
|
|
978
|
-
return first;
|
|
979
|
-
},
|
|
980
|
-
grep: function(elems, callback, invert) {
|
|
981
|
-
var callbackInverse, matches = [], i = 0, length = elems.length, callbackExpect = !invert;
|
|
982
|
-
for (; i < length; i++) {
|
|
983
|
-
callbackInverse = !callback(elems[i], i);
|
|
984
|
-
if (callbackInverse !== callbackExpect) matches.push(elems[i]);
|
|
985
|
-
}
|
|
986
|
-
return matches;
|
|
987
|
-
},
|
|
988
|
-
map: function(elems, callback, arg) {
|
|
989
|
-
var length, value, i = 0, ret = [];
|
|
990
|
-
if (isArrayLike(elems)) {
|
|
991
|
-
length = elems.length;
|
|
992
|
-
for (; i < length; i++) {
|
|
993
|
-
value = callback(elems[i], i, arg);
|
|
994
|
-
if (value != null) ret.push(value);
|
|
995
|
-
}
|
|
996
|
-
} else for (i in elems) {
|
|
997
|
-
value = callback(elems[i], i, arg);
|
|
998
|
-
if (value != null) ret.push(value);
|
|
999
|
-
}
|
|
1000
|
-
return flat(ret);
|
|
1001
|
-
},
|
|
1002
|
-
guid: 1,
|
|
1003
|
-
support
|
|
1004
|
-
});
|
|
1005
|
-
if (typeof Symbol === "function") jQuery.fn[Symbol.iterator] = arr[Symbol.iterator];
|
|
1006
|
-
jQuery.each("Boolean Number String Function Array Date RegExp Object Error Symbol".split(" "), function(_i, name) {
|
|
1007
|
-
class2type["[object " + name + "]"] = name.toLowerCase();
|
|
1008
|
-
});
|
|
1009
|
-
function nodeName(elem, name) {
|
|
1010
|
-
return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase();
|
|
1011
|
-
}
|
|
1012
|
-
var pop = arr.pop;
|
|
1013
|
-
var whitespace = "[\\x20\\t\\r\\n\\f]";
|
|
1014
|
-
var isIE = document.documentMode;
|
|
1015
|
-
try {
|
|
1016
|
-
document.querySelector(":has(*,:jqfake)");
|
|
1017
|
-
support.cssHas = false;
|
|
1018
|
-
} catch (e) {
|
|
1019
|
-
support.cssHas = true;
|
|
1020
|
-
}
|
|
1021
|
-
var rbuggyQSA = [];
|
|
1022
|
-
if (isIE) rbuggyQSA.push(":enabled", ":disabled", "\\[" + whitespace + "*name" + whitespace + "*=" + whitespace + "*(?:''|\"\")");
|
|
1023
|
-
if (!support.cssHas) rbuggyQSA.push(":has");
|
|
1024
|
-
rbuggyQSA = rbuggyQSA.length && new RegExp(rbuggyQSA.join("|"));
|
|
1025
|
-
var rtrimCSS = new RegExp("^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" + whitespace + "+$", "g");
|
|
1026
|
-
var identifier = "(?:\\\\[\\da-fA-F]{1,6}" + whitespace + "?|\\\\[^\\r\\n\\f]|[\\w-]|[^\0-\\x7f])+";
|
|
1027
|
-
var booleans = "checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped";
|
|
1028
|
-
var rleadingCombinator = new RegExp("^" + whitespace + "*([>+~]|" + whitespace + ")" + whitespace + "*");
|
|
1029
|
-
new RegExp(whitespace + "|>");
|
|
1030
|
-
var rsibling = /[+~]/;
|
|
1031
|
-
var documentElement = document.documentElement;
|
|
1032
|
-
var matches = documentElement.matches || documentElement.msMatchesSelector;
|
|
1033
|
-
/**
|
|
1034
|
-
* Create key-value caches of limited size
|
|
1035
|
-
* @returns {function(string, object)} Returns the Object data after storing it on itself with
|
|
1036
|
-
* property name the (space-suffixed) string and (if the cache is larger than Expr.cacheLength)
|
|
1037
|
-
* deleting the oldest entry
|
|
1038
|
-
*/
|
|
1039
|
-
function createCache() {
|
|
1040
|
-
var keys = [];
|
|
1041
|
-
function cache(key, value) {
|
|
1042
|
-
if (keys.push(key + " ") > jQuery.expr.cacheLength) delete cache[keys.shift()];
|
|
1043
|
-
return cache[key + " "] = value;
|
|
1044
|
-
}
|
|
1045
|
-
return cache;
|
|
1046
|
-
}
|
|
1047
|
-
/**
|
|
1048
|
-
* Checks a node for validity as a jQuery selector context
|
|
1049
|
-
* @param {Element|Object=} context
|
|
1050
|
-
* @returns {Element|Object|Boolean} The input node if acceptable, otherwise a falsy value
|
|
1051
|
-
*/
|
|
1052
|
-
function testContext(context) {
|
|
1053
|
-
return context && typeof context.getElementsByTagName !== "undefined" && context;
|
|
1054
|
-
}
|
|
1055
|
-
var attributes = "\\[" + whitespace + "*(" + identifier + ")(?:" + whitespace + "*([*^$|!~]?=)" + whitespace + "*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|(" + identifier + "))|)" + whitespace + "*\\]";
|
|
1056
|
-
var pseudos = ":(" + identifier + ")(?:\\((('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|((?:\\\\.|[^\\\\()[\\]]|" + attributes + ")*)|.*)\\)|)";
|
|
1057
|
-
var filterMatchExpr = {
|
|
1058
|
-
ID: new RegExp("^#(" + identifier + ")"),
|
|
1059
|
-
CLASS: new RegExp("^\\.(" + identifier + ")"),
|
|
1060
|
-
TAG: new RegExp("^(" + identifier + "|[*])"),
|
|
1061
|
-
ATTR: new RegExp("^" + attributes),
|
|
1062
|
-
PSEUDO: new RegExp("^" + pseudos),
|
|
1063
|
-
CHILD: new RegExp("^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\(" + whitespace + "*(even|odd|(([+-]|)(\\d*)n|)" + whitespace + "*(?:([+-]|)" + whitespace + "*(\\d+)|))" + whitespace + "*\\)|)", "i")
|
|
1064
|
-
};
|
|
1065
|
-
var rpseudo = new RegExp(pseudos);
|
|
1066
|
-
var runescape = new RegExp("\\\\[\\da-fA-F]{1,6}" + whitespace + "?|\\\\([^\\r\\n\\f])", "g"), funescape = function(escape, nonHex) {
|
|
1067
|
-
var high = "0x" + escape.slice(1) - 65536;
|
|
1068
|
-
if (nonHex) return nonHex;
|
|
1069
|
-
return high < 0 ? String.fromCharCode(high + 65536) : String.fromCharCode(high >> 10 | 55296, high & 1023 | 56320);
|
|
1070
|
-
};
|
|
1071
|
-
function unescapeSelector(sel) {
|
|
1072
|
-
return sel.replace(runescape, funescape);
|
|
1073
|
-
}
|
|
1074
|
-
function selectorError(msg) {
|
|
1075
|
-
jQuery.error("Syntax error, unrecognized expression: " + msg);
|
|
1076
|
-
}
|
|
1077
|
-
var rcomma = new RegExp("^" + whitespace + "*," + whitespace + "*");
|
|
1078
|
-
var tokenCache = createCache();
|
|
1079
|
-
function tokenize(selector, parseOnly) {
|
|
1080
|
-
var matched, match, tokens, type, soFar, groups, preFilters, cached = tokenCache[selector + " "];
|
|
1081
|
-
if (cached) return parseOnly ? 0 : cached.slice(0);
|
|
1082
|
-
soFar = selector;
|
|
1083
|
-
groups = [];
|
|
1084
|
-
preFilters = jQuery.expr.preFilter;
|
|
1085
|
-
while (soFar) {
|
|
1086
|
-
if (!matched || (match = rcomma.exec(soFar))) {
|
|
1087
|
-
if (match) soFar = soFar.slice(match[0].length) || soFar;
|
|
1088
|
-
groups.push(tokens = []);
|
|
1089
|
-
}
|
|
1090
|
-
matched = false;
|
|
1091
|
-
if (match = rleadingCombinator.exec(soFar)) {
|
|
1092
|
-
matched = match.shift();
|
|
1093
|
-
tokens.push({
|
|
1094
|
-
value: matched,
|
|
1095
|
-
type: match[0].replace(rtrimCSS, " ")
|
|
1096
|
-
});
|
|
1097
|
-
soFar = soFar.slice(matched.length);
|
|
1098
|
-
}
|
|
1099
|
-
for (type in filterMatchExpr) if ((match = jQuery.expr.match[type].exec(soFar)) && (!preFilters[type] || (match = preFilters[type](match)))) {
|
|
1100
|
-
matched = match.shift();
|
|
1101
|
-
tokens.push({
|
|
1102
|
-
value: matched,
|
|
1103
|
-
type,
|
|
1104
|
-
matches: match
|
|
1105
|
-
});
|
|
1106
|
-
soFar = soFar.slice(matched.length);
|
|
1107
|
-
}
|
|
1108
|
-
if (!matched) break;
|
|
1109
|
-
}
|
|
1110
|
-
if (parseOnly) return soFar.length;
|
|
1111
|
-
return soFar ? selectorError(selector) : tokenCache(selector, groups).slice(0);
|
|
1112
|
-
}
|
|
1113
|
-
var preFilter = {
|
|
1114
|
-
ATTR: function(match) {
|
|
1115
|
-
match[1] = unescapeSelector(match[1]);
|
|
1116
|
-
match[3] = unescapeSelector(match[3] || match[4] || match[5] || "");
|
|
1117
|
-
if (match[2] === "~=") match[3] = " " + match[3] + " ";
|
|
1118
|
-
return match.slice(0, 4);
|
|
1119
|
-
},
|
|
1120
|
-
CHILD: function(match) {
|
|
1121
|
-
match[1] = match[1].toLowerCase();
|
|
1122
|
-
if (match[1].slice(0, 3) === "nth") {
|
|
1123
|
-
if (!match[3]) selectorError(match[0]);
|
|
1124
|
-
match[4] = +(match[4] ? match[5] + (match[6] || 1) : 2 * (match[3] === "even" || match[3] === "odd"));
|
|
1125
|
-
match[5] = +(match[7] + match[8] || match[3] === "odd");
|
|
1126
|
-
} else if (match[3]) selectorError(match[0]);
|
|
1127
|
-
return match;
|
|
1128
|
-
},
|
|
1129
|
-
PSEUDO: function(match) {
|
|
1130
|
-
var excess, unquoted = !match[6] && match[2];
|
|
1131
|
-
if (filterMatchExpr.CHILD.test(match[0])) return null;
|
|
1132
|
-
if (match[3]) match[2] = match[4] || match[5] || "";
|
|
1133
|
-
else if (unquoted && rpseudo.test(unquoted) && (excess = tokenize(unquoted, true)) && (excess = unquoted.indexOf(")", unquoted.length - excess) - unquoted.length)) {
|
|
1134
|
-
match[0] = match[0].slice(0, excess);
|
|
1135
|
-
match[2] = unquoted.slice(0, excess);
|
|
1136
|
-
}
|
|
1137
|
-
return match.slice(0, 3);
|
|
1138
|
-
}
|
|
1139
|
-
};
|
|
1140
|
-
function toSelector(tokens) {
|
|
1141
|
-
var i = 0, len = tokens.length, selector = "";
|
|
1142
|
-
for (; i < len; i++) selector += tokens[i].value;
|
|
1143
|
-
return selector;
|
|
1144
|
-
}
|
|
1145
|
-
var rcssescape = /([\0-\x1f\x7f]|^-?\d)|^-$|[^\x80-\uFFFF\w-]/g;
|
|
1146
|
-
function fcssescape(ch, asCodePoint) {
|
|
1147
|
-
if (asCodePoint) {
|
|
1148
|
-
if (ch === "\0") return "�";
|
|
1149
|
-
return ch.slice(0, -1) + "\\" + ch.charCodeAt(ch.length - 1).toString(16) + " ";
|
|
1150
|
-
}
|
|
1151
|
-
return "\\" + ch;
|
|
1152
|
-
}
|
|
1153
|
-
jQuery.escapeSelector = function(sel) {
|
|
1154
|
-
return (sel + "").replace(rcssescape, fcssescape);
|
|
1155
|
-
};
|
|
1156
|
-
var sort = arr.sort;
|
|
1157
|
-
var splice = arr.splice;
|
|
1158
|
-
var hasDuplicate;
|
|
1159
|
-
function sortOrder(a, b) {
|
|
1160
|
-
if (a === b) {
|
|
1161
|
-
hasDuplicate = true;
|
|
1162
|
-
return 0;
|
|
1163
|
-
}
|
|
1164
|
-
var compare = !a.compareDocumentPosition - !b.compareDocumentPosition;
|
|
1165
|
-
if (compare) return compare;
|
|
1166
|
-
compare = (a.ownerDocument || a) == (b.ownerDocument || b) ? a.compareDocumentPosition(b) : 1;
|
|
1167
|
-
if (compare & 1) {
|
|
1168
|
-
if (a == document || a.ownerDocument == document && jQuery.contains(document, a)) return -1;
|
|
1169
|
-
if (b == document || b.ownerDocument == document && jQuery.contains(document, b)) return 1;
|
|
1170
|
-
return 0;
|
|
1171
|
-
}
|
|
1172
|
-
return compare & 4 ? -1 : 1;
|
|
1173
|
-
}
|
|
1174
|
-
/**
|
|
1175
|
-
* Document sorting and removing duplicates
|
|
1176
|
-
* @param {ArrayLike} results
|
|
1177
|
-
*/
|
|
1178
|
-
jQuery.uniqueSort = function(results) {
|
|
1179
|
-
var elem, duplicates = [], j = 0, i = 0;
|
|
1180
|
-
hasDuplicate = false;
|
|
1181
|
-
sort.call(results, sortOrder);
|
|
1182
|
-
if (hasDuplicate) {
|
|
1183
|
-
while (elem = results[i++]) if (elem === results[i]) j = duplicates.push(i);
|
|
1184
|
-
while (j--) splice.call(results, duplicates[j], 1);
|
|
1185
|
-
}
|
|
1186
|
-
return results;
|
|
1187
|
-
};
|
|
1188
|
-
jQuery.fn.uniqueSort = function() {
|
|
1189
|
-
return this.pushStack(jQuery.uniqueSort(slice.apply(this)));
|
|
1190
|
-
};
|
|
1191
|
-
var i, outermostContext, document$1, documentElement$1, documentIsHTML, dirruns = 0, done = 0, classCache = createCache(), compilerCache = createCache(), nonnativeSelectorCache = createCache(), rwhitespace = new RegExp(whitespace + "+", "g"), ridentifier = new RegExp("^" + identifier + "$"), matchExpr = jQuery.extend({
|
|
1192
|
-
bool: new RegExp("^(?:" + booleans + ")$", "i"),
|
|
1193
|
-
needsContext: new RegExp("^" + whitespace + "*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\(" + whitespace + "*((?:-\\d)?\\d*)" + whitespace + "*\\)|)(?=[^-]|$)", "i")
|
|
1194
|
-
}, filterMatchExpr), rinputs = /^(?:input|select|textarea|button)$/i, rheader = /^h\d$/i, unloadHandler = function() {
|
|
1195
|
-
setDocument();
|
|
1196
|
-
}, inDisabledFieldset = addCombinator(function(elem) {
|
|
1197
|
-
return elem.disabled === true && nodeName(elem, "fieldset");
|
|
1198
|
-
}, {
|
|
1199
|
-
dir: "parentNode",
|
|
1200
|
-
next: "legend"
|
|
1201
|
-
});
|
|
1202
|
-
function find(selector, context, results, seed) {
|
|
1203
|
-
context && context.ownerDocument;
|
|
1204
|
-
var nodeType = context ? context.nodeType : 9;
|
|
1205
|
-
results = results || [];
|
|
1206
|
-
if (typeof selector !== "string" || !selector || nodeType !== 1 && nodeType !== 9 && nodeType !== 11) return results;
|
|
1207
|
-
return select(selector.replace(rtrimCSS, "$1"), context, results, seed);
|
|
1208
|
-
}
|
|
1209
|
-
/**
|
|
1210
|
-
* Mark a function for special use by jQuery selector module
|
|
1211
|
-
* @param {Function} fn The function to mark
|
|
1212
|
-
*/
|
|
1213
|
-
function markFunction(fn) {
|
|
1214
|
-
fn[jQuery.expando] = true;
|
|
1215
|
-
return fn;
|
|
1216
|
-
}
|
|
1217
|
-
/**
|
|
1218
|
-
* Returns a function to use in pseudos for input types
|
|
1219
|
-
* @param {String} type
|
|
1220
|
-
*/
|
|
1221
|
-
function createInputPseudo(type) {
|
|
1222
|
-
return function(elem) {
|
|
1223
|
-
return nodeName(elem, "input") && elem.type === type;
|
|
1224
|
-
};
|
|
1225
|
-
}
|
|
1226
|
-
/**
|
|
1227
|
-
* Returns a function to use in pseudos for buttons
|
|
1228
|
-
* @param {String} type
|
|
1229
|
-
*/
|
|
1230
|
-
function createButtonPseudo(type) {
|
|
1231
|
-
return function(elem) {
|
|
1232
|
-
return (nodeName(elem, "input") || nodeName(elem, "button")) && elem.type === type;
|
|
1233
|
-
};
|
|
1234
|
-
}
|
|
1235
|
-
/**
|
|
1236
|
-
* Returns a function to use in pseudos for :enabled/:disabled
|
|
1237
|
-
* @param {Boolean} disabled true for :disabled; false for :enabled
|
|
1238
|
-
*/
|
|
1239
|
-
function createDisabledPseudo(disabled) {
|
|
1240
|
-
return function(elem) {
|
|
1241
|
-
if ("form" in elem) {
|
|
1242
|
-
if (elem.parentNode && elem.disabled === false) {
|
|
1243
|
-
if ("label" in elem) if ("label" in elem.parentNode) return elem.parentNode.disabled === disabled;
|
|
1244
|
-
else return elem.disabled === disabled;
|
|
1245
|
-
return elem.isDisabled === disabled || elem.isDisabled !== !disabled && inDisabledFieldset(elem) === disabled;
|
|
1246
|
-
}
|
|
1247
|
-
return elem.disabled === disabled;
|
|
1248
|
-
} else if ("label" in elem) return elem.disabled === disabled;
|
|
1249
|
-
return false;
|
|
1250
|
-
};
|
|
1251
|
-
}
|
|
1252
|
-
/**
|
|
1253
|
-
* Returns a function to use in pseudos for positionals
|
|
1254
|
-
* @param {Function} fn
|
|
1255
|
-
*/
|
|
1256
|
-
function createPositionalPseudo(fn) {
|
|
1257
|
-
return markFunction(function(argument) {
|
|
1258
|
-
argument = +argument;
|
|
1259
|
-
return markFunction(function(seed, matches) {
|
|
1260
|
-
var j, matchIndexes = fn([], seed.length, argument), i = matchIndexes.length;
|
|
1261
|
-
while (i--) if (seed[j = matchIndexes[i]]) seed[j] = !(matches[j] = seed[j]);
|
|
1262
|
-
});
|
|
1263
|
-
});
|
|
1264
|
-
}
|
|
1265
|
-
/**
|
|
1266
|
-
* Sets document-related variables once based on the current document
|
|
1267
|
-
* @param {Element|Object} [node] An element or document object to use to set the document
|
|
1268
|
-
*/
|
|
1269
|
-
function setDocument(node) {
|
|
1270
|
-
var subWindow, doc = node ? node.ownerDocument || node : document;
|
|
1271
|
-
if (doc == document$1 || doc.nodeType !== 9) return;
|
|
1272
|
-
document$1 = doc;
|
|
1273
|
-
documentElement$1 = document$1.documentElement;
|
|
1274
|
-
documentIsHTML = !jQuery.isXMLDoc(document$1);
|
|
1275
|
-
if (isIE && document != document$1 && (subWindow = document$1.defaultView) && subWindow.top !== subWindow) subWindow.addEventListener("unload", unloadHandler);
|
|
1276
|
-
}
|
|
1277
|
-
find.matches = function(expr, elements) {
|
|
1278
|
-
return find(expr, null, null, elements);
|
|
1279
|
-
};
|
|
1280
|
-
find.matchesSelector = function(elem, expr) {
|
|
1281
|
-
setDocument(elem);
|
|
1282
|
-
if (documentIsHTML && !nonnativeSelectorCache[expr + " "] && (!rbuggyQSA || !rbuggyQSA.test(expr))) try {
|
|
1283
|
-
return matches.call(elem, expr);
|
|
1284
|
-
} catch (e) {
|
|
1285
|
-
nonnativeSelectorCache(expr, true);
|
|
1286
|
-
}
|
|
1287
|
-
return find(expr, document$1, null, [elem]).length > 0;
|
|
1288
|
-
};
|
|
1289
|
-
jQuery.expr = {
|
|
1290
|
-
cacheLength: 50,
|
|
1291
|
-
createPseudo: markFunction,
|
|
1292
|
-
match: matchExpr,
|
|
1293
|
-
find: {
|
|
1294
|
-
ID: function(id, context) {
|
|
1295
|
-
if (typeof context.getElementById !== "undefined" && documentIsHTML) {
|
|
1296
|
-
var elem = context.getElementById(id);
|
|
1297
|
-
return elem ? [elem] : [];
|
|
1298
|
-
}
|
|
1299
|
-
},
|
|
1300
|
-
TAG: function(tag, context) {
|
|
1301
|
-
if (typeof context.getElementsByTagName !== "undefined") return context.getElementsByTagName(tag);
|
|
1302
|
-
else return context.querySelectorAll(tag);
|
|
1303
|
-
},
|
|
1304
|
-
CLASS: function(className, context) {
|
|
1305
|
-
if (typeof context.getElementsByClassName !== "undefined" && documentIsHTML) return context.getElementsByClassName(className);
|
|
1306
|
-
}
|
|
1307
|
-
},
|
|
1308
|
-
relative: {
|
|
1309
|
-
">": {
|
|
1310
|
-
dir: "parentNode",
|
|
1311
|
-
first: true
|
|
1312
|
-
},
|
|
1313
|
-
" ": { dir: "parentNode" },
|
|
1314
|
-
"+": {
|
|
1315
|
-
dir: "previousSibling",
|
|
1316
|
-
first: true
|
|
1317
|
-
},
|
|
1318
|
-
"~": { dir: "previousSibling" }
|
|
1319
|
-
},
|
|
1320
|
-
preFilter,
|
|
1321
|
-
filter: {
|
|
1322
|
-
ID: function(id) {
|
|
1323
|
-
var attrId = unescapeSelector(id);
|
|
1324
|
-
return function(elem) {
|
|
1325
|
-
return elem.getAttribute("id") === attrId;
|
|
1326
|
-
};
|
|
1327
|
-
},
|
|
1328
|
-
TAG: function(nodeNameSelector) {
|
|
1329
|
-
var expectedNodeName = unescapeSelector(nodeNameSelector).toLowerCase();
|
|
1330
|
-
return nodeNameSelector === "*" ? function() {
|
|
1331
|
-
return true;
|
|
1332
|
-
} : function(elem) {
|
|
1333
|
-
return nodeName(elem, expectedNodeName);
|
|
1334
|
-
};
|
|
1335
|
-
},
|
|
1336
|
-
CLASS: function(className) {
|
|
1337
|
-
var pattern = classCache[className + " "];
|
|
1338
|
-
return pattern || (pattern = new RegExp("(^|" + whitespace + ")" + className + "(" + whitespace + "|$)")) && classCache(className, function(elem) {
|
|
1339
|
-
return pattern.test(typeof elem.className === "string" && elem.className || typeof elem.getAttribute !== "undefined" && elem.getAttribute("class") || "");
|
|
1340
|
-
});
|
|
1341
|
-
},
|
|
1342
|
-
ATTR: function(name, operator, check) {
|
|
1343
|
-
return function(elem) {
|
|
1344
|
-
var result = elem.getAttribute(name);
|
|
1345
|
-
if (result == null) return operator === "!=";
|
|
1346
|
-
if (!operator) return true;
|
|
1347
|
-
result += "";
|
|
1348
|
-
if (operator === "=") return result === check;
|
|
1349
|
-
if (operator === "!=") return result !== check;
|
|
1350
|
-
if (operator === "^=") return check && result.indexOf(check) === 0;
|
|
1351
|
-
if (operator === "*=") return check && result.indexOf(check) > -1;
|
|
1352
|
-
if (operator === "$=") return check && result.slice(-check.length) === check;
|
|
1353
|
-
if (operator === "~=") return (" " + result.replace(rwhitespace, " ") + " ").indexOf(check) > -1;
|
|
1354
|
-
if (operator === "|=") return result === check || result.slice(0, check.length + 1) === check + "-";
|
|
1355
|
-
return false;
|
|
1356
|
-
};
|
|
1357
|
-
},
|
|
1358
|
-
CHILD: function(type, what, _argument, first, last) {
|
|
1359
|
-
var simple = type.slice(0, 3) !== "nth", forward = type.slice(-4) !== "last", ofType = what === "of-type";
|
|
1360
|
-
return first === 1 && last === 0 ? function(elem) {
|
|
1361
|
-
return !!elem.parentNode;
|
|
1362
|
-
} : function(elem, _context, xml) {
|
|
1363
|
-
var cache, outerCache, node, nodeIndex, start, dir = simple !== forward ? "nextSibling" : "previousSibling", parent = elem.parentNode, name = ofType && elem.nodeName.toLowerCase(), useCache = !xml && !ofType, diff = false;
|
|
1364
|
-
if (parent) {
|
|
1365
|
-
if (simple) {
|
|
1366
|
-
while (dir) {
|
|
1367
|
-
node = elem;
|
|
1368
|
-
while (node = node[dir]) if (ofType ? nodeName(node, name) : node.nodeType === 1) return false;
|
|
1369
|
-
start = dir = type === "only" && !start && "nextSibling";
|
|
1370
|
-
}
|
|
1371
|
-
return true;
|
|
1372
|
-
}
|
|
1373
|
-
start = [forward ? parent.firstChild : parent.lastChild];
|
|
1374
|
-
if (forward && useCache) {
|
|
1375
|
-
outerCache = parent[jQuery.expando] || (parent[jQuery.expando] = {});
|
|
1376
|
-
cache = outerCache[type] || [];
|
|
1377
|
-
nodeIndex = cache[0] === dirruns && cache[1];
|
|
1378
|
-
diff = nodeIndex && cache[2];
|
|
1379
|
-
node = nodeIndex && parent.childNodes[nodeIndex];
|
|
1380
|
-
while (node = ++nodeIndex && node && node[dir] || (diff = nodeIndex = 0) || start.pop()) if (node.nodeType === 1 && ++diff && node === elem) {
|
|
1381
|
-
outerCache[type] = [
|
|
1382
|
-
dirruns,
|
|
1383
|
-
nodeIndex,
|
|
1384
|
-
diff
|
|
1385
|
-
];
|
|
1386
|
-
break;
|
|
1387
|
-
}
|
|
1388
|
-
} else {
|
|
1389
|
-
if (useCache) {
|
|
1390
|
-
outerCache = elem[jQuery.expando] || (elem[jQuery.expando] = {});
|
|
1391
|
-
cache = outerCache[type] || [];
|
|
1392
|
-
nodeIndex = cache[0] === dirruns && cache[1];
|
|
1393
|
-
diff = nodeIndex;
|
|
1394
|
-
}
|
|
1395
|
-
if (diff === false) {
|
|
1396
|
-
while (node = ++nodeIndex && node && node[dir] || (diff = nodeIndex = 0) || start.pop()) if ((ofType ? nodeName(node, name) : node.nodeType === 1) && ++diff) {
|
|
1397
|
-
if (useCache) {
|
|
1398
|
-
outerCache = node[jQuery.expando] || (node[jQuery.expando] = {});
|
|
1399
|
-
outerCache[type] = [dirruns, diff];
|
|
1400
|
-
}
|
|
1401
|
-
if (node === elem) break;
|
|
1402
|
-
}
|
|
1403
|
-
}
|
|
1404
|
-
}
|
|
1405
|
-
diff -= last;
|
|
1406
|
-
return diff === first || diff % first === 0 && diff / first >= 0;
|
|
1407
|
-
}
|
|
1408
|
-
};
|
|
1409
|
-
},
|
|
1410
|
-
PSEUDO: function(pseudo, argument) {
|
|
1411
|
-
var fn = jQuery.expr.pseudos[pseudo] || jQuery.expr.setFilters[pseudo.toLowerCase()] || selectorError("unsupported pseudo: " + pseudo);
|
|
1412
|
-
if (fn[jQuery.expando]) return fn(argument);
|
|
1413
|
-
return fn;
|
|
1414
|
-
}
|
|
1415
|
-
},
|
|
1416
|
-
pseudos: {
|
|
1417
|
-
not: markFunction(function(selector) {
|
|
1418
|
-
var input = [], results = [], matcher = compile(selector.replace(rtrimCSS, "$1"));
|
|
1419
|
-
return matcher[jQuery.expando] ? markFunction(function(seed, matches, _context, xml) {
|
|
1420
|
-
var elem, unmatched = matcher(seed, null, xml, []), i = seed.length;
|
|
1421
|
-
while (i--) if (elem = unmatched[i]) seed[i] = !(matches[i] = elem);
|
|
1422
|
-
}) : function(elem, _context, xml) {
|
|
1423
|
-
input[0] = elem;
|
|
1424
|
-
matcher(input, null, xml, results);
|
|
1425
|
-
input[0] = null;
|
|
1426
|
-
return !results.pop();
|
|
1427
|
-
};
|
|
1428
|
-
}),
|
|
1429
|
-
has: markFunction(function(selector) {
|
|
1430
|
-
return function(elem) {
|
|
1431
|
-
return find(selector, elem).length > 0;
|
|
1432
|
-
};
|
|
1433
|
-
}),
|
|
1434
|
-
contains: markFunction(function(text) {
|
|
1435
|
-
text = unescapeSelector(text);
|
|
1436
|
-
return function(elem) {
|
|
1437
|
-
return (elem.textContent || jQuery.text(elem)).indexOf(text) > -1;
|
|
1438
|
-
};
|
|
1439
|
-
}),
|
|
1440
|
-
lang: markFunction(function(lang) {
|
|
1441
|
-
if (!ridentifier.test(lang || "")) selectorError("unsupported lang: " + lang);
|
|
1442
|
-
lang = unescapeSelector(lang).toLowerCase();
|
|
1443
|
-
return function(elem) {
|
|
1444
|
-
var elemLang;
|
|
1445
|
-
do
|
|
1446
|
-
if (elemLang = documentIsHTML ? elem.lang : elem.getAttribute("xml:lang") || elem.getAttribute("lang")) {
|
|
1447
|
-
elemLang = elemLang.toLowerCase();
|
|
1448
|
-
return elemLang === lang || elemLang.indexOf(lang + "-") === 0;
|
|
1449
|
-
}
|
|
1450
|
-
while ((elem = elem.parentNode) && elem.nodeType === 1);
|
|
1451
|
-
return false;
|
|
1452
|
-
};
|
|
1453
|
-
}),
|
|
1454
|
-
target: function(elem) {
|
|
1455
|
-
var hash = window.location && window.location.hash;
|
|
1456
|
-
return hash && hash.slice(1) === elem.id;
|
|
1457
|
-
},
|
|
1458
|
-
root: function(elem) {
|
|
1459
|
-
return elem === documentElement$1;
|
|
1460
|
-
},
|
|
1461
|
-
focus: function(elem) {
|
|
1462
|
-
return elem === document$1.activeElement && document$1.hasFocus() && !!(elem.type || elem.href || ~elem.tabIndex);
|
|
1463
|
-
},
|
|
1464
|
-
enabled: createDisabledPseudo(false),
|
|
1465
|
-
disabled: createDisabledPseudo(true),
|
|
1466
|
-
checked: function(elem) {
|
|
1467
|
-
return nodeName(elem, "input") && !!elem.checked || nodeName(elem, "option") && !!elem.selected;
|
|
1468
|
-
},
|
|
1469
|
-
selected: function(elem) {
|
|
1470
|
-
if (isIE && elem.parentNode) elem.parentNode.selectedIndex;
|
|
1471
|
-
return elem.selected === true;
|
|
1472
|
-
},
|
|
1473
|
-
empty: function(elem) {
|
|
1474
|
-
for (elem = elem.firstChild; elem; elem = elem.nextSibling) if (elem.nodeType < 6) return false;
|
|
1475
|
-
return true;
|
|
1476
|
-
},
|
|
1477
|
-
parent: function(elem) {
|
|
1478
|
-
return !jQuery.expr.pseudos.empty(elem);
|
|
1479
|
-
},
|
|
1480
|
-
header: function(elem) {
|
|
1481
|
-
return rheader.test(elem.nodeName);
|
|
1482
|
-
},
|
|
1483
|
-
input: function(elem) {
|
|
1484
|
-
return rinputs.test(elem.nodeName);
|
|
1485
|
-
},
|
|
1486
|
-
button: function(elem) {
|
|
1487
|
-
return nodeName(elem, "input") && elem.type === "button" || nodeName(elem, "button");
|
|
1488
|
-
},
|
|
1489
|
-
text: function(elem) {
|
|
1490
|
-
return nodeName(elem, "input") && elem.type === "text";
|
|
1491
|
-
},
|
|
1492
|
-
first: createPositionalPseudo(function() {
|
|
1493
|
-
return [0];
|
|
1494
|
-
}),
|
|
1495
|
-
last: createPositionalPseudo(function(_matchIndexes, length) {
|
|
1496
|
-
return [length - 1];
|
|
1497
|
-
}),
|
|
1498
|
-
eq: createPositionalPseudo(function(_matchIndexes, length, argument) {
|
|
1499
|
-
return [argument < 0 ? argument + length : argument];
|
|
1500
|
-
}),
|
|
1501
|
-
even: createPositionalPseudo(function(matchIndexes, length) {
|
|
1502
|
-
var i = 0;
|
|
1503
|
-
for (; i < length; i += 2) matchIndexes.push(i);
|
|
1504
|
-
return matchIndexes;
|
|
1505
|
-
}),
|
|
1506
|
-
odd: createPositionalPseudo(function(matchIndexes, length) {
|
|
1507
|
-
var i = 1;
|
|
1508
|
-
for (; i < length; i += 2) matchIndexes.push(i);
|
|
1509
|
-
return matchIndexes;
|
|
1510
|
-
}),
|
|
1511
|
-
lt: createPositionalPseudo(function(matchIndexes, length, argument) {
|
|
1512
|
-
var i;
|
|
1513
|
-
if (argument < 0) i = argument + length;
|
|
1514
|
-
else if (argument > length) i = length;
|
|
1515
|
-
else i = argument;
|
|
1516
|
-
for (; --i >= 0;) matchIndexes.push(i);
|
|
1517
|
-
return matchIndexes;
|
|
1518
|
-
}),
|
|
1519
|
-
gt: createPositionalPseudo(function(matchIndexes, length, argument) {
|
|
1520
|
-
var i = argument < 0 ? argument + length : argument;
|
|
1521
|
-
for (; ++i < length;) matchIndexes.push(i);
|
|
1522
|
-
return matchIndexes;
|
|
1523
|
-
})
|
|
1524
|
-
}
|
|
1525
|
-
};
|
|
1526
|
-
jQuery.expr.pseudos.nth = jQuery.expr.pseudos.eq;
|
|
1527
|
-
for (i in {
|
|
1528
|
-
radio: true,
|
|
1529
|
-
checkbox: true,
|
|
1530
|
-
file: true,
|
|
1531
|
-
password: true,
|
|
1532
|
-
image: true
|
|
1533
|
-
}) jQuery.expr.pseudos[i] = createInputPseudo(i);
|
|
1534
|
-
for (i in {
|
|
1535
|
-
submit: true,
|
|
1536
|
-
reset: true
|
|
1537
|
-
}) jQuery.expr.pseudos[i] = createButtonPseudo(i);
|
|
1538
|
-
function setFilters() {}
|
|
1539
|
-
setFilters.prototype = jQuery.expr.filters = jQuery.expr.pseudos;
|
|
1540
|
-
jQuery.expr.setFilters = new setFilters();
|
|
1541
|
-
function addCombinator(matcher, combinator, base) {
|
|
1542
|
-
var dir = combinator.dir, skip = combinator.next, key = skip || dir, checkNonElements = base && key === "parentNode", doneName = done++;
|
|
1543
|
-
return combinator.first ? function(elem, context, xml) {
|
|
1544
|
-
while (elem = elem[dir]) if (elem.nodeType === 1 || checkNonElements) return matcher(elem, context, xml);
|
|
1545
|
-
return false;
|
|
1546
|
-
} : function(elem, context, xml) {
|
|
1547
|
-
var oldCache, outerCache, newCache = [dirruns, doneName];
|
|
1548
|
-
if (xml) {
|
|
1549
|
-
while (elem = elem[dir]) if (elem.nodeType === 1 || checkNonElements) {
|
|
1550
|
-
if (matcher(elem, context, xml)) return true;
|
|
1551
|
-
}
|
|
1552
|
-
} else while (elem = elem[dir]) if (elem.nodeType === 1 || checkNonElements) {
|
|
1553
|
-
outerCache = elem[jQuery.expando] || (elem[jQuery.expando] = {});
|
|
1554
|
-
if (skip && nodeName(elem, skip)) elem = elem[dir] || elem;
|
|
1555
|
-
else if ((oldCache = outerCache[key]) && oldCache[0] === dirruns && oldCache[1] === doneName) return newCache[2] = oldCache[2];
|
|
1556
|
-
else {
|
|
1557
|
-
outerCache[key] = newCache;
|
|
1558
|
-
if (newCache[2] = matcher(elem, context, xml)) return true;
|
|
1559
|
-
}
|
|
1560
|
-
}
|
|
1561
|
-
return false;
|
|
1562
|
-
};
|
|
1563
|
-
}
|
|
1564
|
-
function elementMatcher(matchers) {
|
|
1565
|
-
return matchers.length > 1 ? function(elem, context, xml) {
|
|
1566
|
-
var i = matchers.length;
|
|
1567
|
-
while (i--) if (!matchers[i](elem, context, xml)) return false;
|
|
1568
|
-
return true;
|
|
1569
|
-
} : matchers[0];
|
|
1570
|
-
}
|
|
1571
|
-
function multipleContexts(selector, contexts, results) {
|
|
1572
|
-
var i = 0, len = contexts.length;
|
|
1573
|
-
for (; i < len; i++) find(selector, contexts[i], results);
|
|
1574
|
-
return results;
|
|
1575
|
-
}
|
|
1576
|
-
function condense(unmatched, map, filter, context, xml) {
|
|
1577
|
-
var elem, newUnmatched = [], i = 0, len = unmatched.length, mapped = map != null;
|
|
1578
|
-
for (; i < len; i++) if (elem = unmatched[i]) {
|
|
1579
|
-
if (!filter || filter(elem, context, xml)) {
|
|
1580
|
-
newUnmatched.push(elem);
|
|
1581
|
-
if (mapped) map.push(i);
|
|
1582
|
-
}
|
|
1583
|
-
}
|
|
1584
|
-
return newUnmatched;
|
|
1585
|
-
}
|
|
1586
|
-
function setMatcher(preFilter, selector, matcher, postFilter, postFinder, postSelector) {
|
|
1587
|
-
if (postFilter && !postFilter[jQuery.expando]) postFilter = setMatcher(postFilter);
|
|
1588
|
-
if (postFinder && !postFinder[jQuery.expando]) postFinder = setMatcher(postFinder, postSelector);
|
|
1589
|
-
return markFunction(function(seed, results, context, xml) {
|
|
1590
|
-
var temp, i, elem, matcherOut, preMap = [], postMap = [], preexisting = results.length, elems = seed || multipleContexts(selector || "*", context.nodeType ? [context] : context, []), matcherIn = preFilter && (seed || !selector) ? condense(elems, preMap, preFilter, context, xml) : elems;
|
|
1591
|
-
if (matcher) {
|
|
1592
|
-
matcherOut = postFinder || (seed ? preFilter : preexisting || postFilter) ? [] : results;
|
|
1593
|
-
matcher(matcherIn, matcherOut, context, xml);
|
|
1594
|
-
} else matcherOut = matcherIn;
|
|
1595
|
-
if (postFilter) {
|
|
1596
|
-
temp = condense(matcherOut, postMap);
|
|
1597
|
-
postFilter(temp, [], context, xml);
|
|
1598
|
-
i = temp.length;
|
|
1599
|
-
while (i--) if (elem = temp[i]) matcherOut[postMap[i]] = !(matcherIn[postMap[i]] = elem);
|
|
1600
|
-
}
|
|
1601
|
-
if (seed) {
|
|
1602
|
-
if (postFinder || preFilter) {
|
|
1603
|
-
if (postFinder) {
|
|
1604
|
-
temp = [];
|
|
1605
|
-
i = matcherOut.length;
|
|
1606
|
-
while (i--) if (elem = matcherOut[i]) temp.push(matcherIn[i] = elem);
|
|
1607
|
-
postFinder(null, matcherOut = [], temp, xml);
|
|
1608
|
-
}
|
|
1609
|
-
i = matcherOut.length;
|
|
1610
|
-
while (i--) if ((elem = matcherOut[i]) && (temp = postFinder ? indexOf.call(seed, elem) : preMap[i]) > -1) seed[temp] = !(results[temp] = elem);
|
|
1611
|
-
}
|
|
1612
|
-
} else {
|
|
1613
|
-
matcherOut = condense(matcherOut === results ? matcherOut.splice(preexisting, matcherOut.length) : matcherOut);
|
|
1614
|
-
if (postFinder) postFinder(null, results, matcherOut, xml);
|
|
1615
|
-
else push.apply(results, matcherOut);
|
|
1616
|
-
}
|
|
1617
|
-
});
|
|
1618
|
-
}
|
|
1619
|
-
function matcherFromTokens(tokens) {
|
|
1620
|
-
var checkContext, matcher, j, len = tokens.length, leadingRelative = jQuery.expr.relative[tokens[0].type], implicitRelative = leadingRelative || jQuery.expr.relative[" "], i = leadingRelative ? 1 : 0, matchContext = addCombinator(function(elem) {
|
|
1621
|
-
return elem === checkContext;
|
|
1622
|
-
}, implicitRelative, true), matchAnyContext = addCombinator(function(elem) {
|
|
1623
|
-
return indexOf.call(checkContext, elem) > -1;
|
|
1624
|
-
}, implicitRelative, true), matchers = [function(elem, context, xml) {
|
|
1625
|
-
var ret = !leadingRelative && (xml || context != outermostContext) || ((checkContext = context).nodeType ? matchContext(elem, context, xml) : matchAnyContext(elem, context, xml));
|
|
1626
|
-
checkContext = null;
|
|
1627
|
-
return ret;
|
|
1628
|
-
}];
|
|
1629
|
-
for (; i < len; i++) if (matcher = jQuery.expr.relative[tokens[i].type]) matchers = [addCombinator(elementMatcher(matchers), matcher)];
|
|
1630
|
-
else {
|
|
1631
|
-
matcher = jQuery.expr.filter[tokens[i].type].apply(null, tokens[i].matches);
|
|
1632
|
-
if (matcher[jQuery.expando]) {
|
|
1633
|
-
j = ++i;
|
|
1634
|
-
for (; j < len; j++) if (jQuery.expr.relative[tokens[j].type]) break;
|
|
1635
|
-
return setMatcher(i > 1 && elementMatcher(matchers), i > 1 && toSelector(tokens.slice(0, i - 1).concat({ value: tokens[i - 2].type === " " ? "*" : "" })).replace(rtrimCSS, "$1"), matcher, i < j && matcherFromTokens(tokens.slice(i, j)), j < len && matcherFromTokens(tokens = tokens.slice(j)), j < len && toSelector(tokens));
|
|
1636
|
-
}
|
|
1637
|
-
matchers.push(matcher);
|
|
1638
|
-
}
|
|
1639
|
-
return elementMatcher(matchers);
|
|
1640
|
-
}
|
|
1641
|
-
function matcherFromGroupMatchers(elementMatchers, setMatchers) {
|
|
1642
|
-
var bySet = setMatchers.length > 0, byElement = elementMatchers.length > 0, superMatcher = function(seed, context, xml, results, outermost) {
|
|
1643
|
-
var elem, j, matcher, matchedCount = 0, i = "0", unmatched = seed && [], setMatched = [], contextBackup = outermostContext, elems = seed || byElement && jQuery.expr.find.TAG("*", outermost), dirrunsUnique = dirruns += contextBackup == null ? 1 : Math.random() || .1;
|
|
1644
|
-
if (outermost) outermostContext = context == document$1 || context || outermost;
|
|
1645
|
-
for (; (elem = elems[i]) != null; i++) {
|
|
1646
|
-
if (byElement && elem) {
|
|
1647
|
-
j = 0;
|
|
1648
|
-
if (!context && elem.ownerDocument != document$1) {
|
|
1649
|
-
setDocument(elem);
|
|
1650
|
-
xml = !documentIsHTML;
|
|
1651
|
-
}
|
|
1652
|
-
while (matcher = elementMatchers[j++]) if (matcher(elem, context || document$1, xml)) {
|
|
1653
|
-
push.call(results, elem);
|
|
1654
|
-
break;
|
|
1655
|
-
}
|
|
1656
|
-
if (outermost) dirruns = dirrunsUnique;
|
|
1657
|
-
}
|
|
1658
|
-
if (bySet) {
|
|
1659
|
-
if (elem = !matcher && elem) matchedCount--;
|
|
1660
|
-
if (seed) unmatched.push(elem);
|
|
1661
|
-
}
|
|
1662
|
-
}
|
|
1663
|
-
matchedCount += i;
|
|
1664
|
-
if (bySet && i !== matchedCount) {
|
|
1665
|
-
j = 0;
|
|
1666
|
-
while (matcher = setMatchers[j++]) matcher(unmatched, setMatched, context, xml);
|
|
1667
|
-
if (seed) {
|
|
1668
|
-
if (matchedCount > 0) {
|
|
1669
|
-
while (i--) if (!(unmatched[i] || setMatched[i])) setMatched[i] = pop.call(results);
|
|
1670
|
-
}
|
|
1671
|
-
setMatched = condense(setMatched);
|
|
1672
|
-
}
|
|
1673
|
-
push.apply(results, setMatched);
|
|
1674
|
-
if (outermost && !seed && setMatched.length > 0 && matchedCount + setMatchers.length > 1) jQuery.uniqueSort(results);
|
|
1675
|
-
}
|
|
1676
|
-
if (outermost) {
|
|
1677
|
-
dirruns = dirrunsUnique;
|
|
1678
|
-
outermostContext = contextBackup;
|
|
1679
|
-
}
|
|
1680
|
-
return unmatched;
|
|
1681
|
-
};
|
|
1682
|
-
return bySet ? markFunction(superMatcher) : superMatcher;
|
|
1683
|
-
}
|
|
1684
|
-
function compile(selector, match) {
|
|
1685
|
-
var i, setMatchers = [], elementMatchers = [], cached = compilerCache[selector + " "];
|
|
1686
|
-
if (!cached) {
|
|
1687
|
-
if (!match) match = tokenize(selector);
|
|
1688
|
-
i = match.length;
|
|
1689
|
-
while (i--) {
|
|
1690
|
-
cached = matcherFromTokens(match[i]);
|
|
1691
|
-
if (cached[jQuery.expando]) setMatchers.push(cached);
|
|
1692
|
-
else elementMatchers.push(cached);
|
|
1693
|
-
}
|
|
1694
|
-
cached = compilerCache(selector, matcherFromGroupMatchers(elementMatchers, setMatchers));
|
|
1695
|
-
cached.selector = selector;
|
|
1696
|
-
}
|
|
1697
|
-
return cached;
|
|
1698
|
-
}
|
|
1699
|
-
/**
|
|
1700
|
-
* A low-level selection function that works with jQuery's compiled
|
|
1701
|
-
* selector functions
|
|
1702
|
-
* @param {String|Function} selector A selector or a pre-compiled
|
|
1703
|
-
* selector function built with jQuery selector compile
|
|
1704
|
-
* @param {Element} context
|
|
1705
|
-
* @param {Array} [results]
|
|
1706
|
-
* @param {Array} [seed] A set of elements to match against
|
|
1707
|
-
*/
|
|
1708
|
-
function select(selector, context, results, seed) {
|
|
1709
|
-
var i, tokens, token, type, find, compiled = typeof selector === "function" && selector, match = !seed && tokenize(selector = compiled.selector || selector);
|
|
1710
|
-
results = results || [];
|
|
1711
|
-
if (match.length === 1) {
|
|
1712
|
-
tokens = match[0] = match[0].slice(0);
|
|
1713
|
-
if (tokens.length > 2 && (token = tokens[0]).type === "ID" && context.nodeType === 9 && documentIsHTML && jQuery.expr.relative[tokens[1].type]) {
|
|
1714
|
-
context = (jQuery.expr.find.ID(unescapeSelector(token.matches[0]), context) || [])[0];
|
|
1715
|
-
if (!context) return results;
|
|
1716
|
-
else if (compiled) context = context.parentNode;
|
|
1717
|
-
selector = selector.slice(tokens.shift().value.length);
|
|
1718
|
-
}
|
|
1719
|
-
i = matchExpr.needsContext.test(selector) ? 0 : tokens.length;
|
|
1720
|
-
while (i--) {
|
|
1721
|
-
token = tokens[i];
|
|
1722
|
-
if (jQuery.expr.relative[type = token.type]) break;
|
|
1723
|
-
if (find = jQuery.expr.find[type]) {
|
|
1724
|
-
if (seed = find(unescapeSelector(token.matches[0]), rsibling.test(tokens[0].type) && testContext(context.parentNode) || context)) {
|
|
1725
|
-
tokens.splice(i, 1);
|
|
1726
|
-
selector = seed.length && toSelector(tokens);
|
|
1727
|
-
if (!selector) {
|
|
1728
|
-
push.apply(results, seed);
|
|
1729
|
-
return results;
|
|
1730
|
-
}
|
|
1731
|
-
break;
|
|
1732
|
-
}
|
|
1733
|
-
}
|
|
1734
|
-
}
|
|
1735
|
-
}
|
|
1736
|
-
(compiled || compile(selector, match))(seed, context, !documentIsHTML, results, !context || rsibling.test(selector) && testContext(context.parentNode) || context);
|
|
1737
|
-
return results;
|
|
1738
|
-
}
|
|
1739
|
-
setDocument();
|
|
1740
|
-
jQuery.find = find;
|
|
1741
|
-
find.compile = compile;
|
|
1742
|
-
find.select = select;
|
|
1743
|
-
find.setDocument = setDocument;
|
|
1744
|
-
find.tokenize = tokenize;
|
|
1745
|
-
return jQuery;
|
|
1746
|
-
});
|
|
1747
|
-
|
|
1748
|
-
//#endregion
|
|
1749
|
-
//#region src/selector.ts
|
|
1750
|
-
/**
|
|
1751
|
-
* Check whether an element of interest matches a given selector.
|
|
1752
|
-
*
|
|
1753
|
-
* @param selector the selector of interest
|
|
1754
|
-
* @param elm an element within which to find matching elements
|
|
1755
|
-
* @returns whether the element matches the selector
|
|
1756
|
-
*/
|
|
1757
|
-
function matches(selector, elm) {
|
|
1758
|
-
try {
|
|
1759
|
-
return jquery_default.find(selector, void 0, void 0, [elm]).length > 0;
|
|
1760
|
-
} catch (e) {
|
|
1761
|
-
updateSelectorError(selector, e);
|
|
1762
|
-
throw e;
|
|
1763
|
-
}
|
|
1764
|
-
}
|
|
1765
|
-
/**
|
|
1766
|
-
* Select the first element that matches a given selector
|
|
1767
|
-
*
|
|
1768
|
-
* @param selector the selector of interest
|
|
1769
|
-
* @param elm the element within which to find a matching element
|
|
1770
|
-
* @returns the first matching element, or null if none is found
|
|
1771
|
-
*/
|
|
1772
|
-
function selectOne(selector, elm) {
|
|
1773
|
-
try {
|
|
1774
|
-
return jquery_default.find(selector, elm, void 0, void 0)[0] || null;
|
|
1775
|
-
} catch (e) {
|
|
1776
|
-
updateSelectorError(selector, e);
|
|
1777
|
-
throw e;
|
|
1778
|
-
}
|
|
1779
|
-
}
|
|
1780
|
-
/**
|
|
1781
|
-
* Select all elements that match a given selector
|
|
1782
|
-
*
|
|
1783
|
-
* @param selector the selector of interest
|
|
1784
|
-
* @param elm an element within which to find matching elements
|
|
1785
|
-
* @returns all matching elements
|
|
1786
|
-
*/
|
|
1787
|
-
function selectAll(selector, elm) {
|
|
1788
|
-
try {
|
|
1789
|
-
return jquery_default.find(selector, elm, void 0, void 0);
|
|
1790
|
-
} catch (e) {
|
|
1791
|
-
updateSelectorError(selector, e);
|
|
1792
|
-
throw e;
|
|
1793
|
-
}
|
|
1794
|
-
}
|
|
1795
|
-
/**
|
|
1796
|
-
* A manifest of selectors which are known to be problematic in jQuery. See
|
|
1797
|
-
* here to track implementation and support:
|
|
1798
|
-
* https://github.com/jquery/jquery/issues/5111
|
|
1799
|
-
*/
|
|
1800
|
-
const PROBLEMATIC_SELECTORS = [
|
|
1801
|
-
":scope",
|
|
1802
|
-
":where",
|
|
1803
|
-
":is"
|
|
1804
|
-
];
|
|
1805
|
-
/**
|
|
1806
|
-
* Given a selector and an error object thrown by jQuery, annotate the
|
|
1807
|
-
* error's message to add some context as to the probable reason for the error.
|
|
1808
|
-
* In particular, if the selector includes a selector which is known to be
|
|
1809
|
-
* unsupported in jQuery, then we know that was likely the cause of the
|
|
1810
|
-
* error.
|
|
1811
|
-
*
|
|
1812
|
-
* @param selector our selector of interest
|
|
1813
|
-
* @param e an error object that was thrown in the course of using jQuery
|
|
1814
|
-
*/
|
|
1815
|
-
function updateSelectorError(selector, e) {
|
|
1816
|
-
const selectorsPresent = PROBLEMATIC_SELECTORS.filter((s) => selector.includes(s));
|
|
1817
|
-
if (selectorsPresent.length > 0 && e.message) e.message = `At present jQuery does not support the ${humanReadableList(selectorsPresent)} ${selectorsPresent.length === 1 ? "selector" : "selectors"}.
|
|
1818
|
-
If you need this in your test, consider writing an end-to-end test instead.\n` + e.message;
|
|
1819
|
-
}
|
|
1820
|
-
/**
|
|
1821
|
-
* Format a list of strings in a 'human readable' way.
|
|
1822
|
-
*
|
|
1823
|
-
* - If one string (['string']), return 'string'
|
|
1824
|
-
* - If two strings (['a', 'b']), return 'a and b'
|
|
1825
|
-
* - If three or more (['a', 'b', 'c']), return 'a, b and c'
|
|
1826
|
-
*
|
|
1827
|
-
* @param items a list of strings to format
|
|
1828
|
-
* @returns a formatted string
|
|
1829
|
-
*/
|
|
1830
|
-
function humanReadableList(items) {
|
|
1831
|
-
if (items.length <= 1) return items.join("");
|
|
1832
|
-
return `${items.slice(0, items.length - 1).join(", ")} and ${items[items.length - 1]}`;
|
|
1833
|
-
}
|
|
1834
|
-
|
|
1835
848
|
//#endregion
|
|
1836
849
|
//#region src/serialize-node.ts
|
|
1837
850
|
/**
|
|
@@ -1897,11 +910,11 @@ const shadowRootTag = "mock:shadow-root";
|
|
|
1897
910
|
* @param node the node to serialize
|
|
1898
911
|
* @param opts options to control serialization behavior
|
|
1899
912
|
* @param output keeps track of the current line width and indentation
|
|
1900
|
-
* @
|
|
913
|
+
* @yields the serialized HTML in chunks
|
|
1901
914
|
*/
|
|
1902
915
|
function* streamToHtml(node, opts, output) {
|
|
1903
|
-
const isShadowRoot = node.nodeType ===
|
|
1904
|
-
if (node.nodeType ===
|
|
916
|
+
const isShadowRoot = node.nodeType === 11;
|
|
917
|
+
if (node.nodeType === 1 || isShadowRoot) {
|
|
1905
918
|
const tagName = isShadowRoot ? shadowRootTag : getTagName(node);
|
|
1906
919
|
if (tagName === "body") output.isWithinBody = true;
|
|
1907
920
|
const ignoreTag = opts.excludeTags != null && opts.excludeTags.includes(tagName);
|
|
@@ -1930,6 +943,19 @@ function* streamToHtml(node, opts, output) {
|
|
|
1930
943
|
yield " shadowrootdelegatesfocus";
|
|
1931
944
|
output.currentLineWidth += 25;
|
|
1932
945
|
}
|
|
946
|
+
if (node.clonable) {
|
|
947
|
+
yield " shadowrootclonable";
|
|
948
|
+
output.currentLineWidth += 19;
|
|
949
|
+
}
|
|
950
|
+
if (node.serializable) {
|
|
951
|
+
yield " shadowrootserializable";
|
|
952
|
+
output.currentLineWidth += 23;
|
|
953
|
+
}
|
|
954
|
+
if ("referenceTarget" in node && typeof node.referenceTarget === "string" && node.referenceTarget) {
|
|
955
|
+
const referenceTargetAttr = ` shadowrootreferencetarget="${escapeString(node.referenceTarget, true)}"`;
|
|
956
|
+
yield referenceTargetAttr;
|
|
957
|
+
output.currentLineWidth += referenceTargetAttr.length;
|
|
958
|
+
}
|
|
1933
959
|
}
|
|
1934
960
|
const attrsLength = node.attributes.length;
|
|
1935
961
|
const attributes = opts.prettyHtml && attrsLength > 1 ? cloneAttributes(node.attributes, true) : node.attributes;
|
|
@@ -1937,7 +963,7 @@ function* streamToHtml(node, opts, output) {
|
|
|
1937
963
|
const attr = attributes.item(i);
|
|
1938
964
|
const attrName = attr.name;
|
|
1939
965
|
if (attrName === "style") continue;
|
|
1940
|
-
if (tag === "template" && isShadowRoot && (attrName === "shadowrootmode" || attrName === "shadowrootdelegatesfocus")) continue;
|
|
966
|
+
if (tag === "template" && isShadowRoot && (attrName === "shadowrootmode" || attrName === "shadowrootdelegatesfocus" || attrName === "shadowrootreferencetarget" || attrName === "shadowrootcustomelementregistry")) continue;
|
|
1941
967
|
let attrValue = attr.value;
|
|
1942
968
|
if (opts.removeEmptyAttributes && attrValue === "" && REMOVE_EMPTY_ATTR.has(attrName)) continue;
|
|
1943
969
|
const attrNamespaceURI = attr.namespaceURI;
|
|
@@ -1951,14 +977,15 @@ function* streamToHtml(node, opts, output) {
|
|
|
1951
977
|
} else if (attrNamespaceURI === "http://www.w3.org/XML/1998/namespace") {
|
|
1952
978
|
yield " xml:" + attrLocalName;
|
|
1953
979
|
output.currentLineWidth += attrLocalName.length + 5;
|
|
1954
|
-
} else if (attrNamespaceURI === "http://www.w3.org/2000/xmlns/")
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
980
|
+
} else if (attrNamespaceURI === "http://www.w3.org/2000/xmlns/") {
|
|
981
|
+
if (attrLocalName !== "xmlns") {
|
|
982
|
+
yield " xmlns:" + attrLocalName;
|
|
983
|
+
output.currentLineWidth += attrLocalName.length + 7;
|
|
984
|
+
} else {
|
|
985
|
+
yield " " + attrLocalName;
|
|
986
|
+
output.currentLineWidth += attrLocalName.length + 1;
|
|
987
|
+
}
|
|
988
|
+
} else if (attrNamespaceURI === "http://www.w3.org/1999/xlink") {
|
|
1962
989
|
yield " xlink:" + attrLocalName;
|
|
1963
990
|
output.currentLineWidth += attrLocalName.length + 7;
|
|
1964
991
|
} else {
|
|
@@ -2000,7 +1027,7 @@ function* streamToHtml(node, opts, output) {
|
|
|
2000
1027
|
yield* streamToHtml(shadowRoot, opts, output);
|
|
2001
1028
|
output.indent = output.indent - (opts.indentSpaces ?? 0);
|
|
2002
1029
|
const childNodes = getChildNodes(node);
|
|
2003
|
-
if (opts.newLines && (childNodes.length === 0 || childNodes.length === 1 && childNodes[0].nodeType ===
|
|
1030
|
+
if (opts.newLines && (childNodes.length === 0 || childNodes.length === 1 && childNodes[0].nodeType === 3 && childNodes[0].nodeValue?.trim() === "")) {
|
|
2004
1031
|
yield "\n";
|
|
2005
1032
|
output.currentLineWidth = 0;
|
|
2006
1033
|
for (let i = 0; i < output.indent; i++) yield " ";
|
|
@@ -2011,34 +1038,24 @@ function* streamToHtml(node, opts, output) {
|
|
|
2011
1038
|
const tag = tagName === shadowRootTag ? "template" : tagName;
|
|
2012
1039
|
const childNodes = tagName === "template" ? node.content.childNodes : getChildNodes(node);
|
|
2013
1040
|
const childNodeLength = childNodes.length;
|
|
2014
|
-
if (childNodeLength > 0)
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
* will be parsing the shadow root of the component again.
|
|
2022
|
-
*
|
|
2023
|
-
* We know it is a hydrated Stencil component by checking if the `HYDRATE_ID`
|
|
2024
|
-
* is set on the node.
|
|
2025
|
-
*/
|
|
2026
|
-
const sId = node.attributes.getNamedItem(HYDRATE_ID);
|
|
2027
|
-
if (childNodes[i].nodeName.toLowerCase() === "template" && sId) {
|
|
2028
|
-
yield `\n${" ".repeat(output.indent)}<!--r.${sId.value}-->`;
|
|
2029
|
-
continue;
|
|
2030
|
-
}
|
|
2031
|
-
yield* streamToHtml(childNodes[i], opts, output);
|
|
2032
|
-
}
|
|
2033
|
-
if (ignoreTag === false) {
|
|
2034
|
-
if (opts.newLines && !isWithinWhitespaceSensitiveNode) {
|
|
2035
|
-
yield "\n";
|
|
2036
|
-
output.currentLineWidth = 0;
|
|
1041
|
+
if (childNodeLength > 0) {
|
|
1042
|
+
if (childNodeLength === 1 && childNodes[0].nodeType === 3 && (typeof childNodes[0].nodeValue !== "string" || childNodes[0].nodeValue.trim() === "")) {} else {
|
|
1043
|
+
const isWithinWhitespaceSensitiveNode = opts.newLines || (opts.indentSpaces ?? 0) > 0 ? isWithinWhitespaceSensitive(node) : false;
|
|
1044
|
+
if (!isWithinWhitespaceSensitiveNode && (opts.indentSpaces ?? 0) > 0 && ignoreTag === false) output.indent = output.indent + (opts.indentSpaces ?? 0);
|
|
1045
|
+
for (let i = 0; i < childNodeLength; i++) {
|
|
1046
|
+
if (childNodes[i].nodeName.toLowerCase() === "template" && node.attributes.getNamedItem("s-id")) continue;
|
|
1047
|
+
yield* streamToHtml(childNodes[i], opts, output);
|
|
2037
1048
|
}
|
|
2038
|
-
if (
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
1049
|
+
if (ignoreTag === false) {
|
|
1050
|
+
if (opts.newLines && !isWithinWhitespaceSensitiveNode) {
|
|
1051
|
+
yield "\n";
|
|
1052
|
+
output.currentLineWidth = 0;
|
|
1053
|
+
}
|
|
1054
|
+
if ((opts.indentSpaces ?? 0) > 0 && !isWithinWhitespaceSensitiveNode) {
|
|
1055
|
+
output.indent = output.indent - (opts.indentSpaces ?? 0);
|
|
1056
|
+
for (let i = 0; i < output.indent; i++) yield " ";
|
|
1057
|
+
output.currentLineWidth += output.indent;
|
|
1058
|
+
}
|
|
2042
1059
|
}
|
|
2043
1060
|
}
|
|
2044
1061
|
}
|
|
@@ -2053,7 +1070,7 @@ function* streamToHtml(node, opts, output) {
|
|
|
2053
1070
|
output.currentLineWidth = 0;
|
|
2054
1071
|
}
|
|
2055
1072
|
if (tagName === "body") output.isWithinBody = false;
|
|
2056
|
-
} else if (node.nodeType ===
|
|
1073
|
+
} else if (node.nodeType === 3) {
|
|
2057
1074
|
let textContent = node.nodeValue;
|
|
2058
1075
|
if (typeof textContent === "string") {
|
|
2059
1076
|
const trimmedTextContent = textContent.trim();
|
|
@@ -2080,7 +1097,7 @@ function* streamToHtml(node, opts, output) {
|
|
|
2080
1097
|
}
|
|
2081
1098
|
let textContentLength = textContent.length;
|
|
2082
1099
|
if (textContentLength > 0) {
|
|
2083
|
-
const parentTagName = node.parentNode != null && node.parentNode.nodeType ===
|
|
1100
|
+
const parentTagName = node.parentNode != null && node.parentNode.nodeType === 1 ? node.parentNode.nodeName : null;
|
|
2084
1101
|
if (typeof parentTagName === "string" && NON_ESCAPABLE_CONTENT.has(parentTagName)) {
|
|
2085
1102
|
if (isWithinWhitespaceSensitive(node)) yield textContent;
|
|
2086
1103
|
else {
|
|
@@ -2094,13 +1111,15 @@ function* streamToHtml(node, opts, output) {
|
|
|
2094
1111
|
} else {
|
|
2095
1112
|
if (isWithinWhitespaceSensitive(node)) output.currentLineWidth += textContentLength;
|
|
2096
1113
|
else {
|
|
2097
|
-
if (/\s/.test(textContent.charAt(0))) textContent = " " + textContent.
|
|
1114
|
+
if (/\s/.test(textContent.charAt(0))) textContent = " " + textContent.trimStart();
|
|
2098
1115
|
textContentLength = textContent.length;
|
|
2099
1116
|
if (textContentLength > 1) {
|
|
2100
|
-
if (/\s/.test(textContent.charAt(textContentLength - 1)))
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
1117
|
+
if (/\s/.test(textContent.charAt(textContentLength - 1))) {
|
|
1118
|
+
if (opts.approximateLineWidth && opts.approximateLineWidth > 0 && output.currentLineWidth + textContentLength > opts.approximateLineWidth) {
|
|
1119
|
+
textContent = textContent.trimEnd() + "\n";
|
|
1120
|
+
output.currentLineWidth = 0;
|
|
1121
|
+
} else textContent = textContent.trimEnd() + " ";
|
|
1122
|
+
}
|
|
2104
1123
|
}
|
|
2105
1124
|
output.currentLineWidth += textContentLength;
|
|
2106
1125
|
}
|
|
@@ -2109,9 +1128,9 @@ function* streamToHtml(node, opts, output) {
|
|
|
2109
1128
|
}
|
|
2110
1129
|
}
|
|
2111
1130
|
}
|
|
2112
|
-
} else if (node.nodeType ===
|
|
1131
|
+
} else if (node.nodeType === 8) {
|
|
2113
1132
|
const nodeValue = node.nodeValue;
|
|
2114
|
-
const isHydrateAnnotation = nodeValue?.startsWith(
|
|
1133
|
+
const isHydrateAnnotation = nodeValue?.startsWith("r.") || nodeValue?.startsWith("o.") || nodeValue?.startsWith("s.") || nodeValue?.startsWith("t.");
|
|
2115
1134
|
/**
|
|
2116
1135
|
* remove comments from stringified output if user set the `removeHtmlComments` e.g.
|
|
2117
1136
|
* in the `renderToString` function and we are no dealing with a hydrate annotation
|
|
@@ -2128,14 +1147,14 @@ function* streamToHtml(node, opts, output) {
|
|
|
2128
1147
|
}
|
|
2129
1148
|
yield "<!--" + nodeValue + "-->";
|
|
2130
1149
|
if (nodeValue) output.currentLineWidth += nodeValue.length + 7;
|
|
2131
|
-
} else if (node.nodeType ===
|
|
1150
|
+
} else if (node.nodeType === 10) yield "<!doctype html>";
|
|
2132
1151
|
}
|
|
2133
1152
|
const AMP_REGEX = /&/g;
|
|
2134
1153
|
const NBSP_REGEX = /\u00a0/g;
|
|
2135
1154
|
const DOUBLE_QUOTE_REGEX = /"/g;
|
|
2136
1155
|
const LT_REGEX = /</g;
|
|
2137
1156
|
const GT_REGEX = />/g;
|
|
2138
|
-
const CAN_REMOVE_ATTR_QUOTES = /^[^ \t\n\f\r"'
|
|
1157
|
+
const CAN_REMOVE_ATTR_QUOTES = /^[^ \t\n\f\r"'`=<>/\\-]+$/;
|
|
2139
1158
|
function getTagName(element) {
|
|
2140
1159
|
if (element.namespaceURI === "http://www.w3.org/1999/xhtml") return element.nodeName.toLowerCase();
|
|
2141
1160
|
else return element.nodeName;
|
|
@@ -2171,50 +1190,40 @@ function isWithinWhitespaceSensitive(node) {
|
|
|
2171
1190
|
function getChildNodes(node) {
|
|
2172
1191
|
return node.__childNodes || node.childNodes;
|
|
2173
1192
|
}
|
|
2174
|
-
const NON_ESCAPABLE_CONTENT = new Set([
|
|
1193
|
+
const NON_ESCAPABLE_CONTENT = /* @__PURE__ */ new Set([
|
|
2175
1194
|
"STYLE",
|
|
2176
1195
|
"SCRIPT",
|
|
2177
1196
|
"IFRAME",
|
|
2178
|
-
"NOSCRIPT"
|
|
2179
|
-
"XMP",
|
|
2180
|
-
"NOEMBED",
|
|
2181
|
-
"NOFRAMES",
|
|
2182
|
-
"PLAINTEXT"
|
|
1197
|
+
"NOSCRIPT"
|
|
2183
1198
|
]);
|
|
2184
1199
|
/**
|
|
2185
1200
|
* A list of whitespace sensitive tag names, such as `code`, `pre`, etc.
|
|
2186
1201
|
*/
|
|
2187
|
-
const WHITESPACE_SENSITIVE = new Set([
|
|
1202
|
+
const WHITESPACE_SENSITIVE = /* @__PURE__ */ new Set([
|
|
2188
1203
|
"CODE",
|
|
2189
1204
|
"OUTPUT",
|
|
2190
|
-
"PLAINTEXT",
|
|
2191
1205
|
"PRE",
|
|
2192
1206
|
"SCRIPT",
|
|
2193
1207
|
"TEMPLATE",
|
|
2194
1208
|
"TEXTAREA"
|
|
2195
1209
|
]);
|
|
2196
|
-
const EMPTY_ELEMENTS = new Set([
|
|
1210
|
+
const EMPTY_ELEMENTS = /* @__PURE__ */ new Set([
|
|
2197
1211
|
"area",
|
|
2198
1212
|
"base",
|
|
2199
|
-
"basefont",
|
|
2200
|
-
"bgsound",
|
|
2201
1213
|
"br",
|
|
2202
1214
|
"col",
|
|
2203
1215
|
"embed",
|
|
2204
|
-
"frame",
|
|
2205
1216
|
"hr",
|
|
2206
1217
|
"img",
|
|
2207
1218
|
"input",
|
|
2208
|
-
"keygen",
|
|
2209
1219
|
"link",
|
|
2210
1220
|
"meta",
|
|
2211
1221
|
"param",
|
|
2212
1222
|
"source",
|
|
2213
|
-
"trace",
|
|
2214
1223
|
"track",
|
|
2215
1224
|
"wbr"
|
|
2216
1225
|
]);
|
|
2217
|
-
const REMOVE_EMPTY_ATTR = new Set([
|
|
1226
|
+
const REMOVE_EMPTY_ATTR = /* @__PURE__ */ new Set([
|
|
2218
1227
|
"class",
|
|
2219
1228
|
"dir",
|
|
2220
1229
|
"id",
|
|
@@ -2222,52 +1231,37 @@ const REMOVE_EMPTY_ATTR = new Set([
|
|
|
2222
1231
|
"name",
|
|
2223
1232
|
"title"
|
|
2224
1233
|
]);
|
|
2225
|
-
const BOOLEAN_ATTR = new Set([
|
|
1234
|
+
const BOOLEAN_ATTR = /* @__PURE__ */ new Set([
|
|
2226
1235
|
"allowfullscreen",
|
|
2227
1236
|
"async",
|
|
2228
1237
|
"autofocus",
|
|
2229
1238
|
"autoplay",
|
|
2230
1239
|
"checked",
|
|
2231
|
-
"compact",
|
|
2232
1240
|
"controls",
|
|
2233
|
-
"declare",
|
|
2234
1241
|
"default",
|
|
2235
|
-
"defaultchecked",
|
|
2236
|
-
"defaultmuted",
|
|
2237
|
-
"defaultselected",
|
|
2238
1242
|
"defer",
|
|
2239
1243
|
"disabled",
|
|
2240
|
-
"enabled",
|
|
2241
1244
|
"formnovalidate",
|
|
2242
1245
|
"hidden",
|
|
2243
|
-
"indeterminate",
|
|
2244
1246
|
"inert",
|
|
2245
1247
|
"ismap",
|
|
2246
1248
|
"itemscope",
|
|
2247
1249
|
"loop",
|
|
2248
1250
|
"multiple",
|
|
2249
1251
|
"muted",
|
|
2250
|
-
"nohref",
|
|
2251
1252
|
"nomodule",
|
|
2252
|
-
"noresize",
|
|
2253
|
-
"noshade",
|
|
2254
1253
|
"novalidate",
|
|
2255
|
-
"nowrap",
|
|
2256
1254
|
"open",
|
|
2257
|
-
"pauseonexit",
|
|
2258
1255
|
"readonly",
|
|
2259
1256
|
"required",
|
|
2260
1257
|
"reversed",
|
|
2261
|
-
"scoped",
|
|
2262
|
-
"seamless",
|
|
2263
1258
|
"selected",
|
|
1259
|
+
"shadowrootclonable",
|
|
1260
|
+
"shadowrootcustomelementregistry",
|
|
2264
1261
|
"shadowrootdelegatesfocus",
|
|
2265
|
-
"
|
|
2266
|
-
"truespeed",
|
|
2267
|
-
"typemustmatch",
|
|
2268
|
-
"visible"
|
|
1262
|
+
"shadowrootserializable"
|
|
2269
1263
|
]);
|
|
2270
|
-
const STRUCTURE_ELEMENTS = new Set([
|
|
1264
|
+
const STRUCTURE_ELEMENTS = /* @__PURE__ */ new Set([
|
|
2271
1265
|
"html",
|
|
2272
1266
|
"body",
|
|
2273
1267
|
"head",
|
|
@@ -2279,10 +1273,11 @@ const STRUCTURE_ELEMENTS = new Set([
|
|
|
2279
1273
|
"script",
|
|
2280
1274
|
"style"
|
|
2281
1275
|
]);
|
|
2282
|
-
|
|
2283
1276
|
//#endregion
|
|
2284
1277
|
//#region src/token-list.ts
|
|
2285
1278
|
var MockTokenList = class {
|
|
1279
|
+
elm;
|
|
1280
|
+
attr;
|
|
2286
1281
|
constructor(elm, attr) {
|
|
2287
1282
|
this.elm = elm;
|
|
2288
1283
|
this.attr = attr;
|
|
@@ -2318,10 +1313,12 @@ var MockTokenList = class {
|
|
|
2318
1313
|
token = String(token);
|
|
2319
1314
|
return getItems(this.elm, this.attr).includes(token);
|
|
2320
1315
|
}
|
|
2321
|
-
toggle(token) {
|
|
1316
|
+
toggle(token, force) {
|
|
2322
1317
|
token = String(token);
|
|
2323
|
-
|
|
2324
|
-
|
|
1318
|
+
const shouldAdd = force === void 0 ? !this.contains(token) : !!force;
|
|
1319
|
+
if (shouldAdd) this.add(token);
|
|
1320
|
+
else this.remove(token);
|
|
1321
|
+
return shouldAdd;
|
|
2325
1322
|
}
|
|
2326
1323
|
get length() {
|
|
2327
1324
|
return getItems(this.elm, this.attr).length;
|
|
@@ -2342,7 +1339,6 @@ function getItems(elm, attr) {
|
|
|
2342
1339
|
if (typeof value === "string" && value.length > 0) return value.trim().split(" ").filter((c) => c.length > 0);
|
|
2343
1340
|
return [];
|
|
2344
1341
|
}
|
|
2345
|
-
|
|
2346
1342
|
//#endregion
|
|
2347
1343
|
//#region src/node.ts
|
|
2348
1344
|
var MockNode = class {
|
|
@@ -2366,7 +1362,7 @@ var MockNode = class {
|
|
|
2366
1362
|
this._childNodes = value;
|
|
2367
1363
|
}
|
|
2368
1364
|
appendChild(newNode) {
|
|
2369
|
-
if (newNode.nodeType ===
|
|
1365
|
+
if (newNode.nodeType === 11) {
|
|
2370
1366
|
const nodes = newNode.childNodes.slice();
|
|
2371
1367
|
for (const child of nodes) this.appendChild(child);
|
|
2372
1368
|
} else {
|
|
@@ -2387,29 +1383,67 @@ var MockNode = class {
|
|
|
2387
1383
|
const firstChild = this.firstChild;
|
|
2388
1384
|
items.forEach((item) => {
|
|
2389
1385
|
const isNode = typeof item === "object" && item !== null && "nodeType" in item;
|
|
2390
|
-
|
|
1386
|
+
this.insertBefore(isNode ? item : this.ownerDocument.createTextNode(String(item)), firstChild);
|
|
2391
1387
|
});
|
|
2392
1388
|
}
|
|
2393
1389
|
cloneNode(deep) {
|
|
2394
1390
|
throw new Error(`invalid node type to clone: ${this.nodeType}, deep: ${deep}`);
|
|
2395
1391
|
}
|
|
2396
|
-
compareDocumentPosition(
|
|
2397
|
-
|
|
1392
|
+
compareDocumentPosition(other) {
|
|
1393
|
+
const DOCUMENT_POSITION_DISCONNECTED = 1;
|
|
1394
|
+
const DOCUMENT_POSITION_PRECEDING = 2;
|
|
1395
|
+
const DOCUMENT_POSITION_FOLLOWING = 4;
|
|
1396
|
+
if (this === other) return 0;
|
|
1397
|
+
let thisRoot = this;
|
|
1398
|
+
while (thisRoot.parentNode) thisRoot = thisRoot.parentNode;
|
|
1399
|
+
let otherRoot = other;
|
|
1400
|
+
while (otherRoot.parentNode) otherRoot = otherRoot.parentNode;
|
|
1401
|
+
if (thisRoot !== otherRoot) return 3;
|
|
1402
|
+
let node = other;
|
|
1403
|
+
while (node) {
|
|
1404
|
+
if (node === this) return 10;
|
|
1405
|
+
node = node.parentNode;
|
|
1406
|
+
}
|
|
1407
|
+
node = this;
|
|
1408
|
+
while (node) {
|
|
1409
|
+
if (node === other) return 20;
|
|
1410
|
+
node = node.parentNode;
|
|
1411
|
+
}
|
|
1412
|
+
const getAncestors = (n) => {
|
|
1413
|
+
const ancestors = [];
|
|
1414
|
+
while (n) {
|
|
1415
|
+
ancestors.unshift(n);
|
|
1416
|
+
n = n.parentNode;
|
|
1417
|
+
}
|
|
1418
|
+
return ancestors;
|
|
1419
|
+
};
|
|
1420
|
+
const thisAncestors = getAncestors(this);
|
|
1421
|
+
const otherAncestors = getAncestors(other);
|
|
1422
|
+
let i = 0;
|
|
1423
|
+
while (thisAncestors[i] === otherAncestors[i]) i++;
|
|
1424
|
+
const commonParent = thisAncestors[i - 1];
|
|
1425
|
+
const thisChild = thisAncestors[i];
|
|
1426
|
+
const otherChild = otherAncestors[i];
|
|
1427
|
+
for (const child of commonParent.childNodes) {
|
|
1428
|
+
if (child === thisChild) return DOCUMENT_POSITION_FOLLOWING;
|
|
1429
|
+
if (child === otherChild) return DOCUMENT_POSITION_PRECEDING;
|
|
1430
|
+
}
|
|
1431
|
+
return DOCUMENT_POSITION_DISCONNECTED;
|
|
2398
1432
|
}
|
|
2399
1433
|
get firstChild() {
|
|
2400
1434
|
return this.childNodes[0] || null;
|
|
2401
1435
|
}
|
|
2402
1436
|
insertBefore(newNode, referenceNode) {
|
|
2403
|
-
if (newNode.nodeType ===
|
|
1437
|
+
if (newNode.nodeType === 11) for (let i = 0, ii = newNode.childNodes.length; i < ii; i++) insertBefore(this, newNode.childNodes[i], referenceNode);
|
|
2404
1438
|
else insertBefore(this, newNode, referenceNode);
|
|
2405
1439
|
return newNode;
|
|
2406
1440
|
}
|
|
2407
1441
|
get isConnected() {
|
|
2408
1442
|
let node = this;
|
|
2409
1443
|
while (node != null) {
|
|
2410
|
-
if (node.nodeType ===
|
|
1444
|
+
if (node.nodeType === 9) return true;
|
|
2411
1445
|
node = node.parentNode;
|
|
2412
|
-
if (node != null && node.nodeType ===
|
|
1446
|
+
if (node != null && node.nodeType === 11) node = node.host;
|
|
2413
1447
|
}
|
|
2414
1448
|
return false;
|
|
2415
1449
|
}
|
|
@@ -2421,8 +1455,9 @@ var MockNode = class {
|
|
|
2421
1455
|
}
|
|
2422
1456
|
get nextSibling() {
|
|
2423
1457
|
if (this.parentNode != null) {
|
|
2424
|
-
const
|
|
2425
|
-
|
|
1458
|
+
const selfIndex = this.parentNode.childNodes.indexOf(this);
|
|
1459
|
+
if (selfIndex === -1) return null;
|
|
1460
|
+
return this.parentNode.childNodes[selfIndex + 1] || null;
|
|
2426
1461
|
}
|
|
2427
1462
|
return null;
|
|
2428
1463
|
}
|
|
@@ -2455,7 +1490,7 @@ var MockNode = class {
|
|
|
2455
1490
|
const index = this.childNodes.indexOf(childNode);
|
|
2456
1491
|
if (index > -1) {
|
|
2457
1492
|
this.childNodes.splice(index, 1);
|
|
2458
|
-
if (this.nodeType ===
|
|
1493
|
+
if (this.nodeType === 1) {
|
|
2459
1494
|
const wasConnected = this.isConnected;
|
|
2460
1495
|
childNode.parentNode = null;
|
|
2461
1496
|
if (wasConnected === true) disconnectNode(childNode);
|
|
@@ -2464,7 +1499,10 @@ var MockNode = class {
|
|
|
2464
1499
|
return childNode;
|
|
2465
1500
|
}
|
|
2466
1501
|
remove() {
|
|
2467
|
-
if (this.parentNode != null)
|
|
1502
|
+
if (this.parentNode != null) {
|
|
1503
|
+
if (this.__parentNode) this.__parentNode.removeChild(this);
|
|
1504
|
+
else this.parentNode.removeChild(this);
|
|
1505
|
+
}
|
|
2468
1506
|
}
|
|
2469
1507
|
replaceChild(newChild, oldChild) {
|
|
2470
1508
|
if (oldChild.parentNode === this) {
|
|
@@ -2480,11 +1518,11 @@ var MockNode = class {
|
|
|
2480
1518
|
set textContent(value) {
|
|
2481
1519
|
this._nodeValue = String(value);
|
|
2482
1520
|
}
|
|
2483
|
-
addEventListener(type, handler) {
|
|
2484
|
-
addEventListener(this, type, handler);
|
|
1521
|
+
addEventListener(type, handler, options) {
|
|
1522
|
+
addEventListener(this, type, handler, options);
|
|
2485
1523
|
}
|
|
2486
|
-
removeEventListener(type, handler) {
|
|
2487
|
-
removeEventListener(this, type, handler);
|
|
1524
|
+
removeEventListener(type, handler, options) {
|
|
1525
|
+
removeEventListener(this, type, handler, options);
|
|
2488
1526
|
}
|
|
2489
1527
|
dispatchEvent(ev) {
|
|
2490
1528
|
return dispatchEvent(this, ev);
|
|
@@ -2507,6 +1545,21 @@ var MockNodeList = class {
|
|
|
2507
1545
|
this.length = length;
|
|
2508
1546
|
}
|
|
2509
1547
|
};
|
|
1548
|
+
/**
|
|
1549
|
+
* Just enough of `ElementInternals` for form-associated components to run without throwing.
|
|
1550
|
+
* There is no form, validation or accessibility tree to update, so the methods do nothing.
|
|
1551
|
+
*/
|
|
1552
|
+
var MockElementInternals = class {
|
|
1553
|
+
states = /* @__PURE__ */ new Set();
|
|
1554
|
+
setFormValue() {}
|
|
1555
|
+
setValidity() {}
|
|
1556
|
+
checkValidity() {
|
|
1557
|
+
return true;
|
|
1558
|
+
}
|
|
1559
|
+
reportValidity() {
|
|
1560
|
+
return true;
|
|
1561
|
+
}
|
|
1562
|
+
};
|
|
2510
1563
|
var MockElement = class extends MockNode {
|
|
2511
1564
|
__namespaceURI;
|
|
2512
1565
|
__localName;
|
|
@@ -2514,27 +1567,25 @@ var MockElement = class extends MockNode {
|
|
|
2514
1567
|
__shadowRoot;
|
|
2515
1568
|
__style;
|
|
2516
1569
|
attachInternals() {
|
|
2517
|
-
return new
|
|
2518
|
-
/**
|
|
2519
|
-
* only print warning when running in a test environment
|
|
2520
|
-
*/
|
|
2521
|
-
if ("process" in globalThis && globalThis.process.env.__STENCIL_SPEC_TESTS__) console.error(`NOTE: Property ${String(prop)} was accessed on ElementInternals, but this property is not implemented.
|
|
2522
|
-
Testing components with ElementInternals is fully supported in e2e tests.`);
|
|
2523
|
-
} });
|
|
1570
|
+
return new MockElementInternals();
|
|
2524
1571
|
}
|
|
2525
1572
|
constructor(ownerDocument, nodeName, namespaceURI = null) {
|
|
2526
|
-
super(ownerDocument,
|
|
1573
|
+
super(ownerDocument, 1, typeof nodeName === "string" ? nodeName : null, null);
|
|
2527
1574
|
this.__namespaceURI = namespaceURI;
|
|
2528
1575
|
this.__localName = typeof nodeName === "string" ? nodeName : null;
|
|
2529
1576
|
this.__shadowRoot = null;
|
|
2530
1577
|
this.__attributeMap = null;
|
|
2531
1578
|
}
|
|
2532
|
-
addEventListener(type, handler) {
|
|
2533
|
-
addEventListener(this, type, handler);
|
|
1579
|
+
addEventListener(type, handler, options) {
|
|
1580
|
+
addEventListener(this, type, handler, options);
|
|
2534
1581
|
}
|
|
2535
1582
|
attachShadow(_opts) {
|
|
2536
1583
|
const shadowRoot = this.ownerDocument.createDocumentFragment();
|
|
1584
|
+
shadowRoot.mode = _opts.mode ?? "open";
|
|
2537
1585
|
shadowRoot.delegatesFocus = _opts.delegatesFocus ?? false;
|
|
1586
|
+
shadowRoot.clonable = _opts.clonable ?? false;
|
|
1587
|
+
shadowRoot.serializable = _opts.serializable ?? false;
|
|
1588
|
+
shadowRoot.referenceTarget = _opts.referenceTarget ?? null;
|
|
2538
1589
|
this.shadowRoot = shadowRoot;
|
|
2539
1590
|
return shadowRoot;
|
|
2540
1591
|
}
|
|
@@ -2597,10 +1648,10 @@ var MockElement = class extends MockNode {
|
|
|
2597
1648
|
this.__attributeMap = attrs;
|
|
2598
1649
|
}
|
|
2599
1650
|
get children() {
|
|
2600
|
-
return this.childNodes.filter((n) => n.nodeType ===
|
|
1651
|
+
return this.childNodes.filter((n) => n.nodeType === 1);
|
|
2601
1652
|
}
|
|
2602
1653
|
get childElementCount() {
|
|
2603
|
-
return this.childNodes.filter((n) => n.nodeType ===
|
|
1654
|
+
return this.childNodes.filter((n) => n.nodeType === 1).length;
|
|
2604
1655
|
}
|
|
2605
1656
|
get className() {
|
|
2606
1657
|
return this.getAttributeNS(null, "class") || "";
|
|
@@ -2628,12 +1679,7 @@ var MockElement = class extends MockNode {
|
|
|
2628
1679
|
return null;
|
|
2629
1680
|
}
|
|
2630
1681
|
closest(selector) {
|
|
2631
|
-
|
|
2632
|
-
while (elm != null) {
|
|
2633
|
-
if (elm.matches(selector)) return elm;
|
|
2634
|
-
elm = elm.parentNode;
|
|
2635
|
-
}
|
|
2636
|
-
return null;
|
|
1682
|
+
return (this.ownerDocument ?? this)._getDOMSelector().closest(selector, this);
|
|
2637
1683
|
}
|
|
2638
1684
|
get dataset() {
|
|
2639
1685
|
return dataset(this);
|
|
@@ -2780,7 +1826,8 @@ var MockElement = class extends MockNode {
|
|
|
2780
1826
|
return this.hasAttributeNS(null, "hidden");
|
|
2781
1827
|
}
|
|
2782
1828
|
set hidden(isHidden) {
|
|
2783
|
-
if (isHidden ===
|
|
1829
|
+
if (isHidden === "until-found") this.setAttributeNS(null, "hidden", "until-found");
|
|
1830
|
+
else if (isHidden === true) this.setAttributeNS(null, "hidden", "");
|
|
2784
1831
|
else this.removeAttributeNS(null, "hidden");
|
|
2785
1832
|
}
|
|
2786
1833
|
get lang() {
|
|
@@ -2794,13 +1841,14 @@ var MockElement = class extends MockNode {
|
|
|
2794
1841
|
return children[children.length - 1] || null;
|
|
2795
1842
|
}
|
|
2796
1843
|
matches(selector) {
|
|
2797
|
-
return
|
|
1844
|
+
return (this.ownerDocument ?? this)._getDOMSelector().match(selector, this);
|
|
2798
1845
|
}
|
|
2799
1846
|
get nextElementSibling() {
|
|
2800
1847
|
const parentElement = this.parentElement;
|
|
2801
|
-
if (parentElement != null && (parentElement.nodeType ===
|
|
2802
|
-
const
|
|
2803
|
-
|
|
1848
|
+
if (parentElement != null && (parentElement.nodeType === 1 || parentElement.nodeType === 11 || parentElement.nodeType === 9)) {
|
|
1849
|
+
const selfIndex = parentElement.children.indexOf(this);
|
|
1850
|
+
if (selfIndex === -1) return null;
|
|
1851
|
+
return parentElement.children[selfIndex + 1] || null;
|
|
2804
1852
|
}
|
|
2805
1853
|
return null;
|
|
2806
1854
|
}
|
|
@@ -2813,9 +1861,10 @@ var MockElement = class extends MockNode {
|
|
|
2813
1861
|
}
|
|
2814
1862
|
get previousElementSibling() {
|
|
2815
1863
|
const parentElement = this.parentElement;
|
|
2816
|
-
if (parentElement != null && (parentElement.nodeType ===
|
|
2817
|
-
const
|
|
2818
|
-
|
|
1864
|
+
if (parentElement != null && (parentElement.nodeType === 1 || parentElement.nodeType === 11 || parentElement.nodeType === 9)) {
|
|
1865
|
+
const selfIndex = parentElement.children.indexOf(this);
|
|
1866
|
+
if (selfIndex === -1) return null;
|
|
1867
|
+
return parentElement.children[selfIndex - 1] || null;
|
|
2819
1868
|
}
|
|
2820
1869
|
return null;
|
|
2821
1870
|
}
|
|
@@ -2831,10 +1880,10 @@ var MockElement = class extends MockNode {
|
|
|
2831
1880
|
return results;
|
|
2832
1881
|
}
|
|
2833
1882
|
querySelector(selector) {
|
|
2834
|
-
return
|
|
1883
|
+
return (this.ownerDocument ?? this)._getDOMSelector().select(selector, this)[0] ?? null;
|
|
2835
1884
|
}
|
|
2836
1885
|
querySelectorAll(selector) {
|
|
2837
|
-
return
|
|
1886
|
+
return (this.ownerDocument ?? this)._getDOMSelector().select(selector, this);
|
|
2838
1887
|
}
|
|
2839
1888
|
removeAttribute(attrName) {
|
|
2840
1889
|
if (attrName === "style") delete this.__style;
|
|
@@ -2853,8 +1902,8 @@ var MockElement = class extends MockNode {
|
|
|
2853
1902
|
if (checkAttributeChanged(this) === true) attributeChanged(this, attrName, attr.value, null);
|
|
2854
1903
|
}
|
|
2855
1904
|
}
|
|
2856
|
-
removeEventListener(type, handler) {
|
|
2857
|
-
removeEventListener(this, type, handler);
|
|
1905
|
+
removeEventListener(type, handler, options) {
|
|
1906
|
+
removeEventListener(this, type, handler, options);
|
|
2858
1907
|
}
|
|
2859
1908
|
setAttribute(attrName, value) {
|
|
2860
1909
|
if (attrName === "style") this.style = value;
|
|
@@ -2862,12 +1911,13 @@ var MockElement = class extends MockNode {
|
|
|
2862
1911
|
const attributes = this.attributes;
|
|
2863
1912
|
let attr = attributes.getNamedItem(attrName);
|
|
2864
1913
|
const checkAttrChanged = checkAttributeChanged(this);
|
|
2865
|
-
if (attr != null)
|
|
2866
|
-
|
|
2867
|
-
|
|
2868
|
-
|
|
2869
|
-
|
|
2870
|
-
|
|
1914
|
+
if (attr != null) {
|
|
1915
|
+
if (checkAttrChanged === true) {
|
|
1916
|
+
const oldValue = attr.value;
|
|
1917
|
+
attr.value = value;
|
|
1918
|
+
if (oldValue !== attr.value) attributeChanged(this, attr.name, oldValue, attr.value);
|
|
1919
|
+
} else attr.value = value;
|
|
1920
|
+
} else {
|
|
2871
1921
|
if (attributes.caseInsensitive) attrName = attrName.toLowerCase();
|
|
2872
1922
|
attr = new MockAttr(attrName, value);
|
|
2873
1923
|
attributes.__items.push(attr);
|
|
@@ -2889,12 +1939,13 @@ var MockElement = class extends MockNode {
|
|
|
2889
1939
|
}
|
|
2890
1940
|
let attr = attributes.getNamedItemNS(namespaceURI, localName);
|
|
2891
1941
|
const checkAttrChanged = checkAttributeChanged(this);
|
|
2892
|
-
if (attr != null)
|
|
2893
|
-
|
|
2894
|
-
|
|
2895
|
-
|
|
2896
|
-
|
|
2897
|
-
|
|
1942
|
+
if (attr != null) {
|
|
1943
|
+
if (checkAttrChanged === true) {
|
|
1944
|
+
const oldValue = attr.value;
|
|
1945
|
+
attr.value = value;
|
|
1946
|
+
if (oldValue !== attr.value) attributeChanged(this, attr.name, oldValue, attr.value);
|
|
1947
|
+
} else attr.value = value;
|
|
1948
|
+
} else {
|
|
2898
1949
|
attr = new MockAttr(localName, value, namespaceURI, prefix);
|
|
2899
1950
|
attributes.__items.push(attr);
|
|
2900
1951
|
if (checkAttrChanged === true) attributeChanged(this, attr.name, null, attr.value);
|
|
@@ -3072,7 +2123,7 @@ function insertBefore(parentNode, newNode, referenceNode) {
|
|
|
3072
2123
|
var MockHTMLElement = class extends MockElement {
|
|
3073
2124
|
__namespaceURI = "http://www.w3.org/1999/xhtml";
|
|
3074
2125
|
constructor(ownerDocument, nodeName) {
|
|
3075
|
-
super(ownerDocument,
|
|
2126
|
+
super(ownerDocument, nodeName ? nodeName.toUpperCase() : null);
|
|
3076
2127
|
}
|
|
3077
2128
|
get tagName() {
|
|
3078
2129
|
return this.nodeName ?? "";
|
|
@@ -3104,7 +2155,7 @@ var MockHTMLElement = class extends MockElement {
|
|
|
3104
2155
|
};
|
|
3105
2156
|
var MockTextNode = class MockTextNode extends MockNode {
|
|
3106
2157
|
constructor(ownerDocument, text) {
|
|
3107
|
-
super(ownerDocument,
|
|
2158
|
+
super(ownerDocument, 3, "#text", text);
|
|
3108
2159
|
}
|
|
3109
2160
|
cloneNode(_deep) {
|
|
3110
2161
|
return new MockTextNode(null, this.nodeValue);
|
|
@@ -3126,7 +2177,7 @@ var MockTextNode = class MockTextNode extends MockNode {
|
|
|
3126
2177
|
const text = [];
|
|
3127
2178
|
for (let i = 0, ii = this.parentNode.childNodes.length; i < ii; i++) {
|
|
3128
2179
|
const childNode = this.parentNode.childNodes[i];
|
|
3129
|
-
if (childNode.nodeType ===
|
|
2180
|
+
if (childNode.nodeType === 3) text.push(childNode.nodeValue);
|
|
3130
2181
|
}
|
|
3131
2182
|
return text.join("");
|
|
3132
2183
|
}
|
|
@@ -3136,8 +2187,8 @@ var MockTextNode = class MockTextNode extends MockNode {
|
|
|
3136
2187
|
function getTextContent(childNodes, text) {
|
|
3137
2188
|
for (let i = 0, ii = childNodes.length; i < ii; i++) {
|
|
3138
2189
|
const childNode = childNodes[i];
|
|
3139
|
-
if (childNode.nodeType ===
|
|
3140
|
-
else if (childNode.nodeType ===
|
|
2190
|
+
if (childNode.nodeType === 3) text.push(childNode.nodeValue);
|
|
2191
|
+
else if (childNode.nodeType === 1) getTextContent(childNode.childNodes, text);
|
|
3141
2192
|
}
|
|
3142
2193
|
}
|
|
3143
2194
|
function setTextContent(elm, text) {
|
|
@@ -3178,12 +2229,11 @@ function unmarkAsDispatching(target, eventType) {
|
|
|
3178
2229
|
if (dispatchingEvents.size === 0) currentlyDispatching.delete(target);
|
|
3179
2230
|
}
|
|
3180
2231
|
}
|
|
3181
|
-
|
|
3182
2232
|
//#endregion
|
|
3183
2233
|
//#region src/comment-node.ts
|
|
3184
2234
|
var MockComment = class MockComment extends MockNode {
|
|
3185
2235
|
constructor(ownerDocument, data) {
|
|
3186
|
-
super(ownerDocument,
|
|
2236
|
+
super(ownerDocument, 8, "#comment", data);
|
|
3187
2237
|
}
|
|
3188
2238
|
cloneNode(_deep) {
|
|
3189
2239
|
return new MockComment(null, this.nodeValue);
|
|
@@ -3195,14 +2245,1136 @@ var MockComment = class MockComment extends MockNode {
|
|
|
3195
2245
|
this.nodeValue = text;
|
|
3196
2246
|
}
|
|
3197
2247
|
};
|
|
3198
|
-
|
|
3199
2248
|
//#endregion
|
|
3200
2249
|
//#region src/document-fragment.ts
|
|
2250
|
+
var import_nwsapi = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
2251
|
+
(function Export(global, factory) {
|
|
2252
|
+
"use strict";
|
|
2253
|
+
if (typeof module == "object" && typeof exports == "object") module.exports = factory;
|
|
2254
|
+
else if (typeof define == "function" && define["amd"]) define(factory);
|
|
2255
|
+
else {
|
|
2256
|
+
global.NW || (global.NW = {});
|
|
2257
|
+
global.NW.Dom = factory(global, Export);
|
|
2258
|
+
}
|
|
2259
|
+
})(exports, function Factory(global, Export) {
|
|
2260
|
+
var version = "nwsapi-2.2.24", doc = global.document, root = doc.documentElement, slice = Array.prototype.slice, HSP = "\\x20\\t", VSP = "\\r\\n\\f", WSP = "[" + HSP + VSP + "]", CFG = {
|
|
2261
|
+
operators: "[~*^$|]=|=",
|
|
2262
|
+
combinators: "[\\x20\\t>+~](?=[^>+~])"
|
|
2263
|
+
}, NOT = {
|
|
2264
|
+
double_enc: "(?=(?:[^\"]*[\"][^\"]*[\"])*[^\"]*$)",
|
|
2265
|
+
single_enc: "(?=(?:[^']*['][^']*['])*[^']*$)",
|
|
2266
|
+
parens_enc: "(?![^\\x28]*\\x29)",
|
|
2267
|
+
square_enc: "(?![^\\x5b]*\\x5d)"
|
|
2268
|
+
}, REX = {
|
|
2269
|
+
HasEscapes: RegExp("\\\\"),
|
|
2270
|
+
HexNumbers: RegExp("^[0-9a-fA-F]"),
|
|
2271
|
+
EscOrQuote: RegExp("^\\\\|[\\x22\\x27]"),
|
|
2272
|
+
RegExpChar: RegExp("(?!\\\\)[\\\\^$.,*+?()[\\]{}|\\/]", "g"),
|
|
2273
|
+
TrimSpaces: RegExp("^" + WSP + "+|" + WSP + "+$|" + VSP, "g"),
|
|
2274
|
+
SplitGroup: RegExp("(\\([^)]*\\)|\\[[^[]*\\]|\\\\.|[^,])+", "g"),
|
|
2275
|
+
CommaGroup: RegExp("(\\s*,\\s*)" + NOT.square_enc + NOT.parens_enc, "g"),
|
|
2276
|
+
FixEscapes: RegExp("\\\\([0-9a-fA-F]{1,6}" + WSP + "?|.)|([\\x22\\x27])", "g"),
|
|
2277
|
+
CombineWSP: RegExp("[\\n\\r\\f\\x20]+" + NOT.single_enc + NOT.double_enc, "g"),
|
|
2278
|
+
TabCharWSP: RegExp("(\\x20?\\t+\\x20?)" + NOT.single_enc + NOT.double_enc, "g"),
|
|
2279
|
+
PseudosWSP: RegExp("\\s+([-+])\\s+" + NOT.square_enc, "g")
|
|
2280
|
+
}, STD = {
|
|
2281
|
+
combinator: RegExp("\\s?([>+~])\\s?", "g"),
|
|
2282
|
+
apimethods: RegExp("^(?:\\w+|\\*)\\|"),
|
|
2283
|
+
namespaces: RegExp("(\\*|\\w+)\\|[\\w-]+")
|
|
2284
|
+
}, GROUPS = {
|
|
2285
|
+
linguistic: "(dir|lang)(?:\\x28\\s?([-\\w]{2,})\\s?(?:\\x29|$))",
|
|
2286
|
+
logicalsel: "(is|where|matches|not|has)(?:\\x28\\s?([^()]*|.*)\\s?(?:\\x29|$))",
|
|
2287
|
+
treestruct: "(nth(?:-last)?(?:-child|-of\\-type))(?:\\x28\\s?(even|odd|(?:[-+]?\\d*)(?:n\\s?[-+]?\\s?\\d*)?)\\s?(?:\\x29|$))",
|
|
2288
|
+
locationpc: "(any\\-link|link|visited|target|defined)\\b",
|
|
2289
|
+
useraction: "(hover|active|focus\\-within|focus\\-visible|focus)\\b",
|
|
2290
|
+
structural: "(scope|root|empty|(?:(?:first|last|only)(?:-child|\\-of\\-type)))\\b",
|
|
2291
|
+
inputstate: "(enabled|disabled|read\\-only|read\\-write|placeholder\\-shown|default)\\b",
|
|
2292
|
+
inputvalue: "(checked|indeterminate|required|optional|valid|invalid|in\\-range|out\\-of\\-range)\\b",
|
|
2293
|
+
rsrc_state: "(playing|paused|seeking|buffering|stalled|muted|volume-locked)\\b",
|
|
2294
|
+
disp_state: "(open|closed|modal|fullscreen|picture-in-picture)\\b",
|
|
2295
|
+
time_state: "(current|past|future)\\b",
|
|
2296
|
+
pseudo_nop: "(autofill|-webkit\\-autofill)\\b",
|
|
2297
|
+
pseudo_sng: "(after|before|first\\-letter|first\\-line)\\b",
|
|
2298
|
+
pseudo_dbl: ":(after|before|first\\-letter|first\\-line|selection|placeholder|-webkit-[-a-zA-Z0-9]{2,})\\b"
|
|
2299
|
+
}, Patterns = {
|
|
2300
|
+
treestruct: RegExp("^:(?:" + GROUPS.treestruct + ")(.*)", "i"),
|
|
2301
|
+
structural: RegExp("^:(?:" + GROUPS.structural + ")(.*)", "i"),
|
|
2302
|
+
linguistic: RegExp("^:(?:" + GROUPS.linguistic + ")(.*)", "i"),
|
|
2303
|
+
useraction: RegExp("^:(?:" + GROUPS.useraction + ")(.*)", "i"),
|
|
2304
|
+
inputstate: RegExp("^:(?:" + GROUPS.inputstate + ")(.*)", "i"),
|
|
2305
|
+
inputvalue: RegExp("^:(?:" + GROUPS.inputvalue + ")(.*)", "i"),
|
|
2306
|
+
rsrc_state: RegExp("^:(?:" + GROUPS.rsrc_state + ")(.*)", "i"),
|
|
2307
|
+
disp_state: RegExp("^:(?:" + GROUPS.disp_state + ")(.*)", "i"),
|
|
2308
|
+
time_state: RegExp("^:(?:" + GROUPS.time_state + ")(.*)", "i"),
|
|
2309
|
+
locationpc: RegExp("^:(?:" + GROUPS.locationpc + ")(.*)", "i"),
|
|
2310
|
+
logicalsel: RegExp("^:(?:" + GROUPS.logicalsel + ")(.*)", "i"),
|
|
2311
|
+
pseudo_nop: RegExp("^:(?:" + GROUPS.pseudo_nop + ")(.*)", "i"),
|
|
2312
|
+
pseudo_sng: RegExp("^:(?:" + GROUPS.pseudo_sng + ")(.*)", "i"),
|
|
2313
|
+
pseudo_dbl: RegExp("^:(?:" + GROUPS.pseudo_dbl + ")(.*)", "i"),
|
|
2314
|
+
children: RegExp("^" + WSP + "?\\>" + WSP + "?(.*)"),
|
|
2315
|
+
adjacent: RegExp("^" + WSP + "?\\+" + WSP + "?(.*)"),
|
|
2316
|
+
relative: RegExp("^" + WSP + "?\\~" + WSP + "?(.*)"),
|
|
2317
|
+
ancestor: RegExp("^" + WSP + "+(.*)"),
|
|
2318
|
+
universal: RegExp("^(\\*)(.*)"),
|
|
2319
|
+
namespace: RegExp("^(\\*|[\\w-]+)?\\|(.*)")
|
|
2320
|
+
}, RTL = RegExp("^(?:[\\u0627-\\u064a]|[\\u0591-\\u08ff]|[\\ufb1d-\\ufdfd]|[\\ufe70-\\ufefc])+$"), qsNotArgs = "Not enough arguments", qsInvalid = " is not a valid selector", reNthElem = RegExp("(:nth(?:-last)?-child)", "i"), reNthType = RegExp("(:nth(?:-last)?-of-type)", "i"), reOptimizer, reValidator, Config = {
|
|
2321
|
+
IDS_DUPES: true,
|
|
2322
|
+
FORGIVING: true,
|
|
2323
|
+
NODE_LIST: false,
|
|
2324
|
+
LOGERRORS: true,
|
|
2325
|
+
USR_EVENT: true,
|
|
2326
|
+
VERBOSITY: true
|
|
2327
|
+
}, NAMESPACE, QUIRKS_MODE, HTML_DOCUMENT, ATTR_STD_OPS = {
|
|
2328
|
+
"=": 1,
|
|
2329
|
+
"^=": 1,
|
|
2330
|
+
"$=": 1,
|
|
2331
|
+
"|=": 1,
|
|
2332
|
+
"*=": 1,
|
|
2333
|
+
"~=": 1
|
|
2334
|
+
}, HTML_TABLE = {
|
|
2335
|
+
"accept": 1,
|
|
2336
|
+
"accept-charset": 1,
|
|
2337
|
+
"align": 1,
|
|
2338
|
+
"alink": 1,
|
|
2339
|
+
"axis": 1,
|
|
2340
|
+
"bgcolor": 1,
|
|
2341
|
+
"charset": 1,
|
|
2342
|
+
"checked": 1,
|
|
2343
|
+
"clear": 1,
|
|
2344
|
+
"codetype": 1,
|
|
2345
|
+
"color": 1,
|
|
2346
|
+
"compact": 1,
|
|
2347
|
+
"declare": 1,
|
|
2348
|
+
"defer": 1,
|
|
2349
|
+
"dir": 1,
|
|
2350
|
+
"direction": 1,
|
|
2351
|
+
"disabled": 1,
|
|
2352
|
+
"enctype": 1,
|
|
2353
|
+
"face": 1,
|
|
2354
|
+
"frame": 1,
|
|
2355
|
+
"hreflang": 1,
|
|
2356
|
+
"http-equiv": 1,
|
|
2357
|
+
"lang": 1,
|
|
2358
|
+
"language": 1,
|
|
2359
|
+
"link": 1,
|
|
2360
|
+
"media": 1,
|
|
2361
|
+
"method": 1,
|
|
2362
|
+
"multiple": 1,
|
|
2363
|
+
"nohref": 1,
|
|
2364
|
+
"noresize": 1,
|
|
2365
|
+
"noshade": 1,
|
|
2366
|
+
"nowrap": 1,
|
|
2367
|
+
"readonly": 1,
|
|
2368
|
+
"rel": 1,
|
|
2369
|
+
"rev": 1,
|
|
2370
|
+
"rules": 1,
|
|
2371
|
+
"scope": 1,
|
|
2372
|
+
"scrolling": 1,
|
|
2373
|
+
"selected": 1,
|
|
2374
|
+
"shape": 1,
|
|
2375
|
+
"target": 1,
|
|
2376
|
+
"text": 1,
|
|
2377
|
+
"type": 1,
|
|
2378
|
+
"valign": 1,
|
|
2379
|
+
"valuetype": 1,
|
|
2380
|
+
"vlink": 1
|
|
2381
|
+
}, Combinators = {}, Selectors = {}, Operators = {
|
|
2382
|
+
"=": {
|
|
2383
|
+
p1: "^",
|
|
2384
|
+
p2: "$",
|
|
2385
|
+
p3: "true"
|
|
2386
|
+
},
|
|
2387
|
+
"^=": {
|
|
2388
|
+
p1: "^",
|
|
2389
|
+
p2: "",
|
|
2390
|
+
p3: "true"
|
|
2391
|
+
},
|
|
2392
|
+
"$=": {
|
|
2393
|
+
p1: "",
|
|
2394
|
+
p2: "$",
|
|
2395
|
+
p3: "true"
|
|
2396
|
+
},
|
|
2397
|
+
"*=": {
|
|
2398
|
+
p1: "",
|
|
2399
|
+
p2: "",
|
|
2400
|
+
p3: "true"
|
|
2401
|
+
},
|
|
2402
|
+
"|=": {
|
|
2403
|
+
p1: "^",
|
|
2404
|
+
p2: "(-|$)",
|
|
2405
|
+
p3: "true"
|
|
2406
|
+
},
|
|
2407
|
+
"~=": {
|
|
2408
|
+
p1: "(^|\\s)",
|
|
2409
|
+
p2: "(\\s|$)",
|
|
2410
|
+
p3: "true"
|
|
2411
|
+
}
|
|
2412
|
+
}, concatCall = function(nodes, callback) {
|
|
2413
|
+
var i = 0, l = nodes.length, list = Array(l);
|
|
2414
|
+
while (l > i) {
|
|
2415
|
+
if (false === callback(list[i] = nodes[i])) break;
|
|
2416
|
+
++i;
|
|
2417
|
+
}
|
|
2418
|
+
return list;
|
|
2419
|
+
}, concatList = function(list, nodes) {
|
|
2420
|
+
var i = -1, l = nodes.length;
|
|
2421
|
+
while (l--) list[list.length] = nodes[++i];
|
|
2422
|
+
return list;
|
|
2423
|
+
}, toNodeList = Config.NODE_LIST == false ? function(x) {
|
|
2424
|
+
return x;
|
|
2425
|
+
} : function() {
|
|
2426
|
+
var emptyNL = doc.createDocumentFragment().childNodes;
|
|
2427
|
+
return function(nodeArray) {
|
|
2428
|
+
if (isInstanceOf(nodeArray)) return nodeArray;
|
|
2429
|
+
if (!Array.isArray(nodeArray)) nodeArray = [nodeArray];
|
|
2430
|
+
var fakeNL = Object.create(emptyNL, {
|
|
2431
|
+
"length": {
|
|
2432
|
+
value: nodeArray.length,
|
|
2433
|
+
enumerable: false
|
|
2434
|
+
},
|
|
2435
|
+
"item": {
|
|
2436
|
+
"value": function(i) {
|
|
2437
|
+
return this[+i || 0];
|
|
2438
|
+
},
|
|
2439
|
+
enumerable: false
|
|
2440
|
+
}
|
|
2441
|
+
});
|
|
2442
|
+
nodeArray.forEach(function(v, i) {
|
|
2443
|
+
fakeNL[i] = v;
|
|
2444
|
+
});
|
|
2445
|
+
return fakeNL;
|
|
2446
|
+
};
|
|
2447
|
+
}(), isInstanceOf = function(nodes) {
|
|
2448
|
+
return nodes instanceof global.NodeList;
|
|
2449
|
+
}, documentOrder = function(a, b) {
|
|
2450
|
+
if (!hasDupes && a === b) {
|
|
2451
|
+
hasDupes = true;
|
|
2452
|
+
return 0;
|
|
2453
|
+
}
|
|
2454
|
+
return a.compareDocumentPosition(b) & 4 ? -1 : 1;
|
|
2455
|
+
}, hasDupes = false, unique = function(nodes) {
|
|
2456
|
+
var i = 0, j = -1, l = nodes.length + 1, list = [];
|
|
2457
|
+
while (--l) {
|
|
2458
|
+
if (nodes[i++] === nodes[i]) continue;
|
|
2459
|
+
list[++j] = nodes[i - 1];
|
|
2460
|
+
}
|
|
2461
|
+
hasDupes = false;
|
|
2462
|
+
return list;
|
|
2463
|
+
}, switchContext = function(context, force) {
|
|
2464
|
+
var oldDoc = doc;
|
|
2465
|
+
doc = context.ownerDocument || context;
|
|
2466
|
+
if (force || oldDoc !== doc) {
|
|
2467
|
+
root = doc.documentElement;
|
|
2468
|
+
HTML_DOCUMENT = isHTML(doc);
|
|
2469
|
+
QUIRKS_MODE = HTML_DOCUMENT && doc.compatMode.indexOf("CSS") < 0;
|
|
2470
|
+
NAMESPACE = root && root.namespaceURI;
|
|
2471
|
+
Snapshot.doc = doc;
|
|
2472
|
+
Snapshot.root = root;
|
|
2473
|
+
}
|
|
2474
|
+
return Snapshot.from = context;
|
|
2475
|
+
}, codePointToUTF16 = function(codePoint) {
|
|
2476
|
+
if (codePoint < 1 || codePoint > 1114111 || codePoint > 55295 && codePoint < 57344) return "\\ufffd";
|
|
2477
|
+
if (codePoint < 65536) {
|
|
2478
|
+
var lowHex = "000" + codePoint.toString(16);
|
|
2479
|
+
return "\\u" + lowHex.substr(lowHex.length - 4);
|
|
2480
|
+
}
|
|
2481
|
+
return "\\u" + ((codePoint - 65536 >> 10) + 55296).toString(16) + "\\u" + ((codePoint - 65536) % 1024 + 56320).toString(16);
|
|
2482
|
+
}, stringFromCodePoint = function(codePoint) {
|
|
2483
|
+
if (codePoint < 1 || codePoint > 1114111 || codePoint > 55295 && codePoint < 57344) return "�";
|
|
2484
|
+
if (codePoint < 65536) return String.fromCharCode(codePoint);
|
|
2485
|
+
return String.fromCodePoint ? String.fromCodePoint(codePoint) : String.fromCharCode((codePoint - 65536 >> 10) + 55296, (codePoint - 65536) % 1024 + 56320);
|
|
2486
|
+
}, escapeIdentifier = function(str) {
|
|
2487
|
+
return REX.HasEscapes.test(str) ? str.replace(REX.FixEscapes, function(substring, p1, p2) {
|
|
2488
|
+
return p2 ? "\\" + p2 : REX.HexNumbers.test(p1) ? codePointToUTF16(parseInt(p1, 16)) : REX.EscOrQuote.test(p1) ? substring : p1;
|
|
2489
|
+
}) : str;
|
|
2490
|
+
}, unescapeIdentifier = function(str) {
|
|
2491
|
+
return REX.HasEscapes.test(str) ? str.replace(REX.FixEscapes, function(substring, p1, p2) {
|
|
2492
|
+
return p2 ? p2 : REX.HexNumbers.test(p1) ? stringFromCodePoint(parseInt(p1, 16)) : REX.EscOrQuote.test(p1) ? substring : p1;
|
|
2493
|
+
}) : str;
|
|
2494
|
+
}, method = {
|
|
2495
|
+
"#": "getElementById",
|
|
2496
|
+
"*": "getElementsByTagName",
|
|
2497
|
+
"|": "getElementsByTagNameNS",
|
|
2498
|
+
".": "getElementsByClassName"
|
|
2499
|
+
}, compat = {
|
|
2500
|
+
"#": (c, n) => (e, f) => byId(n, c),
|
|
2501
|
+
"*": (c, n) => (e, f) => byTag(n, c),
|
|
2502
|
+
"|": (c, n) => (e, f) => byTagNS(n, c),
|
|
2503
|
+
".": (c, n) => (e, f) => byClass(n, c)
|
|
2504
|
+
}, byIdRaw = function(id, context) {
|
|
2505
|
+
var node = context, nodes = [], next = node.firstElementChild;
|
|
2506
|
+
while (node = next) {
|
|
2507
|
+
node.id == id && (nodes[nodes.length] = node);
|
|
2508
|
+
if (next = node.firstElementChild || node.nextElementSibling) continue;
|
|
2509
|
+
while (!next && (node = node.parentElement) && node !== context) next = node.nextElementSibling;
|
|
2510
|
+
}
|
|
2511
|
+
return nodes;
|
|
2512
|
+
}, byId = function(id, context) {
|
|
2513
|
+
var e, i, l, nodes, api = method["#"];
|
|
2514
|
+
if (Config.IDS_DUPES === false) {
|
|
2515
|
+
if (api in context) return (e = context[api](id)) ? [e] : none;
|
|
2516
|
+
} else if ("all" in context) {
|
|
2517
|
+
if (e = context.all[id]) {
|
|
2518
|
+
if (e.nodeType == 1) return e.getAttribute("id") != id ? [] : [e];
|
|
2519
|
+
else if (id == "length") return (e = context[api](id)) ? [e] : none;
|
|
2520
|
+
for (i = 0, l = e.length, nodes = []; l > i; ++i) if (e[i].id == id) nodes[nodes.length] = e[i];
|
|
2521
|
+
return nodes && nodes.length ? nodes : [nodes];
|
|
2522
|
+
} else return none;
|
|
2523
|
+
}
|
|
2524
|
+
return byIdRaw(id, context);
|
|
2525
|
+
}, byTagNS = function(context, tag) {
|
|
2526
|
+
return byTag(tag, context);
|
|
2527
|
+
}, byTag = function(tag, context) {
|
|
2528
|
+
var e, nodes, api = method["*"];
|
|
2529
|
+
if (api in context) return slice.call(context[api](tag));
|
|
2530
|
+
else {
|
|
2531
|
+
tag = tag.toLowerCase();
|
|
2532
|
+
if (e = context.firstElementChild) {
|
|
2533
|
+
if (!(e.nextElementSibling || tag == "*" || e.localName == tag)) return slice.call(e[api](tag));
|
|
2534
|
+
else {
|
|
2535
|
+
nodes = [];
|
|
2536
|
+
do {
|
|
2537
|
+
if (tag == "*" || e.localName == tag) nodes[nodes.length] = e;
|
|
2538
|
+
concatList(nodes, e[api](tag));
|
|
2539
|
+
} while (e = e.nextElementSibling);
|
|
2540
|
+
}
|
|
2541
|
+
} else nodes = none;
|
|
2542
|
+
}
|
|
2543
|
+
return !Config.NODE_LIST ? nodes : isInstanceOf(nodes) ? nodes : toNodeList(nodes);
|
|
2544
|
+
}, byClass = function(cls, context) {
|
|
2545
|
+
var e, nodes, api = method["."], reCls;
|
|
2546
|
+
if (api in context) return slice.call(context[api](cls));
|
|
2547
|
+
else if (e = context.firstElementChild) {
|
|
2548
|
+
reCls = RegExp("(^|\\s)" + cls + "(\\s|$)", QUIRKS_MODE ? "i" : "");
|
|
2549
|
+
if (!(e.nextElementSibling || reCls.test(e.className))) return slice.call(e[api](cls));
|
|
2550
|
+
else {
|
|
2551
|
+
nodes = [];
|
|
2552
|
+
do {
|
|
2553
|
+
if (reCls.test(e.className)) nodes[nodes.length] = e;
|
|
2554
|
+
concatList(nodes, e[api](cls));
|
|
2555
|
+
} while (e = e.nextElementSibling);
|
|
2556
|
+
}
|
|
2557
|
+
} else nodes = none;
|
|
2558
|
+
return !Config.NODE_LIST ? nodes : isInstanceof(nodes) ? nodes : toNodeList(nodes);
|
|
2559
|
+
}, hasAttributeNS = function(e, name) {
|
|
2560
|
+
var i, l, attr = e.getAttributeNames();
|
|
2561
|
+
name = RegExp(":?" + name + "$", HTML_DOCUMENT ? "i" : "");
|
|
2562
|
+
for (i = 0, l = attr.length; l > i; ++i) if (name.test(attr[i])) return true;
|
|
2563
|
+
return false;
|
|
2564
|
+
}, nthElement = (function() {
|
|
2565
|
+
var idx = 0, len = 0, set = 0, parent = void 0, parents = Array(), nodes = Array();
|
|
2566
|
+
return function(element, dir) {
|
|
2567
|
+
if (dir == 2) {
|
|
2568
|
+
idx = 0;
|
|
2569
|
+
len = 0;
|
|
2570
|
+
set = 0;
|
|
2571
|
+
nodes.length = 0;
|
|
2572
|
+
parents.length = 0;
|
|
2573
|
+
parent = void 0;
|
|
2574
|
+
return -1;
|
|
2575
|
+
}
|
|
2576
|
+
var e, i, j, k, l;
|
|
2577
|
+
if (parent === element.parentElement) {
|
|
2578
|
+
i = set;
|
|
2579
|
+
j = idx;
|
|
2580
|
+
l = len;
|
|
2581
|
+
} else {
|
|
2582
|
+
l = parents.length;
|
|
2583
|
+
parent = element.parentElement;
|
|
2584
|
+
for (i = -1, j = 0, k = l - 1; l > j; ++j, --k) {
|
|
2585
|
+
if (parents[j] === parent) {
|
|
2586
|
+
i = j;
|
|
2587
|
+
break;
|
|
2588
|
+
}
|
|
2589
|
+
if (parents[k] === parent) {
|
|
2590
|
+
i = k;
|
|
2591
|
+
break;
|
|
2592
|
+
}
|
|
2593
|
+
}
|
|
2594
|
+
if (i < 0) {
|
|
2595
|
+
parents[i = l] = parent;
|
|
2596
|
+
l = 0;
|
|
2597
|
+
nodes[i] = Array();
|
|
2598
|
+
e = parent && parent.firstElementChild || element;
|
|
2599
|
+
while (e) {
|
|
2600
|
+
nodes[i][l] = e;
|
|
2601
|
+
if (e === element) j = l;
|
|
2602
|
+
e = e.nextElementSibling;
|
|
2603
|
+
++l;
|
|
2604
|
+
}
|
|
2605
|
+
set = i;
|
|
2606
|
+
idx = 0;
|
|
2607
|
+
len = l;
|
|
2608
|
+
if (l < 2) return l;
|
|
2609
|
+
} else {
|
|
2610
|
+
l = nodes[i].length;
|
|
2611
|
+
set = i;
|
|
2612
|
+
}
|
|
2613
|
+
}
|
|
2614
|
+
if (element !== nodes[i][j] && element !== nodes[i][j = 0]) for (j = 0, e = nodes[i], k = l - 1; l > j; ++j, --k) {
|
|
2615
|
+
if (e[j] === element) break;
|
|
2616
|
+
if (e[k] === element) {
|
|
2617
|
+
j = k;
|
|
2618
|
+
break;
|
|
2619
|
+
}
|
|
2620
|
+
}
|
|
2621
|
+
idx = j + 1;
|
|
2622
|
+
len = l;
|
|
2623
|
+
return dir ? l - j : idx;
|
|
2624
|
+
};
|
|
2625
|
+
})(), nthOfType = (function() {
|
|
2626
|
+
var idx = 0, len = 0, set = 0, parent = void 0, parents = Array(), nodes = Array();
|
|
2627
|
+
return function(element, dir) {
|
|
2628
|
+
if (dir == 2) {
|
|
2629
|
+
idx = 0;
|
|
2630
|
+
len = 0;
|
|
2631
|
+
set = 0;
|
|
2632
|
+
nodes.length = 0;
|
|
2633
|
+
parents.length = 0;
|
|
2634
|
+
parent = void 0;
|
|
2635
|
+
return -1;
|
|
2636
|
+
}
|
|
2637
|
+
var e, i, j, k, l, name = element.localName;
|
|
2638
|
+
if (nodes[set] && nodes[set][name] && parent === element.parentElement) {
|
|
2639
|
+
i = set;
|
|
2640
|
+
j = idx;
|
|
2641
|
+
l = len;
|
|
2642
|
+
} else {
|
|
2643
|
+
l = parents.length;
|
|
2644
|
+
parent = element.parentElement;
|
|
2645
|
+
for (i = -1, j = 0, k = l - 1; l > j; ++j, --k) {
|
|
2646
|
+
if (parents[j] === parent) {
|
|
2647
|
+
i = j;
|
|
2648
|
+
break;
|
|
2649
|
+
}
|
|
2650
|
+
if (parents[k] === parent) {
|
|
2651
|
+
i = k;
|
|
2652
|
+
break;
|
|
2653
|
+
}
|
|
2654
|
+
}
|
|
2655
|
+
if (i < 0 || !nodes[i][name]) {
|
|
2656
|
+
parents[i = l] = parent;
|
|
2657
|
+
nodes[i] || (nodes[i] = Object());
|
|
2658
|
+
l = 0;
|
|
2659
|
+
nodes[i][name] = Array();
|
|
2660
|
+
e = parent && parent.firstElementChild || element;
|
|
2661
|
+
while (e) {
|
|
2662
|
+
if (e === element) j = l;
|
|
2663
|
+
if (e.localName == name) {
|
|
2664
|
+
nodes[i][name][l] = e;
|
|
2665
|
+
++l;
|
|
2666
|
+
}
|
|
2667
|
+
e = e.nextElementSibling;
|
|
2668
|
+
}
|
|
2669
|
+
set = i;
|
|
2670
|
+
idx = j;
|
|
2671
|
+
len = l;
|
|
2672
|
+
if (l < 2) return l;
|
|
2673
|
+
} else {
|
|
2674
|
+
l = nodes[i][name].length;
|
|
2675
|
+
set = i;
|
|
2676
|
+
}
|
|
2677
|
+
}
|
|
2678
|
+
if (element !== nodes[i][name][j] && element !== nodes[i][name][j = 0]) for (j = 0, e = nodes[i][name], k = l - 1; l > j; ++j, --k) {
|
|
2679
|
+
if (e[j] === element) break;
|
|
2680
|
+
if (e[k] === element) {
|
|
2681
|
+
j = k;
|
|
2682
|
+
break;
|
|
2683
|
+
}
|
|
2684
|
+
}
|
|
2685
|
+
idx = j + 1;
|
|
2686
|
+
len = l;
|
|
2687
|
+
return dir ? l - j : idx;
|
|
2688
|
+
};
|
|
2689
|
+
})(), isHTML = function(node) {
|
|
2690
|
+
var doc = node.ownerDocument || node;
|
|
2691
|
+
return doc.nodeType == 9 && "contentType" in doc ? doc.contentType.indexOf("/html") > 0 : doc.createElement("DiV").localName == "div";
|
|
2692
|
+
}, isFocusable = function(node) {
|
|
2693
|
+
var doc = node.ownerDocument;
|
|
2694
|
+
if (node.contentDocument && node.localName == "iframe") return false;
|
|
2695
|
+
if (doc.hasFocus() && node === doc.activeElement) {
|
|
2696
|
+
if (node.type || node.href || typeof node.tabIndex == "number") return node;
|
|
2697
|
+
}
|
|
2698
|
+
return false;
|
|
2699
|
+
}, isContentEditable = function(node) {
|
|
2700
|
+
var attrValue = "inherit";
|
|
2701
|
+
if (node.hasAttribute("contenteditable")) attrValue = node.getAttribute("contenteditable");
|
|
2702
|
+
switch (attrValue) {
|
|
2703
|
+
case "":
|
|
2704
|
+
case "plaintext-only":
|
|
2705
|
+
case "true": return true;
|
|
2706
|
+
case "false": return false;
|
|
2707
|
+
default:
|
|
2708
|
+
if (node.parentNode && node.parentNode.nodeType === 1) return isContentEditable(node.parentNode);
|
|
2709
|
+
return false;
|
|
2710
|
+
}
|
|
2711
|
+
}, configure = function(option, clear) {
|
|
2712
|
+
if (typeof option == "string") return !!Config[option];
|
|
2713
|
+
if (typeof option != "object") return Config;
|
|
2714
|
+
for (var i in option) Config[i] = !!option[i];
|
|
2715
|
+
if (clear) {
|
|
2716
|
+
matchResolvers = {};
|
|
2717
|
+
selectResolvers = {};
|
|
2718
|
+
}
|
|
2719
|
+
setIdentifierSyntax();
|
|
2720
|
+
return true;
|
|
2721
|
+
}, emit = function(message, proto) {
|
|
2722
|
+
var err;
|
|
2723
|
+
if (Config.VERBOSITY) {
|
|
2724
|
+
if (proto) err = new proto(message);
|
|
2725
|
+
else err = new global.DOMException(message, "SyntaxError");
|
|
2726
|
+
throw err;
|
|
2727
|
+
}
|
|
2728
|
+
if (Config.LOGERRORS && console && console.log) console.log(message);
|
|
2729
|
+
}, initialize = function(doc) {
|
|
2730
|
+
setIdentifierSyntax();
|
|
2731
|
+
lastContext = switchContext(doc, true);
|
|
2732
|
+
}, setIdentifierSyntax = function() {
|
|
2733
|
+
var identifier = "(?:-|--|\\\\[0-9a-fA-F]{1,6}[" + HSP + "]?|\\\\[^" + VSP + "]|[^\\x00-\\x9f]|[\\w-])+", pseudonames = "[-\\w]+", pseudoparms = "(?:[-+]?\\d*)(?:n\\s?[-+]?\\s?\\d*)", attrparser = identifier + "|\"[^\"\\\\]*(?:\\\\.[^\"\\\\]*)*(?:\"|$)|'[^'\\\\]*(?:\\\\.[^'\\\\]*)*(?:'|$)", attrvalues = "([\\x22\\x27]?)((?!\\3)*|(?:\\\\?.)*?)(?:\\3|$)", attributes = "\\[(?:\\*\\|)?" + WSP + "?(" + identifier + "(?::" + identifier + ")?)" + WSP + "?(?:(" + CFG.operators + ")" + WSP + "?(?:" + attrparser + "))?(?:" + WSP + "?\\b(i))?" + WSP + "?(?:\\]|$)", attrmatcher = attributes.replace(attrparser, attrvalues), pseudoclass = "(?:\\x28" + WSP + "*(?:" + pseudoparms + "?)?|(?:\\*|\\*\\|)|(?:(?::" + pseudonames + "(?:\\x28" + pseudoparms + "?(?:\\x29|$))?|)|(?:[.#]?" + identifier + ")|(?:" + attributes + "))+|(?:" + WSP + "?[>+~][^>+~]" + WSP + "?)|(?:" + WSP + "?," + WSP + "?)|(?:" + WSP + "?)|(?:\\x29|$))*", standardValidator = "(?=" + WSP + "?[^>+~(){}<>])(?:(?:\\*|\\*\\|)|(?:[.#]?" + identifier + ")+|(?:" + attributes + ")+|(?:::?" + pseudonames + pseudoclass + ")|(?:" + WSP + "?" + CFG.combinators + WSP + "?)|(?:" + WSP + "?," + WSP + "?)|(?:" + WSP + "?))+";
|
|
2734
|
+
reOptimizer = RegExp("(?:([.:#*]?)(" + identifier + ")(?::[-\\w]+|\\[[^\\]]+(?:\\]|$)|\\x28[^\\x29]+(?:\\x29|$))*)$");
|
|
2735
|
+
reValidator = RegExp(standardValidator, "g");
|
|
2736
|
+
Patterns.id = RegExp("^#(" + identifier + ")(.*)");
|
|
2737
|
+
Patterns.tagName = RegExp("^(" + identifier + ")(.*)");
|
|
2738
|
+
Patterns.className = RegExp("^\\.(" + identifier + ")(.*)");
|
|
2739
|
+
Patterns.attribute = RegExp("^(?:" + attrmatcher + ")(.*)");
|
|
2740
|
+
}, F_INIT = "\"use strict\";return function Resolver(c,f,x,r)", S_HEAD = "var e,n,o,j=r.length-1,k=-1", M_HEAD = "var e,n,o", N_HEAD = "var e,n,o", S_LOOP = "main:while((e=c[++k]))", M_LOOP = "e=c;", N_LOOP = "main:while((e=c.item(++k)))", S_BODY = "r[++j]=c[k];", M_BODY = "", N_BODY = "r[++j]=c.item(k);", S_TAIL = "continue main;", M_TAIL = "r=true;", N_TAIL = "r=true;", S_TEST = "if(f(c[k])){break main;}", M_TEST = "f(c);", N_TEST = "if(f(c.item(k))){break main;}", S_VARS = [], M_VARS = [], N_VARS = [], S_TEST = "if(f(c[k])){break main;}", M_TEST = "f(c);", N_TEST = "if(f(c.item(k))){break main;}", S_VARS = [], M_VARS = [], N_VARS = [], compile = function(selector, mode, callback) {
|
|
2741
|
+
var factory, head = "", loop = "", macro = "", source = "", vars = "";
|
|
2742
|
+
switch (mode) {
|
|
2743
|
+
case true:
|
|
2744
|
+
if (selectLambdas[selector]) return selectLambdas[selector];
|
|
2745
|
+
macro = S_BODY + (callback ? S_TEST : "") + S_TAIL;
|
|
2746
|
+
head = S_HEAD;
|
|
2747
|
+
loop = S_LOOP;
|
|
2748
|
+
break;
|
|
2749
|
+
case false:
|
|
2750
|
+
if (matchLambdas[selector]) return matchLambdas[selector];
|
|
2751
|
+
macro = M_BODY + (callback ? M_TEST : "") + M_TAIL;
|
|
2752
|
+
head = M_HEAD;
|
|
2753
|
+
loop = M_LOOP;
|
|
2754
|
+
break;
|
|
2755
|
+
case null:
|
|
2756
|
+
if (selectLambdas[selector]) return selectLambdas[selector];
|
|
2757
|
+
macro = N_BODY + (callback ? N_TEST : "") + N_TAIL;
|
|
2758
|
+
head = N_HEAD;
|
|
2759
|
+
loop = N_LOOP;
|
|
2760
|
+
}
|
|
2761
|
+
source = compileSelector(selector, macro, mode, callback);
|
|
2762
|
+
loop += mode || mode === null ? "{" + source + "}" : source;
|
|
2763
|
+
if (mode || mode === null && selector.includes(":nth")) {
|
|
2764
|
+
loop += reNthElem.test(selector) ? "s.nthElement(null, 2);" : "";
|
|
2765
|
+
loop += reNthType.test(selector) ? "s.nthOfType(null, 2);" : "";
|
|
2766
|
+
}
|
|
2767
|
+
if (S_VARS[0] || M_VARS[0] || N_VARS[0]) {
|
|
2768
|
+
vars = "," + (S_VARS.join(",") || M_VARS.join(",") || N_VARS[0]);
|
|
2769
|
+
S_VARS.length = 0;
|
|
2770
|
+
M_VARS.length = 0;
|
|
2771
|
+
N_VARS.length = 0;
|
|
2772
|
+
}
|
|
2773
|
+
factory = Function("s", F_INIT + "{" + head + vars + ";" + loop + "return r;}")(Snapshot);
|
|
2774
|
+
return mode || mode === null ? selectLambdas[selector] = factory : matchLambdas[selector] = factory;
|
|
2775
|
+
}, compileSelector = function(expression, source, mode, callback) {
|
|
2776
|
+
var a, b, n, f, k = 0, name, NS, compat, expr, match, result, status, symbol, test, type, selector = expression, vars;
|
|
2777
|
+
selector = selector.replace(STD.combinator, "$1");
|
|
2778
|
+
selector_recursion_label: while (selector) {
|
|
2779
|
+
++k;
|
|
2780
|
+
symbol = STD.apimethods.test(selector) ? "|" : selector[0];
|
|
2781
|
+
switch (symbol) {
|
|
2782
|
+
case "*":
|
|
2783
|
+
match = selector.match(Patterns.universal);
|
|
2784
|
+
break;
|
|
2785
|
+
case "#":
|
|
2786
|
+
match = selector.match(Patterns.id);
|
|
2787
|
+
source = "if((/^" + match[1] + "$/.test(e.getAttribute(\"id\")))){" + source + "}";
|
|
2788
|
+
break;
|
|
2789
|
+
case ".":
|
|
2790
|
+
match = selector.match(Patterns.className);
|
|
2791
|
+
compat = (QUIRKS_MODE ? "i" : "") + ".test(e.getAttribute(\"class\"))";
|
|
2792
|
+
source = "if((/(^|\\s)" + match[1] + "(\\s|$)/" + compat + ")){" + source + "}";
|
|
2793
|
+
break;
|
|
2794
|
+
case /[_a-z]/i.test(symbol) ? symbol : void 0:
|
|
2795
|
+
match = selector.match(Patterns.tagName);
|
|
2796
|
+
source = "if((e.localName==\"" + match[1] + "\")){" + source + "}";
|
|
2797
|
+
break;
|
|
2798
|
+
case "|":
|
|
2799
|
+
match = selector.match(Patterns.namespace);
|
|
2800
|
+
if (match[1] == "*") source = "if(true){" + source + "}";
|
|
2801
|
+
else if (!match[1]) source = "if((!e.namespaceURI)){" + source + "}";
|
|
2802
|
+
else if (typeof match[1] == "string" && root.prefix == match[1]) source = "if((e.namespaceURI==\"" + NAMESPACE + "\")){" + source + "}";
|
|
2803
|
+
else emit("'" + expression + "'" + qsInvalid);
|
|
2804
|
+
break;
|
|
2805
|
+
case "[":
|
|
2806
|
+
match = selector.match(Patterns.attribute);
|
|
2807
|
+
NS = match[0].match(STD.namespaces);
|
|
2808
|
+
name = match[1];
|
|
2809
|
+
expr = name.split(":");
|
|
2810
|
+
expr = expr.length == 2 ? expr[1] : expr[0];
|
|
2811
|
+
if (match[2] && !(test = Operators[match[2]])) {
|
|
2812
|
+
emit("'" + expression + "'" + qsInvalid);
|
|
2813
|
+
return "";
|
|
2814
|
+
}
|
|
2815
|
+
if (match[4] === "") test = match[2] == "~=" ? {
|
|
2816
|
+
p1: "^\\s",
|
|
2817
|
+
p2: "+$",
|
|
2818
|
+
p3: "true"
|
|
2819
|
+
} : match[2] in ATTR_STD_OPS && match[2] != "~=" ? {
|
|
2820
|
+
p1: "^",
|
|
2821
|
+
p2: "$",
|
|
2822
|
+
p3: "true"
|
|
2823
|
+
} : test;
|
|
2824
|
+
else if (match[2] == "~=" && match[4].includes(" ")) break;
|
|
2825
|
+
else if (match[4]) match[4] = escapeIdentifier(match[4]).replace(REX.RegExpChar, "\\$&");
|
|
2826
|
+
type = match[5] == "i" || HTML_DOCUMENT && HTML_TABLE[expr.toLowerCase()] ? "i" : "";
|
|
2827
|
+
source = "if((" + (!match[2] ? NS ? "s.hasAttributeNS(e,\"" + name + "\")" : "e.hasAttribute&&e.hasAttribute(\"" + name + "\")" : !match[4] && ATTR_STD_OPS[match[2]] && match[2] != "~=" ? "e.getAttribute&&e.getAttribute(\"" + name + "\")==\"\"" : "(/" + test.p1 + match[4] + test.p2 + "/" + type + ").test(e.getAttribute&&e.getAttribute(\"" + name + "\"))==" + test.p3) + ")){" + source + "}";
|
|
2828
|
+
break;
|
|
2829
|
+
case "~":
|
|
2830
|
+
match = selector.match(Patterns.relative);
|
|
2831
|
+
source = "var N" + k + "=e;while(e&&(e=e.previousElementSibling)){" + source + "}e=N" + k + ";";
|
|
2832
|
+
break;
|
|
2833
|
+
case "+":
|
|
2834
|
+
match = selector.match(Patterns.adjacent);
|
|
2835
|
+
source = "var N" + k + "=e;if(e&&(e=e.previousElementSibling)){" + source + "}e=N" + k + ";";
|
|
2836
|
+
break;
|
|
2837
|
+
case " ":
|
|
2838
|
+
case " ":
|
|
2839
|
+
match = selector.match(Patterns.ancestor);
|
|
2840
|
+
source = "var N" + k + "=e;while(e&&(e=e.parentElement)){" + source + "}e=N" + k + ";";
|
|
2841
|
+
break;
|
|
2842
|
+
case ">":
|
|
2843
|
+
match = selector.match(Patterns.children);
|
|
2844
|
+
source = "var N" + k + "=e;if(e&&(e=e.parentElement)){" + source + "}e=N" + k + ";";
|
|
2845
|
+
break;
|
|
2846
|
+
case symbol in Combinators ? symbol : void 0:
|
|
2847
|
+
match[match.length - 1] = "*";
|
|
2848
|
+
source = Combinators[symbol](match) + source;
|
|
2849
|
+
break;
|
|
2850
|
+
case ":":
|
|
2851
|
+
if (match = selector.match(Patterns.structural)) {
|
|
2852
|
+
match[1] = match[1].toLowerCase();
|
|
2853
|
+
switch (match[1]) {
|
|
2854
|
+
case "scope":
|
|
2855
|
+
source = "if(e===(s.from.nodeType===9?s.root:s.from)){" + source + "}";
|
|
2856
|
+
break;
|
|
2857
|
+
case "root":
|
|
2858
|
+
source = "if((e===s.root)){" + source + (mode ? "break main;" : "") + "}";
|
|
2859
|
+
break;
|
|
2860
|
+
case "empty":
|
|
2861
|
+
source = "n=e.firstChild;while(n&&!(/1|3/).test(n.nodeType)){n=n.nextSibling}if(!n){" + source + "}";
|
|
2862
|
+
break;
|
|
2863
|
+
case "only-child":
|
|
2864
|
+
source = "if((!e.nextElementSibling&&!e.previousElementSibling)){" + source + "}";
|
|
2865
|
+
break;
|
|
2866
|
+
case "last-child":
|
|
2867
|
+
source = "if((!e.nextElementSibling)){" + source + "}";
|
|
2868
|
+
break;
|
|
2869
|
+
case "first-child":
|
|
2870
|
+
source = "if((!e.previousElementSibling)){" + source + "}";
|
|
2871
|
+
break;
|
|
2872
|
+
case "only-of-type":
|
|
2873
|
+
source = "o=e.localName;n=e;while((n=n.nextElementSibling)&&n.localName!=o);if(!n){n=e;while((n=n.previousElementSibling)&&n.localName!=o);}if(!n){" + source + "}";
|
|
2874
|
+
break;
|
|
2875
|
+
case "last-of-type":
|
|
2876
|
+
source = "n=e;o=e.localName;while((n=n.nextElementSibling)&&n.localName!=o);if(!n){" + source + "}";
|
|
2877
|
+
break;
|
|
2878
|
+
case "first-of-type":
|
|
2879
|
+
source = "n=e;o=e.localName;while((n=n.previousElementSibling)&&n.localName!=o);if(!n){" + source + "}";
|
|
2880
|
+
break;
|
|
2881
|
+
default: emit("'" + expression + "'" + qsInvalid);
|
|
2882
|
+
}
|
|
2883
|
+
} else if (match = selector.match(Patterns.treestruct)) {
|
|
2884
|
+
match[1] = match[1].toLowerCase();
|
|
2885
|
+
switch (match[1]) {
|
|
2886
|
+
case "nth-child":
|
|
2887
|
+
case "nth-of-type":
|
|
2888
|
+
case "nth-last-child":
|
|
2889
|
+
case "nth-last-of-type":
|
|
2890
|
+
expr = /-of-type/i.test(match[1]);
|
|
2891
|
+
if (match[1] && match[2]) {
|
|
2892
|
+
type = /last/i.test(match[1]);
|
|
2893
|
+
if (match[2] == "n") {
|
|
2894
|
+
source = "if(true){" + source + "}";
|
|
2895
|
+
break;
|
|
2896
|
+
} else if (match[2] == "1") {
|
|
2897
|
+
test = type ? "next" : "previous";
|
|
2898
|
+
source = expr ? "n=e;o=e.localName;while((n=n." + test + "ElementSibling)&&n.localName!=o);if(!n){" + source + "}" : "if(!e." + test + "ElementSibling){" + source + "}";
|
|
2899
|
+
break;
|
|
2900
|
+
} else if (match[2] == "even" || match[2] == "2n0" || match[2] == "2n+0" || match[2] == "2n") test = "n%2==0";
|
|
2901
|
+
else if (match[2] == "odd" || match[2] == "2n1" || match[2] == "2n+1") test = "n%2==1";
|
|
2902
|
+
else {
|
|
2903
|
+
f = /n/i.test(match[2]);
|
|
2904
|
+
n = match[2].split("n");
|
|
2905
|
+
a = parseInt(n[0], 10) || 0;
|
|
2906
|
+
b = parseInt(n[1], 10) || 0;
|
|
2907
|
+
if (n[0] == "-") a = -1;
|
|
2908
|
+
if (n[0] == "+") a = 1;
|
|
2909
|
+
test = (b ? "(n" + (b > 0 ? "-" : "+") + Math.abs(b) + ")" : "n") + "%" + a + "==0";
|
|
2910
|
+
test = a >= 1 ? f ? "n>" + (b - 1) + (Math.abs(a) != 1 ? "&&" + test : "") : "n==" + a : a <= -1 ? f ? "n<" + (b + 1) + (Math.abs(a) != 1 ? "&&" + test : "") : "n==" + a : a === 0 ? n[0] ? "n==" + b : "n>" + (b - 1) : "false";
|
|
2911
|
+
}
|
|
2912
|
+
expr = expr ? "OfType" : "Element";
|
|
2913
|
+
type = type ? "true" : "false";
|
|
2914
|
+
source = "n=s.nth" + expr + "(e," + type + ");if((" + test + ")){" + source + "}";
|
|
2915
|
+
} else emit("'" + expression + "'" + qsInvalid);
|
|
2916
|
+
break;
|
|
2917
|
+
default: emit("'" + expression + "'" + qsInvalid);
|
|
2918
|
+
}
|
|
2919
|
+
} else if (match = selector.match(Patterns.logicalsel)) {
|
|
2920
|
+
match[1] = match[1].toLowerCase();
|
|
2921
|
+
expr = match[2].replace(REX.CommaGroup, ",").replace(REX.TrimSpaces, "").replace(/\x22/g, "\\\"");
|
|
2922
|
+
switch (match[1]) {
|
|
2923
|
+
case "is":
|
|
2924
|
+
case "where":
|
|
2925
|
+
if (Config.FORGIVING) source = "try{if(s.match(\"" + expr + "\",e)){" + source + "}}catch(E){}";
|
|
2926
|
+
else source = "if(s.match(\"" + expr + "\",e)){" + source + "}";
|
|
2927
|
+
break;
|
|
2928
|
+
case "matches":
|
|
2929
|
+
source = "if(s.match(\"" + expr + "\",e)){" + source + "}";
|
|
2930
|
+
break;
|
|
2931
|
+
case "not":
|
|
2932
|
+
source = "if(!s.match(\"" + expr + "\",e)){" + source + "}";
|
|
2933
|
+
break;
|
|
2934
|
+
case "has":
|
|
2935
|
+
if (/^\s*(\+|\~)/.test(match[2])) source = "if(e.parentElement&&Array.from(e.parentElement" + (/^\s*[+]/.test(match[2]) ? ".querySelectorAll(\"*" + expr + "\")" : ".children") + ").includes(e.nextElementSibling)){" + source + "}";
|
|
2936
|
+
else source = "if(s.first(\":scope " + expr + "\",e)){" + source + "}";
|
|
2937
|
+
break;
|
|
2938
|
+
default: emit("'" + expression + "'" + qsInvalid);
|
|
2939
|
+
}
|
|
2940
|
+
} else if (match = selector.match(Patterns.linguistic)) {
|
|
2941
|
+
match[1] = match[1].toLowerCase();
|
|
2942
|
+
switch (match[1]) {
|
|
2943
|
+
case "dir":
|
|
2944
|
+
source = "var p;if(((/" + match[2] + "/i.test(e.dir))||(p=s.ancestor(\"[dir]\", e))&&(/" + match[2] + "/i.test(p.dir))||(e.dir==\"\"||e.dir==\"auto\")&&(" + (match[2] == "ltr" ? "!" : "") + RTL + ".test(e.textContent)))){" + source + "};";
|
|
2945
|
+
break;
|
|
2946
|
+
case "lang":
|
|
2947
|
+
expr = "(?:^|-)" + match[2] + "(?:-|$)";
|
|
2948
|
+
source = "var p;if(((e.isConnected&&(e.lang==\"\"&&(p=s.ancestor(\"[lang]\",e)))&&(p.lang==\"" + match[2] + "\")||/" + expr + "/i.test(e.lang)))){" + source + "};";
|
|
2949
|
+
break;
|
|
2950
|
+
default: emit("'" + expression + "'" + qsInvalid);
|
|
2951
|
+
}
|
|
2952
|
+
} else if (match = selector.match(Patterns.locationpc)) {
|
|
2953
|
+
match[1] = match[1].toLowerCase();
|
|
2954
|
+
switch (match[1]) {
|
|
2955
|
+
case "any-link":
|
|
2956
|
+
source = "if((/^a|area$/i.test(e.localName)&&e.hasAttribute(\"href\")||e.visited)){" + source + "}";
|
|
2957
|
+
break;
|
|
2958
|
+
case "link":
|
|
2959
|
+
source = "if((/^a|area$/i.test(e.localName)&&e.hasAttribute(\"href\"))){" + source + "}";
|
|
2960
|
+
break;
|
|
2961
|
+
case "visited":
|
|
2962
|
+
source = "if((/^a|area$/i.test(e.localName)&&e.hasAttribute(\"href\")&&e.visited)){" + source + "}";
|
|
2963
|
+
break;
|
|
2964
|
+
case "target":
|
|
2965
|
+
source = "if(((s.doc.compareDocumentPosition(e)&16)&&s.doc.location.hash&&e.id==s.doc.location.hash.slice(1))){" + source + "}";
|
|
2966
|
+
break;
|
|
2967
|
+
case "defined":
|
|
2968
|
+
source = "n=s.doc.defaultView.customElements.get(e.localName);if(n&&e instanceof n){" + source + "}";
|
|
2969
|
+
break;
|
|
2970
|
+
default: emit("'" + expression + "'" + qsInvalid);
|
|
2971
|
+
}
|
|
2972
|
+
} else if (match = selector.match(Patterns.useraction)) {
|
|
2973
|
+
match[1] = match[1].toLowerCase();
|
|
2974
|
+
switch (match[1]) {
|
|
2975
|
+
case "hover":
|
|
2976
|
+
source = "if(e===s.HOVER){" + source + "}";
|
|
2977
|
+
break;
|
|
2978
|
+
case "active":
|
|
2979
|
+
source = "if(e===s.doc.activeElement){" + source + "}";
|
|
2980
|
+
break;
|
|
2981
|
+
case "focus":
|
|
2982
|
+
source = "if(s.isFocusable(e)){" + source + "}";
|
|
2983
|
+
break;
|
|
2984
|
+
case "focus-visible":
|
|
2985
|
+
source = "if(n=s.isFocusable(e)){if(e!==n){while(e){e=e.parentElement;if(e===n)break;}}}if((e===n||e.autofocus)){" + source + "}";
|
|
2986
|
+
break;
|
|
2987
|
+
case "focus-within":
|
|
2988
|
+
source = "if(n=s.isFocusable(e)){if(n!==e){while(n){n=n.parentElement;if(n===e)break;}}}if((n===e||n.autofocus)){" + source + "}";
|
|
2989
|
+
break;
|
|
2990
|
+
default: emit("'" + expression + "'" + qsInvalid);
|
|
2991
|
+
}
|
|
2992
|
+
} else if (match = selector.match(Patterns.inputstate)) {
|
|
2993
|
+
match[1] = match[1].toLowerCase();
|
|
2994
|
+
switch (match[1]) {
|
|
2995
|
+
case "enabled":
|
|
2996
|
+
source = "if(((\"form\" in e||/^optgroup$/i.test(e.localName))&&\"disabled\" in e &&e.disabled===false)){" + source + "}";
|
|
2997
|
+
break;
|
|
2998
|
+
case "disabled":
|
|
2999
|
+
source = "if(((\"form\" in e||/^optgroup$/i.test(e.localName))&&\"disabled\" in e)){var x=0,N=[],F=false,L=false;if(!(/^(optgroup|option)$/i.test(e.localName))){n=e.parentElement;while(n){if(n.localName==\"fieldset\"){N[x++]=n;if(n.disabled===true){F=true;break;}}n=n.parentElement;}for(var x=0;x<N.length;x++){if((n=s.first(\"legend\",N[x]))&&n.contains(e)){L=true;break;}}}if(e.disabled===true||(F&&!L)){" + source + "}}";
|
|
3000
|
+
break;
|
|
3001
|
+
case "read-only":
|
|
3002
|
+
source = "if((/^textarea$/i.test(e.localName)&&(e.readOnly||e.disabled))||(/^input$/i.test(e.localName)&&(\"|date|datetime-local|email|month|number|password|search|tel|text|time|url|week|\".includes(\"|\"+e.type+\"|\")?(e.readOnly||e.disabled):true))||(!/^(?:input|textarea)$/i.test(e.localName) && !s.isContentEditable(e))){" + source + "}";
|
|
3003
|
+
break;
|
|
3004
|
+
case "read-write":
|
|
3005
|
+
source = "if((/^textarea$/i.test(e.localName)&&!e.readOnly&&!e.disabled)||(/^input$/i.test(e.localName)&&\"|date|datetime-local|email|month|number|password|search|tel|text|time|url|week|\".includes(\"|\"+e.type+\"|\")&&!e.readOnly&&!e.disabled)||(!/^(?:input|textarea)$/i.test(e.localName) && s.isContentEditable(e))){" + source + "}";
|
|
3006
|
+
break;
|
|
3007
|
+
case "placeholder-shown":
|
|
3008
|
+
source = "if(((/^input|textarea$/i.test(e.localName))&&e.hasAttribute(\"placeholder\")&&(\"|textarea|password|number|search|email|text|tel|url|\".includes(\"|\"+e.type+\"|\"))&&(!s.match(\":focus\",e)))){" + source + "}";
|
|
3009
|
+
break;
|
|
3010
|
+
case "default":
|
|
3011
|
+
source = "if((\"form\" in e && e.form)){var x=0;n=[];if(e.type==\"image\")n=e.form.getElementsByTagName(\"input\");if(e.type==\"submit\")n=e.form.elements;while(n[x]&&e!==n[x]){if(n[x].type==\"image\")break;if(n[x].type==\"submit\")break;x++;}}if((e.form&&(e===n[x]&&\"|image|submit|\".includes(\"|\"+e.type+\"|\"))||((/^option$/i.test(e.localName))&&e.defaultSelected)||((\"|radio|checkbox|\".includes(\"|\"+e.type+\"|\"))&&e.defaultChecked))){" + source + "}";
|
|
3012
|
+
break;
|
|
3013
|
+
default: emit("'" + expression + "'" + qsInvalid);
|
|
3014
|
+
}
|
|
3015
|
+
} else if (match = selector.match(Patterns.inputvalue)) {
|
|
3016
|
+
match[1] = match[1].toLowerCase();
|
|
3017
|
+
switch (match[1]) {
|
|
3018
|
+
case "checked":
|
|
3019
|
+
source = "if((/^input$/i.test(e.localName)&&(\"|radio|checkbox|\".includes(\"|\"+e.type+\"|\")&&e.checked)||(/^option$/i.test(e.localName)&&(e.selected||e.checked)))){" + source + "}";
|
|
3020
|
+
break;
|
|
3021
|
+
case "indeterminate":
|
|
3022
|
+
source = "if((/^progress$/i.test(e.localName)&&!e.hasAttribute(\"value\"))||(/^input$/i.test(e.localName)&&(\"checkbox\"==e.type&&e.indeterminate)||(\"radio\"==e.type&&e.name&&!s.first(\"input[name=\"+e.name+\"]:checked\",e.form)))){" + source + "}";
|
|
3023
|
+
break;
|
|
3024
|
+
case "required":
|
|
3025
|
+
source = "if((/^input|select|textarea$/i.test(e.localName)&&e.required)){" + source + "}";
|
|
3026
|
+
break;
|
|
3027
|
+
case "optional":
|
|
3028
|
+
source = "if((/^input|select|textarea$/i.test(e.localName)&&!e.required)){" + source + "}";
|
|
3029
|
+
break;
|
|
3030
|
+
case "invalid":
|
|
3031
|
+
source = "if((((/^form$/i.test(e.localName)&&!e.noValidate)||(e.willValidate&&!e.formNoValidate))&&!e.checkValidity())||(/^fieldset$/i.test(e.localName)&&s.first(\":invalid\",e))){" + source + "}";
|
|
3032
|
+
break;
|
|
3033
|
+
case "valid":
|
|
3034
|
+
source = "if((((/^form$/i.test(e.localName)&&!e.noValidate)||(e.willValidate&&!e.formNoValidate))&&e.checkValidity())||(/^fieldset$/i.test(e.localName)&&s.first(\":valid\",e))){" + source + "}";
|
|
3035
|
+
break;
|
|
3036
|
+
case "in-range":
|
|
3037
|
+
source = "if((/^input$/i.test(e.localName))&&(e.willValidate&&!e.formNoValidate)&&(!e.validity.rangeUnderflow&&!e.validity.rangeOverflow)&&(\"|date|datetime-local|month|number|range|time|week|\".includes(\"|\"+e.type+\"|\"))&&(\"range\"==e.type||e.getAttribute(\"min\")||e.getAttribute(\"max\"))){" + source + "}";
|
|
3038
|
+
break;
|
|
3039
|
+
case "out-of-range":
|
|
3040
|
+
source = "if((/^input$/i.test(e.localName))&&(e.willValidate&&!e.formNoValidate)&&(e.validity.rangeUnderflow||e.validity.rangeOverflow)&&(\"|date|datetime-local|month|number|range|time|week|\".includes(\"|\"+e.type+\"|\"))&&(\"range\"==e.type||e.getAttribute(\"min\")||e.getAttribute(\"max\"))){" + source + "}";
|
|
3041
|
+
break;
|
|
3042
|
+
default: emit("'" + expression + "'" + qsInvalid);
|
|
3043
|
+
}
|
|
3044
|
+
} else if (match = selector.match(Patterns.rsrc_state)) {
|
|
3045
|
+
match[1] = match[1].toLowerCase();
|
|
3046
|
+
switch (match[1]) {
|
|
3047
|
+
case "playing":
|
|
3048
|
+
source = "if(s.isPlaying(e)){" + source + "}";
|
|
3049
|
+
break;
|
|
3050
|
+
case "paused":
|
|
3051
|
+
source = "if(!s.isPlaying(e)){" + source + "}";
|
|
3052
|
+
break;
|
|
3053
|
+
case "seeking":
|
|
3054
|
+
source = "if(!s.isPlaying(e)){" + source + "}";
|
|
3055
|
+
break;
|
|
3056
|
+
case "buffering": break;
|
|
3057
|
+
case "stalled": break;
|
|
3058
|
+
case "muted": source = "if(e.localName==\"audio\"&&e.getAttribute(\"muted\")){" + source + "}";
|
|
3059
|
+
}
|
|
3060
|
+
} else if (match = selector.match(Patterns.pseudo_nop)) break;
|
|
3061
|
+
else if (match = selector.match(Patterns.pseudo_sng)) source = "if(e.element&&e.type.toLowerCase()==\":" + match[0].toLowerCase() + "\"){e=e.element;" + source + "}";
|
|
3062
|
+
else if (match = selector.match(Patterns.pseudo_dbl)) source = "if(e.element&&e.type.toLowerCase()==\"" + match[0].toLowerCase() + "\"){e=e.element;" + source + "}";
|
|
3063
|
+
else {
|
|
3064
|
+
expr = false;
|
|
3065
|
+
status = false;
|
|
3066
|
+
for (expr in Selectors) if (match = selector.match(Selectors[expr].Expression)) {
|
|
3067
|
+
result = Selectors[expr].Callback(match, source, mode, callback);
|
|
3068
|
+
if ("match" in result) match = result.match;
|
|
3069
|
+
vars = result.modvar;
|
|
3070
|
+
if (mode) vars && S_VARS.indexOf(vars) < 0 && (S_VARS[S_VARS.length] = vars);
|
|
3071
|
+
else vars && M_VARS.indexOf(vars) < 0 && (M_VARS[M_VARS.length] = vars);
|
|
3072
|
+
source = result.source;
|
|
3073
|
+
status = result.status;
|
|
3074
|
+
if (status) break;
|
|
3075
|
+
}
|
|
3076
|
+
if (!status) {
|
|
3077
|
+
if (Config.FORGIVING && selector.match(/(:(?:is|where)\x28)/)) return "";
|
|
3078
|
+
emit("unknown pseudo-class selector '" + selector + "'");
|
|
3079
|
+
return "";
|
|
3080
|
+
}
|
|
3081
|
+
if (!expr) {
|
|
3082
|
+
if (Config.FORGIVING && selector.match(/(:(?:is|where)\x28)/)) return "";
|
|
3083
|
+
emit("unknown token in selector '" + selector + "'");
|
|
3084
|
+
return "";
|
|
3085
|
+
}
|
|
3086
|
+
}
|
|
3087
|
+
break;
|
|
3088
|
+
default:
|
|
3089
|
+
emit("'" + expression + "'" + qsInvalid);
|
|
3090
|
+
break selector_recursion_label;
|
|
3091
|
+
}
|
|
3092
|
+
if (!match) {
|
|
3093
|
+
if (Config.FORGIVING && selector.match(/(:(?:is|where)\x28)/)) return "";
|
|
3094
|
+
emit("'" + expression + "'" + qsInvalid);
|
|
3095
|
+
return "";
|
|
3096
|
+
}
|
|
3097
|
+
selector = match.pop();
|
|
3098
|
+
}
|
|
3099
|
+
return source;
|
|
3100
|
+
}, makeref = function(selectors, element) {
|
|
3101
|
+
if (element.nodeType === 9) element = element.documentElement;
|
|
3102
|
+
return selectors.replace(/:scope/i, element.localName + (element.id ? "#" + escapeIdentifier(element.id) : "") + (element.className ? "." + escapeIdentifier(element.classList[0]) : ""));
|
|
3103
|
+
}, ancestor = function _closest(selectors, element, callback) {
|
|
3104
|
+
parse(selectors, true);
|
|
3105
|
+
selectors = makeref(selectors, element);
|
|
3106
|
+
while (element) {
|
|
3107
|
+
if (match(selectors, element, callback)) break;
|
|
3108
|
+
element = element.parentElement;
|
|
3109
|
+
}
|
|
3110
|
+
return element;
|
|
3111
|
+
}, match_assert = function(f, element, callback) {
|
|
3112
|
+
for (var i = 0, l = f.length, r = false; l > i; ++i) f[i](element, callback, null, false) && (r = true);
|
|
3113
|
+
return r;
|
|
3114
|
+
}, match_collect = function(selectors, callback) {
|
|
3115
|
+
for (var i = 0, l = selectors.length, f = []; l > i; ++i) f[i] = compile(selectors[i], false, callback);
|
|
3116
|
+
return { factory: f };
|
|
3117
|
+
}, parse = function(selectors, type) {
|
|
3118
|
+
var parsed;
|
|
3119
|
+
if (arguments.length === 0) {
|
|
3120
|
+
emit(qsNotArgs, TypeError);
|
|
3121
|
+
return Config.VERBOSITY ? void 0 : type ? none : false;
|
|
3122
|
+
} else if (arguments[0] === "") {
|
|
3123
|
+
emit("''" + qsInvalid);
|
|
3124
|
+
return Config.VERBOSITY ? void 0 : type ? none : false;
|
|
3125
|
+
} else if (/^[.#]?\d/.test(selectors)) {
|
|
3126
|
+
emit("''" + qsInvalid);
|
|
3127
|
+
return Config.VERBOSITY ? void 0 : type ? none : false;
|
|
3128
|
+
}
|
|
3129
|
+
if (typeof selectors != "string") selectors = "" + selectors;
|
|
3130
|
+
parsed = selectors.replace(/\x00|\\$/g, "�").replace(REX.CombineWSP, " ").replace(REX.PseudosWSP, "$1").replace(REX.TabCharWSP, " ").replace(REX.CommaGroup, ",").replace(REX.TrimSpaces, "");
|
|
3131
|
+
if ((selectors = parsed.match(reValidator)) && selectors.join("") == parsed) {
|
|
3132
|
+
selectors = parsed.match(REX.SplitGroup);
|
|
3133
|
+
if (parsed[parsed.length - 1] == ",") {
|
|
3134
|
+
emit(qsInvalid);
|
|
3135
|
+
return Config.VERBOSITY ? void 0 : type ? none : false;
|
|
3136
|
+
}
|
|
3137
|
+
} else if (Config.FORGIVING) {
|
|
3138
|
+
if (!(parsed.includes(":is(") || parsed.includes(":where("))) {
|
|
3139
|
+
emit("'" + selectors + "'" + qsInvalid);
|
|
3140
|
+
return Config.VERBOSITY ? void 0 : type ? none : false;
|
|
3141
|
+
}
|
|
3142
|
+
}
|
|
3143
|
+
return selectors;
|
|
3144
|
+
}, match = function _matches(selectors, element, callback) {
|
|
3145
|
+
if (element && matchResolvers[selectors]) return match_assert(matchResolvers[selectors].factory, element, callback);
|
|
3146
|
+
matchResolvers[selectors] = match_collect(parse(selectors, false), callback);
|
|
3147
|
+
return match_assert(matchResolvers[selectors].factory, element, callback);
|
|
3148
|
+
}, first = function _querySelector(selectors, context, callback) {
|
|
3149
|
+
return select(selectors, context, typeof callback == "function" ? function firstMatch(element) {
|
|
3150
|
+
callback(element);
|
|
3151
|
+
return false;
|
|
3152
|
+
} : function firstMatch() {
|
|
3153
|
+
return false;
|
|
3154
|
+
})[0] || null;
|
|
3155
|
+
}, select = function _querySelectorAll(selectors, context, callback) {
|
|
3156
|
+
var nodes = [], resolver;
|
|
3157
|
+
arguments.length == 0 && emit(qsNotArgs, TypeError);
|
|
3158
|
+
context || (context = doc);
|
|
3159
|
+
lastContext !== context && (lastContext = switchContext(context));
|
|
3160
|
+
if (selectors) {
|
|
3161
|
+
if (resolver = selectResolvers[selectors]) {
|
|
3162
|
+
if (resolver.context === context && resolver.callback === callback) {
|
|
3163
|
+
var i, l, list, f = resolver.factory, h = resolver.htmlset, n = resolver.nodeset;
|
|
3164
|
+
if (n.length > 1) {
|
|
3165
|
+
for (i = 0, l = n.length; l > i; ++i) {
|
|
3166
|
+
list = compat[n[i][0]](context, n[i].slice(1))();
|
|
3167
|
+
if (f[i] !== null) f[i](list, callback, context, nodes);
|
|
3168
|
+
else nodes = nodes.concat(list);
|
|
3169
|
+
}
|
|
3170
|
+
if (l > 1 && nodes.length > 1) {
|
|
3171
|
+
nodes.sort(documentOrder);
|
|
3172
|
+
hasDupes && (nodes = unique(nodes));
|
|
3173
|
+
}
|
|
3174
|
+
} else if (f[0]) nodes = f[0](h[0](), callback, context, nodes);
|
|
3175
|
+
else nodes = h[0]();
|
|
3176
|
+
if (typeof callback == "function") nodes = concatCall(nodes, callback);
|
|
3177
|
+
return !Config.NODE_LIST ? nodes : isInstanceOf(nodes) ? nodes : toNodeList(nodes);
|
|
3178
|
+
}
|
|
3179
|
+
}
|
|
3180
|
+
}
|
|
3181
|
+
selectResolvers[selectors] = collect(parse(selectors, true), context, callback);
|
|
3182
|
+
nodes = selectResolvers[selectors].results;
|
|
3183
|
+
if (typeof callback == "function") nodes = concatCall(nodes, callback);
|
|
3184
|
+
return !Config.NODE_LIST ? nodes : isInstanceOf(nodes) ? nodes : toNodeList(nodes);
|
|
3185
|
+
}, optimize = function(selector, token) {
|
|
3186
|
+
var index = token.index, length = token[1].length + token[2].length;
|
|
3187
|
+
return selector.slice(0, index) + (" >+~".indexOf(selector.charAt(index - 1)) > -1 ? ":[".indexOf(selector.charAt(index + length + 1)) > -1 ? "*" : "" : "") + selector.slice(index + length - (token[1] == "*" ? 1 : 0));
|
|
3188
|
+
}, collect = function(selectors, context, callback) {
|
|
3189
|
+
var i, l, seen = {}, token = [
|
|
3190
|
+
"",
|
|
3191
|
+
"*",
|
|
3192
|
+
"*"
|
|
3193
|
+
], optimized = selectors, factory = [], htmlset = [], nodeset = [], results = [], type;
|
|
3194
|
+
for (i = 0, l = selectors.length; l > i; ++i) {
|
|
3195
|
+
if (!seen[selectors[i]] && (seen[selectors[i]] = true)) {
|
|
3196
|
+
type = selectors[i].match(reOptimizer);
|
|
3197
|
+
if (type && type[1] != ":" && (token = type)) {
|
|
3198
|
+
token[1] || (token[1] = "*");
|
|
3199
|
+
optimized[i] = optimize(optimized[i], token);
|
|
3200
|
+
} else token = [
|
|
3201
|
+
"",
|
|
3202
|
+
"*",
|
|
3203
|
+
"*"
|
|
3204
|
+
];
|
|
3205
|
+
}
|
|
3206
|
+
nodeset[i] = token[1] + token[2];
|
|
3207
|
+
token[2] = unescapeIdentifier(token[2]);
|
|
3208
|
+
htmlset[i] = compat[token[1]](context, token[2]);
|
|
3209
|
+
factory[i] = compile(optimized[i], true, null);
|
|
3210
|
+
factory[i] ? factory[i](htmlset[i](), callback, context, results) : results.concat(htmlset[i]());
|
|
3211
|
+
}
|
|
3212
|
+
if (l > 1) {
|
|
3213
|
+
results.sort(documentOrder);
|
|
3214
|
+
hasDupes && (results = unique(results));
|
|
3215
|
+
}
|
|
3216
|
+
return {
|
|
3217
|
+
callback,
|
|
3218
|
+
context,
|
|
3219
|
+
factory,
|
|
3220
|
+
htmlset,
|
|
3221
|
+
nodeset,
|
|
3222
|
+
results
|
|
3223
|
+
};
|
|
3224
|
+
};
|
|
3225
|
+
(function() {
|
|
3226
|
+
doc.addEventListener("mouseover", function(e) {
|
|
3227
|
+
Snapshot.HOVER = e.target;
|
|
3228
|
+
}, true);
|
|
3229
|
+
doc.addEventListener("mouseout", function(e) {
|
|
3230
|
+
Snapshot.HOVER = null;
|
|
3231
|
+
}, true);
|
|
3232
|
+
})();
|
|
3233
|
+
var _closest, _matches, _querySelector, _querySelectorDoc, _querySelectorAllDoc, install = function(all) {
|
|
3234
|
+
_closest = Element.prototype.closest;
|
|
3235
|
+
_matches = Element.prototype.matches;
|
|
3236
|
+
_querySelector = Element.prototype.querySelector;
|
|
3237
|
+
Element.prototype.querySelectorAll;
|
|
3238
|
+
_querySelectorDoc = Document.prototype.querySelector;
|
|
3239
|
+
_querySelectorAllDoc = Document.prototype.querySelectorAll;
|
|
3240
|
+
function parseQSArgs() {
|
|
3241
|
+
var method = arguments[arguments.length - 1];
|
|
3242
|
+
return arguments.length < 2 ? method.apply(this, []) : arguments.length < 3 ? method.apply(this, [arguments[0], this]) : method.apply(this, [
|
|
3243
|
+
arguments[0],
|
|
3244
|
+
this,
|
|
3245
|
+
typeof arguments[1] == "function" ? arguments[1] : void 0
|
|
3246
|
+
]);
|
|
3247
|
+
}
|
|
3248
|
+
Element.prototype.closest = HTMLElement.prototype.closest = function closest() {
|
|
3249
|
+
return parseQSArgs.apply(this, [].slice.call(arguments).concat(ancestor));
|
|
3250
|
+
};
|
|
3251
|
+
Element.prototype.matches = HTMLElement.prototype.matches = function matches() {
|
|
3252
|
+
return parseQSArgs.apply(this, [].slice.call(arguments).concat(match));
|
|
3253
|
+
};
|
|
3254
|
+
Element.prototype.querySelector = HTMLElement.prototype.querySelector = function querySelector() {
|
|
3255
|
+
return parseQSArgs.apply(this, [].slice.call(arguments).concat(first));
|
|
3256
|
+
};
|
|
3257
|
+
Element.prototype.querySelectorAll = HTMLElement.prototype.querySelectorAll = function querySelectorAll() {
|
|
3258
|
+
return parseQSArgs.apply(this, [].slice.call(arguments).concat(select));
|
|
3259
|
+
};
|
|
3260
|
+
Document.prototype.querySelector = DocumentFragment.prototype.querySelector = function querySelector() {
|
|
3261
|
+
return parseQSArgs.apply(this, [].slice.call(arguments).concat(first));
|
|
3262
|
+
};
|
|
3263
|
+
Document.prototype.querySelectorAll = DocumentFragment.prototype.querySelectorAll = function querySelectorAll() {
|
|
3264
|
+
return parseQSArgs.apply(this, [].slice.call(arguments).concat(select));
|
|
3265
|
+
};
|
|
3266
|
+
if (all) doc.addEventListener("load", function(e) {
|
|
3267
|
+
var c, d, r, s, t = e.target;
|
|
3268
|
+
if (/iframe/i.test(t.localName)) {
|
|
3269
|
+
c = "(" + Export + ")(this, " + Factory + ");";
|
|
3270
|
+
d = t.ownerDocument;
|
|
3271
|
+
s = d.createElement("script");
|
|
3272
|
+
s.textContent = c + "NW.Dom.install(true)";
|
|
3273
|
+
r = d.documentElement;
|
|
3274
|
+
r.removeChild(r.insertBefore(s, r.firstChild));
|
|
3275
|
+
}
|
|
3276
|
+
}, true);
|
|
3277
|
+
}, uninstall = function() {
|
|
3278
|
+
if (_closest) {
|
|
3279
|
+
Element.prototype.closest = _closest;
|
|
3280
|
+
HTMLElement.prototype.closest = _closest;
|
|
3281
|
+
}
|
|
3282
|
+
if (_matches) {
|
|
3283
|
+
Element.prototype.matches = _matches;
|
|
3284
|
+
HTMLElement.prototype.matches = _matches;
|
|
3285
|
+
}
|
|
3286
|
+
if (_querySelector) {
|
|
3287
|
+
Element.prototype.querySelector = HTMLElement.prototype.querySelector = _querySelector;
|
|
3288
|
+
Element.prototype.querySelectorAll = HTMLElement.prototype.querySelectorAll = _querySelector;
|
|
3289
|
+
}
|
|
3290
|
+
if (_querySelectorAllDoc) {
|
|
3291
|
+
Document.prototype.querySelector = DocumentFragment.prototype.querySelector = _querySelectorDoc;
|
|
3292
|
+
Document.prototype.querySelectorAll = DocumentFragment.prototype.querySelectorAll = _querySelectorAllDoc;
|
|
3293
|
+
}
|
|
3294
|
+
}, none = Array(), lastContext, matchLambdas = {}, selectLambdas = {}, matchResolvers = {}, selectResolvers = {}, Snapshot = {
|
|
3295
|
+
doc,
|
|
3296
|
+
from: doc,
|
|
3297
|
+
root,
|
|
3298
|
+
byTag,
|
|
3299
|
+
first,
|
|
3300
|
+
match,
|
|
3301
|
+
select,
|
|
3302
|
+
ancestor,
|
|
3303
|
+
nthOfType,
|
|
3304
|
+
nthElement,
|
|
3305
|
+
isFocusable,
|
|
3306
|
+
isContentEditable,
|
|
3307
|
+
hasAttributeNS
|
|
3308
|
+
}, Dom = {
|
|
3309
|
+
matchLambdas,
|
|
3310
|
+
selectLambdas,
|
|
3311
|
+
matchResolvers,
|
|
3312
|
+
selectResolvers,
|
|
3313
|
+
CFG,
|
|
3314
|
+
S_BODY,
|
|
3315
|
+
M_BODY,
|
|
3316
|
+
N_BODY: M_BODY,
|
|
3317
|
+
S_TEST,
|
|
3318
|
+
M_TEST,
|
|
3319
|
+
N_TEST,
|
|
3320
|
+
byId,
|
|
3321
|
+
byTag,
|
|
3322
|
+
byClass,
|
|
3323
|
+
first,
|
|
3324
|
+
match,
|
|
3325
|
+
select,
|
|
3326
|
+
closest: ancestor,
|
|
3327
|
+
compile,
|
|
3328
|
+
configure,
|
|
3329
|
+
emit,
|
|
3330
|
+
Config,
|
|
3331
|
+
Snapshot,
|
|
3332
|
+
Version: version,
|
|
3333
|
+
install,
|
|
3334
|
+
uninstall,
|
|
3335
|
+
Operators,
|
|
3336
|
+
Selectors,
|
|
3337
|
+
registerCombinator: function(combinator, resolver) {
|
|
3338
|
+
var i = 0, l = combinator.length, symbol;
|
|
3339
|
+
for (; l > i; ++i) if (combinator[i] != "=") {
|
|
3340
|
+
symbol = combinator[i];
|
|
3341
|
+
break;
|
|
3342
|
+
}
|
|
3343
|
+
if (CFG.combinators.indexOf(symbol) < 0) {
|
|
3344
|
+
CFG.combinators = CFG.combinators.replace("](", symbol + "](");
|
|
3345
|
+
CFG.combinators = CFG.combinators.replace("])", symbol + "])");
|
|
3346
|
+
Combinators[combinator] = resolver;
|
|
3347
|
+
setIdentifierSyntax();
|
|
3348
|
+
} else console.warn("Warning: the '" + combinator + "' combinator is already registered.");
|
|
3349
|
+
},
|
|
3350
|
+
registerOperator: function(operator, resolver) {
|
|
3351
|
+
var i = 0, l = operator.length, symbol;
|
|
3352
|
+
for (; l > i; ++i) if (operator[i] != "=") {
|
|
3353
|
+
symbol = operator[i];
|
|
3354
|
+
break;
|
|
3355
|
+
}
|
|
3356
|
+
if (CFG.operators.indexOf(symbol) < 0 && !Operators[operator]) {
|
|
3357
|
+
CFG.operators = CFG.operators.replace("]=", symbol + "]=");
|
|
3358
|
+
Operators[operator] = resolver;
|
|
3359
|
+
setIdentifierSyntax();
|
|
3360
|
+
} else console.warn("Warning: the '" + operator + "' operator is already registered.");
|
|
3361
|
+
},
|
|
3362
|
+
registerSelector: function(name, rexp, func) {
|
|
3363
|
+
Selectors[name] || (Selectors[name] = {
|
|
3364
|
+
Expression: rexp,
|
|
3365
|
+
Callback: func
|
|
3366
|
+
});
|
|
3367
|
+
}
|
|
3368
|
+
};
|
|
3369
|
+
initialize(doc);
|
|
3370
|
+
return Dom;
|
|
3371
|
+
});
|
|
3372
|
+
})))(), 1);
|
|
3201
3373
|
var MockDocumentFragment = class MockDocumentFragment extends MockHTMLElement {
|
|
3202
3374
|
constructor(ownerDocument) {
|
|
3203
3375
|
super(ownerDocument, null);
|
|
3204
|
-
this.nodeName =
|
|
3205
|
-
this.nodeType =
|
|
3376
|
+
this.nodeName = "#document-fragment";
|
|
3377
|
+
this.nodeType = 11;
|
|
3206
3378
|
}
|
|
3207
3379
|
getElementById(id) {
|
|
3208
3380
|
return getElementById(this, id);
|
|
@@ -3217,7 +3389,7 @@ var MockDocumentFragment = class MockDocumentFragment extends MockHTMLElement {
|
|
|
3217
3389
|
const cloned = new MockDocumentFragment(null);
|
|
3218
3390
|
if (deep) for (let i = 0, ii = this.childNodes.length; i < ii; i++) {
|
|
3219
3391
|
const childNode = this.childNodes[i];
|
|
3220
|
-
if (childNode.nodeType ===
|
|
3392
|
+
if (childNode.nodeType === 1 || childNode.nodeType === 3 || childNode.nodeType === 8) {
|
|
3221
3393
|
const clonedChildNode = this.childNodes[i].cloneNode(true);
|
|
3222
3394
|
cloned.appendChild(clonedChildNode);
|
|
3223
3395
|
}
|
|
@@ -3225,20 +3397,19 @@ var MockDocumentFragment = class MockDocumentFragment extends MockHTMLElement {
|
|
|
3225
3397
|
return cloned;
|
|
3226
3398
|
}
|
|
3227
3399
|
};
|
|
3228
|
-
|
|
3229
3400
|
//#endregion
|
|
3230
3401
|
//#region src/document-type-node.ts
|
|
3231
3402
|
var MockDocumentTypeNode = class extends MockHTMLElement {
|
|
3232
3403
|
constructor(ownerDocument) {
|
|
3233
3404
|
super(ownerDocument, "!DOCTYPE");
|
|
3234
|
-
this.nodeType =
|
|
3405
|
+
this.nodeType = 10;
|
|
3235
3406
|
this.setAttribute("html", "");
|
|
3236
3407
|
}
|
|
3237
3408
|
};
|
|
3238
|
-
|
|
3239
3409
|
//#endregion
|
|
3240
3410
|
//#region src/css-style-sheet.ts
|
|
3241
3411
|
var MockCSSRule = class {
|
|
3412
|
+
parentStyleSheet;
|
|
3242
3413
|
cssText = "";
|
|
3243
3414
|
type = 0;
|
|
3244
3415
|
constructor(parentStyleSheet) {
|
|
@@ -3304,7 +3475,6 @@ function updateStyleTextNode(styleElm) {
|
|
|
3304
3475
|
const textNode = styleElm.childNodes[0];
|
|
3305
3476
|
textNode.nodeValue = styleElm.sheet.cssRules.map((r) => r.cssText).join("\n");
|
|
3306
3477
|
}
|
|
3307
|
-
|
|
3308
3478
|
//#endregion
|
|
3309
3479
|
//#region src/element.ts
|
|
3310
3480
|
function createElement(ownerDocument, tagName) {
|
|
@@ -3727,8 +3897,8 @@ var MockSlotElement = class MockSlotElement extends MockHTMLElement {
|
|
|
3727
3897
|
const ownerHost = this.getRootNode().host;
|
|
3728
3898
|
if (!ownerHost) return nodesToReturn;
|
|
3729
3899
|
if (ownerHost.childNodes.length) {
|
|
3730
|
-
if (this.name) nodesToReturn = ownerHost.childNodes.filter((n) => n.nodeType ===
|
|
3731
|
-
else nodesToReturn = ownerHost.childNodes.filter((n) => n.nodeType ===
|
|
3900
|
+
if (this.name) nodesToReturn = ownerHost.childNodes.filter((n) => n.nodeType === 1 && n.getAttribute("slot") === this.name);
|
|
3901
|
+
else nodesToReturn = ownerHost.childNodes.filter((n) => n.nodeType === 1 && !n.getAttribute("slot") || n.nodeType !== 1);
|
|
3732
3902
|
if (nodesToReturn.length) return nodesToReturn;
|
|
3733
3903
|
}
|
|
3734
3904
|
if (!opts?.flatten) return this.childNodes.filter((n) => !(n instanceof MockSlotElement));
|
|
@@ -3813,10 +3983,10 @@ function fullUrl(elm, attrName) {
|
|
|
3813
3983
|
const loc = win.location;
|
|
3814
3984
|
if (loc != null) try {
|
|
3815
3985
|
return new URL(val, loc.href).href;
|
|
3816
|
-
} catch
|
|
3986
|
+
} catch {}
|
|
3817
3987
|
}
|
|
3818
3988
|
}
|
|
3819
|
-
return val.replace(
|
|
3989
|
+
return val.replace(/'|"/g, "").trim();
|
|
3820
3990
|
}
|
|
3821
3991
|
function getLabelsForElement(elm) {
|
|
3822
3992
|
const labels = [];
|
|
@@ -3881,7 +4051,6 @@ MockElement.prototype.cloneNode = function(deep) {
|
|
|
3881
4051
|
}
|
|
3882
4052
|
return cloned;
|
|
3883
4053
|
};
|
|
3884
|
-
|
|
3885
4054
|
//#endregion
|
|
3886
4055
|
//#region src/parse-html.ts
|
|
3887
4056
|
let sharedDocument;
|
|
@@ -3899,7 +4068,150 @@ function parseHtmlToFragment(html, ownerDocument = null) {
|
|
|
3899
4068
|
}
|
|
3900
4069
|
return parseFragmentUtil(ownerDocument, html);
|
|
3901
4070
|
}
|
|
3902
|
-
|
|
4071
|
+
//#endregion
|
|
4072
|
+
//#region src/tree-walker.ts
|
|
4073
|
+
/**
|
|
4074
|
+
* NodeFilter constants for use in Node.js environment.
|
|
4075
|
+
*/
|
|
4076
|
+
const FILTER_ACCEPT = 1;
|
|
4077
|
+
const FILTER_SKIP = 3;
|
|
4078
|
+
/**
|
|
4079
|
+
* A minimal TreeWalker implementation for dom-selector compatibility.
|
|
4080
|
+
*/
|
|
4081
|
+
var MockTreeWalker = class {
|
|
4082
|
+
root;
|
|
4083
|
+
whatToShow;
|
|
4084
|
+
filter;
|
|
4085
|
+
currentNode;
|
|
4086
|
+
constructor(root, whatToShow, filter) {
|
|
4087
|
+
this.root = root;
|
|
4088
|
+
this.whatToShow = whatToShow;
|
|
4089
|
+
this.filter = filter;
|
|
4090
|
+
this.currentNode = root;
|
|
4091
|
+
}
|
|
4092
|
+
acceptNode(node) {
|
|
4093
|
+
const mask = 1 << node.nodeType - 1;
|
|
4094
|
+
if (!(this.whatToShow & mask)) return FILTER_SKIP;
|
|
4095
|
+
if (this.filter) {
|
|
4096
|
+
if (typeof this.filter === "function") return this.filter(node);
|
|
4097
|
+
return this.filter.acceptNode(node);
|
|
4098
|
+
}
|
|
4099
|
+
return FILTER_ACCEPT;
|
|
4100
|
+
}
|
|
4101
|
+
parentNode() {
|
|
4102
|
+
let node = this.currentNode;
|
|
4103
|
+
while (node && node !== this.root) {
|
|
4104
|
+
node = node.parentNode;
|
|
4105
|
+
if (node && this.acceptNode(node) === FILTER_ACCEPT) {
|
|
4106
|
+
this.currentNode = node;
|
|
4107
|
+
return node;
|
|
4108
|
+
}
|
|
4109
|
+
}
|
|
4110
|
+
return null;
|
|
4111
|
+
}
|
|
4112
|
+
firstChild() {
|
|
4113
|
+
return this.traverseChildren("first");
|
|
4114
|
+
}
|
|
4115
|
+
lastChild() {
|
|
4116
|
+
return this.traverseChildren("last");
|
|
4117
|
+
}
|
|
4118
|
+
nextSibling() {
|
|
4119
|
+
return this.traverseSiblings("next");
|
|
4120
|
+
}
|
|
4121
|
+
previousSibling() {
|
|
4122
|
+
return this.traverseSiblings("previous");
|
|
4123
|
+
}
|
|
4124
|
+
nextNode() {
|
|
4125
|
+
let node = this.currentNode;
|
|
4126
|
+
let result;
|
|
4127
|
+
while (node) {
|
|
4128
|
+
if (node.firstChild) {
|
|
4129
|
+
node = node.firstChild;
|
|
4130
|
+
result = this.acceptNode(node);
|
|
4131
|
+
if (result === FILTER_ACCEPT) {
|
|
4132
|
+
this.currentNode = node;
|
|
4133
|
+
return node;
|
|
4134
|
+
}
|
|
4135
|
+
continue;
|
|
4136
|
+
}
|
|
4137
|
+
while (node) {
|
|
4138
|
+
if (node === this.root) return null;
|
|
4139
|
+
if (node.nextSibling) {
|
|
4140
|
+
node = node.nextSibling;
|
|
4141
|
+
result = this.acceptNode(node);
|
|
4142
|
+
if (result === FILTER_ACCEPT) {
|
|
4143
|
+
this.currentNode = node;
|
|
4144
|
+
return node;
|
|
4145
|
+
}
|
|
4146
|
+
break;
|
|
4147
|
+
}
|
|
4148
|
+
node = node.parentNode;
|
|
4149
|
+
}
|
|
4150
|
+
}
|
|
4151
|
+
return null;
|
|
4152
|
+
}
|
|
4153
|
+
previousNode() {
|
|
4154
|
+
let node = this.currentNode;
|
|
4155
|
+
while (node && node !== this.root) if (node.previousSibling) {
|
|
4156
|
+
node = node.previousSibling;
|
|
4157
|
+
while (node.lastChild) node = node.lastChild;
|
|
4158
|
+
if (this.acceptNode(node) === FILTER_ACCEPT) {
|
|
4159
|
+
this.currentNode = node;
|
|
4160
|
+
return node;
|
|
4161
|
+
}
|
|
4162
|
+
} else {
|
|
4163
|
+
node = node.parentNode;
|
|
4164
|
+
if (node && node !== this.root && this.acceptNode(node) === FILTER_ACCEPT) {
|
|
4165
|
+
this.currentNode = node;
|
|
4166
|
+
return node;
|
|
4167
|
+
}
|
|
4168
|
+
}
|
|
4169
|
+
return null;
|
|
4170
|
+
}
|
|
4171
|
+
traverseChildren(type) {
|
|
4172
|
+
let node = type === "first" ? this.currentNode.firstChild : this.currentNode.lastChild;
|
|
4173
|
+
while (node) {
|
|
4174
|
+
const result = this.acceptNode(node);
|
|
4175
|
+
if (result === FILTER_ACCEPT) {
|
|
4176
|
+
this.currentNode = node;
|
|
4177
|
+
return node;
|
|
4178
|
+
}
|
|
4179
|
+
if (result === FILTER_SKIP) {
|
|
4180
|
+
const child = type === "first" ? node.firstChild : node.lastChild;
|
|
4181
|
+
if (child) {
|
|
4182
|
+
node = child;
|
|
4183
|
+
continue;
|
|
4184
|
+
}
|
|
4185
|
+
}
|
|
4186
|
+
node = type === "first" ? node.nextSibling : node.previousSibling;
|
|
4187
|
+
}
|
|
4188
|
+
return null;
|
|
4189
|
+
}
|
|
4190
|
+
traverseSiblings(type) {
|
|
4191
|
+
let node = this.currentNode;
|
|
4192
|
+
while (node && node !== this.root) {
|
|
4193
|
+
const sibling = type === "next" ? node.nextSibling : node.previousSibling;
|
|
4194
|
+
if (sibling) {
|
|
4195
|
+
node = sibling;
|
|
4196
|
+
const result = this.acceptNode(node);
|
|
4197
|
+
if (result === FILTER_ACCEPT) {
|
|
4198
|
+
this.currentNode = node;
|
|
4199
|
+
return node;
|
|
4200
|
+
}
|
|
4201
|
+
if (result === FILTER_SKIP) {
|
|
4202
|
+
const child = type === "next" ? node.firstChild : node.lastChild;
|
|
4203
|
+
if (child) {
|
|
4204
|
+
node = child;
|
|
4205
|
+
continue;
|
|
4206
|
+
}
|
|
4207
|
+
}
|
|
4208
|
+
continue;
|
|
4209
|
+
}
|
|
4210
|
+
node = node.parentNode;
|
|
4211
|
+
}
|
|
4212
|
+
return null;
|
|
4213
|
+
}
|
|
4214
|
+
};
|
|
3903
4215
|
//#endregion
|
|
3904
4216
|
//#region src/console.ts
|
|
3905
4217
|
const consoleNoop = () => {};
|
|
@@ -3931,17 +4243,18 @@ function createConsole() {
|
|
|
3931
4243
|
memory: consoleNoop
|
|
3932
4244
|
};
|
|
3933
4245
|
}
|
|
3934
|
-
|
|
3935
4246
|
//#endregion
|
|
3936
4247
|
//#region src/headers.ts
|
|
3937
4248
|
var MockHeaders = class {
|
|
3938
4249
|
_values = [];
|
|
3939
4250
|
constructor(init) {
|
|
3940
|
-
if (typeof init === "object")
|
|
3941
|
-
|
|
3942
|
-
|
|
3943
|
-
|
|
3944
|
-
|
|
4251
|
+
if (typeof init === "object") {
|
|
4252
|
+
if (typeof init[Symbol.iterator] === "function") {
|
|
4253
|
+
const kvs = [];
|
|
4254
|
+
for (const kv of init) if (typeof kv[Symbol.iterator] === "function") kvs.push([...kv]);
|
|
4255
|
+
for (const kv of kvs) this.append(kv[0], kv[1]);
|
|
4256
|
+
} else for (const key in init) this.append(key, init[key]);
|
|
4257
|
+
}
|
|
3945
4258
|
}
|
|
3946
4259
|
append(key, value) {
|
|
3947
4260
|
this._values.push([key, value + ""]);
|
|
@@ -3952,7 +4265,7 @@ var MockHeaders = class {
|
|
|
3952
4265
|
}
|
|
3953
4266
|
entries() {
|
|
3954
4267
|
const entries = [];
|
|
3955
|
-
for (const kv of this.keys()) entries.push([kv, this.get(kv)]);
|
|
4268
|
+
for (const kv of this.keys()) entries.push([kv, this.get(kv) ?? ""]);
|
|
3956
4269
|
let index = -1;
|
|
3957
4270
|
return {
|
|
3958
4271
|
next() {
|
|
@@ -4029,7 +4342,6 @@ var MockHeaders = class {
|
|
|
4029
4342
|
return this.entries();
|
|
4030
4343
|
}
|
|
4031
4344
|
};
|
|
4032
|
-
|
|
4033
4345
|
//#endregion
|
|
4034
4346
|
//#region src/parser.ts
|
|
4035
4347
|
var MockDOMParser = class {
|
|
@@ -4038,7 +4350,6 @@ var MockDOMParser = class {
|
|
|
4038
4350
|
return parseHtmlToDocument(htmlToParse);
|
|
4039
4351
|
}
|
|
4040
4352
|
};
|
|
4041
|
-
|
|
4042
4353
|
//#endregion
|
|
4043
4354
|
//#region src/request-response.ts
|
|
4044
4355
|
var MockRequest = class MockRequest {
|
|
@@ -4110,7 +4421,6 @@ var MockResponse = class MockResponse {
|
|
|
4110
4421
|
return new MockResponse(this._body, initClone);
|
|
4111
4422
|
}
|
|
4112
4423
|
};
|
|
4113
|
-
|
|
4114
4424
|
//#endregion
|
|
4115
4425
|
//#region src/global.ts
|
|
4116
4426
|
function setupGlobal(gbl) {
|
|
@@ -4254,7 +4564,6 @@ const GLOBAL_CONSTRUCTORS = [
|
|
|
4254
4564
|
["HTMLTitleElement", MockTitleElement],
|
|
4255
4565
|
["HTMLUListElement", MockUListElement]
|
|
4256
4566
|
];
|
|
4257
|
-
|
|
4258
4567
|
//#endregion
|
|
4259
4568
|
//#region src/history.ts
|
|
4260
4569
|
var MockHistory = class {
|
|
@@ -4272,11 +4581,9 @@ var MockHistory = class {
|
|
|
4272
4581
|
pushState(_state, _title, _url) {}
|
|
4273
4582
|
replaceState(_state, _title, _url) {}
|
|
4274
4583
|
};
|
|
4275
|
-
|
|
4276
4584
|
//#endregion
|
|
4277
4585
|
//#region src/intersection-observer.ts
|
|
4278
4586
|
var MockIntersectionObserver = class {
|
|
4279
|
-
constructor() {}
|
|
4280
4587
|
disconnect() {}
|
|
4281
4588
|
observe() {}
|
|
4282
4589
|
takeRecords() {
|
|
@@ -4284,9 +4591,9 @@ var MockIntersectionObserver = class {
|
|
|
4284
4591
|
}
|
|
4285
4592
|
unobserve() {}
|
|
4286
4593
|
};
|
|
4287
|
-
|
|
4288
4594
|
//#endregion
|
|
4289
4595
|
//#region src/location.ts
|
|
4596
|
+
const DEFAULT_LOCATION_HREF = "http://localhost/";
|
|
4290
4597
|
var MockLocation = class {
|
|
4291
4598
|
ancestorOrigins = null;
|
|
4292
4599
|
protocol = "";
|
|
@@ -4317,6 +4624,9 @@ var MockLocation = class {
|
|
|
4317
4624
|
this.password = url.password;
|
|
4318
4625
|
this.origin = url.origin;
|
|
4319
4626
|
}
|
|
4627
|
+
constructor() {
|
|
4628
|
+
this.href = DEFAULT_LOCATION_HREF;
|
|
4629
|
+
}
|
|
4320
4630
|
assign(_url) {}
|
|
4321
4631
|
reload(_forcedReload) {}
|
|
4322
4632
|
replace(_url) {}
|
|
@@ -4324,7 +4634,6 @@ var MockLocation = class {
|
|
|
4324
4634
|
return this.href;
|
|
4325
4635
|
}
|
|
4326
4636
|
};
|
|
4327
|
-
|
|
4328
4637
|
//#endregion
|
|
4329
4638
|
//#region src/navigator.ts
|
|
4330
4639
|
var MockNavigator = class {
|
|
@@ -4334,7 +4643,6 @@ var MockNavigator = class {
|
|
|
4334
4643
|
platform = "MockNavigator";
|
|
4335
4644
|
userAgent = "MockNavigator";
|
|
4336
4645
|
};
|
|
4337
|
-
|
|
4338
4646
|
//#endregion
|
|
4339
4647
|
//#region src/performance.ts
|
|
4340
4648
|
/**
|
|
@@ -4343,6 +4651,7 @@ var MockNavigator = class {
|
|
|
4343
4651
|
var MockPerformance = class {
|
|
4344
4652
|
timeOrigin;
|
|
4345
4653
|
eventCounts;
|
|
4654
|
+
interactionCount = 0;
|
|
4346
4655
|
constructor() {
|
|
4347
4656
|
this.timeOrigin = Date.now();
|
|
4348
4657
|
this.eventCounts = /* @__PURE__ */ new Map();
|
|
@@ -4384,13 +4693,11 @@ var MockPerformance = class {
|
|
|
4384
4693
|
function resetPerformance(perf) {
|
|
4385
4694
|
if (perf != null) try {
|
|
4386
4695
|
perf.timeOrigin = Date.now();
|
|
4387
|
-
} catch
|
|
4696
|
+
} catch {}
|
|
4388
4697
|
}
|
|
4389
|
-
|
|
4390
4698
|
//#endregion
|
|
4391
4699
|
//#region src/resize-observer.ts
|
|
4392
4700
|
var MockResizeObserver = class {
|
|
4393
|
-
constructor() {}
|
|
4394
4701
|
disconnect() {}
|
|
4395
4702
|
observe() {}
|
|
4396
4703
|
takeRecords() {
|
|
@@ -4398,18 +4705,28 @@ var MockResizeObserver = class {
|
|
|
4398
4705
|
}
|
|
4399
4706
|
unobserve() {}
|
|
4400
4707
|
};
|
|
4401
|
-
|
|
4402
4708
|
//#endregion
|
|
4403
4709
|
//#region src/shadow-root.ts
|
|
4404
4710
|
var MockShadowRoot = class extends MockDocumentFragment {
|
|
4711
|
+
_mode = "open";
|
|
4712
|
+
_delegatesFocus = false;
|
|
4713
|
+
_clonable = false;
|
|
4714
|
+
_serializable = false;
|
|
4715
|
+
_referenceTarget = null;
|
|
4405
4716
|
get activeElement() {
|
|
4406
4717
|
return null;
|
|
4407
4718
|
}
|
|
4408
|
-
get
|
|
4409
|
-
return
|
|
4719
|
+
get clonable() {
|
|
4720
|
+
return this._clonable;
|
|
4721
|
+
}
|
|
4722
|
+
set clonable(value) {
|
|
4723
|
+
this._clonable = value;
|
|
4410
4724
|
}
|
|
4411
4725
|
get delegatesFocus() {
|
|
4412
|
-
return
|
|
4726
|
+
return this._delegatesFocus;
|
|
4727
|
+
}
|
|
4728
|
+
set delegatesFocus(value) {
|
|
4729
|
+
this._delegatesFocus = value;
|
|
4413
4730
|
}
|
|
4414
4731
|
get fullscreenElement() {
|
|
4415
4732
|
return null;
|
|
@@ -4423,7 +4740,10 @@ var MockShadowRoot = class extends MockDocumentFragment {
|
|
|
4423
4740
|
return null;
|
|
4424
4741
|
}
|
|
4425
4742
|
get mode() {
|
|
4426
|
-
return
|
|
4743
|
+
return this._mode;
|
|
4744
|
+
}
|
|
4745
|
+
set mode(value) {
|
|
4746
|
+
this._mode = value;
|
|
4427
4747
|
}
|
|
4428
4748
|
get pictureInPictureElement() {
|
|
4429
4749
|
return null;
|
|
@@ -4431,8 +4751,17 @@ var MockShadowRoot = class extends MockDocumentFragment {
|
|
|
4431
4751
|
get pointerLockElement() {
|
|
4432
4752
|
return null;
|
|
4433
4753
|
}
|
|
4754
|
+
get referenceTarget() {
|
|
4755
|
+
return this._referenceTarget;
|
|
4756
|
+
}
|
|
4757
|
+
set referenceTarget(value) {
|
|
4758
|
+
this._referenceTarget = value;
|
|
4759
|
+
}
|
|
4434
4760
|
get serializable() {
|
|
4435
|
-
return
|
|
4761
|
+
return this._serializable;
|
|
4762
|
+
}
|
|
4763
|
+
set serializable(value) {
|
|
4764
|
+
this._serializable = value;
|
|
4436
4765
|
}
|
|
4437
4766
|
get slotAssignment() {
|
|
4438
4767
|
return "named";
|
|
@@ -4441,7 +4770,6 @@ var MockShadowRoot = class extends MockDocumentFragment {
|
|
|
4441
4770
|
return [];
|
|
4442
4771
|
}
|
|
4443
4772
|
};
|
|
4444
|
-
|
|
4445
4773
|
//#endregion
|
|
4446
4774
|
//#region src/storage.ts
|
|
4447
4775
|
var MockStorage = class {
|
|
@@ -4463,11 +4791,11 @@ var MockStorage = class {
|
|
|
4463
4791
|
this.items.clear();
|
|
4464
4792
|
}
|
|
4465
4793
|
};
|
|
4466
|
-
|
|
4467
4794
|
//#endregion
|
|
4468
4795
|
//#region src/window.ts
|
|
4469
4796
|
const nativeClearInterval = globalThis.clearInterval;
|
|
4470
4797
|
const nativeClearTimeout = globalThis.clearTimeout;
|
|
4798
|
+
const nativeDOMException = globalThis.DOMException;
|
|
4471
4799
|
const nativeSetInterval = globalThis.setInterval;
|
|
4472
4800
|
const nativeSetTimeout = globalThis.setTimeout;
|
|
4473
4801
|
const nativeURL = globalThis.URL;
|
|
@@ -4519,8 +4847,8 @@ var MockWindow = class {
|
|
|
4519
4847
|
resetWindowDefaults(this);
|
|
4520
4848
|
resetWindowDimensions(this);
|
|
4521
4849
|
}
|
|
4522
|
-
addEventListener(type, handler) {
|
|
4523
|
-
addEventListener(this, type, handler);
|
|
4850
|
+
addEventListener(type, handler, options) {
|
|
4851
|
+
addEventListener(this, type, handler, options);
|
|
4524
4852
|
}
|
|
4525
4853
|
alert(msg) {
|
|
4526
4854
|
if (this.console) this.console.debug(msg);
|
|
@@ -4624,6 +4952,9 @@ var MockWindow = class {
|
|
|
4624
4952
|
get Element() {
|
|
4625
4953
|
return MockElement;
|
|
4626
4954
|
}
|
|
4955
|
+
get DOMException() {
|
|
4956
|
+
return nativeDOMException;
|
|
4957
|
+
}
|
|
4627
4958
|
fetch(input, init) {
|
|
4628
4959
|
if (typeof fetch === "function") return fetch(input, init);
|
|
4629
4960
|
throw new Error(`fetch() not implemented`);
|
|
@@ -4739,8 +5070,8 @@ var MockWindow = class {
|
|
|
4739
5070
|
get origin() {
|
|
4740
5071
|
return this.location.origin;
|
|
4741
5072
|
}
|
|
4742
|
-
removeEventListener(type, handler) {
|
|
4743
|
-
removeEventListener(this, type, handler);
|
|
5073
|
+
removeEventListener(type, handler, options) {
|
|
5074
|
+
removeEventListener(this, type, handler, options);
|
|
4744
5075
|
}
|
|
4745
5076
|
requestAnimationFrame(callback) {
|
|
4746
5077
|
return this.setTimeout(() => {
|
|
@@ -4946,6 +5277,77 @@ function constrainTimeouts(win) {
|
|
|
4946
5277
|
win.__allowInterval = false;
|
|
4947
5278
|
win.__maxTimeout = 0;
|
|
4948
5279
|
}
|
|
5280
|
+
/**
|
|
5281
|
+
* Reset a window so the same object can be used for another render, then parse `html` into its
|
|
5282
|
+
* document.
|
|
5283
|
+
*
|
|
5284
|
+
* Code that captured the window's sub-objects (e.g. an SSR platform holding `win.location`,
|
|
5285
|
+
* `win.console` or `win.document`) keeps working: those objects are kept and reset in place,
|
|
5286
|
+
* rather than replaced. Everything else on the window - including anything a previous render
|
|
5287
|
+
* added - is removed.
|
|
5288
|
+
* @param win the window to reset
|
|
5289
|
+
* @param html the HTML for the next render
|
|
5290
|
+
*/
|
|
5291
|
+
function resetWindowForReuse(win, html) {
|
|
5292
|
+
const retained = {
|
|
5293
|
+
console: win.console,
|
|
5294
|
+
document: win.document,
|
|
5295
|
+
eventCounts: win.performance.eventCounts,
|
|
5296
|
+
history: win.history,
|
|
5297
|
+
localStorage: win.localStorage,
|
|
5298
|
+
location: win.location,
|
|
5299
|
+
navigator: win.navigator,
|
|
5300
|
+
orientation: win.screen.orientation,
|
|
5301
|
+
performance: win.performance,
|
|
5302
|
+
screen: win.screen,
|
|
5303
|
+
sessionStorage: win.sessionStorage
|
|
5304
|
+
};
|
|
5305
|
+
if (win.__timeouts) win.__timeouts.forEach((timeoutId) => {
|
|
5306
|
+
nativeClearInterval(timeoutId);
|
|
5307
|
+
nativeClearTimeout(timeoutId);
|
|
5308
|
+
});
|
|
5309
|
+
resetObject(retained.console, createConsole());
|
|
5310
|
+
resetObject(retained.history, new MockHistory());
|
|
5311
|
+
resetObject(retained.location, new MockLocation());
|
|
5312
|
+
resetObject(retained.navigator, new MockNavigator());
|
|
5313
|
+
retained.localStorage.clear();
|
|
5314
|
+
retained.sessionStorage.clear();
|
|
5315
|
+
retained.eventCounts.clear();
|
|
5316
|
+
resetObject(retained.performance, {
|
|
5317
|
+
eventCounts: retained.eventCounts,
|
|
5318
|
+
interactionCount: 0,
|
|
5319
|
+
timeOrigin: Date.now()
|
|
5320
|
+
});
|
|
5321
|
+
for (const key of Reflect.ownKeys(win)) delete win[key];
|
|
5322
|
+
resetWindowDefaults(win);
|
|
5323
|
+
resetWindowDimensions(win);
|
|
5324
|
+
const defaultScreen = win.screen;
|
|
5325
|
+
resetObject(retained.orientation, defaultScreen.orientation);
|
|
5326
|
+
resetObject(retained.screen, {
|
|
5327
|
+
...defaultScreen,
|
|
5328
|
+
orientation: retained.orientation
|
|
5329
|
+
});
|
|
5330
|
+
win.console = retained.console;
|
|
5331
|
+
win.customElements = null;
|
|
5332
|
+
win.document = retained.document;
|
|
5333
|
+
win.history = retained.history;
|
|
5334
|
+
win.localStorage = retained.localStorage;
|
|
5335
|
+
win.location = retained.location;
|
|
5336
|
+
win.navigator = retained.navigator;
|
|
5337
|
+
win.performance = retained.performance;
|
|
5338
|
+
win.screen = retained.screen;
|
|
5339
|
+
win.sessionStorage = retained.sessionStorage;
|
|
5340
|
+
resetDocumentForReuse(retained.document, win, html);
|
|
5341
|
+
}
|
|
5342
|
+
/**
|
|
5343
|
+
* Replace every own property of `target` with those of `defaults`, keeping the object itself.
|
|
5344
|
+
* @param target the object to reset in place
|
|
5345
|
+
* @param defaults the properties it should have afterwards
|
|
5346
|
+
*/
|
|
5347
|
+
function resetObject(target, defaults) {
|
|
5348
|
+
for (const key of Reflect.ownKeys(target)) delete target[key];
|
|
5349
|
+
Object.assign(target, defaults);
|
|
5350
|
+
}
|
|
4949
5351
|
function resetWindow(win) {
|
|
4950
5352
|
if (win != null) {
|
|
4951
5353
|
if (win.__timeouts) {
|
|
@@ -4964,12 +5366,15 @@ function resetWindow(win) {
|
|
|
4964
5366
|
resetEventListeners(win);
|
|
4965
5367
|
if (win.document != null) try {
|
|
4966
5368
|
win.document.defaultView = win;
|
|
4967
|
-
} catch
|
|
4968
|
-
|
|
4969
|
-
|
|
4970
|
-
|
|
4971
|
-
win.
|
|
4972
|
-
win.
|
|
5369
|
+
} catch {}
|
|
5370
|
+
const windowDestroyed = () => {
|
|
5371
|
+
throw new Error("MockWindow was already destroyed");
|
|
5372
|
+
};
|
|
5373
|
+
win.fetch = windowDestroyed;
|
|
5374
|
+
win.Headers = windowDestroyed;
|
|
5375
|
+
win.Request = windowDestroyed;
|
|
5376
|
+
win.Response = windowDestroyed;
|
|
5377
|
+
win.FetchError = windowDestroyed;
|
|
4973
5378
|
}
|
|
4974
5379
|
}
|
|
4975
5380
|
function resetWindowDimensions(win) {
|
|
@@ -5000,19 +5405,29 @@ function resetWindowDimensions(win) {
|
|
|
5000
5405
|
pixelDepth: 24,
|
|
5001
5406
|
width: win.innerWidth
|
|
5002
5407
|
};
|
|
5003
|
-
} catch
|
|
5408
|
+
} catch {}
|
|
5004
5409
|
}
|
|
5005
|
-
|
|
5006
5410
|
//#endregion
|
|
5007
5411
|
//#region src/document.ts
|
|
5008
5412
|
var MockDocument = class MockDocument extends MockHTMLElement {
|
|
5009
5413
|
defaultView;
|
|
5010
5414
|
cookie;
|
|
5011
5415
|
referrer;
|
|
5416
|
+
/**
|
|
5417
|
+
* Returns 'CSS1Compat' for standards mode (the default).
|
|
5418
|
+
* Required by nwsapi for quirks mode detection.
|
|
5419
|
+
*/
|
|
5420
|
+
compatMode = "CSS1Compat";
|
|
5421
|
+
/**
|
|
5422
|
+
* Returns the MIME type of the document.
|
|
5423
|
+
* Required by nwsapi for HTML document detection.
|
|
5424
|
+
*/
|
|
5425
|
+
contentType = "text/html";
|
|
5426
|
+
#nwsapi = null;
|
|
5012
5427
|
constructor(html = null, win = null) {
|
|
5013
5428
|
super(null, null);
|
|
5014
|
-
this.nodeName =
|
|
5015
|
-
this.nodeType =
|
|
5429
|
+
this.nodeName = "#document";
|
|
5430
|
+
this.nodeType = 9;
|
|
5016
5431
|
this.defaultView = win;
|
|
5017
5432
|
this.cookie = "";
|
|
5018
5433
|
this.referrer = "";
|
|
@@ -5030,6 +5445,34 @@ var MockDocument = class MockDocument extends MockHTMLElement {
|
|
|
5030
5445
|
documentElement.appendChild(new MockHTMLElement(this, "body"));
|
|
5031
5446
|
}
|
|
5032
5447
|
}
|
|
5448
|
+
/**
|
|
5449
|
+
* Get the nwsapi instance for this document.
|
|
5450
|
+
* Lazily creates one if it doesn't exist.
|
|
5451
|
+
* Creates a window if the document doesn't have one.
|
|
5452
|
+
* @returns the nwsapi instance
|
|
5453
|
+
*/
|
|
5454
|
+
_getDOMSelector() {
|
|
5455
|
+
if (!this.#nwsapi) {
|
|
5456
|
+
if (!this.defaultView) {
|
|
5457
|
+
const win = new MockWindow(false);
|
|
5458
|
+
win.document = this;
|
|
5459
|
+
this.defaultView = win;
|
|
5460
|
+
}
|
|
5461
|
+
this.#nwsapi = (0, import_nwsapi.default)({ document: this });
|
|
5462
|
+
this.#nwsapi.configure({
|
|
5463
|
+
LOGERRORS: false,
|
|
5464
|
+
VERBOSITY: false,
|
|
5465
|
+
IDS_DUPES: false
|
|
5466
|
+
});
|
|
5467
|
+
}
|
|
5468
|
+
return this.#nwsapi;
|
|
5469
|
+
}
|
|
5470
|
+
/**
|
|
5471
|
+
* Clear the nwsapi cache. Call this when the document structure changes significantly.
|
|
5472
|
+
*/
|
|
5473
|
+
_clearDOMSelector() {
|
|
5474
|
+
this.#nwsapi = null;
|
|
5475
|
+
}
|
|
5033
5476
|
get dir() {
|
|
5034
5477
|
return this.documentElement.dir;
|
|
5035
5478
|
}
|
|
@@ -5076,7 +5519,7 @@ var MockDocument = class MockDocument extends MockHTMLElement {
|
|
|
5076
5519
|
return documentElement;
|
|
5077
5520
|
}
|
|
5078
5521
|
set documentElement(documentElement) {
|
|
5079
|
-
for (let i = this.childNodes.length - 1; i >= 0; i--) if (this.childNodes[i].nodeType !==
|
|
5522
|
+
for (let i = this.childNodes.length - 1; i >= 0; i--) if (this.childNodes[i].nodeType !== 10) this.childNodes[i].remove();
|
|
5080
5523
|
if (documentElement != null) {
|
|
5081
5524
|
this.appendChild(documentElement);
|
|
5082
5525
|
setOwnerDocument(documentElement, this);
|
|
@@ -5128,7 +5571,7 @@ var MockDocument = class MockDocument extends MockHTMLElement {
|
|
|
5128
5571
|
return new MockAttr(attrName, "", namespaceURI);
|
|
5129
5572
|
}
|
|
5130
5573
|
createElement(tagName) {
|
|
5131
|
-
if (tagName ===
|
|
5574
|
+
if (tagName === "#document") {
|
|
5132
5575
|
const doc = new MockDocument(false);
|
|
5133
5576
|
doc.nodeName = tagName;
|
|
5134
5577
|
doc.parentNode = null;
|
|
@@ -5148,6 +5591,17 @@ var MockDocument = class MockDocument extends MockHTMLElement {
|
|
|
5148
5591
|
createDocumentTypeNode() {
|
|
5149
5592
|
return new MockDocumentTypeNode(this);
|
|
5150
5593
|
}
|
|
5594
|
+
/**
|
|
5595
|
+
* Creates a TreeWalker for traversing the document tree.
|
|
5596
|
+
* This is a simplified implementation for dom-selector compatibility.
|
|
5597
|
+
* @param root - the root node for the tree walker
|
|
5598
|
+
* @param whatToShow - a bitmask specifying which nodes to show
|
|
5599
|
+
* @param filter - an optional node filter
|
|
5600
|
+
* @returns a new TreeWalker instance
|
|
5601
|
+
*/
|
|
5602
|
+
createTreeWalker(root, whatToShow = 4294967295, filter = null) {
|
|
5603
|
+
return new MockTreeWalker(root, whatToShow, filter);
|
|
5604
|
+
}
|
|
5151
5605
|
getElementById(id) {
|
|
5152
5606
|
return getElementById(this, id);
|
|
5153
5607
|
}
|
|
@@ -5173,7 +5627,7 @@ function createDocument(html = null) {
|
|
|
5173
5627
|
return new MockWindow(html).document;
|
|
5174
5628
|
}
|
|
5175
5629
|
function createFragment(html) {
|
|
5176
|
-
return parseHtmlToFragment(html, null);
|
|
5630
|
+
return parseHtmlToFragment(html ?? "", null);
|
|
5177
5631
|
}
|
|
5178
5632
|
function resetDocument(doc) {
|
|
5179
5633
|
if (doc != null) {
|
|
@@ -5189,20 +5643,51 @@ function resetDocument(doc) {
|
|
|
5189
5643
|
}
|
|
5190
5644
|
for (const key in doc) if (doc.hasOwnProperty(key) && !DOC_KEY_KEEPERS.has(key)) delete doc[key];
|
|
5191
5645
|
try {
|
|
5192
|
-
doc.nodeName =
|
|
5193
|
-
} catch
|
|
5646
|
+
doc.nodeName = "#document";
|
|
5647
|
+
} catch {}
|
|
5194
5648
|
try {
|
|
5195
|
-
doc.nodeType =
|
|
5196
|
-
} catch
|
|
5649
|
+
doc.nodeType = 9;
|
|
5650
|
+
} catch {}
|
|
5197
5651
|
try {
|
|
5198
5652
|
doc.cookie = "";
|
|
5199
|
-
} catch
|
|
5653
|
+
} catch {}
|
|
5200
5654
|
try {
|
|
5201
5655
|
doc.referrer = "";
|
|
5202
|
-
} catch
|
|
5656
|
+
} catch {}
|
|
5203
5657
|
}
|
|
5204
5658
|
}
|
|
5205
|
-
|
|
5659
|
+
/**
|
|
5660
|
+
* Reset a document so the same object can be used for another render, then parse `html` into
|
|
5661
|
+
* it. The document object itself is kept (code holding a reference to it stays valid), but its
|
|
5662
|
+
* whole element tree is replaced with freshly parsed elements - so caches keyed on elements, like
|
|
5663
|
+
* the runtime's applied-styles cache keyed on `<head>`, start empty.
|
|
5664
|
+
* @param doc the document to reset
|
|
5665
|
+
* @param win the window that owns the document
|
|
5666
|
+
* @param html the HTML to parse into the document
|
|
5667
|
+
*/
|
|
5668
|
+
function resetDocumentForReuse(doc, win, html) {
|
|
5669
|
+
resetDocument(doc);
|
|
5670
|
+
for (const key of Reflect.ownKeys(doc)) if (typeof key !== "string" || !REUSABLE_DOC_KEY_KEEPERS.has(key)) delete doc[key];
|
|
5671
|
+
doc.defaultView = win;
|
|
5672
|
+
doc.documentElement = parseDocumentUtil(doc, html).documentElement;
|
|
5673
|
+
}
|
|
5674
|
+
/** Structural document properties kept by {@link resetDocumentForReuse}; everything else is per-render state. */
|
|
5675
|
+
const REUSABLE_DOC_KEY_KEEPERS = /* @__PURE__ */ new Set([
|
|
5676
|
+
"_nodeValue",
|
|
5677
|
+
"nodeName",
|
|
5678
|
+
"nodeType",
|
|
5679
|
+
"ownerDocument",
|
|
5680
|
+
"parentNode",
|
|
5681
|
+
"_childNodes",
|
|
5682
|
+
"__namespaceURI",
|
|
5683
|
+
"__localName",
|
|
5684
|
+
"defaultView",
|
|
5685
|
+
"cookie",
|
|
5686
|
+
"referrer",
|
|
5687
|
+
"compatMode",
|
|
5688
|
+
"contentType"
|
|
5689
|
+
]);
|
|
5690
|
+
const DOC_KEY_KEEPERS = /* @__PURE__ */ new Set([
|
|
5206
5691
|
"nodeName",
|
|
5207
5692
|
"nodeType",
|
|
5208
5693
|
"nodeValue",
|
|
@@ -5210,7 +5695,9 @@ const DOC_KEY_KEEPERS = new Set([
|
|
|
5210
5695
|
"parentNode",
|
|
5211
5696
|
"childNodes",
|
|
5212
5697
|
"_childNodes",
|
|
5213
|
-
"_shadowRoot"
|
|
5698
|
+
"_shadowRoot",
|
|
5699
|
+
"compatMode",
|
|
5700
|
+
"contentType"
|
|
5214
5701
|
]);
|
|
5215
5702
|
function getElementById(elm, id) {
|
|
5216
5703
|
const children = elm.children;
|
|
@@ -5234,9 +5721,8 @@ function getElementsByName(elm, elmName, foundElms = []) {
|
|
|
5234
5721
|
function setOwnerDocument(elm, ownerDocument) {
|
|
5235
5722
|
for (let i = 0, ii = elm.childNodes.length; i < ii; i++) {
|
|
5236
5723
|
elm.childNodes[i].ownerDocument = ownerDocument;
|
|
5237
|
-
if (elm.childNodes[i].nodeType ===
|
|
5724
|
+
if (elm.childNodes[i].nodeType === 1) setOwnerDocument(elm.childNodes[i], ownerDocument);
|
|
5238
5725
|
}
|
|
5239
5726
|
}
|
|
5240
|
-
|
|
5241
5727
|
//#endregion
|
|
5242
|
-
export { MockAttr, MockAttributeMap, MockComment, MockCustomEvent, MockDocument, MockElement, MockHTMLElement, MockHeaders, MockKeyboardEvent, MockMouseEvent, MockNode, MockRequest, MockResponse, MockTextNode, MockWindow, NODE_TYPES, cloneAttributes, cloneDocument, cloneWindow, constrainTimeouts, createDocument, createFragment, parseHtmlToDocument, parseHtmlToFragment, patchWindow, resetDocument, serializeNodeToHtml, setupGlobal, teardownGlobal };
|
|
5728
|
+
export { MockAttr, MockAttributeMap, MockComment, MockCustomEvent, MockDocument, MockElement, MockHTMLElement, MockHeaders, MockKeyboardEvent, MockMouseEvent, MockNode, MockRequest, MockResponse, MockTextNode, MockWindow, NODE_TYPES, cloneAttributes, cloneDocument, cloneWindow, constrainTimeouts, createDocument, createFragment, parseHtmlToDocument, parseHtmlToFragment, patchWindow, resetDocument, resetWindowForReuse, serializeNodeToHtml, setupGlobal, teardownGlobal };
|