@stencil/mock-doc 5.0.0-alpha.27 → 5.0.0-alpha.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +1 -8
- package/dist/index.mjs +125 -129
- package/package.json +7 -7
- /package/{LICENSE.md → LICENSE} +0 -0
package/dist/index.d.mts
CHANGED
|
@@ -510,13 +510,6 @@ declare class MockEventListener {
|
|
|
510
510
|
handler: (ev?: any) => void;
|
|
511
511
|
constructor(type: string, handler: any);
|
|
512
512
|
}
|
|
513
|
-
/**
|
|
514
|
-
* Add an event listener to an element.
|
|
515
|
-
*
|
|
516
|
-
* @param elm - the element to add the listener to
|
|
517
|
-
* @param type - the event type to listen for
|
|
518
|
-
* @param handler - the event handler function
|
|
519
|
-
*/
|
|
520
513
|
interface EventTarget {
|
|
521
514
|
__listeners: MockEventListener[];
|
|
522
515
|
}
|
|
@@ -972,7 +965,7 @@ declare class MockHeaders {
|
|
|
972
965
|
value: string;
|
|
973
966
|
done: boolean;
|
|
974
967
|
};
|
|
975
|
-
[Symbol.iterator](): /*elided*/any;
|
|
968
|
+
[Symbol.iterator](): /*elided*/ any;
|
|
976
969
|
};
|
|
977
970
|
set(key: string, value: string): void;
|
|
978
971
|
values(): any;
|
package/dist/index.mjs
CHANGED
|
@@ -17,7 +17,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
}
|
|
18
18
|
return to;
|
|
19
19
|
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
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
21
|
value: mod,
|
|
22
22
|
enumerable: true
|
|
23
23
|
}) : target, mod));
|
|
@@ -934,14 +934,15 @@ function* streamToHtml(node, opts, output) {
|
|
|
934
934
|
} else if (attrNamespaceURI === "http://www.w3.org/XML/1998/namespace") {
|
|
935
935
|
yield " xml:" + attrLocalName;
|
|
936
936
|
output.currentLineWidth += attrLocalName.length + 5;
|
|
937
|
-
} else if (attrNamespaceURI === "http://www.w3.org/2000/xmlns/")
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
937
|
+
} else if (attrNamespaceURI === "http://www.w3.org/2000/xmlns/") {
|
|
938
|
+
if (attrLocalName !== "xmlns") {
|
|
939
|
+
yield " xmlns:" + attrLocalName;
|
|
940
|
+
output.currentLineWidth += attrLocalName.length + 7;
|
|
941
|
+
} else {
|
|
942
|
+
yield " " + attrLocalName;
|
|
943
|
+
output.currentLineWidth += attrLocalName.length + 1;
|
|
944
|
+
}
|
|
945
|
+
} else if (attrNamespaceURI === "http://www.w3.org/1999/xlink") {
|
|
945
946
|
yield " xlink:" + attrLocalName;
|
|
946
947
|
output.currentLineWidth += attrLocalName.length + 7;
|
|
947
948
|
} else {
|
|
@@ -994,34 +995,36 @@ function* streamToHtml(node, opts, output) {
|
|
|
994
995
|
const tag = tagName === shadowRootTag ? "template" : tagName;
|
|
995
996
|
const childNodes = tagName === "template" ? node.content.childNodes : getChildNodes(node);
|
|
996
997
|
const childNodeLength = childNodes.length;
|
|
997
|
-
if (childNodeLength > 0)
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
if (ignoreTag === false) {
|
|
1017
|
-
if (opts.newLines && !isWithinWhitespaceSensitiveNode) {
|
|
1018
|
-
yield "\n";
|
|
1019
|
-
output.currentLineWidth = 0;
|
|
998
|
+
if (childNodeLength > 0) {
|
|
999
|
+
if (childNodeLength === 1 && childNodes[0].nodeType === 3 && (typeof childNodes[0].nodeValue !== "string" || childNodes[0].nodeValue.trim() === "")) {} else {
|
|
1000
|
+
const isWithinWhitespaceSensitiveNode = opts.newLines || (opts.indentSpaces ?? 0) > 0 ? isWithinWhitespaceSensitive(node) : false;
|
|
1001
|
+
if (!isWithinWhitespaceSensitiveNode && (opts.indentSpaces ?? 0) > 0 && ignoreTag === false) output.indent = output.indent + (opts.indentSpaces ?? 0);
|
|
1002
|
+
for (let i = 0; i < childNodeLength; i++) {
|
|
1003
|
+
/**
|
|
1004
|
+
* In cases where a user would pass in a declarative shadow dom of a
|
|
1005
|
+
* Stencil component, we want to skip over the template tag as we
|
|
1006
|
+
* will be parsing the shadow root of the component again.
|
|
1007
|
+
*
|
|
1008
|
+
* We know it is a hydrated Stencil component by checking if the `HYDRATE_ID`
|
|
1009
|
+
* is set on the node.
|
|
1010
|
+
*/
|
|
1011
|
+
const sId = node.attributes.getNamedItem(HYDRATE_ID);
|
|
1012
|
+
if (childNodes[i].nodeName.toLowerCase() === "template" && sId) {
|
|
1013
|
+
yield `\n${" ".repeat(output.indent)}<!--r.${sId.value}-->`;
|
|
1014
|
+
continue;
|
|
1015
|
+
}
|
|
1016
|
+
yield* streamToHtml(childNodes[i], opts, output);
|
|
1020
1017
|
}
|
|
1021
|
-
if (
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1018
|
+
if (ignoreTag === false) {
|
|
1019
|
+
if (opts.newLines && !isWithinWhitespaceSensitiveNode) {
|
|
1020
|
+
yield "\n";
|
|
1021
|
+
output.currentLineWidth = 0;
|
|
1022
|
+
}
|
|
1023
|
+
if ((opts.indentSpaces ?? 0) > 0 && !isWithinWhitespaceSensitiveNode) {
|
|
1024
|
+
output.indent = output.indent - (opts.indentSpaces ?? 0);
|
|
1025
|
+
for (let i = 0; i < output.indent; i++) yield " ";
|
|
1026
|
+
output.currentLineWidth += output.indent;
|
|
1027
|
+
}
|
|
1025
1028
|
}
|
|
1026
1029
|
}
|
|
1027
1030
|
}
|
|
@@ -1080,10 +1083,12 @@ function* streamToHtml(node, opts, output) {
|
|
|
1080
1083
|
if (/\s/.test(textContent.charAt(0))) textContent = " " + textContent.trimStart();
|
|
1081
1084
|
textContentLength = textContent.length;
|
|
1082
1085
|
if (textContentLength > 1) {
|
|
1083
|
-
if (/\s/.test(textContent.charAt(textContentLength - 1)))
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1086
|
+
if (/\s/.test(textContent.charAt(textContentLength - 1))) {
|
|
1087
|
+
if (opts.approximateLineWidth && opts.approximateLineWidth > 0 && output.currentLineWidth + textContentLength > opts.approximateLineWidth) {
|
|
1088
|
+
textContent = textContent.trimEnd() + "\n";
|
|
1089
|
+
output.currentLineWidth = 0;
|
|
1090
|
+
} else textContent = textContent.trimEnd() + " ";
|
|
1091
|
+
}
|
|
1087
1092
|
}
|
|
1088
1093
|
output.currentLineWidth += textContentLength;
|
|
1089
1094
|
}
|
|
@@ -1154,7 +1159,7 @@ function isWithinWhitespaceSensitive(node) {
|
|
|
1154
1159
|
function getChildNodes(node) {
|
|
1155
1160
|
return node.__childNodes || node.childNodes;
|
|
1156
1161
|
}
|
|
1157
|
-
const NON_ESCAPABLE_CONTENT = new Set([
|
|
1162
|
+
const NON_ESCAPABLE_CONTENT = /* @__PURE__ */ new Set([
|
|
1158
1163
|
"STYLE",
|
|
1159
1164
|
"SCRIPT",
|
|
1160
1165
|
"IFRAME",
|
|
@@ -1163,7 +1168,7 @@ const NON_ESCAPABLE_CONTENT = new Set([
|
|
|
1163
1168
|
/**
|
|
1164
1169
|
* A list of whitespace sensitive tag names, such as `code`, `pre`, etc.
|
|
1165
1170
|
*/
|
|
1166
|
-
const WHITESPACE_SENSITIVE = new Set([
|
|
1171
|
+
const WHITESPACE_SENSITIVE = /* @__PURE__ */ new Set([
|
|
1167
1172
|
"CODE",
|
|
1168
1173
|
"OUTPUT",
|
|
1169
1174
|
"PRE",
|
|
@@ -1171,7 +1176,7 @@ const WHITESPACE_SENSITIVE = new Set([
|
|
|
1171
1176
|
"TEMPLATE",
|
|
1172
1177
|
"TEXTAREA"
|
|
1173
1178
|
]);
|
|
1174
|
-
const EMPTY_ELEMENTS = new Set([
|
|
1179
|
+
const EMPTY_ELEMENTS = /* @__PURE__ */ new Set([
|
|
1175
1180
|
"area",
|
|
1176
1181
|
"base",
|
|
1177
1182
|
"br",
|
|
@@ -1187,7 +1192,7 @@ const EMPTY_ELEMENTS = new Set([
|
|
|
1187
1192
|
"track",
|
|
1188
1193
|
"wbr"
|
|
1189
1194
|
]);
|
|
1190
|
-
const REMOVE_EMPTY_ATTR = new Set([
|
|
1195
|
+
const REMOVE_EMPTY_ATTR = /* @__PURE__ */ new Set([
|
|
1191
1196
|
"class",
|
|
1192
1197
|
"dir",
|
|
1193
1198
|
"id",
|
|
@@ -1195,7 +1200,7 @@ const REMOVE_EMPTY_ATTR = new Set([
|
|
|
1195
1200
|
"name",
|
|
1196
1201
|
"title"
|
|
1197
1202
|
]);
|
|
1198
|
-
const BOOLEAN_ATTR = new Set([
|
|
1203
|
+
const BOOLEAN_ATTR = /* @__PURE__ */ new Set([
|
|
1199
1204
|
"allowfullscreen",
|
|
1200
1205
|
"async",
|
|
1201
1206
|
"autofocus",
|
|
@@ -1225,7 +1230,7 @@ const BOOLEAN_ATTR = new Set([
|
|
|
1225
1230
|
"shadowrootdelegatesfocus",
|
|
1226
1231
|
"shadowrootserializable"
|
|
1227
1232
|
]);
|
|
1228
|
-
const STRUCTURE_ELEMENTS = new Set([
|
|
1233
|
+
const STRUCTURE_ELEMENTS = /* @__PURE__ */ new Set([
|
|
1229
1234
|
"html",
|
|
1230
1235
|
"body",
|
|
1231
1236
|
"head",
|
|
@@ -1460,8 +1465,10 @@ var MockNode = class {
|
|
|
1460
1465
|
return childNode;
|
|
1461
1466
|
}
|
|
1462
1467
|
remove() {
|
|
1463
|
-
if (this.parentNode != null)
|
|
1464
|
-
|
|
1468
|
+
if (this.parentNode != null) {
|
|
1469
|
+
if (this.__parentNode) this.__parentNode.removeChild(this);
|
|
1470
|
+
else this.parentNode.removeChild(this);
|
|
1471
|
+
}
|
|
1465
1472
|
}
|
|
1466
1473
|
replaceChild(newChild, oldChild) {
|
|
1467
1474
|
if (oldChild.parentNode === this) {
|
|
@@ -1855,12 +1862,13 @@ var MockElement = class extends MockNode {
|
|
|
1855
1862
|
const attributes = this.attributes;
|
|
1856
1863
|
let attr = attributes.getNamedItem(attrName);
|
|
1857
1864
|
const checkAttrChanged = checkAttributeChanged(this);
|
|
1858
|
-
if (attr != null)
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1865
|
+
if (attr != null) {
|
|
1866
|
+
if (checkAttrChanged === true) {
|
|
1867
|
+
const oldValue = attr.value;
|
|
1868
|
+
attr.value = value;
|
|
1869
|
+
if (oldValue !== attr.value) attributeChanged(this, attr.name, oldValue, attr.value);
|
|
1870
|
+
} else attr.value = value;
|
|
1871
|
+
} else {
|
|
1864
1872
|
if (attributes.caseInsensitive) attrName = attrName.toLowerCase();
|
|
1865
1873
|
attr = new MockAttr(attrName, value);
|
|
1866
1874
|
attributes.__items.push(attr);
|
|
@@ -1882,12 +1890,13 @@ var MockElement = class extends MockNode {
|
|
|
1882
1890
|
}
|
|
1883
1891
|
let attr = attributes.getNamedItemNS(namespaceURI, localName);
|
|
1884
1892
|
const checkAttrChanged = checkAttributeChanged(this);
|
|
1885
|
-
if (attr != null)
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1893
|
+
if (attr != null) {
|
|
1894
|
+
if (checkAttrChanged === true) {
|
|
1895
|
+
const oldValue = attr.value;
|
|
1896
|
+
attr.value = value;
|
|
1897
|
+
if (oldValue !== attr.value) attributeChanged(this, attr.name, oldValue, attr.value);
|
|
1898
|
+
} else attr.value = value;
|
|
1899
|
+
} else {
|
|
1891
1900
|
attr = new MockAttr(localName, value, namespaceURI, prefix);
|
|
1892
1901
|
attributes.__items.push(attr);
|
|
1893
1902
|
if (checkAttrChanged === true) attributeChanged(this, attr.name, null, attr.value);
|
|
@@ -2199,7 +2208,7 @@ var import_nwsapi = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((exp
|
|
|
2199
2208
|
global.NW.Dom = factory(global, Export);
|
|
2200
2209
|
}
|
|
2201
2210
|
})(exports, function Factory(global, Export) {
|
|
2202
|
-
var version = "nwsapi-2.2.
|
|
2211
|
+
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 = {
|
|
2203
2212
|
operators: "[~*^$|]=|=",
|
|
2204
2213
|
combinators: "[\\x20\\t>+~](?=[^>+~])"
|
|
2205
2214
|
}, NOT = {
|
|
@@ -2224,9 +2233,9 @@ var import_nwsapi = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((exp
|
|
|
2224
2233
|
apimethods: RegExp("^(?:\\w+|\\*)\\|"),
|
|
2225
2234
|
namespaces: RegExp("(\\*|\\w+)\\|[\\w-]+")
|
|
2226
2235
|
}, GROUPS = {
|
|
2227
|
-
linguistic: "(dir|lang)(?:\\x28\\s?([-\\w]{2,})\\s
|
|
2228
|
-
logicalsel: "(is|where|matches|not|has)(?:\\x28\\s?([^()]*|.*)\\s
|
|
2229
|
-
treestruct: "(nth(?:-last)?(?:-child|-of\\-type))(?:\\x28\\s?(even|odd|(?:[-+]?\\d*)(?:n\\s?[-+]?\\s?\\d*)?)\\s
|
|
2236
|
+
linguistic: "(dir|lang)(?:\\x28\\s?([-\\w]{2,})\\s?(?:\\x29|$))",
|
|
2237
|
+
logicalsel: "(is|where|matches|not|has)(?:\\x28\\s?([^()]*|.*)\\s?(?:\\x29|$))",
|
|
2238
|
+
treestruct: "(nth(?:-last)?(?:-child|-of\\-type))(?:\\x28\\s?(even|odd|(?:[-+]?\\d*)(?:n\\s?[-+]?\\s?\\d*)?)\\s?(?:\\x29|$))",
|
|
2230
2239
|
locationpc: "(any\\-link|link|visited|target|defined)\\b",
|
|
2231
2240
|
useraction: "(hover|active|focus\\-within|focus\\-visible|focus)\\b",
|
|
2232
2241
|
structural: "(scope|root|empty|(?:(?:first|last|only)(?:-child|\\-of\\-type)))\\b",
|
|
@@ -2425,7 +2434,7 @@ var import_nwsapi = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((exp
|
|
|
2425
2434
|
if (codePoint < 1 || codePoint > 1114111 || codePoint > 55295 && codePoint < 57344) return "�";
|
|
2426
2435
|
if (codePoint < 65536) return String.fromCharCode(codePoint);
|
|
2427
2436
|
return String.fromCodePoint ? String.fromCodePoint(codePoint) : String.fromCharCode((codePoint - 65536 >> 10) + 55296, (codePoint - 65536) % 1024 + 56320);
|
|
2428
|
-
},
|
|
2437
|
+
}, escapeIdentifier = function(str) {
|
|
2429
2438
|
return REX.HasEscapes.test(str) ? str.replace(REX.FixEscapes, function(substring, p1, p2) {
|
|
2430
2439
|
return p2 ? "\\" + p2 : REX.HexNumbers.test(p1) ? codePointToUTF16(parseInt(p1, 16)) : REX.EscOrQuote.test(p1) ? substring : p1;
|
|
2431
2440
|
}) : str;
|
|
@@ -2455,12 +2464,14 @@ var import_nwsapi = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((exp
|
|
|
2455
2464
|
var e, i, l, nodes, api = method["#"];
|
|
2456
2465
|
if (Config.IDS_DUPES === false) {
|
|
2457
2466
|
if (api in context) return (e = context[api](id)) ? [e] : none;
|
|
2458
|
-
} else if ("all" in context)
|
|
2459
|
-
if (e
|
|
2460
|
-
|
|
2461
|
-
|
|
2462
|
-
|
|
2463
|
-
|
|
2467
|
+
} else if ("all" in context) {
|
|
2468
|
+
if (e = context.all[id]) {
|
|
2469
|
+
if (e.nodeType == 1) return e.getAttribute("id") != id ? [] : [e];
|
|
2470
|
+
else if (id == "length") return (e = context[api](id)) ? [e] : none;
|
|
2471
|
+
for (i = 0, l = e.length, nodes = []; l > i; ++i) if (e[i].id == id) nodes[nodes.length] = e[i];
|
|
2472
|
+
return nodes && nodes.length ? nodes : [nodes];
|
|
2473
|
+
} else return none;
|
|
2474
|
+
}
|
|
2464
2475
|
return byIdRaw(id, context);
|
|
2465
2476
|
}, byTagNS = function(context, tag) {
|
|
2466
2477
|
return byTag(tag, context);
|
|
@@ -2469,15 +2480,16 @@ var import_nwsapi = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((exp
|
|
|
2469
2480
|
if (api in context) return slice.call(context[api](tag));
|
|
2470
2481
|
else {
|
|
2471
2482
|
tag = tag.toLowerCase();
|
|
2472
|
-
if (e = context.firstElementChild)
|
|
2473
|
-
|
|
2474
|
-
|
|
2475
|
-
|
|
2476
|
-
|
|
2477
|
-
|
|
2478
|
-
|
|
2479
|
-
|
|
2480
|
-
|
|
2483
|
+
if (e = context.firstElementChild) {
|
|
2484
|
+
if (!(e.nextElementSibling || tag == "*" || e.localName == tag)) return slice.call(e[api](tag));
|
|
2485
|
+
else {
|
|
2486
|
+
nodes = [];
|
|
2487
|
+
do {
|
|
2488
|
+
if (tag == "*" || e.localName == tag) nodes[nodes.length] = e;
|
|
2489
|
+
concatList(nodes, e[api](tag));
|
|
2490
|
+
} while (e = e.nextElementSibling);
|
|
2491
|
+
}
|
|
2492
|
+
} else nodes = none;
|
|
2481
2493
|
}
|
|
2482
2494
|
return !Config.NODE_LIST ? nodes : isInstanceOf(nodes) ? nodes : toNodeList(nodes);
|
|
2483
2495
|
}, byClass = function(cls, context) {
|
|
@@ -2669,7 +2681,7 @@ var import_nwsapi = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((exp
|
|
|
2669
2681
|
setIdentifierSyntax();
|
|
2670
2682
|
lastContext = switchContext(doc, true);
|
|
2671
2683
|
}, setIdentifierSyntax = function() {
|
|
2672
|
-
var
|
|
2684
|
+
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 + "?))+";
|
|
2673
2685
|
reOptimizer = RegExp("(?:([.:#*]?)(" + identifier + ")(?::[-\\w]+|\\[[^\\]]+(?:\\]|$)|\\x28[^\\x29]+(?:\\x29|$))*)$");
|
|
2674
2686
|
reValidator = RegExp(standardValidator, "g");
|
|
2675
2687
|
Patterns.id = RegExp("^#(" + identifier + ")(.*)");
|
|
@@ -2696,8 +2708,6 @@ var import_nwsapi = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((exp
|
|
|
2696
2708
|
macro = N_BODY + (callback ? N_TEST : "") + N_TAIL;
|
|
2697
2709
|
head = N_HEAD;
|
|
2698
2710
|
loop = N_LOOP;
|
|
2699
|
-
break;
|
|
2700
|
-
default: break;
|
|
2701
2711
|
}
|
|
2702
2712
|
source = compileSelector(selector, macro, mode, callback);
|
|
2703
2713
|
loop += mode || mode === null ? "{" + source + "}" : source;
|
|
@@ -2714,9 +2724,10 @@ var import_nwsapi = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((exp
|
|
|
2714
2724
|
factory = Function("s", F_INIT + "{" + head + vars + ";" + loop + "return r;}")(Snapshot);
|
|
2715
2725
|
return mode || mode === null ? selectLambdas[selector] = factory : matchLambdas[selector] = factory;
|
|
2716
2726
|
}, compileSelector = function(expression, source, mode, callback) {
|
|
2717
|
-
var a, b, n, f, name, NS, compat, expr, match, result, status, symbol, test, type, selector = expression, vars;
|
|
2727
|
+
var a, b, n, f, k = 0, name, NS, compat, expr, match, result, status, symbol, test, type, selector = expression, vars;
|
|
2718
2728
|
selector = selector.replace(STD.combinator, "$1");
|
|
2719
2729
|
selector_recursion_label: while (selector) {
|
|
2730
|
+
++k;
|
|
2720
2731
|
symbol = STD.apimethods.test(selector) ? "|" : selector[0];
|
|
2721
2732
|
switch (symbol) {
|
|
2722
2733
|
case "*":
|
|
@@ -2762,26 +2773,26 @@ var import_nwsapi = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((exp
|
|
|
2762
2773
|
p3: "true"
|
|
2763
2774
|
} : test;
|
|
2764
2775
|
else if (match[2] == "~=" && match[4].includes(" ")) break;
|
|
2765
|
-
else if (match[4]) match[4] =
|
|
2776
|
+
else if (match[4]) match[4] = escapeIdentifier(match[4]).replace(REX.RegExpChar, "\\$&");
|
|
2766
2777
|
type = match[5] == "i" || HTML_DOCUMENT && HTML_TABLE[expr.toLowerCase()] ? "i" : "";
|
|
2767
2778
|
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 + "}";
|
|
2768
2779
|
break;
|
|
2769
2780
|
case "~":
|
|
2770
2781
|
match = selector.match(Patterns.relative);
|
|
2771
|
-
source = "while(e&&(e=e.previousElementSibling)){" + source + "}";
|
|
2782
|
+
source = "var N" + k + "=e;while(e&&(e=e.previousElementSibling)){" + source + "}e=N" + k + ";";
|
|
2772
2783
|
break;
|
|
2773
2784
|
case "+":
|
|
2774
2785
|
match = selector.match(Patterns.adjacent);
|
|
2775
|
-
source = "if(e&&(e=e.previousElementSibling)){" + source + "}";
|
|
2786
|
+
source = "var N" + k + "=e;if(e&&(e=e.previousElementSibling)){" + source + "}e=N" + k + ";";
|
|
2776
2787
|
break;
|
|
2777
2788
|
case " ":
|
|
2778
2789
|
case " ":
|
|
2779
2790
|
match = selector.match(Patterns.ancestor);
|
|
2780
|
-
source = "while(e&&(e=e.parentElement)){" + source + "}";
|
|
2791
|
+
source = "var N" + k + "=e;while(e&&(e=e.parentElement)){" + source + "}e=N" + k + ";";
|
|
2781
2792
|
break;
|
|
2782
2793
|
case ">":
|
|
2783
2794
|
match = selector.match(Patterns.children);
|
|
2784
|
-
source = "if(e&&(e=e.parentElement)){" + source + "}";
|
|
2795
|
+
source = "var N" + k + "=e;if(e&&(e=e.parentElement)){" + source + "}e=N" + k + ";";
|
|
2785
2796
|
break;
|
|
2786
2797
|
case symbol in Combinators ? symbol : void 0:
|
|
2787
2798
|
match[match.length - 1] = "*";
|
|
@@ -2818,9 +2829,7 @@ var import_nwsapi = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((exp
|
|
|
2818
2829
|
case "first-of-type":
|
|
2819
2830
|
source = "n=e;o=e.localName;while((n=n.previousElementSibling)&&n.localName!=o);if(!n){" + source + "}";
|
|
2820
2831
|
break;
|
|
2821
|
-
default:
|
|
2822
|
-
emit("'" + expression + "'" + qsInvalid);
|
|
2823
|
-
break;
|
|
2832
|
+
default: emit("'" + expression + "'" + qsInvalid);
|
|
2824
2833
|
}
|
|
2825
2834
|
} else if (match = selector.match(Patterns.treestruct)) {
|
|
2826
2835
|
match[1] = match[1].toLowerCase();
|
|
@@ -2856,9 +2865,7 @@ var import_nwsapi = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((exp
|
|
|
2856
2865
|
source = "n=s.nth" + expr + "(e," + type + ");if((" + test + ")){" + source + "}";
|
|
2857
2866
|
} else emit("'" + expression + "'" + qsInvalid);
|
|
2858
2867
|
break;
|
|
2859
|
-
default:
|
|
2860
|
-
emit("'" + expression + "'" + qsInvalid);
|
|
2861
|
-
break;
|
|
2868
|
+
default: emit("'" + expression + "'" + qsInvalid);
|
|
2862
2869
|
}
|
|
2863
2870
|
} else if (match = selector.match(Patterns.logicalsel)) {
|
|
2864
2871
|
match[1] = match[1].toLowerCase();
|
|
@@ -2877,11 +2884,9 @@ var import_nwsapi = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((exp
|
|
|
2877
2884
|
break;
|
|
2878
2885
|
case "has":
|
|
2879
2886
|
if (/^\s*(\+|\~)/.test(match[2])) source = "if(e.parentElement&&Array.from(e.parentElement" + (/^\s*[+]/.test(match[2]) ? ".querySelectorAll(\"*" + expr + "\")" : ".children") + ").includes(e.nextElementSibling)){" + source + "}";
|
|
2880
|
-
else source = "if(
|
|
2881
|
-
break;
|
|
2882
|
-
default:
|
|
2883
|
-
emit("'" + expression + "'" + qsInvalid);
|
|
2887
|
+
else source = "if(s.first(\":scope " + expr + "\",e)){" + source + "}";
|
|
2884
2888
|
break;
|
|
2889
|
+
default: emit("'" + expression + "'" + qsInvalid);
|
|
2885
2890
|
}
|
|
2886
2891
|
} else if (match = selector.match(Patterns.linguistic)) {
|
|
2887
2892
|
match[1] = match[1].toLowerCase();
|
|
@@ -2893,9 +2898,7 @@ var import_nwsapi = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((exp
|
|
|
2893
2898
|
expr = "(?:^|-)" + match[2] + "(?:-|$)";
|
|
2894
2899
|
source = "var p;if(((e.isConnected&&(e.lang==\"\"&&(p=s.ancestor(\"[lang]\",e)))&&(p.lang==\"" + match[2] + "\")||/" + expr + "/i.test(e.lang)))){" + source + "};";
|
|
2895
2900
|
break;
|
|
2896
|
-
default:
|
|
2897
|
-
emit("'" + expression + "'" + qsInvalid);
|
|
2898
|
-
break;
|
|
2901
|
+
default: emit("'" + expression + "'" + qsInvalid);
|
|
2899
2902
|
}
|
|
2900
2903
|
} else if (match = selector.match(Patterns.locationpc)) {
|
|
2901
2904
|
match[1] = match[1].toLowerCase();
|
|
@@ -2915,9 +2918,7 @@ var import_nwsapi = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((exp
|
|
|
2915
2918
|
case "defined":
|
|
2916
2919
|
source = "n=s.doc.defaultView.customElements.get(e.localName);if(n&&e instanceof n){" + source + "}";
|
|
2917
2920
|
break;
|
|
2918
|
-
default:
|
|
2919
|
-
emit("'" + expression + "'" + qsInvalid);
|
|
2920
|
-
break;
|
|
2921
|
+
default: emit("'" + expression + "'" + qsInvalid);
|
|
2921
2922
|
}
|
|
2922
2923
|
} else if (match = selector.match(Patterns.useraction)) {
|
|
2923
2924
|
match[1] = match[1].toLowerCase();
|
|
@@ -2937,9 +2938,7 @@ var import_nwsapi = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((exp
|
|
|
2937
2938
|
case "focus-within":
|
|
2938
2939
|
source = "if(n=s.isFocusable(e)){if(n!==e){while(n){n=n.parentElement;if(n===e)break;}}}if((n===e||n.autofocus)){" + source + "}";
|
|
2939
2940
|
break;
|
|
2940
|
-
default:
|
|
2941
|
-
emit("'" + expression + "'" + qsInvalid);
|
|
2942
|
-
break;
|
|
2941
|
+
default: emit("'" + expression + "'" + qsInvalid);
|
|
2943
2942
|
}
|
|
2944
2943
|
} else if (match = selector.match(Patterns.inputstate)) {
|
|
2945
2944
|
match[1] = match[1].toLowerCase();
|
|
@@ -2962,9 +2961,7 @@ var import_nwsapi = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((exp
|
|
|
2962
2961
|
case "default":
|
|
2963
2962
|
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 + "}";
|
|
2964
2963
|
break;
|
|
2965
|
-
default:
|
|
2966
|
-
emit("'" + expression + "'" + qsInvalid);
|
|
2967
|
-
break;
|
|
2964
|
+
default: emit("'" + expression + "'" + qsInvalid);
|
|
2968
2965
|
}
|
|
2969
2966
|
} else if (match = selector.match(Patterns.inputvalue)) {
|
|
2970
2967
|
match[1] = match[1].toLowerCase();
|
|
@@ -2993,9 +2990,7 @@ var import_nwsapi = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((exp
|
|
|
2993
2990
|
case "out-of-range":
|
|
2994
2991
|
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 + "}";
|
|
2995
2992
|
break;
|
|
2996
|
-
default:
|
|
2997
|
-
emit("'" + expression + "'" + qsInvalid);
|
|
2998
|
-
break;
|
|
2993
|
+
default: emit("'" + expression + "'" + qsInvalid);
|
|
2999
2994
|
}
|
|
3000
2995
|
} else if (match = selector.match(Patterns.rsrc_state)) {
|
|
3001
2996
|
match[1] = match[1].toLowerCase();
|
|
@@ -3011,11 +3006,7 @@ var import_nwsapi = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((exp
|
|
|
3011
3006
|
break;
|
|
3012
3007
|
case "buffering": break;
|
|
3013
3008
|
case "stalled": break;
|
|
3014
|
-
case "muted":
|
|
3015
|
-
source = "if(e.localName==\"audio\"&&e.getAttribute(\"muted\")){" + source + "}";
|
|
3016
|
-
break;
|
|
3017
|
-
case "volume-locked": break;
|
|
3018
|
-
default: break;
|
|
3009
|
+
case "muted": source = "if(e.localName==\"audio\"&&e.getAttribute(\"muted\")){" + source + "}";
|
|
3019
3010
|
}
|
|
3020
3011
|
} else if (match = selector.match(Patterns.pseudo_nop)) break;
|
|
3021
3012
|
else if (match = selector.match(Patterns.pseudo_sng)) source = "if(e.element&&e.type.toLowerCase()==\":" + match[0].toLowerCase() + "\"){e=e.element;" + source + "}";
|
|
@@ -3059,7 +3050,7 @@ var import_nwsapi = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((exp
|
|
|
3059
3050
|
return source;
|
|
3060
3051
|
}, makeref = function(selectors, element) {
|
|
3061
3052
|
if (element.nodeType === 9) element = element.documentElement;
|
|
3062
|
-
return selectors.replace(/:scope/i, element.localName + (element.id ? "#" +
|
|
3053
|
+
return selectors.replace(/:scope/i, element.localName + (element.id ? "#" + escapeIdentifier(element.id) : "") + (element.className ? "." + escapeIdentifier(element.classList[0]) : ""));
|
|
3063
3054
|
}, ancestor = function _closest(selectors, element, callback) {
|
|
3064
3055
|
parse(selectors, true);
|
|
3065
3056
|
selectors = makeref(selectors, element);
|
|
@@ -3082,10 +3073,12 @@ var import_nwsapi = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((exp
|
|
|
3082
3073
|
} else if (arguments[0] === "") {
|
|
3083
3074
|
emit("''" + qsInvalid);
|
|
3084
3075
|
return Config.VERBOSITY ? void 0 : type ? none : false;
|
|
3076
|
+
} else if (/^[.#]?\d/.test(selectors)) {
|
|
3077
|
+
emit("''" + qsInvalid);
|
|
3078
|
+
return Config.VERBOSITY ? void 0 : type ? none : false;
|
|
3085
3079
|
}
|
|
3086
3080
|
if (typeof selectors != "string") selectors = "" + selectors;
|
|
3087
|
-
|
|
3088
|
-
parsed = unescape(selectors).replace(/\x00|\\$/g, "�").replace(REX.CombineWSP, " ").replace(REX.PseudosWSP, "$1").replace(REX.TabCharWSP, " ").replace(REX.CommaGroup, ",").replace(REX.TrimSpaces, "");
|
|
3081
|
+
parsed = selectors.replace(/\x00|\\$/g, "�").replace(REX.CombineWSP, " ").replace(REX.PseudosWSP, "$1").replace(REX.TabCharWSP, " ").replace(REX.CommaGroup, ",").replace(REX.TrimSpaces, "");
|
|
3089
3082
|
if ((selectors = parsed.match(reValidator)) && selectors.join("") == parsed) {
|
|
3090
3083
|
selectors = parsed.match(REX.SplitGroup);
|
|
3091
3084
|
if (parsed[parsed.length - 1] == ",") {
|
|
@@ -3256,6 +3249,7 @@ var import_nwsapi = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((exp
|
|
|
3256
3249
|
byTag,
|
|
3257
3250
|
first,
|
|
3258
3251
|
match,
|
|
3252
|
+
select,
|
|
3259
3253
|
ancestor,
|
|
3260
3254
|
nthOfType,
|
|
3261
3255
|
nthElement,
|
|
@@ -3277,8 +3271,8 @@ var import_nwsapi = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((exp
|
|
|
3277
3271
|
byId,
|
|
3278
3272
|
byTag,
|
|
3279
3273
|
byClass,
|
|
3280
|
-
match,
|
|
3281
3274
|
first,
|
|
3275
|
+
match,
|
|
3282
3276
|
select,
|
|
3283
3277
|
closest: ancestor,
|
|
3284
3278
|
compile,
|
|
@@ -4205,11 +4199,13 @@ function createConsole() {
|
|
|
4205
4199
|
var MockHeaders = class {
|
|
4206
4200
|
_values = [];
|
|
4207
4201
|
constructor(init) {
|
|
4208
|
-
if (typeof init === "object")
|
|
4209
|
-
|
|
4210
|
-
|
|
4211
|
-
|
|
4212
|
-
|
|
4202
|
+
if (typeof init === "object") {
|
|
4203
|
+
if (typeof init[Symbol.iterator] === "function") {
|
|
4204
|
+
const kvs = [];
|
|
4205
|
+
for (const kv of init) if (typeof kv[Symbol.iterator] === "function") kvs.push([...kv]);
|
|
4206
|
+
for (const kv of kvs) this.append(kv[0], kv[1]);
|
|
4207
|
+
} else for (const key in init) this.append(key, init[key]);
|
|
4208
|
+
}
|
|
4213
4209
|
}
|
|
4214
4210
|
append(key, value) {
|
|
4215
4211
|
this._values.push([key, value + ""]);
|
|
@@ -5517,7 +5513,7 @@ function resetDocument(doc) {
|
|
|
5517
5513
|
} catch {}
|
|
5518
5514
|
}
|
|
5519
5515
|
}
|
|
5520
|
-
const DOC_KEY_KEEPERS = new Set([
|
|
5516
|
+
const DOC_KEY_KEEPERS = /* @__PURE__ */ new Set([
|
|
5521
5517
|
"nodeName",
|
|
5522
5518
|
"nodeType",
|
|
5523
5519
|
"nodeValue",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stencil/mock-doc",
|
|
3
|
-
"version": "5.0.0-alpha.
|
|
3
|
+
"version": "5.0.0-alpha.29",
|
|
4
4
|
"description": "A minimal mock DOM implementation for SSR and testing",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"dom",
|
|
@@ -32,14 +32,14 @@
|
|
|
32
32
|
}
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"nwsapi": "^2.
|
|
36
|
-
"parse5": "^8.0.
|
|
35
|
+
"nwsapi": "^2.2.24",
|
|
36
|
+
"parse5": "^8.0.1"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
|
-
"@stencil/vitest": "^1.
|
|
40
|
-
"tsdown": "
|
|
41
|
-
"typescript": "
|
|
42
|
-
"vitest": "^4.1.
|
|
39
|
+
"@stencil/vitest": "^1.14.0",
|
|
40
|
+
"tsdown": "^0.22.14",
|
|
41
|
+
"typescript": "^6.0.3",
|
|
42
|
+
"vitest": "^4.1.10"
|
|
43
43
|
},
|
|
44
44
|
"volta": {
|
|
45
45
|
"extends": "../../package.json"
|
/package/{LICENSE.md → LICENSE}
RENAMED
|
File without changes
|