htmljs-parser 3.3.4 → 3.3.5
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 +15 -16
- package/dist/index.mjs +15 -16
- package/package.json +2 -3
package/dist/index.js
CHANGED
|
@@ -422,6 +422,7 @@ var ATTRIBUTE = {
|
|
|
422
422
|
return;
|
|
423
423
|
} else if (code === 61 /* EQUAL */ || code === 58 /* COLON */ && this.lookAtCharCodeAhead(1) === 61 /* EQUAL */ || code === 46 /* PERIOD */ && this.lookAheadFor("..")) {
|
|
424
424
|
attr.valueStart = this.pos;
|
|
425
|
+
this.forward = 0;
|
|
425
426
|
if (code === 58 /* COLON */) {
|
|
426
427
|
ensureAttrName(this, attr);
|
|
427
428
|
attr.bound = true;
|
|
@@ -439,28 +440,27 @@ var ATTRIBUTE = {
|
|
|
439
440
|
const expr = this.enterState(states_exports.EXPRESSION);
|
|
440
441
|
expr.terminatedByWhitespace = true;
|
|
441
442
|
expr.terminator = this.isConcise ? CONCISE_VALUE_TERMINATORS : HTML_VALUE_TERMINATORS;
|
|
442
|
-
this.pos--;
|
|
443
443
|
} else if (code === 40 /* OPEN_PAREN */) {
|
|
444
444
|
ensureAttrName(this, attr);
|
|
445
445
|
attr.stage = 3 /* ARGUMENT */;
|
|
446
446
|
this.pos++;
|
|
447
|
+
this.forward = 0;
|
|
447
448
|
this.enterState(states_exports.EXPRESSION).terminator = 41 /* CLOSE_PAREN */;
|
|
448
|
-
this.pos--;
|
|
449
449
|
} else if (code === 123 /* OPEN_CURLY_BRACE */ && attr.args) {
|
|
450
450
|
ensureAttrName(this, attr);
|
|
451
451
|
attr.stage = 4 /* BLOCK */;
|
|
452
452
|
this.pos++;
|
|
453
|
+
this.forward = 0;
|
|
453
454
|
const expr = this.enterState(states_exports.EXPRESSION);
|
|
454
455
|
expr.terminatedByWhitespace = false;
|
|
455
456
|
expr.terminator = 125 /* CLOSE_CURLY_BRACE */;
|
|
456
|
-
this.pos--;
|
|
457
457
|
} else if (attr.stage === 0 /* UNKNOWN */) {
|
|
458
458
|
attr.stage = 1 /* NAME */;
|
|
459
|
+
this.forward = 0;
|
|
459
460
|
const expr = this.enterState(states_exports.EXPRESSION);
|
|
460
461
|
expr.terminatedByWhitespace = true;
|
|
461
462
|
expr.skipOperators = true;
|
|
462
463
|
expr.terminator = this.isConcise ? CONCISE_NAME_TERMINATORS : HTML_NAME_TERMINATORS;
|
|
463
|
-
this.pos--;
|
|
464
464
|
} else {
|
|
465
465
|
this.exitState();
|
|
466
466
|
}
|
|
@@ -597,8 +597,8 @@ var BEGIN_DELIMITED_HTML_BLOCK = {
|
|
|
597
597
|
const startPos = this.pos;
|
|
598
598
|
if (!this.consumeWhitespaceOnLine()) {
|
|
599
599
|
this.pos = startPos + 1;
|
|
600
|
+
this.forward = 0;
|
|
600
601
|
this.beginHtmlBlock(void 0, true);
|
|
601
|
-
this.pos--;
|
|
602
602
|
}
|
|
603
603
|
}
|
|
604
604
|
},
|
|
@@ -861,7 +861,7 @@ var CONCISE_HTML_CONTENT = {
|
|
|
861
861
|
}
|
|
862
862
|
}
|
|
863
863
|
this.enterState(states_exports.OPEN_TAG);
|
|
864
|
-
this.
|
|
864
|
+
this.forward = 0;
|
|
865
865
|
}
|
|
866
866
|
},
|
|
867
867
|
eol() {
|
|
@@ -1307,17 +1307,16 @@ var INLINE_SCRIPT = {
|
|
|
1307
1307
|
eof() {
|
|
1308
1308
|
},
|
|
1309
1309
|
char(code, inlineScript) {
|
|
1310
|
+
this.forward = 0;
|
|
1310
1311
|
if (code === 123 /* OPEN_CURLY_BRACE */) {
|
|
1311
1312
|
inlineScript.block = true;
|
|
1312
1313
|
this.pos++;
|
|
1313
1314
|
const expr = this.enterState(states_exports.EXPRESSION);
|
|
1314
1315
|
expr.terminator = 125 /* CLOSE_CURLY_BRACE */;
|
|
1315
1316
|
expr.skipOperators = true;
|
|
1316
|
-
this.pos--;
|
|
1317
1317
|
} else {
|
|
1318
1318
|
const expr = this.enterState(states_exports.EXPRESSION);
|
|
1319
1319
|
expr.terminatedByEOL = true;
|
|
1320
|
-
this.pos--;
|
|
1321
1320
|
}
|
|
1322
1321
|
},
|
|
1323
1322
|
return(child, inlineScript) {
|
|
@@ -1513,8 +1512,8 @@ function checkForPlaceholder(parser, code) {
|
|
|
1513
1512
|
parser.endText();
|
|
1514
1513
|
parser.enterState(PLACEHOLDER).escape = escape;
|
|
1515
1514
|
parser.pos += escape ? 2 : 3;
|
|
1515
|
+
parser.forward = 0;
|
|
1516
1516
|
parser.enterState(states_exports.EXPRESSION).terminator = 125 /* CLOSE_CURLY_BRACE */;
|
|
1517
|
-
parser.pos--;
|
|
1518
1517
|
return true;
|
|
1519
1518
|
}
|
|
1520
1519
|
}
|
|
@@ -1660,8 +1659,8 @@ var TAG_NAME = {
|
|
|
1660
1659
|
char(code) {
|
|
1661
1660
|
if (code === 36 /* DOLLAR */ && this.lookAtCharCodeAhead(1) === 123 /* OPEN_CURLY_BRACE */) {
|
|
1662
1661
|
this.pos += 2;
|
|
1662
|
+
this.forward = 0;
|
|
1663
1663
|
this.enterState(states_exports.EXPRESSION).terminator = 125 /* CLOSE_CURLY_BRACE */;
|
|
1664
|
-
this.pos--;
|
|
1665
1664
|
} 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 */ || (this.isConcise ? code === 59 /* SEMICOLON */ : code === 62 /* CLOSE_ANGLE_BRACKET */)) {
|
|
1666
1665
|
this.activeTag.shorthandEnd = this.pos;
|
|
1667
1666
|
this.exitState();
|
|
@@ -1931,18 +1930,18 @@ var OPEN_TAG = {
|
|
|
1931
1930
|
if (isWhitespaceCode(code)) {
|
|
1932
1931
|
} else if (code === 44 /* COMMA */) {
|
|
1933
1932
|
this.pos++;
|
|
1933
|
+
this.forward = 0;
|
|
1934
1934
|
this.consumeWhitespace();
|
|
1935
|
-
this.pos--;
|
|
1936
1935
|
} else if (code === 47 /* FORWARD_SLASH */ && !tag.hasAttrs) {
|
|
1937
1936
|
tag.stage = 1 /* VAR */;
|
|
1938
1937
|
this.pos++;
|
|
1938
|
+
this.forward = 0;
|
|
1939
1939
|
if (isWhitespaceCode(this.lookAtCharCodeAhead(0))) {
|
|
1940
1940
|
return this.emitError(this.pos, 23 /* MISSING_TAG_VARIABLE */, "A slash was found that was not followed by a variable name or lhs expression");
|
|
1941
1941
|
}
|
|
1942
1942
|
const expr = this.enterState(states_exports.EXPRESSION);
|
|
1943
1943
|
expr.terminatedByWhitespace = true;
|
|
1944
1944
|
expr.terminator = this.isConcise ? CONCISE_TAG_VAR_TERMINATORS : HTML_TAG_VAR_TERMINATORS;
|
|
1945
|
-
this.pos--;
|
|
1946
1945
|
} else if (code === 40 /* OPEN_PAREN */ && !tag.hasAttrs) {
|
|
1947
1946
|
if (tag.hasArgs) {
|
|
1948
1947
|
this.emitError(this.pos, 11 /* INVALID_TAG_ARGUMENT */, "A tag can only have one argument");
|
|
@@ -1950,25 +1949,25 @@ var OPEN_TAG = {
|
|
|
1950
1949
|
}
|
|
1951
1950
|
tag.stage = 2 /* ARGUMENT */;
|
|
1952
1951
|
this.pos++;
|
|
1952
|
+
this.forward = 0;
|
|
1953
1953
|
const expr = this.enterState(states_exports.EXPRESSION);
|
|
1954
1954
|
expr.skipOperators = true;
|
|
1955
1955
|
expr.terminator = 41 /* CLOSE_PAREN */;
|
|
1956
|
-
this.pos--;
|
|
1957
1956
|
} else if (code === 124 /* PIPE */ && !tag.hasAttrs) {
|
|
1958
1957
|
tag.stage = 3 /* PARAMS */;
|
|
1959
1958
|
this.pos++;
|
|
1959
|
+
this.forward = 0;
|
|
1960
1960
|
const expr = this.enterState(states_exports.EXPRESSION);
|
|
1961
1961
|
expr.skipOperators = true;
|
|
1962
1962
|
expr.terminator = 124 /* PIPE */;
|
|
1963
|
-
this.pos--;
|
|
1964
1963
|
} else {
|
|
1964
|
+
this.forward = 0;
|
|
1965
1965
|
if (tag.tagName) {
|
|
1966
1966
|
this.enterState(states_exports.ATTRIBUTE);
|
|
1967
1967
|
tag.hasAttrs = true;
|
|
1968
1968
|
} else {
|
|
1969
1969
|
this.enterState(states_exports.TAG_NAME);
|
|
1970
1970
|
}
|
|
1971
|
-
this.pos--;
|
|
1972
1971
|
}
|
|
1973
1972
|
},
|
|
1974
1973
|
return(child, tag) {
|
|
@@ -2005,7 +2004,7 @@ var OPEN_TAG = {
|
|
|
2005
2004
|
attr.start = start;
|
|
2006
2005
|
attr.args = { start, end, value };
|
|
2007
2006
|
tag.hasAttrs = true;
|
|
2008
|
-
this.
|
|
2007
|
+
this.forward = 0;
|
|
2009
2008
|
} else {
|
|
2010
2009
|
tag.hasArgs = true;
|
|
2011
2010
|
(_d = (_c = this.options).onTagArgs) == null ? void 0 : _d.call(_c, {
|
package/dist/index.mjs
CHANGED
|
@@ -401,6 +401,7 @@ var ATTRIBUTE = {
|
|
|
401
401
|
return;
|
|
402
402
|
} else if (code === 61 /* EQUAL */ || code === 58 /* COLON */ && this.lookAtCharCodeAhead(1) === 61 /* EQUAL */ || code === 46 /* PERIOD */ && this.lookAheadFor("..")) {
|
|
403
403
|
attr.valueStart = this.pos;
|
|
404
|
+
this.forward = 0;
|
|
404
405
|
if (code === 58 /* COLON */) {
|
|
405
406
|
ensureAttrName(this, attr);
|
|
406
407
|
attr.bound = true;
|
|
@@ -418,28 +419,27 @@ var ATTRIBUTE = {
|
|
|
418
419
|
const expr = this.enterState(states_exports.EXPRESSION);
|
|
419
420
|
expr.terminatedByWhitespace = true;
|
|
420
421
|
expr.terminator = this.isConcise ? CONCISE_VALUE_TERMINATORS : HTML_VALUE_TERMINATORS;
|
|
421
|
-
this.pos--;
|
|
422
422
|
} else if (code === 40 /* OPEN_PAREN */) {
|
|
423
423
|
ensureAttrName(this, attr);
|
|
424
424
|
attr.stage = 3 /* ARGUMENT */;
|
|
425
425
|
this.pos++;
|
|
426
|
+
this.forward = 0;
|
|
426
427
|
this.enterState(states_exports.EXPRESSION).terminator = 41 /* CLOSE_PAREN */;
|
|
427
|
-
this.pos--;
|
|
428
428
|
} else if (code === 123 /* OPEN_CURLY_BRACE */ && attr.args) {
|
|
429
429
|
ensureAttrName(this, attr);
|
|
430
430
|
attr.stage = 4 /* BLOCK */;
|
|
431
431
|
this.pos++;
|
|
432
|
+
this.forward = 0;
|
|
432
433
|
const expr = this.enterState(states_exports.EXPRESSION);
|
|
433
434
|
expr.terminatedByWhitespace = false;
|
|
434
435
|
expr.terminator = 125 /* CLOSE_CURLY_BRACE */;
|
|
435
|
-
this.pos--;
|
|
436
436
|
} else if (attr.stage === 0 /* UNKNOWN */) {
|
|
437
437
|
attr.stage = 1 /* NAME */;
|
|
438
|
+
this.forward = 0;
|
|
438
439
|
const expr = this.enterState(states_exports.EXPRESSION);
|
|
439
440
|
expr.terminatedByWhitespace = true;
|
|
440
441
|
expr.skipOperators = true;
|
|
441
442
|
expr.terminator = this.isConcise ? CONCISE_NAME_TERMINATORS : HTML_NAME_TERMINATORS;
|
|
442
|
-
this.pos--;
|
|
443
443
|
} else {
|
|
444
444
|
this.exitState();
|
|
445
445
|
}
|
|
@@ -576,8 +576,8 @@ var BEGIN_DELIMITED_HTML_BLOCK = {
|
|
|
576
576
|
const startPos = this.pos;
|
|
577
577
|
if (!this.consumeWhitespaceOnLine()) {
|
|
578
578
|
this.pos = startPos + 1;
|
|
579
|
+
this.forward = 0;
|
|
579
580
|
this.beginHtmlBlock(void 0, true);
|
|
580
|
-
this.pos--;
|
|
581
581
|
}
|
|
582
582
|
}
|
|
583
583
|
},
|
|
@@ -840,7 +840,7 @@ var CONCISE_HTML_CONTENT = {
|
|
|
840
840
|
}
|
|
841
841
|
}
|
|
842
842
|
this.enterState(states_exports.OPEN_TAG);
|
|
843
|
-
this.
|
|
843
|
+
this.forward = 0;
|
|
844
844
|
}
|
|
845
845
|
},
|
|
846
846
|
eol() {
|
|
@@ -1286,17 +1286,16 @@ var INLINE_SCRIPT = {
|
|
|
1286
1286
|
eof() {
|
|
1287
1287
|
},
|
|
1288
1288
|
char(code, inlineScript) {
|
|
1289
|
+
this.forward = 0;
|
|
1289
1290
|
if (code === 123 /* OPEN_CURLY_BRACE */) {
|
|
1290
1291
|
inlineScript.block = true;
|
|
1291
1292
|
this.pos++;
|
|
1292
1293
|
const expr = this.enterState(states_exports.EXPRESSION);
|
|
1293
1294
|
expr.terminator = 125 /* CLOSE_CURLY_BRACE */;
|
|
1294
1295
|
expr.skipOperators = true;
|
|
1295
|
-
this.pos--;
|
|
1296
1296
|
} else {
|
|
1297
1297
|
const expr = this.enterState(states_exports.EXPRESSION);
|
|
1298
1298
|
expr.terminatedByEOL = true;
|
|
1299
|
-
this.pos--;
|
|
1300
1299
|
}
|
|
1301
1300
|
},
|
|
1302
1301
|
return(child, inlineScript) {
|
|
@@ -1492,8 +1491,8 @@ function checkForPlaceholder(parser, code) {
|
|
|
1492
1491
|
parser.endText();
|
|
1493
1492
|
parser.enterState(PLACEHOLDER).escape = escape;
|
|
1494
1493
|
parser.pos += escape ? 2 : 3;
|
|
1494
|
+
parser.forward = 0;
|
|
1495
1495
|
parser.enterState(states_exports.EXPRESSION).terminator = 125 /* CLOSE_CURLY_BRACE */;
|
|
1496
|
-
parser.pos--;
|
|
1497
1496
|
return true;
|
|
1498
1497
|
}
|
|
1499
1498
|
}
|
|
@@ -1639,8 +1638,8 @@ var TAG_NAME = {
|
|
|
1639
1638
|
char(code) {
|
|
1640
1639
|
if (code === 36 /* DOLLAR */ && this.lookAtCharCodeAhead(1) === 123 /* OPEN_CURLY_BRACE */) {
|
|
1641
1640
|
this.pos += 2;
|
|
1641
|
+
this.forward = 0;
|
|
1642
1642
|
this.enterState(states_exports.EXPRESSION).terminator = 125 /* CLOSE_CURLY_BRACE */;
|
|
1643
|
-
this.pos--;
|
|
1644
1643
|
} 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 */ || (this.isConcise ? code === 59 /* SEMICOLON */ : code === 62 /* CLOSE_ANGLE_BRACKET */)) {
|
|
1645
1644
|
this.activeTag.shorthandEnd = this.pos;
|
|
1646
1645
|
this.exitState();
|
|
@@ -1910,18 +1909,18 @@ var OPEN_TAG = {
|
|
|
1910
1909
|
if (isWhitespaceCode(code)) {
|
|
1911
1910
|
} else if (code === 44 /* COMMA */) {
|
|
1912
1911
|
this.pos++;
|
|
1912
|
+
this.forward = 0;
|
|
1913
1913
|
this.consumeWhitespace();
|
|
1914
|
-
this.pos--;
|
|
1915
1914
|
} else if (code === 47 /* FORWARD_SLASH */ && !tag.hasAttrs) {
|
|
1916
1915
|
tag.stage = 1 /* VAR */;
|
|
1917
1916
|
this.pos++;
|
|
1917
|
+
this.forward = 0;
|
|
1918
1918
|
if (isWhitespaceCode(this.lookAtCharCodeAhead(0))) {
|
|
1919
1919
|
return this.emitError(this.pos, 23 /* MISSING_TAG_VARIABLE */, "A slash was found that was not followed by a variable name or lhs expression");
|
|
1920
1920
|
}
|
|
1921
1921
|
const expr = this.enterState(states_exports.EXPRESSION);
|
|
1922
1922
|
expr.terminatedByWhitespace = true;
|
|
1923
1923
|
expr.terminator = this.isConcise ? CONCISE_TAG_VAR_TERMINATORS : HTML_TAG_VAR_TERMINATORS;
|
|
1924
|
-
this.pos--;
|
|
1925
1924
|
} else if (code === 40 /* OPEN_PAREN */ && !tag.hasAttrs) {
|
|
1926
1925
|
if (tag.hasArgs) {
|
|
1927
1926
|
this.emitError(this.pos, 11 /* INVALID_TAG_ARGUMENT */, "A tag can only have one argument");
|
|
@@ -1929,25 +1928,25 @@ var OPEN_TAG = {
|
|
|
1929
1928
|
}
|
|
1930
1929
|
tag.stage = 2 /* ARGUMENT */;
|
|
1931
1930
|
this.pos++;
|
|
1931
|
+
this.forward = 0;
|
|
1932
1932
|
const expr = this.enterState(states_exports.EXPRESSION);
|
|
1933
1933
|
expr.skipOperators = true;
|
|
1934
1934
|
expr.terminator = 41 /* CLOSE_PAREN */;
|
|
1935
|
-
this.pos--;
|
|
1936
1935
|
} else if (code === 124 /* PIPE */ && !tag.hasAttrs) {
|
|
1937
1936
|
tag.stage = 3 /* PARAMS */;
|
|
1938
1937
|
this.pos++;
|
|
1938
|
+
this.forward = 0;
|
|
1939
1939
|
const expr = this.enterState(states_exports.EXPRESSION);
|
|
1940
1940
|
expr.skipOperators = true;
|
|
1941
1941
|
expr.terminator = 124 /* PIPE */;
|
|
1942
|
-
this.pos--;
|
|
1943
1942
|
} else {
|
|
1943
|
+
this.forward = 0;
|
|
1944
1944
|
if (tag.tagName) {
|
|
1945
1945
|
this.enterState(states_exports.ATTRIBUTE);
|
|
1946
1946
|
tag.hasAttrs = true;
|
|
1947
1947
|
} else {
|
|
1948
1948
|
this.enterState(states_exports.TAG_NAME);
|
|
1949
1949
|
}
|
|
1950
|
-
this.pos--;
|
|
1951
1950
|
}
|
|
1952
1951
|
},
|
|
1953
1952
|
return(child, tag) {
|
|
@@ -1984,7 +1983,7 @@ var OPEN_TAG = {
|
|
|
1984
1983
|
attr.start = start;
|
|
1985
1984
|
attr.args = { start, end, value };
|
|
1986
1985
|
tag.hasAttrs = true;
|
|
1987
|
-
this.
|
|
1986
|
+
this.forward = 0;
|
|
1988
1987
|
} else {
|
|
1989
1988
|
tag.hasArgs = true;
|
|
1990
1989
|
(_d = (_c = this.options).onTagArgs) == null ? void 0 : _d.call(_c, {
|
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": "3.3.
|
|
4
|
+
"version": "3.3.5",
|
|
5
5
|
"devDependencies": {
|
|
6
6
|
"@changesets/changelog-github": "^0.4.4",
|
|
7
7
|
"@changesets/cli": "^2.22.0",
|
|
@@ -68,13 +68,12 @@
|
|
|
68
68
|
"lint:prettier": "prettier \"./**/*{.ts,.js,.json,.md,.yml,rc}\"",
|
|
69
69
|
"mocha": "cross-env NODE_ENV=test mocha \"./src/**/__tests__/*.test.ts\"",
|
|
70
70
|
"prepare": "husky install",
|
|
71
|
-
"prepublishOnly": "npm run build",
|
|
72
71
|
"publish": "npm run build && changeset publish",
|
|
73
72
|
"report": "open ./coverage/lcov-report/index.html",
|
|
74
73
|
"test": "npm run mocha -- --watch",
|
|
75
74
|
"test:inspect": "npm test -- --inspect",
|
|
76
75
|
"test:update": "npm run mocha -- --update",
|
|
77
|
-
"version": "changeset version"
|
|
76
|
+
"version": "changeset version && npm i --package-lock-only"
|
|
78
77
|
},
|
|
79
78
|
"types": "dist/index.d.ts"
|
|
80
79
|
}
|