html-validate 9.4.1 → 9.4.2
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/cjs/core.js +226 -161
- package/dist/cjs/core.js.map +1 -1
- package/dist/cjs/html-validate.d.ts +1 -0
- package/dist/cjs/html5.d.ts +1 -0
- package/dist/cjs/jest-worker.d.ts +1 -0
- package/dist/cjs/package.json +2 -2
- package/dist/cjs/vitest.d.ts +1 -0
- package/dist/es/core.js +226 -161
- package/dist/es/core.js.map +1 -1
- package/dist/es/html-validate.d.ts +1 -0
- package/dist/es/html5.d.ts +1 -0
- package/dist/es/jest-worker.d.ts +1 -0
- package/dist/es/package.json +2 -2
- package/dist/es/vitest.d.ts +1 -0
- package/dist/types/browser.d.ts +1 -1
- package/dist/types/index.d.ts +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "../types/html-validate";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "../types/html5";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "../types/jest-worker";
|
package/dist/cjs/package.json
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
}
|
|
2
|
+
"type": "commonjs"
|
|
3
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "../types/vitest";
|
package/dist/es/core.js
CHANGED
|
@@ -1935,15 +1935,15 @@ function nthChild(node, args) {
|
|
|
1935
1935
|
return cur === n;
|
|
1936
1936
|
}
|
|
1937
1937
|
|
|
1938
|
-
function scope(node) {
|
|
1939
|
-
return node.isSameNode(this.scope);
|
|
1938
|
+
function scope$1(node) {
|
|
1939
|
+
return Boolean(this.scope && node.isSameNode(this.scope));
|
|
1940
1940
|
}
|
|
1941
1941
|
|
|
1942
1942
|
const table = {
|
|
1943
1943
|
"first-child": firstChild,
|
|
1944
1944
|
"last-child": lastChild,
|
|
1945
1945
|
"nth-child": nthChild,
|
|
1946
|
-
scope
|
|
1946
|
+
scope: scope$1
|
|
1947
1947
|
};
|
|
1948
1948
|
function factory(name, context) {
|
|
1949
1949
|
const fn = table[name];
|
|
@@ -1954,139 +1954,12 @@ function factory(name, context) {
|
|
|
1954
1954
|
}
|
|
1955
1955
|
}
|
|
1956
1956
|
|
|
1957
|
-
const escapedCodepoints = ["9", "a", "d"];
|
|
1958
|
-
function* splitSelectorElements(selector) {
|
|
1959
|
-
let begin = 0;
|
|
1960
|
-
let end = 0;
|
|
1961
|
-
function initialState(ch, p) {
|
|
1962
|
-
if (ch === "\\") {
|
|
1963
|
-
return 1 /* ESCAPED */;
|
|
1964
|
-
}
|
|
1965
|
-
if (ch === " ") {
|
|
1966
|
-
end = p;
|
|
1967
|
-
return 2 /* WHITESPACE */;
|
|
1968
|
-
}
|
|
1969
|
-
return 0 /* INITIAL */;
|
|
1970
|
-
}
|
|
1971
|
-
function escapedState(ch) {
|
|
1972
|
-
if (escapedCodepoints.includes(ch)) {
|
|
1973
|
-
return 1 /* ESCAPED */;
|
|
1974
|
-
}
|
|
1975
|
-
return 0 /* INITIAL */;
|
|
1976
|
-
}
|
|
1977
|
-
function* whitespaceState(ch, p) {
|
|
1978
|
-
if (ch === " ") {
|
|
1979
|
-
return 2 /* WHITESPACE */;
|
|
1980
|
-
}
|
|
1981
|
-
yield selector.slice(begin, end);
|
|
1982
|
-
begin = p;
|
|
1983
|
-
end = p;
|
|
1984
|
-
return 0 /* INITIAL */;
|
|
1985
|
-
}
|
|
1986
|
-
let state = 0 /* INITIAL */;
|
|
1987
|
-
for (let p = 0; p < selector.length; p++) {
|
|
1988
|
-
const ch = selector[p];
|
|
1989
|
-
switch (state) {
|
|
1990
|
-
case 0 /* INITIAL */:
|
|
1991
|
-
state = initialState(ch, p);
|
|
1992
|
-
break;
|
|
1993
|
-
case 1 /* ESCAPED */:
|
|
1994
|
-
state = escapedState(ch);
|
|
1995
|
-
break;
|
|
1996
|
-
case 2 /* WHITESPACE */:
|
|
1997
|
-
state = yield* whitespaceState(ch, p);
|
|
1998
|
-
break;
|
|
1999
|
-
}
|
|
2000
|
-
}
|
|
2001
|
-
if (begin !== selector.length) {
|
|
2002
|
-
yield selector.slice(begin);
|
|
2003
|
-
}
|
|
2004
|
-
}
|
|
2005
|
-
|
|
2006
1957
|
function stripslashes(value) {
|
|
2007
1958
|
return value.replace(/\\(.)/g, "$1");
|
|
2008
1959
|
}
|
|
2009
|
-
|
|
2010
|
-
const replacement = {
|
|
2011
|
-
"\\9 ": " ",
|
|
2012
|
-
"\\a ": "\n",
|
|
2013
|
-
"\\d ": "\r"
|
|
2014
|
-
};
|
|
2015
|
-
return value.replace(
|
|
2016
|
-
/(\\[\u0039\u0061\u0064] )/g,
|
|
2017
|
-
(_, codepoint) => replacement[codepoint]
|
|
2018
|
-
);
|
|
1960
|
+
class Condition {
|
|
2019
1961
|
}
|
|
2020
|
-
|
|
2021
|
-
const codepoints = {
|
|
2022
|
-
" ": "\\9 ",
|
|
2023
|
-
"\n": "\\a ",
|
|
2024
|
-
"\r": "\\d "
|
|
2025
|
-
};
|
|
2026
|
-
return text.toString().replace(/([\t\n\r]|[^a-z0-9_-])/gi, (_, ch) => {
|
|
2027
|
-
if (codepoints[ch]) {
|
|
2028
|
-
return codepoints[ch];
|
|
2029
|
-
} else {
|
|
2030
|
-
return `\\${ch}`;
|
|
2031
|
-
}
|
|
2032
|
-
});
|
|
2033
|
-
}
|
|
2034
|
-
function generateIdSelector(id) {
|
|
2035
|
-
const escaped = escapeSelectorComponent(id);
|
|
2036
|
-
return escaped.match(/^\d/) ? `[id="${escaped}"]` : `#${escaped}`;
|
|
2037
|
-
}
|
|
2038
|
-
function isDelimiter(ch) {
|
|
2039
|
-
return /[.#[:]/.test(ch);
|
|
2040
|
-
}
|
|
2041
|
-
function isQuotationMark(ch) {
|
|
2042
|
-
return /['"]/.test(ch);
|
|
2043
|
-
}
|
|
2044
|
-
function isPseudoElement(ch, buffer) {
|
|
2045
|
-
return ch === ":" && buffer === ":";
|
|
2046
|
-
}
|
|
2047
|
-
function* splitPattern(pattern) {
|
|
2048
|
-
if (pattern === "") {
|
|
2049
|
-
return;
|
|
2050
|
-
}
|
|
2051
|
-
const end = pattern.length;
|
|
2052
|
-
let begin = 0;
|
|
2053
|
-
let cur = 1;
|
|
2054
|
-
let quoted = false;
|
|
2055
|
-
while (cur < end) {
|
|
2056
|
-
const ch = pattern[cur];
|
|
2057
|
-
const buffer = pattern.slice(begin, cur);
|
|
2058
|
-
if (ch === "\\") {
|
|
2059
|
-
cur += 2;
|
|
2060
|
-
continue;
|
|
2061
|
-
}
|
|
2062
|
-
if (quoted) {
|
|
2063
|
-
if (ch === quoted) {
|
|
2064
|
-
quoted = false;
|
|
2065
|
-
}
|
|
2066
|
-
cur += 1;
|
|
2067
|
-
continue;
|
|
2068
|
-
}
|
|
2069
|
-
if (isQuotationMark(ch)) {
|
|
2070
|
-
quoted = ch;
|
|
2071
|
-
cur += 1;
|
|
2072
|
-
continue;
|
|
2073
|
-
}
|
|
2074
|
-
if (isPseudoElement(ch, buffer)) {
|
|
2075
|
-
cur += 1;
|
|
2076
|
-
continue;
|
|
2077
|
-
}
|
|
2078
|
-
if (isDelimiter(ch)) {
|
|
2079
|
-
begin = cur;
|
|
2080
|
-
yield buffer;
|
|
2081
|
-
}
|
|
2082
|
-
cur += 1;
|
|
2083
|
-
}
|
|
2084
|
-
const tail = pattern.slice(begin, cur);
|
|
2085
|
-
yield tail;
|
|
2086
|
-
}
|
|
2087
|
-
class Matcher {
|
|
2088
|
-
}
|
|
2089
|
-
class ClassMatcher extends Matcher {
|
|
1962
|
+
class ClassCondition extends Condition {
|
|
2090
1963
|
classname;
|
|
2091
1964
|
constructor(classname) {
|
|
2092
1965
|
super();
|
|
@@ -2096,7 +1969,7 @@ class ClassMatcher extends Matcher {
|
|
|
2096
1969
|
return node.classList.contains(this.classname);
|
|
2097
1970
|
}
|
|
2098
1971
|
}
|
|
2099
|
-
class
|
|
1972
|
+
class IdCondition extends Condition {
|
|
2100
1973
|
id;
|
|
2101
1974
|
constructor(id) {
|
|
2102
1975
|
super();
|
|
@@ -2106,7 +1979,7 @@ class IdMatcher extends Matcher {
|
|
|
2106
1979
|
return node.id === this.id;
|
|
2107
1980
|
}
|
|
2108
1981
|
}
|
|
2109
|
-
class
|
|
1982
|
+
class AttributeCondition extends Condition {
|
|
2110
1983
|
key;
|
|
2111
1984
|
op;
|
|
2112
1985
|
value;
|
|
@@ -2132,7 +2005,7 @@ class AttrMatcher extends Matcher {
|
|
|
2132
2005
|
});
|
|
2133
2006
|
}
|
|
2134
2007
|
}
|
|
2135
|
-
class
|
|
2008
|
+
class PseudoClassCondition extends Condition {
|
|
2136
2009
|
name;
|
|
2137
2010
|
args;
|
|
2138
2011
|
constructor(pseudoclass, context) {
|
|
@@ -2150,11 +2023,62 @@ class PseudoClassMatcher extends Matcher {
|
|
|
2150
2023
|
return fn(node, this.args);
|
|
2151
2024
|
}
|
|
2152
2025
|
}
|
|
2153
|
-
|
|
2026
|
+
|
|
2027
|
+
function isDelimiter(ch) {
|
|
2028
|
+
return /[.#[:]/.test(ch);
|
|
2029
|
+
}
|
|
2030
|
+
function isQuotationMark(ch) {
|
|
2031
|
+
return /['"]/.test(ch);
|
|
2032
|
+
}
|
|
2033
|
+
function isPseudoElement(ch, buffer) {
|
|
2034
|
+
return ch === ":" && buffer === ":";
|
|
2035
|
+
}
|
|
2036
|
+
function* splitCompound(pattern) {
|
|
2037
|
+
if (pattern === "") {
|
|
2038
|
+
return;
|
|
2039
|
+
}
|
|
2040
|
+
const end = pattern.length;
|
|
2041
|
+
let begin = 0;
|
|
2042
|
+
let cur = 1;
|
|
2043
|
+
let quoted = false;
|
|
2044
|
+
while (cur < end) {
|
|
2045
|
+
const ch = pattern[cur];
|
|
2046
|
+
const buffer = pattern.slice(begin, cur);
|
|
2047
|
+
if (ch === "\\") {
|
|
2048
|
+
cur += 2;
|
|
2049
|
+
continue;
|
|
2050
|
+
}
|
|
2051
|
+
if (quoted) {
|
|
2052
|
+
if (ch === quoted) {
|
|
2053
|
+
quoted = false;
|
|
2054
|
+
}
|
|
2055
|
+
cur += 1;
|
|
2056
|
+
continue;
|
|
2057
|
+
}
|
|
2058
|
+
if (isQuotationMark(ch)) {
|
|
2059
|
+
quoted = ch;
|
|
2060
|
+
cur += 1;
|
|
2061
|
+
continue;
|
|
2062
|
+
}
|
|
2063
|
+
if (isPseudoElement(ch, buffer)) {
|
|
2064
|
+
cur += 1;
|
|
2065
|
+
continue;
|
|
2066
|
+
}
|
|
2067
|
+
if (isDelimiter(ch)) {
|
|
2068
|
+
begin = cur;
|
|
2069
|
+
yield buffer;
|
|
2070
|
+
}
|
|
2071
|
+
cur += 1;
|
|
2072
|
+
}
|
|
2073
|
+
const tail = pattern.slice(begin, cur);
|
|
2074
|
+
yield tail;
|
|
2075
|
+
}
|
|
2076
|
+
|
|
2077
|
+
class Compound {
|
|
2154
2078
|
combinator;
|
|
2155
2079
|
tagName;
|
|
2156
2080
|
selector;
|
|
2157
|
-
|
|
2081
|
+
conditions;
|
|
2158
2082
|
constructor(pattern) {
|
|
2159
2083
|
const match = pattern.match(/^([~+\->]?)((?:[*]|[^.#[:]+)?)([^]*)$/);
|
|
2160
2084
|
if (!match) {
|
|
@@ -2164,25 +2088,166 @@ class Pattern {
|
|
|
2164
2088
|
this.selector = pattern;
|
|
2165
2089
|
this.combinator = parseCombinator(match.shift(), pattern);
|
|
2166
2090
|
this.tagName = match.shift() || "*";
|
|
2167
|
-
this.
|
|
2091
|
+
this.conditions = Array.from(splitCompound(match[0]), (it) => this.createCondition(it));
|
|
2168
2092
|
}
|
|
2169
2093
|
match(node, context) {
|
|
2170
|
-
return node.is(this.tagName) && this.
|
|
2094
|
+
return node.is(this.tagName) && this.conditions.every((cur) => cur.match(node, context));
|
|
2171
2095
|
}
|
|
2172
|
-
|
|
2096
|
+
createCondition(pattern) {
|
|
2173
2097
|
switch (pattern[0]) {
|
|
2174
2098
|
case ".":
|
|
2175
|
-
return new
|
|
2099
|
+
return new ClassCondition(pattern.slice(1));
|
|
2176
2100
|
case "#":
|
|
2177
|
-
return new
|
|
2101
|
+
return new IdCondition(pattern.slice(1));
|
|
2178
2102
|
case "[":
|
|
2179
|
-
return new
|
|
2103
|
+
return new AttributeCondition(pattern.slice(1, -1));
|
|
2180
2104
|
case ":":
|
|
2181
|
-
return new
|
|
2105
|
+
return new PseudoClassCondition(pattern.slice(1), this.selector);
|
|
2182
2106
|
default:
|
|
2183
|
-
throw new Error(`Failed to create
|
|
2107
|
+
throw new Error(`Failed to create selector condition for "${pattern}"`);
|
|
2108
|
+
}
|
|
2109
|
+
}
|
|
2110
|
+
}
|
|
2111
|
+
|
|
2112
|
+
function* ancestors$1(element) {
|
|
2113
|
+
let current = element.parent;
|
|
2114
|
+
while (current && !current.isRootElement()) {
|
|
2115
|
+
yield current;
|
|
2116
|
+
current = current.parent;
|
|
2117
|
+
}
|
|
2118
|
+
}
|
|
2119
|
+
function* parent(element) {
|
|
2120
|
+
const parent2 = element.parent;
|
|
2121
|
+
if (parent2 && !parent2.isRootElement()) {
|
|
2122
|
+
yield parent2;
|
|
2123
|
+
}
|
|
2124
|
+
}
|
|
2125
|
+
function* adjacentSibling(element) {
|
|
2126
|
+
const sibling = element.previousSibling;
|
|
2127
|
+
if (sibling) {
|
|
2128
|
+
yield sibling;
|
|
2129
|
+
}
|
|
2130
|
+
}
|
|
2131
|
+
function* generalSibling(element) {
|
|
2132
|
+
const siblings = element.siblings;
|
|
2133
|
+
const index = siblings.findIndex((it) => it.isSameNode(element));
|
|
2134
|
+
for (let i = 0; i < index; i++) {
|
|
2135
|
+
yield siblings[i];
|
|
2136
|
+
}
|
|
2137
|
+
}
|
|
2138
|
+
function* scope(element) {
|
|
2139
|
+
yield element;
|
|
2140
|
+
}
|
|
2141
|
+
function candidatesFromCombinator(element, combinator) {
|
|
2142
|
+
switch (combinator) {
|
|
2143
|
+
case Combinator.DESCENDANT:
|
|
2144
|
+
return ancestors$1(element);
|
|
2145
|
+
case Combinator.CHILD:
|
|
2146
|
+
return parent(element);
|
|
2147
|
+
case Combinator.ADJACENT_SIBLING:
|
|
2148
|
+
return adjacentSibling(element);
|
|
2149
|
+
case Combinator.GENERAL_SIBLING:
|
|
2150
|
+
return generalSibling(element);
|
|
2151
|
+
/* istanbul ignore next -- cannot really happen, the selector would be malformed */
|
|
2152
|
+
case Combinator.SCOPE:
|
|
2153
|
+
return scope(element);
|
|
2154
|
+
}
|
|
2155
|
+
}
|
|
2156
|
+
function matchElement(element, compounds, context) {
|
|
2157
|
+
const last = compounds[compounds.length - 1];
|
|
2158
|
+
if (!last.match(element, context)) {
|
|
2159
|
+
return false;
|
|
2160
|
+
}
|
|
2161
|
+
const remainder = compounds.slice(0, -1);
|
|
2162
|
+
if (remainder.length === 0) {
|
|
2163
|
+
return true;
|
|
2164
|
+
}
|
|
2165
|
+
const candidates = candidatesFromCombinator(element, last.combinator);
|
|
2166
|
+
for (const candidate of candidates) {
|
|
2167
|
+
if (matchElement(candidate, remainder, context)) {
|
|
2168
|
+
return true;
|
|
2169
|
+
}
|
|
2170
|
+
}
|
|
2171
|
+
return false;
|
|
2172
|
+
}
|
|
2173
|
+
|
|
2174
|
+
const escapedCodepoints = ["9", "a", "d"];
|
|
2175
|
+
function* splitSelectorElements(selector) {
|
|
2176
|
+
let begin = 0;
|
|
2177
|
+
let end = 0;
|
|
2178
|
+
function initialState(ch, p) {
|
|
2179
|
+
if (ch === "\\") {
|
|
2180
|
+
return 1 /* ESCAPED */;
|
|
2181
|
+
}
|
|
2182
|
+
if (ch === " ") {
|
|
2183
|
+
end = p;
|
|
2184
|
+
return 2 /* WHITESPACE */;
|
|
2185
|
+
}
|
|
2186
|
+
return 0 /* INITIAL */;
|
|
2187
|
+
}
|
|
2188
|
+
function escapedState(ch) {
|
|
2189
|
+
if (escapedCodepoints.includes(ch)) {
|
|
2190
|
+
return 1 /* ESCAPED */;
|
|
2191
|
+
}
|
|
2192
|
+
return 0 /* INITIAL */;
|
|
2193
|
+
}
|
|
2194
|
+
function* whitespaceState(ch, p) {
|
|
2195
|
+
if (ch === " ") {
|
|
2196
|
+
return 2 /* WHITESPACE */;
|
|
2197
|
+
}
|
|
2198
|
+
yield selector.slice(begin, end);
|
|
2199
|
+
begin = p;
|
|
2200
|
+
end = p;
|
|
2201
|
+
return 0 /* INITIAL */;
|
|
2202
|
+
}
|
|
2203
|
+
let state = 0 /* INITIAL */;
|
|
2204
|
+
for (let p = 0; p < selector.length; p++) {
|
|
2205
|
+
const ch = selector[p];
|
|
2206
|
+
switch (state) {
|
|
2207
|
+
case 0 /* INITIAL */:
|
|
2208
|
+
state = initialState(ch, p);
|
|
2209
|
+
break;
|
|
2210
|
+
case 1 /* ESCAPED */:
|
|
2211
|
+
state = escapedState(ch);
|
|
2212
|
+
break;
|
|
2213
|
+
case 2 /* WHITESPACE */:
|
|
2214
|
+
state = yield* whitespaceState(ch, p);
|
|
2215
|
+
break;
|
|
2184
2216
|
}
|
|
2185
2217
|
}
|
|
2218
|
+
if (begin !== selector.length) {
|
|
2219
|
+
yield selector.slice(begin);
|
|
2220
|
+
}
|
|
2221
|
+
}
|
|
2222
|
+
|
|
2223
|
+
function unescapeCodepoint(value) {
|
|
2224
|
+
const replacement = {
|
|
2225
|
+
"\\9 ": " ",
|
|
2226
|
+
"\\a ": "\n",
|
|
2227
|
+
"\\d ": "\r"
|
|
2228
|
+
};
|
|
2229
|
+
return value.replace(
|
|
2230
|
+
/(\\[\u0039\u0061\u0064] )/g,
|
|
2231
|
+
(_, codepoint) => replacement[codepoint]
|
|
2232
|
+
);
|
|
2233
|
+
}
|
|
2234
|
+
function escapeSelectorComponent(text) {
|
|
2235
|
+
const codepoints = {
|
|
2236
|
+
" ": "\\9 ",
|
|
2237
|
+
"\n": "\\a ",
|
|
2238
|
+
"\r": "\\d "
|
|
2239
|
+
};
|
|
2240
|
+
return text.toString().replace(/([\t\n\r]|[^a-z0-9_-])/gi, (_, ch) => {
|
|
2241
|
+
if (codepoints[ch]) {
|
|
2242
|
+
return codepoints[ch];
|
|
2243
|
+
} else {
|
|
2244
|
+
return `\\${ch}`;
|
|
2245
|
+
}
|
|
2246
|
+
});
|
|
2247
|
+
}
|
|
2248
|
+
function generateIdSelector(id) {
|
|
2249
|
+
const escaped = escapeSelectorComponent(id);
|
|
2250
|
+
return escaped.match(/^\d/) ? `[id="${escaped}"]` : `#${escaped}`;
|
|
2186
2251
|
}
|
|
2187
2252
|
class Selector {
|
|
2188
2253
|
pattern;
|
|
@@ -2199,6 +2264,13 @@ class Selector {
|
|
|
2199
2264
|
const context = { scope: root };
|
|
2200
2265
|
yield* this.matchInternal(root, 0, context);
|
|
2201
2266
|
}
|
|
2267
|
+
/**
|
|
2268
|
+
* Returns `true` if the element matches this selector.
|
|
2269
|
+
*/
|
|
2270
|
+
matchElement(element) {
|
|
2271
|
+
const context = { scope: null };
|
|
2272
|
+
return matchElement(element, this.pattern, context);
|
|
2273
|
+
}
|
|
2202
2274
|
*matchInternal(root, level, context) {
|
|
2203
2275
|
if (level >= this.pattern.length) {
|
|
2204
2276
|
yield root;
|
|
@@ -2216,7 +2288,7 @@ class Selector {
|
|
|
2216
2288
|
static parse(selector) {
|
|
2217
2289
|
selector = selector.replace(/([+~>]) /g, "$1");
|
|
2218
2290
|
return Array.from(splitSelectorElements(selector), (element) => {
|
|
2219
|
-
return new
|
|
2291
|
+
return new Compound(unescapeCodepoint(element));
|
|
2220
2292
|
});
|
|
2221
2293
|
}
|
|
2222
2294
|
static findCandidates(root, pattern) {
|
|
@@ -2232,7 +2304,6 @@ class Selector {
|
|
|
2232
2304
|
case Combinator.SCOPE:
|
|
2233
2305
|
return [root];
|
|
2234
2306
|
}
|
|
2235
|
-
return [];
|
|
2236
2307
|
}
|
|
2237
2308
|
static findAdjacentSibling(node) {
|
|
2238
2309
|
let adjacent = false;
|
|
@@ -2568,17 +2639,11 @@ class HtmlElement extends DOMNode {
|
|
|
2568
2639
|
*
|
|
2569
2640
|
* Implementation of DOM specification of Element.matches(selectors).
|
|
2570
2641
|
*/
|
|
2571
|
-
matches(
|
|
2572
|
-
|
|
2573
|
-
|
|
2574
|
-
|
|
2575
|
-
}
|
|
2576
|
-
for (const match of root.querySelectorAll(selector)) {
|
|
2577
|
-
if (match.unique === this.unique) {
|
|
2578
|
-
return true;
|
|
2579
|
-
}
|
|
2580
|
-
}
|
|
2581
|
-
return false;
|
|
2642
|
+
matches(selectorList) {
|
|
2643
|
+
return selectorList.split(",").some((it) => {
|
|
2644
|
+
const selector = new Selector(it.trim());
|
|
2645
|
+
return selector.matchElement(this);
|
|
2646
|
+
});
|
|
2582
2647
|
}
|
|
2583
2648
|
get meta() {
|
|
2584
2649
|
return this.metaElement;
|
|
@@ -6018,7 +6083,7 @@ class ElementPermittedContent extends Rule {
|
|
|
6018
6083
|
}
|
|
6019
6084
|
validatePermittedDescendant(node, parent) {
|
|
6020
6085
|
for (let cur = parent; cur && !cur.isRootElement(); cur = /* istanbul ignore next */
|
|
6021
|
-
cur
|
|
6086
|
+
cur.parent ?? null) {
|
|
6022
6087
|
const meta = cur.meta;
|
|
6023
6088
|
if (!meta) {
|
|
6024
6089
|
continue;
|
|
@@ -6626,7 +6691,7 @@ class HeadingLevel extends Rule {
|
|
|
6626
6691
|
constructor(options) {
|
|
6627
6692
|
super({ ...defaults$j, ...options });
|
|
6628
6693
|
this.minInitialRank = parseMaxInitial(this.options.minInitialRank);
|
|
6629
|
-
this.sectionRoots = this.options.sectioningRoots.map((it) => new
|
|
6694
|
+
this.sectionRoots = this.options.sectioningRoots.map((it) => new Compound(it));
|
|
6630
6695
|
this.stack.push({
|
|
6631
6696
|
node: null,
|
|
6632
6697
|
current: 0,
|
|
@@ -11643,7 +11708,7 @@ class EventHandler {
|
|
|
11643
11708
|
}
|
|
11644
11709
|
|
|
11645
11710
|
const name = "html-validate";
|
|
11646
|
-
const version = "9.4.
|
|
11711
|
+
const version = "9.4.2";
|
|
11647
11712
|
const bugs = "https://gitlab.com/html-validate/html-validate/issues/new";
|
|
11648
11713
|
|
|
11649
11714
|
function freeze(src) {
|