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/es/core.js
CHANGED
|
@@ -1734,6 +1734,77 @@ function stripslashes(value) {
|
|
|
1734
1734
|
function escapeSelectorComponent(text) {
|
|
1735
1735
|
return text.toString().replace(/([^a-z0-9_-])/gi, "\\$1");
|
|
1736
1736
|
}
|
|
1737
|
+
/**
|
|
1738
|
+
* Returns true if the character is a delimiter for different kinds of selectors:
|
|
1739
|
+
*
|
|
1740
|
+
* - `.` - begins a class selector
|
|
1741
|
+
* - `#` - begins an id selector
|
|
1742
|
+
* - `[` - begins an attribute selector
|
|
1743
|
+
* - `:` - begins a pseudo class or element selector
|
|
1744
|
+
*/
|
|
1745
|
+
function isDelimiter(ch) {
|
|
1746
|
+
return /[.#[:]/.test(ch);
|
|
1747
|
+
}
|
|
1748
|
+
/**
|
|
1749
|
+
* Returns true if the character is a quotation mark.
|
|
1750
|
+
*/
|
|
1751
|
+
function isQuotationMark(ch) {
|
|
1752
|
+
return /['"]/.test(ch);
|
|
1753
|
+
}
|
|
1754
|
+
function isPseudoElement(ch, buffer) {
|
|
1755
|
+
return ch === ":" && buffer === ":";
|
|
1756
|
+
}
|
|
1757
|
+
/**
|
|
1758
|
+
* @internal
|
|
1759
|
+
*/
|
|
1760
|
+
function* splitPattern(pattern) {
|
|
1761
|
+
if (pattern === "") {
|
|
1762
|
+
return;
|
|
1763
|
+
}
|
|
1764
|
+
const end = pattern.length;
|
|
1765
|
+
let begin = 0;
|
|
1766
|
+
let cur = 1;
|
|
1767
|
+
let quoted = false;
|
|
1768
|
+
while (cur < end) {
|
|
1769
|
+
const ch = pattern[cur];
|
|
1770
|
+
const buffer = pattern.slice(begin, cur);
|
|
1771
|
+
/* escaped character, ignore whatever is next */
|
|
1772
|
+
if (ch === "\\") {
|
|
1773
|
+
cur += 2;
|
|
1774
|
+
continue;
|
|
1775
|
+
}
|
|
1776
|
+
/* if inside quoted string we only look for the end quotation mark */
|
|
1777
|
+
if (quoted) {
|
|
1778
|
+
if (ch === quoted) {
|
|
1779
|
+
quoted = false;
|
|
1780
|
+
}
|
|
1781
|
+
cur += 1;
|
|
1782
|
+
continue;
|
|
1783
|
+
}
|
|
1784
|
+
/* if the character is a quotation mark we store the character and the above
|
|
1785
|
+
* condition will look for a similar end quotation mark */
|
|
1786
|
+
if (isQuotationMark(ch)) {
|
|
1787
|
+
quoted = ch;
|
|
1788
|
+
cur += 1;
|
|
1789
|
+
continue;
|
|
1790
|
+
}
|
|
1791
|
+
/* special case when using :: pseudo element selector */
|
|
1792
|
+
if (isPseudoElement(ch, buffer)) {
|
|
1793
|
+
cur += 1;
|
|
1794
|
+
continue;
|
|
1795
|
+
}
|
|
1796
|
+
/* if the character is a delimiter we yield the string and reset the
|
|
1797
|
+
* position */
|
|
1798
|
+
if (isDelimiter(ch)) {
|
|
1799
|
+
begin = cur;
|
|
1800
|
+
yield buffer;
|
|
1801
|
+
}
|
|
1802
|
+
cur += 1;
|
|
1803
|
+
}
|
|
1804
|
+
/* yield the rest of the string */
|
|
1805
|
+
const tail = pattern.slice(begin, cur);
|
|
1806
|
+
yield tail;
|
|
1807
|
+
}
|
|
1737
1808
|
class Matcher {
|
|
1738
1809
|
}
|
|
1739
1810
|
class ClassMatcher extends Matcher {
|
|
@@ -1799,8 +1870,7 @@ class Pattern {
|
|
|
1799
1870
|
this.selector = pattern;
|
|
1800
1871
|
this.combinator = parseCombinator(match.shift(), pattern);
|
|
1801
1872
|
this.tagName = match.shift() || "*";
|
|
1802
|
-
|
|
1803
|
-
this.pattern = p.map((cur) => this.createMatcher(cur));
|
|
1873
|
+
this.pattern = Array.from(splitPattern(match[0]), (it) => this.createMatcher(it));
|
|
1804
1874
|
}
|
|
1805
1875
|
match(node, context) {
|
|
1806
1876
|
return node.is(this.tagName) && this.pattern.every((cur) => cur.match(node, context));
|
|
@@ -3086,7 +3156,7 @@ var TRANSFORMER_API;
|
|
|
3086
3156
|
/** @public */
|
|
3087
3157
|
const name = "html-validate";
|
|
3088
3158
|
/** @public */
|
|
3089
|
-
const version = "7.2
|
|
3159
|
+
const version = "7.3.2";
|
|
3090
3160
|
/** @public */
|
|
3091
3161
|
const homepage = "https://html-validate.org";
|
|
3092
3162
|
/** @public */
|
|
@@ -11519,7 +11589,7 @@ class Parser {
|
|
|
11519
11589
|
consumeDirective(token) {
|
|
11520
11590
|
const [text, , action, directive, end] = token.data;
|
|
11521
11591
|
if (end === "") {
|
|
11522
|
-
throw new
|
|
11592
|
+
throw new ParserError(token.location, `Missing end bracket "]" on directive "${text}"`);
|
|
11523
11593
|
}
|
|
11524
11594
|
const match = directive.match(/^(.*?)(?:\s*(?:--|:)\s*(.*))?$/);
|
|
11525
11595
|
/* istanbul ignore next: should not be possible, would be emitted as comment token */
|