-
Notifications
You must be signed in to change notification settings - Fork 190
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Throw error if closing tag contains Muststache Statement #982
Open
camerondubas
wants to merge
3
commits into
glimmerjs:main
Choose a base branch
from
camerondubas:fix/end-tag-modifiers
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm surprised we enter this state during a close tag 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was surprised as well. This state is hit in this scenario:
<div></div {{some-modifier}}>
, and it was actually already throwing this error"Error: expected start tag"
which is triggered in thethis.currentStartTag
call on line 160, but doesn't really describe the error accurately.currentStartTag
snippet:If you comment out this
if
check, two of the tests I added will fail, throwing theexpected start tag
error instead of the one added in this PR.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, gotcha, thank you for explaining.
I believe what is going on is that the HTML spec requires the tagname immediately after the
</
.See the spec info here:
https://html.spec.whatwg.org/multipage/parsing.html#end-tag-open-state
And our implementation here:
https://github.com/tildeio/simple-html-tokenizer/blob/691662c9f00aec719d0eec8e622ed99935119c55/src/evented-tokenizer.ts#L482-L491
I think essentially we want an
else
to theif
above that throws a useful error (RE: invalid end tag). I think that would look something like:Would you be interested in working on a fix over in simple-html-tokenizer also?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also think this is a bit wrong:
https://github.com/tildeio/simple-html-tokenizer/blob/691662c9f00aec719d0eec8e622ed99935119c55/src/evented-tokenizer.ts#L266-L282
We have created the
endTagName
state, and made it essentially the same as thetagName
state (the spec actually says to use thetagName
state (see here), but thats a tad bit difficult for us). But honestly, I don't think we actually are allowed to enter those other states (beforeAttributeName
andselfClosingStartTag
). We should probably add errors there too.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll make an attempt at fixing those issues in Simple HTML Tokenizer this weekend. I'll open a PR with the fixes, or an issue, if I'm unable to come up with solutions
Thanks for looking into this!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Made a PR here tildeio/simple-html-tokenizer#73 would love feedback 😄