marko-js / htmljs-parser

An HTML parser recognizes content and string placeholders and allows JavaScript expressions as attribute values
MIT License
135 stars 20 forks source link

fix: require a whitespace before js style comments inside html content #127

Closed DylanPiercey closed 2 years ago

DylanPiercey commented 2 years ago

Description

Fix regression around JS style comments in the body by requiring that they are preceded by a whitespace.

Motivation and Context

This was caused by #119 which noted that this was potentially a breaking change. We didn't for see a common edge case however which was http links inside some content, eg:

<a href="http://ebay.com">
  http://ebay.com
</a>

With #119 that caused the code above to treat //ebay.com as a JS comment which was not desirable. Now by requiring a whitespace (eg a newline) before any JS style comments within the html content we avoid this common gotcha while maintaining support for this syntax/feature.

Checklist:

changeset-bot[bot] commented 2 years ago

🦋 Changeset detected

Latest commit: b35460b5692aefa6d6cd8141eac8f476d7f986c2

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package | Name | Type | | ------------- | ----- | | htmljs-parser | Patch |

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

codecov[bot] commented 2 years ago

Codecov Report

Merging #127 (b35460b) into main (89fe2c7) will decrease coverage by 0.26%. The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main     #127      +/-   ##
==========================================
- Coverage   92.79%   92.53%   -0.27%     
==========================================
  Files          26       26              
  Lines         736      737       +1     
  Branches      253      254       +1     
==========================================
- Hits          683      682       -1     
- Misses         38       40       +2     
  Partials       15       15              
Impacted Files Coverage Δ
src/states/HTML_CONTENT.ts 93.02% <100.00%> (-4.60%) :arrow_down:

Help us with your feedback. Take ten seconds to tell us how you rate us.