html-validate 7.2.0 → 7.3.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 +74 -4
- package/dist/cjs/core.js.map +1 -1
- package/dist/es/core.js +74 -4
- package/dist/es/core.js.map +1 -1
- package/elements/html5.js +4 -1
- package/package.json +9 -9
package/dist/cjs/core.js
CHANGED
|
@@ -1765,6 +1765,77 @@ function stripslashes(value) {
|
|
|
1765
1765
|
function escapeSelectorComponent(text) {
|
|
1766
1766
|
return text.toString().replace(/([^a-z0-9_-])/gi, "\\$1");
|
|
1767
1767
|
}
|
|
1768
|
+
/**
|
|
1769
|
+
* Returns true if the character is a delimiter for different kinds of selectors:
|
|
1770
|
+
*
|
|
1771
|
+
* - `.` - begins a class selector
|
|
1772
|
+
* - `#` - begins an id selector
|
|
1773
|
+
* - `[` - begins an attribute selector
|
|
1774
|
+
* - `:` - begins a pseudo class or element selector
|
|
1775
|
+
*/
|
|
1776
|
+
function isDelimiter(ch) {
|
|
1777
|
+
return /[.#[:]/.test(ch);
|
|
1778
|
+
}
|
|
1779
|
+
/**
|
|
1780
|
+
* Returns true if the character is a quotation mark.
|
|
1781
|
+
*/
|
|
1782
|
+
function isQuotationMark(ch) {
|
|
1783
|
+
return /['"]/.test(ch);
|
|
1784
|
+
}
|
|
1785
|
+
function isPseudoElement(ch, buffer) {
|
|
1786
|
+
return ch === ":" && buffer === ":";
|
|
1787
|
+
}
|
|
1788
|
+
/**
|
|
1789
|
+
* @internal
|
|
1790
|
+
*/
|
|
1791
|
+
function* splitPattern(pattern) {
|
|
1792
|
+
if (pattern === "") {
|
|
1793
|
+
return;
|
|
1794
|
+
}
|
|
1795
|
+
const end = pattern.length;
|
|
1796
|
+
let begin = 0;
|
|
1797
|
+
let cur = 1;
|
|
1798
|
+
let quoted = false;
|
|
1799
|
+
while (cur < end) {
|
|
1800
|
+
const ch = pattern[cur];
|
|
1801
|
+
const buffer = pattern.slice(begin, cur);
|
|
1802
|
+
/* escaped character, ignore whatever is next */
|
|
1803
|
+
if (ch === "\\") {
|
|
1804
|
+
cur += 2;
|
|
1805
|
+
continue;
|
|
1806
|
+
}
|
|
1807
|
+
/* if inside quoted string we only look for the end quotation mark */
|
|
1808
|
+
if (quoted) {
|
|
1809
|
+
if (ch === quoted) {
|
|
1810
|
+
quoted = false;
|
|
1811
|
+
}
|
|
1812
|
+
cur += 1;
|
|
1813
|
+
continue;
|
|
1814
|
+
}
|
|
1815
|
+
/* if the character is a quotation mark we store the character and the above
|
|
1816
|
+
* condition will look for a similar end quotation mark */
|
|
1817
|
+
if (isQuotationMark(ch)) {
|
|
1818
|
+
quoted = ch;
|
|
1819
|
+
cur += 1;
|
|
1820
|
+
continue;
|
|
1821
|
+
}
|
|
1822
|
+
/* special case when using :: pseudo element selector */
|
|
1823
|
+
if (isPseudoElement(ch, buffer)) {
|
|
1824
|
+
cur += 1;
|
|
1825
|
+
continue;
|
|
1826
|
+
}
|
|
1827
|
+
/* if the character is a delimiter we yield the string and reset the
|
|
1828
|
+
* position */
|
|
1829
|
+
if (isDelimiter(ch)) {
|
|
1830
|
+
begin = cur;
|
|
1831
|
+
yield buffer;
|
|
1832
|
+
}
|
|
1833
|
+
cur += 1;
|
|
1834
|
+
}
|
|
1835
|
+
/* yield the rest of the string */
|
|
1836
|
+
const tail = pattern.slice(begin, cur);
|
|
1837
|
+
yield tail;
|
|
1838
|
+
}
|
|
1768
1839
|
class Matcher {
|
|
1769
1840
|
}
|
|
1770
1841
|
class ClassMatcher extends Matcher {
|
|
@@ -1830,8 +1901,7 @@ class Pattern {
|
|
|
1830
1901
|
this.selector = pattern;
|
|
1831
1902
|
this.combinator = parseCombinator(match.shift(), pattern);
|
|
1832
1903
|
this.tagName = match.shift() || "*";
|
|
1833
|
-
|
|
1834
|
-
this.pattern = p.map((cur) => this.createMatcher(cur));
|
|
1904
|
+
this.pattern = Array.from(splitPattern(match[0]), (it) => this.createMatcher(it));
|
|
1835
1905
|
}
|
|
1836
1906
|
match(node, context) {
|
|
1837
1907
|
return node.is(this.tagName) && this.pattern.every((cur) => cur.match(node, context));
|
|
@@ -3117,7 +3187,7 @@ var TRANSFORMER_API;
|
|
|
3117
3187
|
/** @public */
|
|
3118
3188
|
const name = "html-validate";
|
|
3119
3189
|
/** @public */
|
|
3120
|
-
const version = "7.2
|
|
3190
|
+
const version = "7.3.2";
|
|
3121
3191
|
/** @public */
|
|
3122
3192
|
const homepage = "https://html-validate.org";
|
|
3123
3193
|
/** @public */
|
|
@@ -11550,7 +11620,7 @@ class Parser {
|
|
|
11550
11620
|
consumeDirective(token) {
|
|
11551
11621
|
const [text, , action, directive, end] = token.data;
|
|
11552
11622
|
if (end === "") {
|
|
11553
|
-
throw new
|
|
11623
|
+
throw new ParserError(token.location, `Missing end bracket "]" on directive "${text}"`);
|
|
11554
11624
|
}
|
|
11555
11625
|
const match = directive.match(/^(.*?)(?:\s*(?:--|:)\s*(.*))?$/);
|
|
11556
11626
|
/* istanbul ignore next: should not be possible, would be emitted as comment token */
|