htmljs-parser 5.3.0 → 5.4.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/dist/index.js CHANGED
@@ -272,6 +272,8 @@ var Parser = class {
272
272
  cur++;
273
273
  if (this.lookAheadFor(str, cur)) {
274
274
  this.pos = cur;
275
+ if (this.forward > 1)
276
+ this.forward = 1;
275
277
  return true;
276
278
  }
277
279
  return false;
@@ -458,7 +460,7 @@ var OPEN_TAG = {
458
460
  }
459
461
  },
460
462
  eol(_, tag) {
461
- if (this.isConcise && tag.stage !== 5 /* ATTR_GROUP */) {
463
+ if (this.isConcise && tag.stage !== 5 /* ATTR_GROUP */ && !this.consumeWhitespaceIfBefore(",")) {
462
464
  this.exitState();
463
465
  }
464
466
  },
@@ -1781,11 +1783,14 @@ function lookBehindForOperator(data, pos) {
1781
1783
  case 60 /* OPEN_ANGLE_BRACKET */:
1782
1784
  case 62 /* CLOSE_ANGLE_BRACKET */:
1783
1785
  case 37 /* PERCENT */:
1784
- case 46 /* PERIOD */:
1785
1786
  case 124 /* PIPE */:
1786
1787
  case 63 /* QUESTION */:
1787
1788
  case 126 /* TILDE */:
1788
1789
  return curPos;
1790
+ case 46 /* PERIOD */: {
1791
+ const nextPos = lookAheadWhile(isWhitespaceCode, data, pos);
1792
+ return isWordCode(data.charCodeAt(nextPos)) ? nextPos : -1;
1793
+ }
1789
1794
  case 43 /* PLUS */:
1790
1795
  case 45 /* HYPHEN */: {
1791
1796
  if (data.charCodeAt(curPos - 1) === code) {
@@ -1800,7 +1805,8 @@ function lookBehindForOperator(data, pos) {
1800
1805
  for (const keyword of unaryKeywords) {
1801
1806
  const keywordPos = lookBehindFor(data, curPos, keyword);
1802
1807
  if (keywordPos !== -1) {
1803
- return data.charCodeAt(keywordPos - 1) === 46 /* PERIOD */ ? -1 : keywordPos;
1808
+ const prevCode = data.charCodeAt(keywordPos - 1);
1809
+ return prevCode === 46 /* PERIOD */ || isWordCode(prevCode) ? -1 : keywordPos;
1804
1810
  }
1805
1811
  }
1806
1812
  return -1;
@@ -1828,8 +1834,10 @@ function lookAheadForOperator(data, pos) {
1828
1834
  case 123 /* OPEN_CURLY_BRACE */:
1829
1835
  case 40 /* OPEN_PAREN */:
1830
1836
  return pos;
1831
- case 46 /* PERIOD */:
1832
- return data.charCodeAt(pos + 1) === 46 /* PERIOD */ ? -1 : pos + 1;
1837
+ case 46 /* PERIOD */: {
1838
+ const nextPos = lookAheadWhile(isWhitespaceCode, data, pos + 1);
1839
+ return isWordCode(data.charCodeAt(nextPos)) ? nextPos : -1;
1840
+ }
1833
1841
  default: {
1834
1842
  for (const keyword of binaryKeywords) {
1835
1843
  let nextPos = lookAheadFor(data, pos, keyword);
@@ -1867,7 +1875,7 @@ function canFollowDivision(code) {
1867
1875
  return isWordCode(code) || code === 37 /* PERCENT */ || code === 41 /* CLOSE_PAREN */ || code === 46 /* PERIOD */ || code === 60 /* OPEN_ANGLE_BRACKET */ || code === 93 /* CLOSE_SQUARE_BRACKET */ || code === 125 /* CLOSE_CURLY_BRACE */;
1868
1876
  }
1869
1877
  function isWordCode(code) {
1870
- return code >= 65 /* UPPER_A */ && code <= 90 /* UPPER_Z */ || code >= 97 /* LOWER_A */ && code <= 122 /* LOWER_Z */ || code >= 48 /* NUMBER_0 */ && code <= 57 /* NUMBER_9 */ || code === 95 /* UNDERSCORE */;
1878
+ return code >= 65 /* UPPER_A */ && code <= 90 /* UPPER_Z */ || code >= 97 /* LOWER_A */ && code <= 122 /* LOWER_Z */ || code >= 48 /* NUMBER_0 */ && code <= 57 /* NUMBER_9 */ || code == 36 /* DOLLAR */ || code === 95 /* UNDERSCORE */;
1871
1879
  }
1872
1880
  function isIndentCode(code) {
1873
1881
  return code === 9 /* TAB */ || code === 32 /* SPACE */;
@@ -2521,7 +2529,7 @@ var TAG_NAME = {
2521
2529
  this.pos += 2;
2522
2530
  this.forward = 0;
2523
2531
  this.enterState(states_exports.EXPRESSION).shouldTerminate = matchesCloseCurlyBrace;
2524
- } else if (isWhitespaceCode(code) || code === 61 /* EQUAL */ || code === 58 /* COLON */ && this.lookAtCharCodeAhead(1) === 61 /* EQUAL */ || code === 40 /* OPEN_PAREN */ || code === 47 /* FORWARD_SLASH */ || code === 124 /* PIPE */ || code === 60 /* OPEN_ANGLE_BRACKET */ || (this.isConcise ? code === 59 /* SEMICOLON */ : code === 62 /* CLOSE_ANGLE_BRACKET */)) {
2532
+ } else if (isWhitespaceCode(code) || code === 61 /* EQUAL */ || code === 58 /* COLON */ && this.lookAtCharCodeAhead(1) === 61 /* EQUAL */ || code === 40 /* OPEN_PAREN */ || code === 47 /* FORWARD_SLASH */ || code === 124 /* PIPE */ || code === 60 /* OPEN_ANGLE_BRACKET */ || code === 44 /* COMMA */ || (this.isConcise ? code === 59 /* SEMICOLON */ : code === 62 /* CLOSE_ANGLE_BRACKET */)) {
2525
2533
  this.activeTag.shorthandEnd = this.pos;
2526
2534
  this.exitState();
2527
2535
  } else if (code === 46 /* PERIOD */ || code === 35 /* NUMBER_SIGN */) {
package/dist/index.mjs CHANGED
@@ -247,6 +247,8 @@ var Parser = class {
247
247
  cur++;
248
248
  if (this.lookAheadFor(str, cur)) {
249
249
  this.pos = cur;
250
+ if (this.forward > 1)
251
+ this.forward = 1;
250
252
  return true;
251
253
  }
252
254
  return false;
@@ -433,7 +435,7 @@ var OPEN_TAG = {
433
435
  }
434
436
  },
435
437
  eol(_, tag) {
436
- if (this.isConcise && tag.stage !== 5 /* ATTR_GROUP */) {
438
+ if (this.isConcise && tag.stage !== 5 /* ATTR_GROUP */ && !this.consumeWhitespaceIfBefore(",")) {
437
439
  this.exitState();
438
440
  }
439
441
  },
@@ -1756,11 +1758,14 @@ function lookBehindForOperator(data, pos) {
1756
1758
  case 60 /* OPEN_ANGLE_BRACKET */:
1757
1759
  case 62 /* CLOSE_ANGLE_BRACKET */:
1758
1760
  case 37 /* PERCENT */:
1759
- case 46 /* PERIOD */:
1760
1761
  case 124 /* PIPE */:
1761
1762
  case 63 /* QUESTION */:
1762
1763
  case 126 /* TILDE */:
1763
1764
  return curPos;
1765
+ case 46 /* PERIOD */: {
1766
+ const nextPos = lookAheadWhile(isWhitespaceCode, data, pos);
1767
+ return isWordCode(data.charCodeAt(nextPos)) ? nextPos : -1;
1768
+ }
1764
1769
  case 43 /* PLUS */:
1765
1770
  case 45 /* HYPHEN */: {
1766
1771
  if (data.charCodeAt(curPos - 1) === code) {
@@ -1775,7 +1780,8 @@ function lookBehindForOperator(data, pos) {
1775
1780
  for (const keyword of unaryKeywords) {
1776
1781
  const keywordPos = lookBehindFor(data, curPos, keyword);
1777
1782
  if (keywordPos !== -1) {
1778
- return data.charCodeAt(keywordPos - 1) === 46 /* PERIOD */ ? -1 : keywordPos;
1783
+ const prevCode = data.charCodeAt(keywordPos - 1);
1784
+ return prevCode === 46 /* PERIOD */ || isWordCode(prevCode) ? -1 : keywordPos;
1779
1785
  }
1780
1786
  }
1781
1787
  return -1;
@@ -1803,8 +1809,10 @@ function lookAheadForOperator(data, pos) {
1803
1809
  case 123 /* OPEN_CURLY_BRACE */:
1804
1810
  case 40 /* OPEN_PAREN */:
1805
1811
  return pos;
1806
- case 46 /* PERIOD */:
1807
- return data.charCodeAt(pos + 1) === 46 /* PERIOD */ ? -1 : pos + 1;
1812
+ case 46 /* PERIOD */: {
1813
+ const nextPos = lookAheadWhile(isWhitespaceCode, data, pos + 1);
1814
+ return isWordCode(data.charCodeAt(nextPos)) ? nextPos : -1;
1815
+ }
1808
1816
  default: {
1809
1817
  for (const keyword of binaryKeywords) {
1810
1818
  let nextPos = lookAheadFor(data, pos, keyword);
@@ -1842,7 +1850,7 @@ function canFollowDivision(code) {
1842
1850
  return isWordCode(code) || code === 37 /* PERCENT */ || code === 41 /* CLOSE_PAREN */ || code === 46 /* PERIOD */ || code === 60 /* OPEN_ANGLE_BRACKET */ || code === 93 /* CLOSE_SQUARE_BRACKET */ || code === 125 /* CLOSE_CURLY_BRACE */;
1843
1851
  }
1844
1852
  function isWordCode(code) {
1845
- return code >= 65 /* UPPER_A */ && code <= 90 /* UPPER_Z */ || code >= 97 /* LOWER_A */ && code <= 122 /* LOWER_Z */ || code >= 48 /* NUMBER_0 */ && code <= 57 /* NUMBER_9 */ || code === 95 /* UNDERSCORE */;
1853
+ return code >= 65 /* UPPER_A */ && code <= 90 /* UPPER_Z */ || code >= 97 /* LOWER_A */ && code <= 122 /* LOWER_Z */ || code >= 48 /* NUMBER_0 */ && code <= 57 /* NUMBER_9 */ || code == 36 /* DOLLAR */ || code === 95 /* UNDERSCORE */;
1846
1854
  }
1847
1855
  function isIndentCode(code) {
1848
1856
  return code === 9 /* TAB */ || code === 32 /* SPACE */;
@@ -2496,7 +2504,7 @@ var TAG_NAME = {
2496
2504
  this.pos += 2;
2497
2505
  this.forward = 0;
2498
2506
  this.enterState(states_exports.EXPRESSION).shouldTerminate = matchesCloseCurlyBrace;
2499
- } else if (isWhitespaceCode(code) || code === 61 /* EQUAL */ || code === 58 /* COLON */ && this.lookAtCharCodeAhead(1) === 61 /* EQUAL */ || code === 40 /* OPEN_PAREN */ || code === 47 /* FORWARD_SLASH */ || code === 124 /* PIPE */ || code === 60 /* OPEN_ANGLE_BRACKET */ || (this.isConcise ? code === 59 /* SEMICOLON */ : code === 62 /* CLOSE_ANGLE_BRACKET */)) {
2507
+ } else if (isWhitespaceCode(code) || code === 61 /* EQUAL */ || code === 58 /* COLON */ && this.lookAtCharCodeAhead(1) === 61 /* EQUAL */ || code === 40 /* OPEN_PAREN */ || code === 47 /* FORWARD_SLASH */ || code === 124 /* PIPE */ || code === 60 /* OPEN_ANGLE_BRACKET */ || code === 44 /* COMMA */ || (this.isConcise ? code === 59 /* SEMICOLON */ : code === 62 /* CLOSE_ANGLE_BRACKET */)) {
2500
2508
  this.activeTag.shorthandEnd = this.pos;
2501
2509
  this.exitState();
2502
2510
  } else if (code === 46 /* PERIOD */ || code === 35 /* NUMBER_SIGN */) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "htmljs-parser",
3
3
  "description": "An HTML parser recognizes content and string placeholders and allows JavaScript expressions as attribute values",
4
- "version": "5.3.0",
4
+ "version": "5.4.1",
5
5
  "devDependencies": {
6
6
  "@changesets/changelog-github": "^0.4.7",
7
7
  "@changesets/cli": "^2.25.2",