-
Notifications
You must be signed in to change notification settings - Fork 63
Fix false reporting of UndefinedObject within visible_if #1061
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
Conversation
|
|
||
| it('should not report unused assigns for things used in a raw-like tag', async () => { | ||
| const tags = ['style', 'javascript', 'stylesheet']; | ||
| const tags = ['style']; |
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.
that was wrong.
Liquid isn't rendered in {% javascript %} or {% stylesheet %} tags. Including Liquid code in these tags can cause syntax errors, or prevent styles from being applied to the theme.
684c07f to
f96d13f
Compare
karreiro
left a comment
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.
Thank you, @charlespwd! I've left only two minor questions, please let me know your thoughts 🙏
f96d13f to
bbf2ba1
Compare
| async LiquidVariableOutput(node) { | ||
| async LiquidVariableOutput(node, ancestors) { | ||
| // Do not report {{ foo == bar }} errors inside {% schema %} where they are supported | ||
| if (isWithinRawTagThatDoesNotParseItsContents(ancestors)) return; |
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.
bbf2ba1 to
d7b7796
Compare
karreiro
left a comment
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.
Thank you, @charlespwd!
We were visiting those nodes as though they were part of the execution
of the file when in fact those are not parsed by the backend but
stripped away.
I first tried doing that at the parsing layer by putting the body as a
TextNode (the same way `{% raw %}` does it) but quickly discovered that
we do depend on it being parsed for the StaticStylesheetAndJavascriptTags
check.
So instead, I just added a helper that both UndefinedObject and
UnusedAssign use to skip visiting of nodes that are parent'ed by a
"raw-like" tag
Fixes #685
d7b7796 to
294e604
Compare

What are you adding in this PR?
We were visiting those nodes as though they were part of the execution of the file when in fact those are not parsed by the backend but stripped away.
I first tried doing that at the parsing layer by putting the body as a TextNode (the same way
{% raw %}does it) but quickly discovered that we do depend on it being parsed for the StaticStylesheetAndJavascriptTags check.So instead, I just added a helper that both UndefinedObject and UnusedAssign use to skip visiting of nodes that are parent'ed by a "raw-like" tag
Fixes #685
Before you deploy
changeset