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: always consume terminator if it is preceded by an operator #162

Closed DylanPiercey closed 1 year ago

DylanPiercey commented 1 year ago

Description

Ensures that in the expression state whenever a terminator is found for the expression and the terminator is preceded by an operator that expression state continues.

Motivation and Context

This allows for better parsing of expressions in several places. The case that brought about this change was as follows:

<let/a:(B | C) = D/>

With the above the tag variable state was being terminated by the ( and going into tag arguments / shorthand default method mode. With this change it will now see the paren and walk backward past whitespace to see the : which is an expression operator causing the (B | C) to be a part of the tag variable (for types).

Screenshots (if appropriate):

Checklist:

changeset-bot[bot] commented 1 year ago

🦋 Changeset detected

Latest commit: e8463ff045e6051646584172643d370ca7a220fb

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 1 year ago

Codecov Report

Patch coverage: 100.00% and project coverage change: +0.18 :tada:

Comparison is base (be73442) 93.66% compared to head (e8463ff) 93.84%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #162 +/- ## ========================================== + Coverage 93.66% 93.84% +0.18% ========================================== Files 27 27 Lines 1294 1300 +6 Branches 293 296 +3 ========================================== + Hits 1212 1220 +8 + Misses 53 51 -2 Partials 29 29 ``` | [Impacted Files](https://codecov.io/gh/marko-js/htmljs-parser/pull/162?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=marko-js) | Coverage Δ | | |---|---|---| | [src/states/EXPRESSION.ts](https://codecov.io/gh/marko-js/htmljs-parser/pull/162?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=marko-js#diff-c3JjL3N0YXRlcy9FWFBSRVNTSU9OLnRz) | `93.78% <100.00%> (+0.24%)` | :arrow_up: | ... and [1 file with indirect coverage changes](https://codecov.io/gh/marko-js/htmljs-parser/pull/162/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=marko-js) Help us with your feedback. Take ten seconds to tell us [how you rate us](https://about.codecov.io/nps?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=marko-js). Have a feature suggestion? [Share it here.](https://app.codecov.io/gh/feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=marko-js)

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.