Skip to content

Commit

Permalink
Merge pull request #21 from danderson/empty-style
Browse files Browse the repository at this point in the history
Allow empty style elements in components
  • Loading branch information
vrischmann authored Jan 4, 2024
2 parents f5c56b4 + 020a906 commit 64f3ded
Show file tree
Hide file tree
Showing 6 changed files with 26,332 additions and 26,144 deletions.
37 changes: 37 additions & 0 deletions corpus/css.txt
Original file line number Diff line number Diff line change
Expand Up @@ -204,3 +204,40 @@ font-size: 20px;
(style_element_text))
(style_element
(style_element_text)))))

===
Empty style element
===

package main

templ Foobar() {
<style type="text/css">
</style>
<h1 id="foo">Foobar</h1>
}

---

(source_file
(package_clause
(package_identifier))
(component_declaration
name: (component_identifier)
(parameter_list)
(component_block
(style_element
(attribute
name: (attribute_name)
value: (quoted_attribute_value
(attribute_value))))
(element
(tag_start
name: (element_identifier)
(attribute
name: (attribute_name)
value: (quoted_attribute_value
(attribute_value))))
(element_text)
(tag_end
name: (element_identifier))))))
26 changes: 26 additions & 0 deletions corpus/script.txt
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,29 @@ script noScript() {}
(script_identifier)
(parameter_list)
(script_block)))

===
Empty script in a templ element
===

package main

templ Foobar() {
<script type="text/javascript">
</script>
}

---

(source_file
(package_clause
(package_identifier))
(component_declaration
name: (component_identifier)
(parameter_list)
(component_block
(script_element
(attribute
name: (attribute_name)
value: (quoted_attribute_value
(attribute_value)))))))
2 changes: 1 addition & 1 deletion grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ module.exports = grammar(GO, {
field('name', 'style'),
repeat($.attribute),
'>',
$.style_element_text,
optional($.style_element_text),
'</',
'style',
'>'
Expand Down
12 changes: 10 additions & 2 deletions src/grammar.json
Original file line number Diff line number Diff line change
Expand Up @@ -7551,8 +7551,16 @@
"value": ">"
},
{
"type": "SYMBOL",
"name": "style_element_text"
"type": "CHOICE",
"members": [
{
"type": "SYMBOL",
"name": "style_element_text"
},
{
"type": "BLANK"
}
]
},
{
"type": "STRING",
Expand Down
2 changes: 1 addition & 1 deletion src/node-types.json
Original file line number Diff line number Diff line change
Expand Up @@ -2979,7 +2979,7 @@
},
"children": {
"multiple": true,
"required": true,
"required": false,
"types": [
{
"type": "attribute",
Expand Down
Loading

0 comments on commit 64f3ded

Please sign in to comment.