htmljs-parser 5.0.1 → 5.0.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/index.js CHANGED
@@ -1249,6 +1249,22 @@ var HTML_CONTENT = {
1249
1249
  this.endText();
1250
1250
  this.enterState(states_exports.INLINE_SCRIPT);
1251
1251
  this.pos++;
1252
+ } else if (code === 47 /* FORWARD_SLASH */) {
1253
+ switch (this.lookAtCharCodeAhead(1)) {
1254
+ case 47 /* FORWARD_SLASH */:
1255
+ this.endText();
1256
+ this.enterState(states_exports.JS_COMMENT_LINE);
1257
+ this.pos++;
1258
+ break;
1259
+ case 42 /* ASTERISK */:
1260
+ this.endText();
1261
+ this.enterState(states_exports.JS_COMMENT_BLOCK);
1262
+ this.pos++;
1263
+ break;
1264
+ default:
1265
+ this.startText();
1266
+ break;
1267
+ }
1252
1268
  } else if (!states_exports.checkForPlaceholder(this, code)) {
1253
1269
  this.startText();
1254
1270
  }
@@ -1267,7 +1283,31 @@ var HTML_CONTENT = {
1267
1283
  }
1268
1284
  },
1269
1285
  eof: htmlEOF,
1270
- return() {
1286
+ return(child) {
1287
+ var _a, _b, _c, _d;
1288
+ switch (child.state) {
1289
+ case states_exports.JS_COMMENT_LINE:
1290
+ (_b = (_a = this.options).onComment) == null ? void 0 : _b.call(_a, {
1291
+ start: child.start,
1292
+ end: child.end,
1293
+ value: {
1294
+ start: child.start + 2,
1295
+ end: child.end
1296
+ }
1297
+ });
1298
+ break;
1299
+ case states_exports.JS_COMMENT_BLOCK: {
1300
+ (_d = (_c = this.options).onComment) == null ? void 0 : _d.call(_c, {
1301
+ start: child.start,
1302
+ end: child.end,
1303
+ value: {
1304
+ start: child.start + 2,
1305
+ end: child.end - 2
1306
+ }
1307
+ });
1308
+ break;
1309
+ }
1310
+ }
1271
1311
  }
1272
1312
  };
1273
1313
  function isBeginningOfLine(parser) {
@@ -1933,10 +1973,17 @@ var OPEN_TAG = {
1933
1973
  if (code === 60 /* OPEN_ANGLE_BRACKET */) {
1934
1974
  return this.emitError(this.pos, 2 /* INVALID_ATTRIBUTE_NAME */, 'Invalid attribute name. Attribute name cannot begin with the "<" character.');
1935
1975
  }
1936
- if (code === 47 /* FORWARD_SLASH */ && this.lookAtCharCodeAhead(1) === 42 /* ASTERISK */) {
1937
- this.enterState(states_exports.JS_COMMENT_BLOCK);
1938
- this.pos++;
1939
- return;
1976
+ if (code === 47 /* FORWARD_SLASH */) {
1977
+ switch (this.lookAtCharCodeAhead(1)) {
1978
+ case 47 /* FORWARD_SLASH */:
1979
+ this.enterState(states_exports.JS_COMMENT_LINE);
1980
+ this.pos++;
1981
+ return;
1982
+ case 42 /* ASTERISK */:
1983
+ this.enterState(states_exports.JS_COMMENT_BLOCK);
1984
+ this.pos++;
1985
+ return;
1986
+ }
1940
1987
  }
1941
1988
  if (isWhitespaceCode(code)) {
1942
1989
  } else if (code === 44 /* COMMA */) {
package/dist/index.mjs CHANGED
@@ -1228,6 +1228,22 @@ var HTML_CONTENT = {
1228
1228
  this.endText();
1229
1229
  this.enterState(states_exports.INLINE_SCRIPT);
1230
1230
  this.pos++;
1231
+ } else if (code === 47 /* FORWARD_SLASH */) {
1232
+ switch (this.lookAtCharCodeAhead(1)) {
1233
+ case 47 /* FORWARD_SLASH */:
1234
+ this.endText();
1235
+ this.enterState(states_exports.JS_COMMENT_LINE);
1236
+ this.pos++;
1237
+ break;
1238
+ case 42 /* ASTERISK */:
1239
+ this.endText();
1240
+ this.enterState(states_exports.JS_COMMENT_BLOCK);
1241
+ this.pos++;
1242
+ break;
1243
+ default:
1244
+ this.startText();
1245
+ break;
1246
+ }
1231
1247
  } else if (!states_exports.checkForPlaceholder(this, code)) {
1232
1248
  this.startText();
1233
1249
  }
@@ -1246,7 +1262,31 @@ var HTML_CONTENT = {
1246
1262
  }
1247
1263
  },
1248
1264
  eof: htmlEOF,
1249
- return() {
1265
+ return(child) {
1266
+ var _a, _b, _c, _d;
1267
+ switch (child.state) {
1268
+ case states_exports.JS_COMMENT_LINE:
1269
+ (_b = (_a = this.options).onComment) == null ? void 0 : _b.call(_a, {
1270
+ start: child.start,
1271
+ end: child.end,
1272
+ value: {
1273
+ start: child.start + 2,
1274
+ end: child.end
1275
+ }
1276
+ });
1277
+ break;
1278
+ case states_exports.JS_COMMENT_BLOCK: {
1279
+ (_d = (_c = this.options).onComment) == null ? void 0 : _d.call(_c, {
1280
+ start: child.start,
1281
+ end: child.end,
1282
+ value: {
1283
+ start: child.start + 2,
1284
+ end: child.end - 2
1285
+ }
1286
+ });
1287
+ break;
1288
+ }
1289
+ }
1250
1290
  }
1251
1291
  };
1252
1292
  function isBeginningOfLine(parser) {
@@ -1912,10 +1952,17 @@ var OPEN_TAG = {
1912
1952
  if (code === 60 /* OPEN_ANGLE_BRACKET */) {
1913
1953
  return this.emitError(this.pos, 2 /* INVALID_ATTRIBUTE_NAME */, 'Invalid attribute name. Attribute name cannot begin with the "<" character.');
1914
1954
  }
1915
- if (code === 47 /* FORWARD_SLASH */ && this.lookAtCharCodeAhead(1) === 42 /* ASTERISK */) {
1916
- this.enterState(states_exports.JS_COMMENT_BLOCK);
1917
- this.pos++;
1918
- return;
1955
+ if (code === 47 /* FORWARD_SLASH */) {
1956
+ switch (this.lookAtCharCodeAhead(1)) {
1957
+ case 47 /* FORWARD_SLASH */:
1958
+ this.enterState(states_exports.JS_COMMENT_LINE);
1959
+ this.pos++;
1960
+ return;
1961
+ case 42 /* ASTERISK */:
1962
+ this.enterState(states_exports.JS_COMMENT_BLOCK);
1963
+ this.pos++;
1964
+ return;
1965
+ }
1919
1966
  }
1920
1967
  if (isWhitespaceCode(code)) {
1921
1968
  } else if (code === 44 /* COMMA */) {
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.0.1",
4
+ "version": "5.0.2",
5
5
  "devDependencies": {
6
6
  "@changesets/changelog-github": "^0.4.4",
7
7
  "@changesets/cli": "^2.22.0",