tree-sitter-html: lit-html - non quoted attribute values give ERROR
When working with lit-element webcomponents, i have a problem for binded attribute values.
When the attribute value is just ${…} without quotes, the next line gives an error because the parser is not recognizing the attribute value as a quoted_attribute_value
As you can see, i get ERROR in the tree sitter playground. But when the binded value is enclosed with quotes the problem goes away:
Note: for the framework, it is not necessary for attribute values to be enclosed with quotes, they work without them too.
About this issue
- Original URL
- State: closed
- Created 5 months ago
- Comments: 19 (2 by maintainers)
nice try, but that is still no javascript-in-javascript-string-interpolation parser
grammar.js.diff
this fails on
and
nit: rename tree-sitter-html to tree-sitter-lit-html nit: use latest tree-sitter-cli to reduce diff noise in src/tree_sitter/parser.h nit: add online playground, example: ikatyang/tree-sitter-yaml
it does matter where this html is stored. context matters
exactly this means the html parser will never see
${expr}at least this should not give a parse error but should parse
${function('value')}as attribute valueunquoted attribute values end on space or
>so this would break onbody=${function('va space lue')}which would parse${function('vaas attribute valuespaceas boolean attribute andlue')}as parse errorsuch hacks dont make sense either you want to support all javascript expressions in
${expr}or nonemaybe look at JSX parsers maybe modify the template string parser of a javascript parser maybe find a way to merge javascript and html parser
see also