diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 49b078c96..8e2b1530c 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -46,7 +46,7 @@ go test -v ./internal/printer ``` ### Run a specific test case -Many of your test cases are designed like this: +Many of our test cases are designed like this: ```go func TestPrintToJSON(t *testing.T) { @@ -72,11 +72,7 @@ go test -v ./internal/... -run TestPrintToJSON/basic go test -v ./internal/... -run TestPrintToJSON/Comment preserves whitespace ``` -### Adding new tests - -Adding tests for the tokenizer, scanner, and printer can be found in `internal/token_test.go`, `internal/js_scanner_test.go`, and `internal/printer/printer_test.go`, respectively. - -### Snapshot testing +#### Snapshot testing We use [go-snaps](https://github.com/gkampitakis/go-snaps) for snapshot testing. Visit their repository for more details on how to use it @@ -94,6 +90,39 @@ Instead, if there are some **obsolete snapshots**, you can `UPDATE_SNAPS=clean`: UPDATE_SNAPS=clean go test -v ./internal/... ``` + +### Adding new test cases + +The printer tests emit only snapshots. Go to `printer_test.go` and add a new test case: + +```go +{ + name: "New name for this test" + code: "
" +} +``` + +Then run the below command, and a new snapshot named `new_name_for_this_test.snap` should appear in the snapshot folder. + +```shell +go test -v ./internal/printer/printer_test.go +``` + +Other tests, like tokenizer and scanner be found in `internal/token_test.go`, `internal/js_scanner_test.go` and respectively. + +Those tests don't emit any snapshot, and you'll have to add a `want` field: + +```go +{ + name: "New name for this test" + code: "
", + want: want{ + code: "
" + } +} +``` + + [homebrew]: https://brew.sh/ [go]: https://golang.org/ [go-vscode]: https://marketplace.visualstudio.com/items?itemName=golang.go diff --git a/internal/js_scanner/js_scanner_test.go b/internal/js_scanner/js_scanner_test.go index a2208caa1..c54edc879 100644 --- a/internal/js_scanner/js_scanner_test.go +++ b/internal/js_scanner/js_scanner_test.go @@ -661,6 +661,7 @@ func TestGetObjectKeys(t *testing.T) { if diff := test_utils.ANSIDiff(string(want), string(got)); diff != "" { t.Errorf("mismatch (-want +got):\n%s", diff) } + }) } } diff --git a/internal/printer/__printer_css__/scopedStyleStrategy___attribute_.snap b/internal/printer/__printer_css__/scopedStyleStrategy___attribute_.snap new file mode 100755 index 000000000..c1f675633 --- /dev/null +++ b/internal/printer/__printer_css__/scopedStyleStrategy___attribute_.snap @@ -0,0 +1,26 @@ + +[TestPrinterCSS/scopedStyleStrategy:_'attribute' - 1] +## Input + +``` + + +

Page Title

+

I’m a page

+``` + +## Output + +```css +.title[data-astro-cid-dpohflym]{font-family:fantasy;font-size:28px}.body[data-astro-cid-dpohflym]{font-size:1em} +``` +--- diff --git a/internal/printer/__printer_css__/scopedStyleStrategy___class_.snap b/internal/printer/__printer_css__/scopedStyleStrategy___class_.snap new file mode 100755 index 000000000..bdd3d3b8a --- /dev/null +++ b/internal/printer/__printer_css__/scopedStyleStrategy___class_.snap @@ -0,0 +1,26 @@ + +[TestPrinterCSS/scopedStyleStrategy:_'class' - 1] +## Input + +``` + + +

Page Title

+

I’m a page

+``` + +## Output + +```css +.title.astro-dpohflym{font-family:fantasy;font-size:28px}.body.astro-dpohflym{font-size:1em} +``` +--- diff --git a/internal/printer/__printer_css__/styles__no_frontmatter_.snap b/internal/printer/__printer_css__/styles__no_frontmatter_.snap new file mode 100755 index 000000000..a22544b8a --- /dev/null +++ b/internal/printer/__printer_css__/styles__no_frontmatter_.snap @@ -0,0 +1,26 @@ + +[TestPrinterCSS/styles_(no_frontmatter) - 1] +## Input + +``` + + +

Page Title

+

I’m a page

+``` + +## Output + +```css +.title:where(.astro-dpohflym){font-family:fantasy;font-size:28px}.body:where(.astro-dpohflym){font-size:1em} +``` +--- diff --git a/internal/printer/__snapshots__/All_components.snap b/internal/printer/__printer_js__/All_components.snap similarity index 100% rename from internal/printer/__snapshots__/All_components.snap rename to internal/printer/__printer_js__/All_components.snap diff --git a/internal/printer/__snapshots__/Component_is_raw.snap b/internal/printer/__printer_js__/Component_is_raw.snap similarity index 100% rename from internal/printer/__snapshots__/Component_is_raw.snap rename to internal/printer/__printer_js__/Component_is_raw.snap diff --git a/internal/printer/__snapshots__/Component_names_A-Z.snap b/internal/printer/__printer_js__/Component_names_A-Z.snap similarity index 100% rename from internal/printer/__snapshots__/Component_names_A-Z.snap rename to internal/printer/__printer_js__/Component_names_A-Z.snap diff --git a/internal/printer/__snapshots__/Component_siblings_are_siblings.snap b/internal/printer/__printer_js__/Component_siblings_are_siblings.snap similarity index 100% rename from internal/printer/__snapshots__/Component_siblings_are_siblings.snap rename to internal/printer/__printer_js__/Component_siblings_are_siblings.snap diff --git a/internal/printer/__snapshots__/Empty_attribute_expression.snap b/internal/printer/__printer_js__/Empty_attribute_expression.snap similarity index 100% rename from internal/printer/__snapshots__/Empty_attribute_expression.snap rename to internal/printer/__printer_js__/Empty_attribute_expression.snap diff --git a/internal/printer/__snapshots__/Empty_expression.snap b/internal/printer/__printer_js__/Empty_expression.snap similarity index 100% rename from internal/printer/__snapshots__/Empty_expression.snap rename to internal/printer/__printer_js__/Empty_expression.snap diff --git a/internal/printer/__snapshots__/Empty_expression_with_whitespace.snap b/internal/printer/__printer_js__/Empty_expression_with_whitespace.snap similarity index 100% rename from internal/printer/__snapshots__/Empty_expression_with_whitespace.snap rename to internal/printer/__printer_js__/Empty_expression_with_whitespace.snap diff --git a/internal/printer/__snapshots__/Empty_script.snap b/internal/printer/__printer_js__/Empty_script.snap similarity index 100% rename from internal/printer/__snapshots__/Empty_script.snap rename to internal/printer/__printer_js__/Empty_script.snap diff --git a/internal/printer/__snapshots__/Empty_style.snap b/internal/printer/__printer_js__/Empty_style.snap similarity index 100% rename from internal/printer/__snapshots__/Empty_style.snap rename to internal/printer/__printer_js__/Empty_style.snap diff --git a/internal/printer/__snapshots__/Expression_in_form_followed_by_other_sibling_forms.snap b/internal/printer/__printer_js__/Expression_in_form_followed_by_other_sibling_forms.snap similarity index 100% rename from internal/printer/__snapshots__/Expression_in_form_followed_by_other_sibling_forms.snap rename to internal/printer/__printer_js__/Expression_in_form_followed_by_other_sibling_forms.snap diff --git a/internal/printer/__snapshots__/Fragment.snap b/internal/printer/__printer_js__/Fragment.snap similarity index 100% rename from internal/printer/__snapshots__/Fragment.snap rename to internal/printer/__printer_js__/Fragment.snap diff --git a/internal/printer/__snapshots__/Fragment_literal_only.snap b/internal/printer/__printer_js__/Fragment_literal_only.snap similarity index 100% rename from internal/printer/__snapshots__/Fragment_literal_only.snap rename to internal/printer/__printer_js__/Fragment_literal_only.snap diff --git a/internal/printer/__snapshots__/Fragment_shorthand.snap b/internal/printer/__printer_js__/Fragment_shorthand.snap similarity index 100% rename from internal/printer/__snapshots__/Fragment_shorthand.snap rename to internal/printer/__printer_js__/Fragment_shorthand.snap diff --git a/internal/printer/__snapshots__/Fragment_shorthand_only.snap b/internal/printer/__printer_js__/Fragment_shorthand_only.snap similarity index 100% rename from internal/printer/__snapshots__/Fragment_shorthand_only.snap rename to internal/printer/__printer_js__/Fragment_shorthand_only.snap diff --git a/internal/printer/__snapshots__/Fragment_slotted.snap b/internal/printer/__printer_js__/Fragment_slotted.snap similarity index 100% rename from internal/printer/__snapshots__/Fragment_slotted.snap rename to internal/printer/__printer_js__/Fragment_slotted.snap diff --git a/internal/printer/__snapshots__/Fragment_slotted_with_name.snap b/internal/printer/__printer_js__/Fragment_slotted_with_name.snap similarity index 100% rename from internal/printer/__snapshots__/Fragment_slotted_with_name.snap rename to internal/printer/__printer_js__/Fragment_slotted_with_name.snap diff --git a/internal/printer/__snapshots__/HTML_comment_in_component_inside_expression_I.snap b/internal/printer/__printer_js__/HTML_comment_in_component_inside_expression_I.snap similarity index 100% rename from internal/printer/__snapshots__/HTML_comment_in_component_inside_expression_I.snap rename to internal/printer/__printer_js__/HTML_comment_in_component_inside_expression_I.snap diff --git a/internal/printer/__snapshots__/HTML_comment_in_component_inside_expression_II.snap b/internal/printer/__printer_js__/HTML_comment_in_component_inside_expression_II.snap similarity index 100% rename from internal/printer/__snapshots__/HTML_comment_in_component_inside_expression_II.snap rename to internal/printer/__printer_js__/HTML_comment_in_component_inside_expression_II.snap diff --git a/internal/printer/__snapshots__/Mixed_style_siblings.snap b/internal/printer/__printer_js__/Mixed_style_siblings.snap similarity index 100% rename from internal/printer/__snapshots__/Mixed_style_siblings.snap rename to internal/printer/__printer_js__/Mixed_style_siblings.snap diff --git a/internal/printer/__snapshots__/Nested_HTML_in_expressions,_wrapped_in_parens.snap b/internal/printer/__printer_js__/Nested_HTML_in_expressions,_wrapped_in_parens.snap similarity index 100% rename from internal/printer/__snapshots__/Nested_HTML_in_expressions,_wrapped_in_parens.snap rename to internal/printer/__printer_js__/Nested_HTML_in_expressions,_wrapped_in_parens.snap diff --git a/internal/printer/__snapshots__/No_extra_script_tag.snap b/internal/printer/__printer_js__/No_extra_script_tag.snap similarity index 100% rename from internal/printer/__snapshots__/No_extra_script_tag.snap rename to internal/printer/__printer_js__/No_extra_script_tag.snap diff --git a/internal/printer/__snapshots__/Parser_can_handle_files___4096_chars.snap b/internal/printer/__printer_js__/Parser_can_handle_files___4096_chars.snap similarity index 100% rename from internal/printer/__snapshots__/Parser_can_handle_files___4096_chars.snap rename to internal/printer/__printer_js__/Parser_can_handle_files___4096_chars.snap diff --git a/internal/printer/__snapshots__/Preserve_namespaces.snap b/internal/printer/__printer_js__/Preserve_namespaces.snap similarity index 100% rename from internal/printer/__snapshots__/Preserve_namespaces.snap rename to internal/printer/__printer_js__/Preserve_namespaces.snap diff --git a/internal/printer/__snapshots__/Preserve_namespaces_for_components.snap b/internal/printer/__printer_js__/Preserve_namespaces_for_components.snap similarity index 100% rename from internal/printer/__snapshots__/Preserve_namespaces_for_components.snap rename to internal/printer/__printer_js__/Preserve_namespaces_for_components.snap diff --git a/internal/printer/__snapshots__/Preserve_namespaces_in_expressions.snap b/internal/printer/__printer_js__/Preserve_namespaces_in_expressions.snap similarity index 100% rename from internal/printer/__snapshots__/Preserve_namespaces_in_expressions.snap rename to internal/printer/__printer_js__/Preserve_namespaces_in_expressions.snap diff --git a/internal/printer/__snapshots__/Preserve_slot_whitespace.snap b/internal/printer/__printer_js__/Preserve_slot_whitespace.snap similarity index 100% rename from internal/printer/__snapshots__/Preserve_slot_whitespace.snap rename to internal/printer/__printer_js__/Preserve_slot_whitespace.snap diff --git a/internal/printer/__snapshots__/Preserve_slots_inside_custom-element.snap b/internal/printer/__printer_js__/Preserve_slots_inside_custom-element.snap similarity index 100% rename from internal/printer/__snapshots__/Preserve_slots_inside_custom-element.snap rename to internal/printer/__printer_js__/Preserve_slots_inside_custom-element.snap diff --git a/internal/printer/__snapshots__/React_framework_example.snap b/internal/printer/__printer_js__/React_framework_example.snap similarity index 100% rename from internal/printer/__snapshots__/React_framework_example.snap rename to internal/printer/__printer_js__/React_framework_example.snap diff --git a/internal/printer/__snapshots__/SVG_styles.snap b/internal/printer/__printer_js__/SVG_styles.snap similarity index 100% rename from internal/printer/__snapshots__/SVG_styles.snap rename to internal/printer/__printer_js__/SVG_styles.snap diff --git a/internal/printer/__snapshots__/Self-closing_components_in_head_can_have_siblings.snap b/internal/printer/__printer_js__/Self-closing_components_in_head_can_have_siblings.snap similarity index 100% rename from internal/printer/__snapshots__/Self-closing_components_in_head_can_have_siblings.snap rename to internal/printer/__printer_js__/Self-closing_components_in_head_can_have_siblings.snap diff --git a/internal/printer/__snapshots__/Self-closing_components_siblings_are_siblings.snap b/internal/printer/__printer_js__/Self-closing_components_siblings_are_siblings.snap similarity index 100% rename from internal/printer/__snapshots__/Self-closing_components_siblings_are_siblings.snap rename to internal/printer/__printer_js__/Self-closing_components_siblings_are_siblings.snap diff --git a/internal/printer/__snapshots__/Self-closing_formatting_elements.snap b/internal/printer/__printer_js__/Self-closing_formatting_elements.snap similarity index 100% rename from internal/printer/__snapshots__/Self-closing_formatting_elements.snap rename to internal/printer/__printer_js__/Self-closing_formatting_elements.snap diff --git a/internal/printer/__snapshots__/Self-closing_formatting_elements_2.snap b/internal/printer/__printer_js__/Self-closing_formatting_elements_2.snap similarity index 100% rename from internal/printer/__snapshots__/Self-closing_formatting_elements_2.snap rename to internal/printer/__printer_js__/Self-closing_formatting_elements_2.snap diff --git a/internal/printer/__snapshots__/Self-closing_script_in_head_works.snap b/internal/printer/__printer_js__/Self-closing_script_in_head_works.snap similarity index 100% rename from internal/printer/__snapshots__/Self-closing_script_in_head_works.snap rename to internal/printer/__printer_js__/Self-closing_script_in_head_works.snap diff --git a/internal/printer/__snapshots__/Self-closing_title.snap b/internal/printer/__printer_js__/Self-closing_title.snap similarity index 100% rename from internal/printer/__snapshots__/Self-closing_title.snap rename to internal/printer/__printer_js__/Self-closing_title.snap diff --git a/internal/printer/__snapshots__/Self-closing_title_II.snap b/internal/printer/__printer_js__/Self-closing_title_II.snap similarity index 100% rename from internal/printer/__snapshots__/Self-closing_title_II.snap rename to internal/printer/__printer_js__/Self-closing_title_II.snap diff --git a/internal/printer/__snapshots__/Use_of_interfaces_within_frontmatter.snap b/internal/printer/__printer_js__/Use_of_interfaces_within_frontmatter.snap similarity index 100% rename from internal/printer/__snapshots__/Use_of_interfaces_within_frontmatter.snap rename to internal/printer/__printer_js__/Use_of_interfaces_within_frontmatter.snap diff --git a/internal/printer/__snapshots__/XElement.snap b/internal/printer/__printer_js__/XElement.snap similarity index 100% rename from internal/printer/__snapshots__/XElement.snap rename to internal/printer/__printer_js__/XElement.snap diff --git a/internal/printer/__snapshots__/_955_ternary_slot_with_elements.snap b/internal/printer/__printer_js__/_955_ternary_slot_with_elements.snap similarity index 100% rename from internal/printer/__snapshots__/_955_ternary_slot_with_elements.snap rename to internal/printer/__printer_js__/_955_ternary_slot_with_elements.snap diff --git a/internal/printer/__snapshots__/_955_ternary_slot_with_text.snap b/internal/printer/__printer_js__/_955_ternary_slot_with_text.snap similarity index 100% rename from internal/printer/__snapshots__/_955_ternary_slot_with_text.snap rename to internal/printer/__printer_js__/_955_ternary_slot_with_text.snap diff --git a/internal/printer/__snapshots__/advanced_svg_expression.snap b/internal/printer/__printer_js__/advanced_svg_expression.snap similarity index 100% rename from internal/printer/__snapshots__/advanced_svg_expression.snap rename to internal/printer/__printer_js__/advanced_svg_expression.snap diff --git a/internal/printer/__snapshots__/anchor_content.snap b/internal/printer/__printer_js__/anchor_content.snap similarity index 100% rename from internal/printer/__snapshots__/anchor_content.snap rename to internal/printer/__printer_js__/anchor_content.snap diff --git a/internal/printer/__snapshots__/anchor_expressions.snap b/internal/printer/__printer_js__/anchor_expressions.snap similarity index 100% rename from internal/printer/__snapshots__/anchor_expressions.snap rename to internal/printer/__printer_js__/anchor_expressions.snap diff --git a/internal/printer/__snapshots__/anchor_inside_expression.snap b/internal/printer/__printer_js__/anchor_inside_expression.snap similarity index 100% rename from internal/printer/__snapshots__/anchor_inside_expression.snap rename to internal/printer/__printer_js__/anchor_inside_expression.snap diff --git a/internal/printer/__snapshots__/attribute_with_template_literal.snap b/internal/printer/__printer_js__/attribute_with_template_literal.snap similarity index 100% rename from internal/printer/__snapshots__/attribute_with_template_literal.snap rename to internal/printer/__printer_js__/attribute_with_template_literal.snap diff --git a/internal/printer/__snapshots__/attribute_with_template_literal_interpolation.snap b/internal/printer/__printer_js__/attribute_with_template_literal_interpolation.snap similarity index 100% rename from internal/printer/__snapshots__/attribute_with_template_literal_interpolation.snap rename to internal/printer/__printer_js__/attribute_with_template_literal_interpolation.snap diff --git a/internal/printer/__snapshots__/backtick_in_HTML_comment.snap b/internal/printer/__printer_js__/backtick_in_HTML_comment.snap similarity index 100% rename from internal/printer/__snapshots__/backtick_in_HTML_comment.snap rename to internal/printer/__printer_js__/backtick_in_HTML_comment.snap diff --git a/internal/printer/__snapshots__/basic__frontmatter_.snap b/internal/printer/__printer_js__/basic__frontmatter_.snap similarity index 100% rename from internal/printer/__snapshots__/basic__frontmatter_.snap rename to internal/printer/__printer_js__/basic__frontmatter_.snap diff --git a/internal/printer/__snapshots__/basic__no_frontmatter_.snap b/internal/printer/__printer_js__/basic__no_frontmatter_.snap similarity index 100% rename from internal/printer/__snapshots__/basic__no_frontmatter_.snap rename to internal/printer/__printer_js__/basic__no_frontmatter_.snap diff --git a/internal/printer/__snapshots__/basic_renderHead.snap b/internal/printer/__printer_js__/basic_renderHead.snap similarity index 100% rename from internal/printer/__snapshots__/basic_renderHead.snap rename to internal/printer/__printer_js__/basic_renderHead.snap diff --git a/internal/printer/__snapshots__/caption_only.snap b/internal/printer/__printer_js__/caption_only.snap similarity index 100% rename from internal/printer/__snapshots__/caption_only.snap rename to internal/printer/__printer_js__/caption_only.snap diff --git a/internal/printer/__snapshots__/class_and_class_list_object.snap b/internal/printer/__printer_js__/class_and_class_list_object.snap similarity index 100% rename from internal/printer/__snapshots__/class_and_class_list_object.snap rename to internal/printer/__printer_js__/class_and_class_list_object.snap diff --git a/internal/printer/__snapshots__/class_and_class_list_set.snap b/internal/printer/__printer_js__/class_and_class_list_set.snap similarity index 100% rename from internal/printer/__snapshots__/class_and_class_list_set.snap rename to internal/printer/__printer_js__/class_and_class_list_set.snap diff --git a/internal/printer/__snapshots__/class_and_class_list_simple_array.snap b/internal/printer/__printer_js__/class_and_class_list_simple_array.snap similarity index 100% rename from internal/printer/__snapshots__/class_and_class_list_simple_array.snap rename to internal/printer/__printer_js__/class_and_class_list_simple_array.snap diff --git a/internal/printer/__snapshots__/class_list.snap b/internal/printer/__printer_js__/class_list.snap similarity index 100% rename from internal/printer/__snapshots__/class_list.snap rename to internal/printer/__printer_js__/class_list.snap diff --git a/internal/printer/__snapshots__/class_list_with_spread.snap b/internal/printer/__printer_js__/class_list_with_spread.snap similarity index 100% rename from internal/printer/__snapshots__/class_list_with_spread.snap rename to internal/printer/__printer_js__/class_list_with_spread.snap diff --git a/internal/printer/__snapshots__/class_with_spread.snap b/internal/printer/__printer_js__/class_with_spread.snap similarity index 100% rename from internal/printer/__snapshots__/class_with_spread.snap rename to internal/printer/__printer_js__/class_with_spread.snap diff --git a/internal/printer/__snapshots__/client_only_component__default_.snap b/internal/printer/__printer_js__/client_only_component__default_.snap similarity index 100% rename from internal/printer/__snapshots__/client_only_component__default_.snap rename to internal/printer/__printer_js__/client_only_component__default_.snap diff --git a/internal/printer/__snapshots__/client_only_component__multiple_.snap b/internal/printer/__printer_js__/client_only_component__multiple_.snap similarity index 100% rename from internal/printer/__snapshots__/client_only_component__multiple_.snap rename to internal/printer/__printer_js__/client_only_component__multiple_.snap diff --git a/internal/printer/__snapshots__/client_only_component__named_.snap b/internal/printer/__printer_js__/client_only_component__named_.snap similarity index 100% rename from internal/printer/__snapshots__/client_only_component__named_.snap rename to internal/printer/__printer_js__/client_only_component__named_.snap diff --git a/internal/printer/__snapshots__/client_only_component__namespace_.snap b/internal/printer/__printer_js__/client_only_component__namespace_.snap similarity index 100% rename from internal/printer/__snapshots__/client_only_component__namespace_.snap rename to internal/printer/__printer_js__/client_only_component__namespace_.snap diff --git a/internal/printer/__snapshots__/client_only_component__namespaced_default_.snap b/internal/printer/__printer_js__/client_only_component__namespaced_default_.snap similarity index 100% rename from internal/printer/__snapshots__/client_only_component__namespaced_default_.snap rename to internal/printer/__printer_js__/client_only_component__namespaced_default_.snap diff --git a/internal/printer/__snapshots__/client_only_component__namespaced_named_.snap b/internal/printer/__printer_js__/client_only_component__namespaced_named_.snap similarity index 100% rename from internal/printer/__snapshots__/client_only_component__namespaced_named_.snap rename to internal/printer/__printer_js__/client_only_component__namespaced_named_.snap diff --git a/internal/printer/__snapshots__/comment_only_expressions_are_removed_I.snap b/internal/printer/__printer_js__/comment_only_expressions_are_removed_I.snap similarity index 100% rename from internal/printer/__snapshots__/comment_only_expressions_are_removed_I.snap rename to internal/printer/__printer_js__/comment_only_expressions_are_removed_I.snap diff --git a/internal/printer/__snapshots__/comment_only_expressions_are_removed_II.snap b/internal/printer/__printer_js__/comment_only_expressions_are_removed_II.snap similarity index 100% rename from internal/printer/__snapshots__/comment_only_expressions_are_removed_II.snap rename to internal/printer/__printer_js__/comment_only_expressions_are_removed_II.snap diff --git a/internal/printer/__snapshots__/comment_only_expressions_are_removed_III.snap b/internal/printer/__printer_js__/comment_only_expressions_are_removed_III.snap similarity index 100% rename from internal/printer/__snapshots__/comment_only_expressions_are_removed_III.snap rename to internal/printer/__printer_js__/comment_only_expressions_are_removed_III.snap diff --git a/internal/printer/__snapshots__/comments_removed_from_attribute_list.snap b/internal/printer/__printer_js__/comments_removed_from_attribute_list.snap similarity index 100% rename from internal/printer/__snapshots__/comments_removed_from_attribute_list.snap rename to internal/printer/__printer_js__/comments_removed_from_attribute_list.snap diff --git a/internal/printer/__snapshots__/complex_nested_template_literal_expression.snap b/internal/printer/__printer_js__/complex_nested_template_literal_expression.snap similarity index 100% rename from internal/printer/__snapshots__/complex_nested_template_literal_expression.snap rename to internal/printer/__printer_js__/complex_nested_template_literal_expression.snap diff --git a/internal/printer/__snapshots__/complex_recursive_component.snap b/internal/printer/__printer_js__/complex_recursive_component.snap similarity index 100% rename from internal/printer/__snapshots__/complex_recursive_component.snap rename to internal/printer/__printer_js__/complex_recursive_component.snap diff --git a/internal/printer/__snapshots__/complex_table.snap b/internal/printer/__printer_js__/complex_table.snap similarity index 100% rename from internal/printer/__snapshots__/complex_table.snap rename to internal/printer/__printer_js__/complex_table.snap diff --git a/internal/printer/__snapshots__/component.snap b/internal/printer/__printer_js__/component.snap similarity index 100% rename from internal/printer/__snapshots__/component.snap rename to internal/printer/__printer_js__/component.snap diff --git a/internal/printer/__snapshots__/component_in_expression_with_its_child_expression_before_its_child_element.snap b/internal/printer/__printer_js__/component_in_expression_with_its_child_expression_before_its_child_element.snap similarity index 100% rename from internal/printer/__snapshots__/component_in_expression_with_its_child_expression_before_its_child_element.snap rename to internal/printer/__printer_js__/component_in_expression_with_its_child_expression_before_its_child_element.snap diff --git a/internal/printer/__snapshots__/component_with_only_a_script.snap b/internal/printer/__printer_js__/component_with_only_a_script.snap similarity index 100% rename from internal/printer/__snapshots__/component_with_only_a_script.snap rename to internal/printer/__printer_js__/component_with_only_a_script.snap diff --git a/internal/printer/__snapshots__/component_with_quoted_attributes.snap b/internal/printer/__printer_js__/component_with_quoted_attributes.snap similarity index 100% rename from internal/printer/__snapshots__/component_with_quoted_attributes.snap rename to internal/printer/__printer_js__/component_with_quoted_attributes.snap diff --git a/internal/printer/__snapshots__/condition_expressions_at_the_top-level.snap b/internal/printer/__printer_js__/condition_expressions_at_the_top-level.snap similarity index 100% rename from internal/printer/__snapshots__/condition_expressions_at_the_top-level.snap rename to internal/printer/__printer_js__/condition_expressions_at_the_top-level.snap diff --git a/internal/printer/__snapshots__/condition_expressions_at_the_top-level_with_head_content.snap b/internal/printer/__printer_js__/condition_expressions_at_the_top-level_with_head_content.snap similarity index 100% rename from internal/printer/__snapshots__/condition_expressions_at_the_top-level_with_head_content.snap rename to internal/printer/__printer_js__/condition_expressions_at_the_top-level_with_head_content.snap diff --git a/internal/printer/__snapshots__/conditional_iframe.snap b/internal/printer/__printer_js__/conditional_iframe.snap similarity index 100% rename from internal/printer/__snapshots__/conditional_iframe.snap rename to internal/printer/__printer_js__/conditional_iframe.snap diff --git a/internal/printer/__snapshots__/conditional_noscript.snap b/internal/printer/__printer_js__/conditional_noscript.snap similarity index 100% rename from internal/printer/__snapshots__/conditional_noscript.snap rename to internal/printer/__printer_js__/conditional_noscript.snap diff --git a/internal/printer/__snapshots__/conditional_render.snap b/internal/printer/__printer_js__/conditional_render.snap similarity index 100% rename from internal/printer/__snapshots__/conditional_render.snap rename to internal/printer/__printer_js__/conditional_render.snap diff --git a/internal/printer/__snapshots__/conditional_rendering_of_title_containing_expression.snap b/internal/printer/__printer_js__/conditional_rendering_of_title_containing_expression.snap similarity index 100% rename from internal/printer/__snapshots__/conditional_rendering_of_title_containing_expression.snap rename to internal/printer/__printer_js__/conditional_rendering_of_title_containing_expression.snap diff --git a/internal/printer/__snapshots__/conditional_slot.snap b/internal/printer/__printer_js__/conditional_slot.snap similarity index 100% rename from internal/printer/__snapshots__/conditional_slot.snap rename to internal/printer/__printer_js__/conditional_slot.snap diff --git "a/internal/printer/__snapshots__/css_comment_doesn\342\200\231t_produce_semicolon.snap" "b/internal/printer/__printer_js__/css_comment_doesn\342\200\231t_produce_semicolon.snap" similarity index 100% rename from "internal/printer/__snapshots__/css_comment_doesn\342\200\231t_produce_semicolon.snap" rename to "internal/printer/__printer_js__/css_comment_doesn\342\200\231t_produce_semicolon.snap" diff --git a/internal/printer/__snapshots__/css_imports_are_not_included_in_module_metadata.snap b/internal/printer/__printer_js__/css_imports_are_not_included_in_module_metadata.snap similarity index 100% rename from internal/printer/__snapshots__/css_imports_are_not_included_in_module_metadata.snap rename to internal/printer/__printer_js__/css_imports_are_not_included_in_module_metadata.snap diff --git a/internal/printer/__snapshots__/custom-element.snap b/internal/printer/__printer_js__/custom-element.snap similarity index 100% rename from internal/printer/__snapshots__/custom-element.snap rename to internal/printer/__printer_js__/custom-element.snap diff --git a/internal/printer/__snapshots__/custom_elements.snap b/internal/printer/__printer_js__/custom_elements.snap similarity index 100% rename from internal/printer/__snapshots__/custom_elements.snap rename to internal/printer/__printer_js__/custom_elements.snap diff --git a/internal/printer/__snapshots__/define_vars_on_a_module_script_with_imports.snap b/internal/printer/__printer_js__/define_vars_on_a_module_script_with_imports.snap similarity index 100% rename from internal/printer/__snapshots__/define_vars_on_a_module_script_with_imports.snap rename to internal/printer/__printer_js__/define_vars_on_a_module_script_with_imports.snap diff --git a/internal/printer/__snapshots__/define_vars_on_non-root_elements.snap b/internal/printer/__printer_js__/define_vars_on_non-root_elements.snap similarity index 100% rename from internal/printer/__snapshots__/define_vars_on_non-root_elements.snap rename to internal/printer/__printer_js__/define_vars_on_non-root_elements.snap diff --git a/internal/printer/__snapshots__/define_vars_on_script_with_StaticExpression_turned_on.snap b/internal/printer/__printer_js__/define_vars_on_script_with_StaticExpression_turned_on.snap similarity index 100% rename from internal/printer/__snapshots__/define_vars_on_script_with_StaticExpression_turned_on.snap rename to internal/printer/__printer_js__/define_vars_on_script_with_StaticExpression_turned_on.snap diff --git a/internal/printer/__snapshots__/define_vars_on_style.snap b/internal/printer/__printer_js__/define_vars_on_style.snap similarity index 100% rename from internal/printer/__snapshots__/define_vars_on_style.snap rename to internal/printer/__printer_js__/define_vars_on_style.snap diff --git a/internal/printer/__snapshots__/define_vars_on_style_tag_with_style_empty_attribute_on_element.snap b/internal/printer/__printer_js__/define_vars_on_style_tag_with_style_empty_attribute_on_element.snap similarity index 100% rename from internal/printer/__snapshots__/define_vars_on_style_tag_with_style_empty_attribute_on_element.snap rename to internal/printer/__printer_js__/define_vars_on_style_tag_with_style_empty_attribute_on_element.snap diff --git a/internal/printer/__snapshots__/define_vars_on_style_tag_with_style_expression_attribute_on_element.snap b/internal/printer/__printer_js__/define_vars_on_style_tag_with_style_expression_attribute_on_element.snap similarity index 100% rename from internal/printer/__snapshots__/define_vars_on_style_tag_with_style_expression_attribute_on_element.snap rename to internal/printer/__printer_js__/define_vars_on_style_tag_with_style_expression_attribute_on_element.snap diff --git a/internal/printer/__snapshots__/define_vars_on_style_tag_with_style_quoted_attribute_on_element.snap b/internal/printer/__printer_js__/define_vars_on_style_tag_with_style_quoted_attribute_on_element.snap similarity index 100% rename from internal/printer/__snapshots__/define_vars_on_style_tag_with_style_quoted_attribute_on_element.snap rename to internal/printer/__printer_js__/define_vars_on_style_tag_with_style_quoted_attribute_on_element.snap diff --git a/internal/printer/__snapshots__/define_vars_on_style_tag_with_style_shorthand_attribute_on_element.snap b/internal/printer/__printer_js__/define_vars_on_style_tag_with_style_shorthand_attribute_on_element.snap similarity index 100% rename from internal/printer/__snapshots__/define_vars_on_style_tag_with_style_shorthand_attribute_on_element.snap rename to internal/printer/__printer_js__/define_vars_on_style_tag_with_style_shorthand_attribute_on_element.snap diff --git a/internal/printer/__snapshots__/define_vars_on_style_tag_with_style_template_literal_attribute_on_element.snap b/internal/printer/__printer_js__/define_vars_on_style_tag_with_style_template_literal_attribute_on_element.snap similarity index 100% rename from internal/printer/__snapshots__/define_vars_on_style_tag_with_style_template_literal_attribute_on_element.snap rename to internal/printer/__printer_js__/define_vars_on_style_tag_with_style_template_literal_attribute_on_element.snap diff --git a/internal/printer/__snapshots__/division_inside_expression.snap b/internal/printer/__printer_js__/division_inside_expression.snap similarity index 100% rename from internal/printer/__snapshots__/division_inside_expression.snap rename to internal/printer/__printer_js__/division_inside_expression.snap diff --git a/internal/printer/__snapshots__/doctype.snap b/internal/printer/__printer_js__/doctype.snap similarity index 100% rename from internal/printer/__snapshots__/doctype.snap rename to internal/printer/__printer_js__/doctype.snap diff --git a/internal/printer/__snapshots__/dot_component.snap b/internal/printer/__printer_js__/dot_component.snap similarity index 100% rename from internal/printer/__snapshots__/dot_component.snap rename to internal/printer/__printer_js__/dot_component.snap diff --git a/internal/printer/__snapshots__/dynamic_import.snap b/internal/printer/__printer_js__/dynamic_import.snap similarity index 100% rename from internal/printer/__snapshots__/dynamic_import.snap rename to internal/printer/__printer_js__/dynamic_import.snap diff --git a/internal/printer/__snapshots__/escaped_entity.snap b/internal/printer/__printer_js__/escaped_entity.snap similarity index 100% rename from internal/printer/__snapshots__/escaped_entity.snap rename to internal/printer/__printer_js__/escaped_entity.snap diff --git a/internal/printer/__snapshots__/export_comments_I.snap b/internal/printer/__printer_js__/export_comments_I.snap similarity index 100% rename from internal/printer/__snapshots__/export_comments_I.snap rename to internal/printer/__printer_js__/export_comments_I.snap diff --git a/internal/printer/__snapshots__/export_comments_II.snap b/internal/printer/__printer_js__/export_comments_II.snap similarity index 100% rename from internal/printer/__snapshots__/export_comments_II.snap rename to internal/printer/__printer_js__/export_comments_II.snap diff --git a/internal/printer/__snapshots__/export_member_does_not_panic.snap b/internal/printer/__printer_js__/export_member_does_not_panic.snap similarity index 100% rename from internal/printer/__snapshots__/export_member_does_not_panic.snap rename to internal/printer/__printer_js__/export_member_does_not_panic.snap diff --git a/internal/printer/__snapshots__/expression_returning_multiple_elements.snap b/internal/printer/__printer_js__/expression_returning_multiple_elements.snap similarity index 100% rename from internal/printer/__snapshots__/expression_returning_multiple_elements.snap rename to internal/printer/__printer_js__/expression_returning_multiple_elements.snap diff --git a/internal/printer/__snapshots__/expression_slot.snap b/internal/printer/__printer_js__/expression_slot.snap similarity index 100% rename from internal/printer/__snapshots__/expression_slot.snap rename to internal/printer/__printer_js__/expression_slot.snap diff --git a/internal/printer/__snapshots__/expression_with_leading_whitespace.snap b/internal/printer/__printer_js__/expression_with_leading_whitespace.snap similarity index 100% rename from internal/printer/__snapshots__/expression_with_leading_whitespace.snap rename to internal/printer/__printer_js__/expression_with_leading_whitespace.snap diff --git a/internal/printer/__snapshots__/expressions_with_JS_comments.snap b/internal/printer/__printer_js__/expressions_with_JS_comments.snap similarity index 100% rename from internal/printer/__snapshots__/expressions_with_JS_comments.snap rename to internal/printer/__printer_js__/expressions_with_JS_comments.snap diff --git a/internal/printer/__snapshots__/expressions_with_multiple_curly_braces.snap b/internal/printer/__printer_js__/expressions_with_multiple_curly_braces.snap similarity index 100% rename from internal/printer/__snapshots__/expressions_with_multiple_curly_braces.snap rename to internal/printer/__printer_js__/expressions_with_multiple_curly_braces.snap diff --git a/internal/printer/__snapshots__/function_expression_slots_I.snap b/internal/printer/__printer_js__/function_expression_slots_I.snap similarity index 100% rename from internal/printer/__snapshots__/function_expression_slots_I.snap rename to internal/printer/__printer_js__/function_expression_slots_I.snap diff --git a/internal/printer/__snapshots__/function_expression_slots_II___959_.snap b/internal/printer/__printer_js__/function_expression_slots_II___959_.snap similarity index 100% rename from internal/printer/__snapshots__/function_expression_slots_II___959_.snap rename to internal/printer/__printer_js__/function_expression_slots_II___959_.snap diff --git a/internal/printer/__snapshots__/getStaticPaths__basic_.snap b/internal/printer/__printer_js__/getStaticPaths__basic_.snap similarity index 100% rename from internal/printer/__snapshots__/getStaticPaths__basic_.snap rename to internal/printer/__printer_js__/getStaticPaths__basic_.snap diff --git a/internal/printer/__snapshots__/getStaticPaths__hoisted_.snap b/internal/printer/__printer_js__/getStaticPaths__hoisted_.snap similarity index 100% rename from internal/printer/__snapshots__/getStaticPaths__hoisted_.snap rename to internal/printer/__printer_js__/getStaticPaths__hoisted_.snap diff --git a/internal/printer/__snapshots__/getStaticPaths__hoisted_II_.snap b/internal/printer/__printer_js__/getStaticPaths__hoisted_II_.snap similarity index 100% rename from internal/printer/__snapshots__/getStaticPaths__hoisted_II_.snap rename to internal/printer/__printer_js__/getStaticPaths__hoisted_II_.snap diff --git a/internal/printer/__snapshots__/gets_all_potential_hydrated_components.snap b/internal/printer/__printer_js__/gets_all_potential_hydrated_components.snap similarity index 100% rename from internal/printer/__snapshots__/gets_all_potential_hydrated_components.snap rename to internal/printer/__printer_js__/gets_all_potential_hydrated_components.snap diff --git a/internal/printer/__snapshots__/head_expression.snap b/internal/printer/__printer_js__/head_expression.snap similarity index 100% rename from internal/printer/__snapshots__/head_expression.snap rename to internal/printer/__printer_js__/head_expression.snap diff --git a/internal/printer/__snapshots__/head_expression_and_conditional_rendering_of_fragment.snap b/internal/printer/__printer_js__/head_expression_and_conditional_rendering_of_fragment.snap similarity index 100% rename from internal/printer/__snapshots__/head_expression_and_conditional_rendering_of_fragment.snap rename to internal/printer/__printer_js__/head_expression_and_conditional_rendering_of_fragment.snap diff --git a/internal/printer/__snapshots__/head_inside_slot.snap b/internal/printer/__printer_js__/head_inside_slot.snap similarity index 100% rename from internal/printer/__snapshots__/head_inside_slot.snap rename to internal/printer/__printer_js__/head_inside_slot.snap diff --git a/internal/printer/__snapshots__/head_slot.snap b/internal/printer/__printer_js__/head_slot.snap similarity index 100% rename from internal/printer/__snapshots__/head_slot.snap rename to internal/printer/__printer_js__/head_slot.snap diff --git a/internal/printer/__snapshots__/head_slot_II.snap b/internal/printer/__printer_js__/head_slot_II.snap similarity index 100% rename from internal/printer/__snapshots__/head_slot_II.snap rename to internal/printer/__printer_js__/head_slot_II.snap diff --git a/internal/printer/__snapshots__/head_slot_III.snap b/internal/printer/__printer_js__/head_slot_III.snap similarity index 100% rename from internal/printer/__snapshots__/head_slot_III.snap rename to internal/printer/__printer_js__/head_slot_III.snap diff --git a/internal/printer/__snapshots__/html5_boilerplate.snap b/internal/printer/__printer_js__/html5_boilerplate.snap similarity index 100% rename from internal/printer/__snapshots__/html5_boilerplate.snap rename to internal/printer/__printer_js__/html5_boilerplate.snap diff --git a/internal/printer/__snapshots__/iframe.snap b/internal/printer/__printer_js__/iframe.snap similarity index 100% rename from internal/printer/__snapshots__/iframe.snap rename to internal/printer/__printer_js__/iframe.snap diff --git a/internal/printer/__snapshots__/import.meta.env.snap b/internal/printer/__printer_js__/import.meta.env.snap similarity index 100% rename from internal/printer/__snapshots__/import.meta.env.snap rename to internal/printer/__printer_js__/import.meta.env.snap diff --git a/internal/printer/__snapshots__/import.meta.snap b/internal/printer/__printer_js__/import.meta.snap similarity index 100% rename from internal/printer/__snapshots__/import.meta.snap rename to internal/printer/__printer_js__/import.meta.snap diff --git a/internal/printer/__snapshots__/import_assertions.snap b/internal/printer/__printer_js__/import_assertions.snap similarity index 100% rename from internal/printer/__snapshots__/import_assertions.snap rename to internal/printer/__printer_js__/import_assertions.snap diff --git a/internal/printer/__snapshots__/import_order.snap b/internal/printer/__printer_js__/import_order.snap similarity index 100% rename from internal/printer/__snapshots__/import_order.snap rename to internal/printer/__printer_js__/import_order.snap diff --git a/internal/printer/__snapshots__/import_to_identifier_named_assert.snap b/internal/printer/__printer_js__/import_to_identifier_named_assert.snap similarity index 100% rename from internal/printer/__snapshots__/import_to_identifier_named_assert.snap rename to internal/printer/__printer_js__/import_to_identifier_named_assert.snap diff --git a/internal/printer/__snapshots__/includes_comments_for_expression_attribute.snap b/internal/printer/__printer_js__/includes_comments_for_expression_attribute.snap similarity index 100% rename from internal/printer/__snapshots__/includes_comments_for_expression_attribute.snap rename to internal/printer/__printer_js__/includes_comments_for_expression_attribute.snap diff --git a/internal/printer/__snapshots__/includes_comments_for_shorthand_attribute.snap b/internal/printer/__printer_js__/includes_comments_for_shorthand_attribute.snap similarity index 100% rename from internal/printer/__snapshots__/includes_comments_for_shorthand_attribute.snap rename to internal/printer/__printer_js__/includes_comments_for_shorthand_attribute.snap diff --git a/internal/printer/__snapshots__/is_raw.snap b/internal/printer/__printer_js__/is_raw.snap similarity index 100% rename from internal/printer/__snapshots__/is_raw.snap rename to internal/printer/__printer_js__/is_raw.snap diff --git a/internal/printer/__snapshots__/map_basic.snap b/internal/printer/__printer_js__/map_basic.snap similarity index 100% rename from internal/printer/__snapshots__/map_basic.snap rename to internal/printer/__printer_js__/map_basic.snap diff --git a/internal/printer/__snapshots__/map_nested.snap b/internal/printer/__printer_js__/map_nested.snap similarity index 100% rename from internal/printer/__snapshots__/map_nested.snap rename to internal/printer/__printer_js__/map_nested.snap diff --git a/internal/printer/__snapshots__/map_with_component.snap b/internal/printer/__printer_js__/map_with_component.snap similarity index 100% rename from internal/printer/__snapshots__/map_with_component.snap rename to internal/printer/__printer_js__/map_with_component.snap diff --git a/internal/printer/__snapshots__/map_without_component.snap b/internal/printer/__printer_js__/map_without_component.snap similarity index 100% rename from internal/printer/__snapshots__/map_without_component.snap rename to internal/printer/__printer_js__/map_without_component.snap diff --git a/internal/printer/__snapshots__/maybeRenderHead_not_printed_for_hoisted_scripts.snap b/internal/printer/__printer_js__/maybeRenderHead_not_printed_for_hoisted_scripts.snap similarity index 100% rename from internal/printer/__snapshots__/maybeRenderHead_not_printed_for_hoisted_scripts.snap rename to internal/printer/__printer_js__/maybeRenderHead_not_printed_for_hoisted_scripts.snap diff --git a/internal/printer/__snapshots__/multibyte_character_+_script.snap b/internal/printer/__printer_js__/multibyte_character___script.snap similarity index 100% rename from internal/printer/__snapshots__/multibyte_character_+_script.snap rename to internal/printer/__printer_js__/multibyte_character___script.snap diff --git a/internal/printer/__snapshots__/multibyte_character_+_style.snap b/internal/printer/__printer_js__/multibyte_character___style.snap similarity index 100% rename from internal/printer/__snapshots__/multibyte_character_+_style.snap rename to internal/printer/__printer_js__/multibyte_character___style.snap diff --git a/internal/printer/__snapshots__/multibyte_characters.snap b/internal/printer/__printer_js__/multibyte_characters.snap similarity index 100% rename from internal/printer/__snapshots__/multibyte_characters.snap rename to internal/printer/__printer_js__/multibyte_characters.snap diff --git a/internal/printer/__snapshots__/multiple_define_vars_on_style.snap b/internal/printer/__printer_js__/multiple_define_vars_on_style.snap similarity index 100% rename from internal/printer/__snapshots__/multiple_define_vars_on_style.snap rename to internal/printer/__printer_js__/multiple_define_vars_on_style.snap diff --git a/internal/printer/__snapshots__/nested_expressions.snap b/internal/printer/__printer_js__/nested_expressions.snap similarity index 100% rename from internal/printer/__snapshots__/nested_expressions.snap rename to internal/printer/__printer_js__/nested_expressions.snap diff --git a/internal/printer/__snapshots__/nested_expressions_II.snap b/internal/printer/__printer_js__/nested_expressions_II.snap similarity index 100% rename from internal/printer/__snapshots__/nested_expressions_II.snap rename to internal/printer/__printer_js__/nested_expressions_II.snap diff --git a/internal/printer/__snapshots__/nested_expressions_III.snap b/internal/printer/__printer_js__/nested_expressions_III.snap similarity index 100% rename from internal/printer/__snapshots__/nested_expressions_III.snap rename to internal/printer/__printer_js__/nested_expressions_III.snap diff --git a/internal/printer/__snapshots__/nested_expressions_IV.snap b/internal/printer/__printer_js__/nested_expressions_IV.snap similarity index 100% rename from internal/printer/__snapshots__/nested_expressions_IV.snap rename to internal/printer/__printer_js__/nested_expressions_IV.snap diff --git a/internal/printer/__snapshots__/nested_expressions_V.snap b/internal/printer/__printer_js__/nested_expressions_V.snap similarity index 100% rename from internal/printer/__snapshots__/nested_expressions_V.snap rename to internal/printer/__printer_js__/nested_expressions_V.snap diff --git a/internal/printer/__snapshots__/nested_expressions_VI.snap b/internal/printer/__printer_js__/nested_expressions_VI.snap similarity index 100% rename from internal/printer/__snapshots__/nested_expressions_VI.snap rename to internal/printer/__printer_js__/nested_expressions_VI.snap diff --git a/internal/printer/__snapshots__/nested_expressions_VII.snap b/internal/printer/__printer_js__/nested_expressions_VII.snap similarity index 100% rename from internal/printer/__snapshots__/nested_expressions_VII.snap rename to internal/printer/__printer_js__/nested_expressions_VII.snap diff --git a/internal/printer/__snapshots__/nested_expressions_VIII.snap b/internal/printer/__printer_js__/nested_expressions_VIII.snap similarity index 100% rename from internal/printer/__snapshots__/nested_expressions_VIII.snap rename to internal/printer/__printer_js__/nested_expressions_VIII.snap diff --git a/internal/printer/__snapshots__/nested_head_content_stays_in_the_head.snap b/internal/printer/__printer_js__/nested_head_content_stays_in_the_head.snap similarity index 100% rename from internal/printer/__snapshots__/nested_head_content_stays_in_the_head.snap rename to internal/printer/__printer_js__/nested_head_content_stays_in_the_head.snap diff --git a/internal/printer/__snapshots__/nested_template_literal_expression.snap b/internal/printer/__printer_js__/nested_template_literal_expression.snap similarity index 100% rename from internal/printer/__snapshots__/nested_template_literal_expression.snap rename to internal/printer/__printer_js__/nested_template_literal_expression.snap diff --git a/internal/printer/__snapshots__/no_expressions_in_math.snap b/internal/printer/__printer_js__/no_expressions_in_math.snap similarity index 100% rename from internal/printer/__snapshots__/no_expressions_in_math.snap rename to internal/printer/__printer_js__/no_expressions_in_math.snap diff --git a/internal/printer/__snapshots__/noscript_component.snap b/internal/printer/__printer_js__/noscript_component.snap similarity index 100% rename from internal/printer/__snapshots__/noscript_component.snap rename to internal/printer/__printer_js__/noscript_component.snap diff --git a/internal/printer/__snapshots__/noscript_deep_styles.snap b/internal/printer/__printer_js__/noscript_deep_styles.snap similarity index 100% rename from internal/printer/__snapshots__/noscript_deep_styles.snap rename to internal/printer/__printer_js__/noscript_deep_styles.snap diff --git a/internal/printer/__snapshots__/noscript_only.snap b/internal/printer/__printer_js__/noscript_only.snap similarity index 100% rename from internal/printer/__snapshots__/noscript_only.snap rename to internal/printer/__printer_js__/noscript_only.snap diff --git a/internal/printer/__snapshots__/noscript_styles.snap b/internal/printer/__printer_js__/noscript_styles.snap similarity index 100% rename from internal/printer/__snapshots__/noscript_styles.snap rename to internal/printer/__printer_js__/noscript_styles.snap diff --git a/internal/printer/__snapshots__/orphan_slot.snap b/internal/printer/__printer_js__/orphan_slot.snap similarity index 100% rename from internal/printer/__snapshots__/orphan_slot.snap rename to internal/printer/__printer_js__/orphan_slot.snap diff --git a/internal/printer/__snapshots__/passes_escaped_filename_into_createComponent_if_it_contains_single_quotes.snap b/internal/printer/__printer_js__/passes_escaped_filename_into_createComponent_if_it_contains_single_quotes.snap similarity index 100% rename from internal/printer/__snapshots__/passes_escaped_filename_into_createComponent_if_it_contains_single_quotes.snap rename to internal/printer/__printer_js__/passes_escaped_filename_into_createComponent_if_it_contains_single_quotes.snap diff --git a/internal/printer/__snapshots__/passes_filename_into_createComponent_if_passed_into_the_compiler_options.snap b/internal/printer/__printer_js__/passes_filename_into_createComponent_if_passed_into_the_compiler_options.snap similarity index 100% rename from internal/printer/__snapshots__/passes_filename_into_createComponent_if_passed_into_the_compiler_options.snap rename to internal/printer/__printer_js__/passes_filename_into_createComponent_if_passed_into_the_compiler_options.snap diff --git a/internal/printer/__snapshots__/preserve_is_inline_slot.snap b/internal/printer/__printer_js__/preserve_is_inline_slot.snap similarity index 100% rename from internal/printer/__snapshots__/preserve_is_inline_slot.snap rename to internal/printer/__printer_js__/preserve_is_inline_slot.snap diff --git a/internal/printer/__snapshots__/preserve_is_inline_slot_II.snap b/internal/printer/__printer_js__/preserve_is_inline_slot_II.snap similarity index 100% rename from internal/printer/__snapshots__/preserve_is_inline_slot_II.snap rename to internal/printer/__printer_js__/preserve_is_inline_slot_II.snap diff --git a/internal/printer/__snapshots__/script__renderScript__true_.snap b/internal/printer/__printer_js__/script__renderScript__true_.snap similarity index 100% rename from internal/printer/__snapshots__/script__renderScript__true_.snap rename to internal/printer/__printer_js__/script__renderScript__true_.snap diff --git a/internal/printer/__snapshots__/script_before_elements.snap b/internal/printer/__printer_js__/script_before_elements.snap similarity index 100% rename from internal/printer/__snapshots__/script_before_elements.snap rename to internal/printer/__printer_js__/script_before_elements.snap diff --git a/internal/printer/__snapshots__/script_define_vars_I.snap b/internal/printer/__printer_js__/script_define_vars_I.snap similarity index 100% rename from internal/printer/__snapshots__/script_define_vars_I.snap rename to internal/printer/__printer_js__/script_define_vars_I.snap diff --git a/internal/printer/__snapshots__/script_define_vars_II.snap b/internal/printer/__printer_js__/script_define_vars_II.snap similarity index 100% rename from internal/printer/__snapshots__/script_define_vars_II.snap rename to internal/printer/__printer_js__/script_define_vars_II.snap diff --git a/internal/printer/__snapshots__/script_external__renderScript__true_.snap b/internal/printer/__printer_js__/script_external__renderScript__true_.snap similarity index 100% rename from internal/printer/__snapshots__/script_external__renderScript__true_.snap rename to internal/printer/__printer_js__/script_external__renderScript__true_.snap diff --git a/internal/printer/__snapshots__/script_hoist_with_frontmatter.snap b/internal/printer/__printer_js__/script_hoist_with_frontmatter.snap similarity index 100% rename from internal/printer/__snapshots__/script_hoist_with_frontmatter.snap rename to internal/printer/__printer_js__/script_hoist_with_frontmatter.snap diff --git a/internal/printer/__snapshots__/script_hoist_without_frontmatter.snap b/internal/printer/__printer_js__/script_hoist_without_frontmatter.snap similarity index 100% rename from internal/printer/__snapshots__/script_hoist_without_frontmatter.snap rename to internal/printer/__printer_js__/script_hoist_without_frontmatter.snap diff --git a/internal/printer/__snapshots__/script_in__head_.snap b/internal/printer/__printer_js__/script_in__head_.snap similarity index 100% rename from internal/printer/__snapshots__/script_in__head_.snap rename to internal/printer/__printer_js__/script_in__head_.snap diff --git a/internal/printer/__snapshots__/script_inline.snap b/internal/printer/__printer_js__/script_inline.snap similarity index 100% rename from internal/printer/__snapshots__/script_inline.snap rename to internal/printer/__printer_js__/script_inline.snap diff --git a/internal/printer/__snapshots__/script_inline__renderScript__true_.snap b/internal/printer/__printer_js__/script_inline__renderScript__true_.snap similarity index 100% rename from internal/printer/__snapshots__/script_inline__renderScript__true_.snap rename to internal/printer/__printer_js__/script_inline__renderScript__true_.snap diff --git a/internal/printer/__snapshots__/script_mixed_handled_and_inline__renderScript__true_.snap b/internal/printer/__printer_js__/script_mixed_handled_and_inline__renderScript__true_.snap similarity index 100% rename from internal/printer/__snapshots__/script_mixed_handled_and_inline__renderScript__true_.snap rename to internal/printer/__printer_js__/script_mixed_handled_and_inline__renderScript__true_.snap diff --git a/internal/printer/__snapshots__/script_multiple__renderScript__true_.snap b/internal/printer/__printer_js__/script_multiple__renderScript__true_.snap similarity index 100% rename from internal/printer/__snapshots__/script_multiple__renderScript__true_.snap rename to internal/printer/__printer_js__/script_multiple__renderScript__true_.snap diff --git a/internal/printer/__printer_js__/scriptinline.snap b/internal/printer/__printer_js__/scriptinline.snap new file mode 100755 index 000000000..37db1063f --- /dev/null +++ b/internal/printer/__printer_js__/scriptinline.snap @@ -0,0 +1,41 @@ + +[TestPrinter/scriptinline - 1] +## Input + +``` +
+``` + +## Output + +```js +import { + Fragment, + render as $$render, + createAstro as $$createAstro, + createComponent as $$createComponent, + renderComponent as $$renderComponent, + renderHead as $$renderHead, + maybeRenderHead as $$maybeRenderHead, + unescapeHTML as $$unescapeHTML, + renderSlot as $$renderSlot, + mergeSlots as $$mergeSlots, + addAttribute as $$addAttribute, + spreadAttributes as $$spreadAttributes, + defineStyleVars as $$defineStyleVars, + defineScriptVars as $$defineScriptVars, + renderTransition as $$renderTransition, + createTransitionScope as $$createTransitionScope, + renderScript as $$renderScript, + createMetadata as $$createMetadata +} from "http://localhost:3000/"; + +export const $$metadata = $$createMetadata(import.meta.url, { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: new Set([]), hoisted: [] }); + +const $$Component = $$createComponent(($$result, $$props, $$slots) => { + +return $$render`${$$maybeRenderHead($$result)}
`; +}, undefined, undefined); +export default $$Component; +``` +--- diff --git a/internal/printer/__snapshots__/select_in_form.snap b/internal/printer/__printer_js__/select_in_form.snap similarity index 100% rename from internal/printer/__snapshots__/select_in_form.snap rename to internal/printer/__printer_js__/select_in_form.snap diff --git a/internal/printer/__snapshots__/select_map_expression.snap b/internal/printer/__printer_js__/select_map_expression.snap similarity index 100% rename from internal/printer/__snapshots__/select_map_expression.snap rename to internal/printer/__printer_js__/select_map_expression.snap diff --git a/internal/printer/__snapshots__/select_nested_option.snap b/internal/printer/__printer_js__/select_nested_option.snap similarity index 100% rename from internal/printer/__snapshots__/select_nested_option.snap rename to internal/printer/__printer_js__/select_nested_option.snap diff --git a/internal/printer/__snapshots__/select_option_expression.snap b/internal/printer/__printer_js__/select_option_expression.snap similarity index 100% rename from internal/printer/__snapshots__/select_option_expression.snap rename to internal/printer/__printer_js__/select_option_expression.snap diff --git a/internal/printer/__snapshots__/self-closing_td.snap b/internal/printer/__printer_js__/self-closing_td.snap similarity index 100% rename from internal/printer/__snapshots__/self-closing_td.snap rename to internal/printer/__printer_js__/self-closing_td.snap diff --git a/internal/printer/__snapshots__/set_html.snap b/internal/printer/__printer_js__/set_html.snap similarity index 100% rename from internal/printer/__snapshots__/set_html.snap rename to internal/printer/__printer_js__/set_html.snap diff --git a/internal/printer/__snapshots__/set_html_and_set_text.snap b/internal/printer/__printer_js__/set_html_and_set_text.snap similarity index 100% rename from internal/printer/__snapshots__/set_html_and_set_text.snap rename to internal/printer/__printer_js__/set_html_and_set_text.snap diff --git a/internal/printer/__snapshots__/set_html_on_Component.snap b/internal/printer/__printer_js__/set_html_on_Component.snap similarity index 100% rename from internal/printer/__snapshots__/set_html_on_Component.snap rename to internal/printer/__printer_js__/set_html_on_Component.snap diff --git a/internal/printer/__snapshots__/set_html_on_Component_with_quoted_attribute.snap b/internal/printer/__printer_js__/set_html_on_Component_with_quoted_attribute.snap similarity index 100% rename from internal/printer/__snapshots__/set_html_on_Component_with_quoted_attribute.snap rename to internal/printer/__printer_js__/set_html_on_Component_with_quoted_attribute.snap diff --git a/internal/printer/__snapshots__/set_html_on_Component_with_template_literal_attribute_with_variable.snap b/internal/printer/__printer_js__/set_html_on_Component_with_template_literal_attribute_with_variable.snap similarity index 100% rename from internal/printer/__snapshots__/set_html_on_Component_with_template_literal_attribute_with_variable.snap rename to internal/printer/__printer_js__/set_html_on_Component_with_template_literal_attribute_with_variable.snap diff --git a/internal/printer/__snapshots__/set_html_on_Component_with_template_literal_attribute_without_variable.snap b/internal/printer/__printer_js__/set_html_on_Component_with_template_literal_attribute_without_variable.snap similarity index 100% rename from internal/printer/__snapshots__/set_html_on_Component_with_template_literal_attribute_without_variable.snap rename to internal/printer/__printer_js__/set_html_on_Component_with_template_literal_attribute_without_variable.snap diff --git a/internal/printer/__snapshots__/set_html_on_Fragment.snap b/internal/printer/__printer_js__/set_html_on_Fragment.snap similarity index 100% rename from internal/printer/__snapshots__/set_html_on_Fragment.snap rename to internal/printer/__printer_js__/set_html_on_Fragment.snap diff --git a/internal/printer/__snapshots__/set_html_on_Fragment_with_quoted_attribute.snap b/internal/printer/__printer_js__/set_html_on_Fragment_with_quoted_attribute.snap similarity index 100% rename from internal/printer/__snapshots__/set_html_on_Fragment_with_quoted_attribute.snap rename to internal/printer/__printer_js__/set_html_on_Fragment_with_quoted_attribute.snap diff --git a/internal/printer/__snapshots__/set_html_on_Fragment_with_template_literal_attribute_with_variable.snap b/internal/printer/__printer_js__/set_html_on_Fragment_with_template_literal_attribute_with_variable.snap similarity index 100% rename from internal/printer/__snapshots__/set_html_on_Fragment_with_template_literal_attribute_with_variable.snap rename to internal/printer/__printer_js__/set_html_on_Fragment_with_template_literal_attribute_with_variable.snap diff --git a/internal/printer/__snapshots__/set_html_on_Fragment_with_template_literal_attribute_without_variable.snap b/internal/printer/__printer_js__/set_html_on_Fragment_with_template_literal_attribute_without_variable.snap similarity index 100% rename from internal/printer/__snapshots__/set_html_on_Fragment_with_template_literal_attribute_without_variable.snap rename to internal/printer/__printer_js__/set_html_on_Fragment_with_template_literal_attribute_without_variable.snap diff --git a/internal/printer/__snapshots__/set_html_on_custom-element.snap b/internal/printer/__printer_js__/set_html_on_custom-element.snap similarity index 100% rename from internal/printer/__snapshots__/set_html_on_custom-element.snap rename to internal/printer/__printer_js__/set_html_on_custom-element.snap diff --git a/internal/printer/__snapshots__/set_html_on_custom-element_with_quoted_attribute.snap b/internal/printer/__printer_js__/set_html_on_custom-element_with_quoted_attribute.snap similarity index 100% rename from internal/printer/__snapshots__/set_html_on_custom-element_with_quoted_attribute.snap rename to internal/printer/__printer_js__/set_html_on_custom-element_with_quoted_attribute.snap diff --git a/internal/printer/__snapshots__/set_html_on_custom-element_with_template_literal_attribute_with_variable.snap b/internal/printer/__printer_js__/set_html_on_custom-element_with_template_literal_attribute_with_variable.snap similarity index 100% rename from internal/printer/__snapshots__/set_html_on_custom-element_with_template_literal_attribute_with_variable.snap rename to internal/printer/__printer_js__/set_html_on_custom-element_with_template_literal_attribute_with_variable.snap diff --git a/internal/printer/__snapshots__/set_html_on_custom-element_with_template_literal_attribute_without_variable.snap b/internal/printer/__printer_js__/set_html_on_custom-element_with_template_literal_attribute_without_variable.snap similarity index 100% rename from internal/printer/__snapshots__/set_html_on_custom-element_with_template_literal_attribute_without_variable.snap rename to internal/printer/__printer_js__/set_html_on_custom-element_with_template_literal_attribute_without_variable.snap diff --git a/internal/printer/__snapshots__/set_html_on_empty_tag.snap b/internal/printer/__printer_js__/set_html_on_empty_tag.snap similarity index 100% rename from internal/printer/__snapshots__/set_html_on_empty_tag.snap rename to internal/printer/__printer_js__/set_html_on_empty_tag.snap diff --git a/internal/printer/__snapshots__/set_html_on_empty_tag_with_quoted_attribute.snap b/internal/printer/__printer_js__/set_html_on_empty_tag_with_quoted_attribute.snap similarity index 100% rename from internal/printer/__snapshots__/set_html_on_empty_tag_with_quoted_attribute.snap rename to internal/printer/__printer_js__/set_html_on_empty_tag_with_quoted_attribute.snap diff --git a/internal/printer/__snapshots__/set_html_on_empty_tag_with_template_literal_attribute_with_variable.snap b/internal/printer/__printer_js__/set_html_on_empty_tag_with_template_literal_attribute_with_variable.snap similarity index 100% rename from internal/printer/__snapshots__/set_html_on_empty_tag_with_template_literal_attribute_with_variable.snap rename to internal/printer/__printer_js__/set_html_on_empty_tag_with_template_literal_attribute_with_variable.snap diff --git a/internal/printer/__snapshots__/set_html_on_empty_tag_with_template_literal_attribute_without_variable.snap b/internal/printer/__printer_js__/set_html_on_empty_tag_with_template_literal_attribute_without_variable.snap similarity index 100% rename from internal/printer/__snapshots__/set_html_on_empty_tag_with_template_literal_attribute_without_variable.snap rename to internal/printer/__printer_js__/set_html_on_empty_tag_with_template_literal_attribute_without_variable.snap diff --git a/internal/printer/__snapshots__/set_html_on_script.snap b/internal/printer/__printer_js__/set_html_on_script.snap similarity index 100% rename from internal/printer/__snapshots__/set_html_on_script.snap rename to internal/printer/__printer_js__/set_html_on_script.snap diff --git a/internal/printer/__snapshots__/set_html_on_script_with_quoted_attribute.snap b/internal/printer/__printer_js__/set_html_on_script_with_quoted_attribute.snap similarity index 100% rename from internal/printer/__snapshots__/set_html_on_script_with_quoted_attribute.snap rename to internal/printer/__printer_js__/set_html_on_script_with_quoted_attribute.snap diff --git a/internal/printer/__snapshots__/set_html_on_script_with_template_literal_attribute_with_variable.snap b/internal/printer/__printer_js__/set_html_on_script_with_template_literal_attribute_with_variable.snap similarity index 100% rename from internal/printer/__snapshots__/set_html_on_script_with_template_literal_attribute_with_variable.snap rename to internal/printer/__printer_js__/set_html_on_script_with_template_literal_attribute_with_variable.snap diff --git a/internal/printer/__snapshots__/set_html_on_script_with_template_literal_attribute_without_variable.snap b/internal/printer/__printer_js__/set_html_on_script_with_template_literal_attribute_without_variable.snap similarity index 100% rename from internal/printer/__snapshots__/set_html_on_script_with_template_literal_attribute_without_variable.snap rename to internal/printer/__printer_js__/set_html_on_script_with_template_literal_attribute_without_variable.snap diff --git a/internal/printer/__snapshots__/set_html_on_self-closing_tag.snap b/internal/printer/__printer_js__/set_html_on_self-closing_tag.snap similarity index 100% rename from internal/printer/__snapshots__/set_html_on_self-closing_tag.snap rename to internal/printer/__printer_js__/set_html_on_self-closing_tag.snap diff --git a/internal/printer/__snapshots__/set_html_on_self-closing_tag_with_quoted_attribute.snap b/internal/printer/__printer_js__/set_html_on_self-closing_tag_with_quoted_attribute.snap similarity index 100% rename from internal/printer/__snapshots__/set_html_on_self-closing_tag_with_quoted_attribute.snap rename to internal/printer/__printer_js__/set_html_on_self-closing_tag_with_quoted_attribute.snap diff --git a/internal/printer/__snapshots__/set_html_on_self-closing_tag_with_template_literal_attribute_with_variable.snap b/internal/printer/__printer_js__/set_html_on_self-closing_tag_with_template_literal_attribute_with_variable.snap similarity index 100% rename from internal/printer/__snapshots__/set_html_on_self-closing_tag_with_template_literal_attribute_with_variable.snap rename to internal/printer/__printer_js__/set_html_on_self-closing_tag_with_template_literal_attribute_with_variable.snap diff --git a/internal/printer/__snapshots__/set_html_on_self-closing_tag_with_template_literal_attribute_without_variable.snap b/internal/printer/__printer_js__/set_html_on_self-closing_tag_with_template_literal_attribute_without_variable.snap similarity index 100% rename from internal/printer/__snapshots__/set_html_on_self-closing_tag_with_template_literal_attribute_without_variable.snap rename to internal/printer/__printer_js__/set_html_on_self-closing_tag_with_template_literal_attribute_without_variable.snap diff --git a/internal/printer/__snapshots__/set_html_on_style.snap b/internal/printer/__printer_js__/set_html_on_style.snap similarity index 100% rename from internal/printer/__snapshots__/set_html_on_style.snap rename to internal/printer/__printer_js__/set_html_on_style.snap diff --git a/internal/printer/__snapshots__/set_html_on_style_with_quoted_attribute.snap b/internal/printer/__printer_js__/set_html_on_style_with_quoted_attribute.snap similarity index 100% rename from internal/printer/__snapshots__/set_html_on_style_with_quoted_attribute.snap rename to internal/printer/__printer_js__/set_html_on_style_with_quoted_attribute.snap diff --git a/internal/printer/__snapshots__/set_html_on_style_with_template_literal_attribute_with_variable.snap b/internal/printer/__printer_js__/set_html_on_style_with_template_literal_attribute_with_variable.snap similarity index 100% rename from internal/printer/__snapshots__/set_html_on_style_with_template_literal_attribute_with_variable.snap rename to internal/printer/__printer_js__/set_html_on_style_with_template_literal_attribute_with_variable.snap diff --git a/internal/printer/__snapshots__/set_html_on_style_with_template_literal_attribute_without_variable.snap b/internal/printer/__printer_js__/set_html_on_style_with_template_literal_attribute_without_variable.snap similarity index 100% rename from internal/printer/__snapshots__/set_html_on_style_with_template_literal_attribute_without_variable.snap rename to internal/printer/__printer_js__/set_html_on_style_with_template_literal_attribute_without_variable.snap diff --git a/internal/printer/__snapshots__/set_html_on_tag_with_children.snap b/internal/printer/__printer_js__/set_html_on_tag_with_children.snap similarity index 100% rename from internal/printer/__snapshots__/set_html_on_tag_with_children.snap rename to internal/printer/__printer_js__/set_html_on_tag_with_children.snap diff --git a/internal/printer/__snapshots__/set_html_on_tag_with_children_and_quoted_attribute.snap b/internal/printer/__printer_js__/set_html_on_tag_with_children_and_quoted_attribute.snap similarity index 100% rename from internal/printer/__snapshots__/set_html_on_tag_with_children_and_quoted_attribute.snap rename to internal/printer/__printer_js__/set_html_on_tag_with_children_and_quoted_attribute.snap diff --git a/internal/printer/__snapshots__/set_html_on_tag_with_children_and_template_literal_attribute_with_variable.snap b/internal/printer/__printer_js__/set_html_on_tag_with_children_and_template_literal_attribute_with_variable.snap similarity index 100% rename from internal/printer/__snapshots__/set_html_on_tag_with_children_and_template_literal_attribute_with_variable.snap rename to internal/printer/__printer_js__/set_html_on_tag_with_children_and_template_literal_attribute_with_variable.snap diff --git a/internal/printer/__snapshots__/set_html_on_tag_with_children_and_template_literal_attribute_without_variable.snap b/internal/printer/__printer_js__/set_html_on_tag_with_children_and_template_literal_attribute_without_variable.snap similarity index 100% rename from internal/printer/__snapshots__/set_html_on_tag_with_children_and_template_literal_attribute_without_variable.snap rename to internal/printer/__printer_js__/set_html_on_tag_with_children_and_template_literal_attribute_without_variable.snap diff --git a/internal/printer/__snapshots__/set_html_on_tag_with_empty_whitespace.snap b/internal/printer/__printer_js__/set_html_on_tag_with_empty_whitespace.snap similarity index 100% rename from internal/printer/__snapshots__/set_html_on_tag_with_empty_whitespace.snap rename to internal/printer/__printer_js__/set_html_on_tag_with_empty_whitespace.snap diff --git a/internal/printer/__snapshots__/set_html_on_tag_with_empty_whitespace_and_quoted_attribute.snap b/internal/printer/__printer_js__/set_html_on_tag_with_empty_whitespace_and_quoted_attribute.snap similarity index 100% rename from internal/printer/__snapshots__/set_html_on_tag_with_empty_whitespace_and_quoted_attribute.snap rename to internal/printer/__printer_js__/set_html_on_tag_with_empty_whitespace_and_quoted_attribute.snap diff --git a/internal/printer/__snapshots__/set_html_on_tag_with_empty_whitespace_and_template_literal_attribute_with_variable.snap b/internal/printer/__printer_js__/set_html_on_tag_with_empty_whitespace_and_template_literal_attribute_with_variable.snap similarity index 100% rename from internal/printer/__snapshots__/set_html_on_tag_with_empty_whitespace_and_template_literal_attribute_with_variable.snap rename to internal/printer/__printer_js__/set_html_on_tag_with_empty_whitespace_and_template_literal_attribute_with_variable.snap diff --git a/internal/printer/__snapshots__/set_html_on_tag_with_empty_whitespace_and_template_literal_attribute_without_variable.snap b/internal/printer/__printer_js__/set_html_on_tag_with_empty_whitespace_and_template_literal_attribute_without_variable.snap similarity index 100% rename from internal/printer/__snapshots__/set_html_on_tag_with_empty_whitespace_and_template_literal_attribute_without_variable.snap rename to internal/printer/__printer_js__/set_html_on_tag_with_empty_whitespace_and_template_literal_attribute_without_variable.snap diff --git a/internal/printer/__snapshots__/set_html_with_other_attributes.snap b/internal/printer/__printer_js__/set_html_with_other_attributes.snap similarity index 100% rename from internal/printer/__snapshots__/set_html_with_other_attributes.snap rename to internal/printer/__printer_js__/set_html_with_other_attributes.snap diff --git a/internal/printer/__snapshots__/set_html_with_quoted_attribute.snap b/internal/printer/__printer_js__/set_html_with_quoted_attribute.snap similarity index 100% rename from internal/printer/__snapshots__/set_html_with_quoted_attribute.snap rename to internal/printer/__printer_js__/set_html_with_quoted_attribute.snap diff --git a/internal/printer/__snapshots__/set_html_with_quoted_attribute_and_other_attributes.snap b/internal/printer/__printer_js__/set_html_with_quoted_attribute_and_other_attributes.snap similarity index 100% rename from internal/printer/__snapshots__/set_html_with_quoted_attribute_and_other_attributes.snap rename to internal/printer/__printer_js__/set_html_with_quoted_attribute_and_other_attributes.snap diff --git a/internal/printer/__snapshots__/set_html_with_template_literal_attribute_with_variable.snap b/internal/printer/__printer_js__/set_html_with_template_literal_attribute_with_variable.snap similarity index 100% rename from internal/printer/__snapshots__/set_html_with_template_literal_attribute_with_variable.snap rename to internal/printer/__printer_js__/set_html_with_template_literal_attribute_with_variable.snap diff --git a/internal/printer/__snapshots__/set_html_with_template_literal_attribute_with_variable_and_other_attributes.snap b/internal/printer/__printer_js__/set_html_with_template_literal_attribute_with_variable_and_other_attributes.snap similarity index 100% rename from internal/printer/__snapshots__/set_html_with_template_literal_attribute_with_variable_and_other_attributes.snap rename to internal/printer/__printer_js__/set_html_with_template_literal_attribute_with_variable_and_other_attributes.snap diff --git a/internal/printer/__snapshots__/set_html_with_template_literal_attribute_without_variable.snap b/internal/printer/__printer_js__/set_html_with_template_literal_attribute_without_variable.snap similarity index 100% rename from internal/printer/__snapshots__/set_html_with_template_literal_attribute_without_variable.snap rename to internal/printer/__printer_js__/set_html_with_template_literal_attribute_without_variable.snap diff --git a/internal/printer/__snapshots__/set_html_with_template_literal_attribute_without_variable_and_other_attributes.snap b/internal/printer/__printer_js__/set_html_with_template_literal_attribute_without_variable_and_other_attributes.snap similarity index 100% rename from internal/printer/__snapshots__/set_html_with_template_literal_attribute_without_variable_and_other_attributes.snap rename to internal/printer/__printer_js__/set_html_with_template_literal_attribute_without_variable_and_other_attributes.snap diff --git a/internal/printer/__snapshots__/set_text.snap b/internal/printer/__printer_js__/set_text.snap similarity index 100% rename from internal/printer/__snapshots__/set_text.snap rename to internal/printer/__printer_js__/set_text.snap diff --git a/internal/printer/__snapshots__/set_text_on_Component.snap b/internal/printer/__printer_js__/set_text_on_Component.snap similarity index 100% rename from internal/printer/__snapshots__/set_text_on_Component.snap rename to internal/printer/__printer_js__/set_text_on_Component.snap diff --git a/internal/printer/__snapshots__/set_text_on_Component_with_quoted_attribute.snap b/internal/printer/__printer_js__/set_text_on_Component_with_quoted_attribute.snap similarity index 100% rename from internal/printer/__snapshots__/set_text_on_Component_with_quoted_attribute.snap rename to internal/printer/__printer_js__/set_text_on_Component_with_quoted_attribute.snap diff --git a/internal/printer/__snapshots__/set_text_on_Component_with_template_literal_attribute_with_variable.snap b/internal/printer/__printer_js__/set_text_on_Component_with_template_literal_attribute_with_variable.snap similarity index 100% rename from internal/printer/__snapshots__/set_text_on_Component_with_template_literal_attribute_with_variable.snap rename to internal/printer/__printer_js__/set_text_on_Component_with_template_literal_attribute_with_variable.snap diff --git a/internal/printer/__snapshots__/set_text_on_Component_with_template_literal_attribute_without_variable.snap b/internal/printer/__printer_js__/set_text_on_Component_with_template_literal_attribute_without_variable.snap similarity index 100% rename from internal/printer/__snapshots__/set_text_on_Component_with_template_literal_attribute_without_variable.snap rename to internal/printer/__printer_js__/set_text_on_Component_with_template_literal_attribute_without_variable.snap diff --git a/internal/printer/__snapshots__/set_text_on_custom-element.snap b/internal/printer/__printer_js__/set_text_on_custom-element.snap similarity index 100% rename from internal/printer/__snapshots__/set_text_on_custom-element.snap rename to internal/printer/__printer_js__/set_text_on_custom-element.snap diff --git a/internal/printer/__snapshots__/set_text_on_custom-element_with_quoted_attribute.snap b/internal/printer/__printer_js__/set_text_on_custom-element_with_quoted_attribute.snap similarity index 100% rename from internal/printer/__snapshots__/set_text_on_custom-element_with_quoted_attribute.snap rename to internal/printer/__printer_js__/set_text_on_custom-element_with_quoted_attribute.snap diff --git a/internal/printer/__snapshots__/set_text_on_custom-element_with_template_literal_attribute_with_variable.snap b/internal/printer/__printer_js__/set_text_on_custom-element_with_template_literal_attribute_with_variable.snap similarity index 100% rename from internal/printer/__snapshots__/set_text_on_custom-element_with_template_literal_attribute_with_variable.snap rename to internal/printer/__printer_js__/set_text_on_custom-element_with_template_literal_attribute_with_variable.snap diff --git a/internal/printer/__snapshots__/set_text_on_custom-element_with_template_literal_attribute_without_variable.snap b/internal/printer/__printer_js__/set_text_on_custom-element_with_template_literal_attribute_without_variable.snap similarity index 100% rename from internal/printer/__snapshots__/set_text_on_custom-element_with_template_literal_attribute_without_variable.snap rename to internal/printer/__printer_js__/set_text_on_custom-element_with_template_literal_attribute_without_variable.snap diff --git a/internal/printer/__snapshots__/set_text_with_quoted_attribute.snap b/internal/printer/__printer_js__/set_text_with_quoted_attribute.snap similarity index 100% rename from internal/printer/__snapshots__/set_text_with_quoted_attribute.snap rename to internal/printer/__printer_js__/set_text_with_quoted_attribute.snap diff --git a/internal/printer/__snapshots__/set_text_with_template_literal_attribute_with_variable.snap b/internal/printer/__printer_js__/set_text_with_template_literal_attribute_with_variable.snap similarity index 100% rename from internal/printer/__snapshots__/set_text_with_template_literal_attribute_with_variable.snap rename to internal/printer/__printer_js__/set_text_with_template_literal_attribute_with_variable.snap diff --git a/internal/printer/__snapshots__/set_text_with_template_literal_attribute_without_variable.snap b/internal/printer/__printer_js__/set_text_with_template_literal_attribute_without_variable.snap similarity index 100% rename from internal/printer/__snapshots__/set_text_with_template_literal_attribute_without_variable.snap rename to internal/printer/__printer_js__/set_text_with_template_literal_attribute_without_variable.snap diff --git a/internal/printer/__snapshots__/sibling_expressions.snap b/internal/printer/__printer_js__/sibling_expressions.snap similarity index 100% rename from internal/printer/__snapshots__/sibling_expressions.snap rename to internal/printer/__printer_js__/sibling_expressions.snap diff --git a/internal/printer/__snapshots__/simple_ternary.snap b/internal/printer/__printer_js__/simple_ternary.snap similarity index 100% rename from internal/printer/__snapshots__/simple_ternary.snap rename to internal/printer/__printer_js__/simple_ternary.snap diff --git a/internal/printer/__snapshots__/slot_inside_of_Base.snap b/internal/printer/__printer_js__/slot_inside_of_Base.snap similarity index 100% rename from internal/printer/__snapshots__/slot_inside_of_Base.snap rename to internal/printer/__printer_js__/slot_inside_of_Base.snap diff --git a/internal/printer/__snapshots__/slot_with_fallback.snap b/internal/printer/__printer_js__/slot_with_fallback.snap similarity index 100% rename from internal/printer/__snapshots__/slot_with_fallback.snap rename to internal/printer/__printer_js__/slot_with_fallback.snap diff --git a/internal/printer/__snapshots__/slot_with_fallback_II.snap b/internal/printer/__printer_js__/slot_with_fallback_II.snap similarity index 100% rename from internal/printer/__snapshots__/slot_with_fallback_II.snap rename to internal/printer/__printer_js__/slot_with_fallback_II.snap diff --git a/internal/printer/__snapshots__/slot_with_fallback_III.snap b/internal/printer/__printer_js__/slot_with_fallback_III.snap similarity index 100% rename from internal/printer/__snapshots__/slot_with_fallback_III.snap rename to internal/printer/__printer_js__/slot_with_fallback_III.snap diff --git a/internal/printer/__snapshots__/slot_with_quoted_attributes.snap b/internal/printer/__printer_js__/slot_with_quoted_attributes.snap similarity index 100% rename from internal/printer/__snapshots__/slot_with_quoted_attributes.snap rename to internal/printer/__printer_js__/slot_with_quoted_attributes.snap diff --git a/internal/printer/__snapshots__/slots__basic_.snap b/internal/printer/__printer_js__/slots__basic_.snap similarity index 100% rename from internal/printer/__snapshots__/slots__basic_.snap rename to internal/printer/__printer_js__/slots__basic_.snap diff --git a/internal/printer/__snapshots__/slots__dynamic_name_.snap b/internal/printer/__printer_js__/slots__dynamic_name_.snap similarity index 100% rename from internal/printer/__snapshots__/slots__dynamic_name_.snap rename to internal/printer/__printer_js__/slots__dynamic_name_.snap diff --git a/internal/printer/__snapshots__/slots__expression_.snap b/internal/printer/__printer_js__/slots__expression_.snap similarity index 100% rename from internal/printer/__snapshots__/slots__expression_.snap rename to internal/printer/__printer_js__/slots__expression_.snap diff --git a/internal/printer/__snapshots__/slots__named_only_.snap b/internal/printer/__printer_js__/slots__named_only_.snap similarity index 100% rename from internal/printer/__snapshots__/slots__named_only_.snap rename to internal/printer/__printer_js__/slots__named_only_.snap diff --git a/internal/printer/__snapshots__/slots__no_comments_.snap b/internal/printer/__printer_js__/slots__no_comments_.snap similarity index 100% rename from internal/printer/__snapshots__/slots__no_comments_.snap rename to internal/printer/__printer_js__/slots__no_comments_.snap diff --git a/internal/printer/__snapshots__/small_expression.snap b/internal/printer/__printer_js__/small_expression.snap similarity index 100% rename from internal/printer/__snapshots__/small_expression.snap rename to internal/printer/__printer_js__/small_expression.snap diff --git a/internal/printer/__snapshots__/solidus_in_template_literal_expression.snap b/internal/printer/__printer_js__/solidus_in_template_literal_expression.snap similarity index 100% rename from internal/printer/__snapshots__/solidus_in_template_literal_expression.snap rename to internal/printer/__printer_js__/solidus_in_template_literal_expression.snap diff --git a/internal/printer/__snapshots__/spread_with_double_quotation_marks.snap b/internal/printer/__printer_js__/spread_with_double_quotation_marks.snap similarity index 100% rename from internal/printer/__snapshots__/spread_with_double_quotation_marks.snap rename to internal/printer/__printer_js__/spread_with_double_quotation_marks.snap diff --git a/internal/printer/__snapshots__/spread_with_style_but_no_explicit_class.snap b/internal/printer/__printer_js__/spread_with_style_but_no_explicit_class.snap similarity index 100% rename from internal/printer/__snapshots__/spread_with_style_but_no_explicit_class.snap rename to internal/printer/__printer_js__/spread_with_style_but_no_explicit_class.snap diff --git a/internal/printer/__snapshots__/spread_without_style_or_class.snap b/internal/printer/__printer_js__/spread_without_style_or_class.snap similarity index 100% rename from internal/printer/__snapshots__/spread_without_style_or_class.snap rename to internal/printer/__printer_js__/spread_without_style_or_class.snap diff --git a/internal/printer/__snapshots__/styles__no_frontmatter_.snap b/internal/printer/__printer_js__/styles__no_frontmatter_.snap similarity index 100% rename from internal/printer/__snapshots__/styles__no_frontmatter_.snap rename to internal/printer/__printer_js__/styles__no_frontmatter_.snap diff --git a/internal/printer/__snapshots__/svg_expressions.snap b/internal/printer/__printer_js__/svg_expressions.snap similarity index 100% rename from internal/printer/__snapshots__/svg_expressions.snap rename to internal/printer/__printer_js__/svg_expressions.snap diff --git a/internal/printer/__snapshots__/table.snap b/internal/printer/__printer_js__/table.snap similarity index 100% rename from internal/printer/__snapshots__/table.snap rename to internal/printer/__printer_js__/table.snap diff --git a/internal/printer/__snapshots__/table_II.snap b/internal/printer/__printer_js__/table_II.snap similarity index 100% rename from internal/printer/__snapshots__/table_II.snap rename to internal/printer/__printer_js__/table_II.snap diff --git a/internal/printer/__snapshots__/table_III.snap b/internal/printer/__printer_js__/table_III.snap similarity index 100% rename from internal/printer/__snapshots__/table_III.snap rename to internal/printer/__printer_js__/table_III.snap diff --git a/internal/printer/__snapshots__/table_IV.snap b/internal/printer/__printer_js__/table_IV.snap similarity index 100% rename from internal/printer/__snapshots__/table_IV.snap rename to internal/printer/__printer_js__/table_IV.snap diff --git a/internal/printer/__snapshots__/table_caption_expression.snap b/internal/printer/__printer_js__/table_caption_expression.snap similarity index 100% rename from internal/printer/__snapshots__/table_caption_expression.snap rename to internal/printer/__printer_js__/table_caption_expression.snap diff --git a/internal/printer/__snapshots__/table_expression_with_trailing_div.snap b/internal/printer/__printer_js__/table_expression_with_trailing_div.snap similarity index 100% rename from internal/printer/__snapshots__/table_expression_with_trailing_div.snap rename to internal/printer/__printer_js__/table_expression_with_trailing_div.snap diff --git a/internal/printer/__snapshots__/table_expressions__no_implicit_tbody_.snap b/internal/printer/__printer_js__/table_expressions__no_implicit_tbody_.snap similarity index 100% rename from internal/printer/__snapshots__/table_expressions__no_implicit_tbody_.snap rename to internal/printer/__printer_js__/table_expressions__no_implicit_tbody_.snap diff --git a/internal/printer/__snapshots__/table_simple_case.snap b/internal/printer/__printer_js__/table_simple_case.snap similarity index 100% rename from internal/printer/__snapshots__/table_simple_case.snap rename to internal/printer/__printer_js__/table_simple_case.snap diff --git a/internal/printer/__snapshots__/table_slot_I.snap b/internal/printer/__printer_js__/table_slot_I.snap similarity index 100% rename from internal/printer/__snapshots__/table_slot_I.snap rename to internal/printer/__printer_js__/table_slot_I.snap diff --git a/internal/printer/__snapshots__/table_slot_II.snap b/internal/printer/__printer_js__/table_slot_II.snap similarity index 100% rename from internal/printer/__snapshots__/table_slot_II.snap rename to internal/printer/__printer_js__/table_slot_II.snap diff --git a/internal/printer/__snapshots__/table_slot_III.snap b/internal/printer/__printer_js__/table_slot_III.snap similarity index 100% rename from internal/printer/__snapshots__/table_slot_III.snap rename to internal/printer/__printer_js__/table_slot_III.snap diff --git a/internal/printer/__snapshots__/table_slot_IV.snap b/internal/printer/__printer_js__/table_slot_IV.snap similarity index 100% rename from internal/printer/__snapshots__/table_slot_IV.snap rename to internal/printer/__printer_js__/table_slot_IV.snap diff --git a/internal/printer/__snapshots__/table_slot_V.snap b/internal/printer/__printer_js__/table_slot_V.snap similarity index 100% rename from internal/printer/__snapshots__/table_slot_V.snap rename to internal/printer/__printer_js__/table_slot_V.snap diff --git a/internal/printer/__snapshots__/table_with_expression_in_'th'.snap b/internal/printer/__printer_js__/table_with_expression_in__th_.snap similarity index 100% rename from internal/printer/__snapshots__/table_with_expression_in_'th'.snap rename to internal/printer/__printer_js__/table_with_expression_in__th_.snap diff --git a/internal/printer/__snapshots__/tbody_expressions.snap b/internal/printer/__printer_js__/tbody_expressions.snap similarity index 100% rename from internal/printer/__snapshots__/tbody_expressions.snap rename to internal/printer/__printer_js__/tbody_expressions.snap diff --git a/internal/printer/__snapshots__/tbody_expressions_2.snap b/internal/printer/__printer_js__/tbody_expressions_2.snap similarity index 100% rename from internal/printer/__snapshots__/tbody_expressions_2.snap rename to internal/printer/__printer_js__/tbody_expressions_2.snap diff --git a/internal/printer/__snapshots__/tbody_expressions_3.snap b/internal/printer/__printer_js__/tbody_expressions_3.snap similarity index 100% rename from internal/printer/__snapshots__/tbody_expressions_3.snap rename to internal/printer/__printer_js__/tbody_expressions_3.snap diff --git a/internal/printer/__snapshots__/td_expressions.snap b/internal/printer/__printer_js__/td_expressions.snap similarity index 100% rename from internal/printer/__snapshots__/td_expressions.snap rename to internal/printer/__printer_js__/td_expressions.snap diff --git a/internal/printer/__snapshots__/td_expressions_II.snap b/internal/printer/__printer_js__/td_expressions_II.snap similarity index 100% rename from internal/printer/__snapshots__/td_expressions_II.snap rename to internal/printer/__printer_js__/td_expressions_II.snap diff --git a/internal/printer/__snapshots__/template_literal_attribute_on_component.snap b/internal/printer/__printer_js__/template_literal_attribute_on_component.snap similarity index 100% rename from internal/printer/__snapshots__/template_literal_attribute_on_component.snap rename to internal/printer/__printer_js__/template_literal_attribute_on_component.snap diff --git a/internal/printer/__snapshots__/template_literal_attribute_with_variable_on_component.snap b/internal/printer/__printer_js__/template_literal_attribute_with_variable_on_component.snap similarity index 100% rename from internal/printer/__snapshots__/template_literal_attribute_with_variable_on_component.snap rename to internal/printer/__printer_js__/template_literal_attribute_with_variable_on_component.snap diff --git a/internal/printer/__snapshots__/ternary_component.snap b/internal/printer/__printer_js__/ternary_component.snap similarity index 100% rename from internal/printer/__snapshots__/ternary_component.snap rename to internal/printer/__printer_js__/ternary_component.snap diff --git a/internal/printer/__snapshots__/ternary_layout.snap b/internal/printer/__printer_js__/ternary_layout.snap similarity index 100% rename from internal/printer/__snapshots__/ternary_layout.snap rename to internal/printer/__printer_js__/ternary_layout.snap diff --git a/internal/printer/__snapshots__/ternary_slot.snap b/internal/printer/__printer_js__/ternary_slot.snap similarity index 100% rename from internal/printer/__snapshots__/ternary_slot.snap rename to internal/printer/__printer_js__/ternary_slot.snap diff --git a/internal/printer/__snapshots__/text_after_title_expression.snap b/internal/printer/__printer_js__/text_after_title_expression.snap similarity index 100% rename from internal/printer/__snapshots__/text_after_title_expression.snap rename to internal/printer/__printer_js__/text_after_title_expression.snap diff --git a/internal/printer/__snapshots__/text_after_title_expressions.snap b/internal/printer/__printer_js__/text_after_title_expressions.snap similarity index 100% rename from internal/printer/__snapshots__/text_after_title_expressions.snap rename to internal/printer/__printer_js__/text_after_title_expressions.snap diff --git a/internal/printer/__snapshots__/text_only.snap b/internal/printer/__printer_js__/text_only.snap similarity index 100% rename from internal/printer/__snapshots__/text_only.snap rename to internal/printer/__printer_js__/text_only.snap diff --git a/internal/printer/__snapshots__/textarea.snap b/internal/printer/__printer_js__/textarea.snap similarity index 100% rename from internal/printer/__snapshots__/textarea.snap rename to internal/printer/__printer_js__/textarea.snap diff --git a/internal/printer/__snapshots__/textarea_in_form.snap b/internal/printer/__printer_js__/textarea_in_form.snap similarity index 100% rename from internal/printer/__snapshots__/textarea_in_form.snap rename to internal/printer/__printer_js__/textarea_in_form.snap diff --git a/internal/printer/__snapshots__/textarea_inside_expression.snap b/internal/printer/__printer_js__/textarea_inside_expression.snap similarity index 100% rename from internal/printer/__snapshots__/textarea_inside_expression.snap rename to internal/printer/__printer_js__/textarea_inside_expression.snap diff --git a/internal/printer/__snapshots__/th_expressions.snap b/internal/printer/__printer_js__/th_expressions.snap similarity index 100% rename from internal/printer/__snapshots__/th_expressions.snap rename to internal/printer/__printer_js__/th_expressions.snap diff --git a/internal/printer/__snapshots__/tr_only.snap b/internal/printer/__printer_js__/tr_only.snap similarity index 100% rename from internal/printer/__snapshots__/tr_only.snap rename to internal/printer/__printer_js__/tr_only.snap diff --git a/internal/printer/__snapshots__/trailing_expression.snap b/internal/printer/__printer_js__/trailing_expression.snap similarity index 100% rename from internal/printer/__snapshots__/trailing_expression.snap rename to internal/printer/__printer_js__/trailing_expression.snap diff --git a/internal/printer/__snapshots__/transition_animate_on_Component.snap b/internal/printer/__printer_js__/transition_animate_on_Component.snap similarity index 100% rename from internal/printer/__snapshots__/transition_animate_on_Component.snap rename to internal/printer/__printer_js__/transition_animate_on_Component.snap diff --git a/internal/printer/__snapshots__/transition_animate_with_an_expression.snap b/internal/printer/__printer_js__/transition_animate_with_an_expression.snap similarity index 100% rename from internal/printer/__snapshots__/transition_animate_with_an_expression.snap rename to internal/printer/__printer_js__/transition_animate_with_an_expression.snap diff --git a/internal/printer/__snapshots__/transition_name_with_an_expression.snap b/internal/printer/__printer_js__/transition_name_with_an_expression.snap similarity index 100% rename from internal/printer/__snapshots__/transition_name_with_an_expression.snap rename to internal/printer/__printer_js__/transition_name_with_an_expression.snap diff --git a/internal/printer/__snapshots__/transition_name_with_an_template_literal.snap b/internal/printer/__printer_js__/transition_name_with_an_template_literal.snap similarity index 100% rename from internal/printer/__snapshots__/transition_name_with_an_template_literal.snap rename to internal/printer/__printer_js__/transition_name_with_an_template_literal.snap diff --git a/internal/printer/__snapshots__/transition_persist-props_converted_to_a_data_attribute.snap b/internal/printer/__printer_js__/transition_persist-props_converted_to_a_data_attribute.snap similarity index 100% rename from internal/printer/__snapshots__/transition_persist-props_converted_to_a_data_attribute.snap rename to internal/printer/__printer_js__/transition_persist-props_converted_to_a_data_attribute.snap diff --git a/internal/printer/__snapshots__/transition_persist_converted_to_a_data_attribute.snap b/internal/printer/__printer_js__/transition_persist_converted_to_a_data_attribute.snap similarity index 100% rename from internal/printer/__snapshots__/transition_persist_converted_to_a_data_attribute.snap rename to internal/printer/__printer_js__/transition_persist_converted_to_a_data_attribute.snap diff --git a/internal/printer/__snapshots__/transition_persist_uses_transition_name_if_defined.snap b/internal/printer/__printer_js__/transition_persist_uses_transition_name_if_defined.snap similarity index 100% rename from internal/printer/__snapshots__/transition_persist_uses_transition_name_if_defined.snap rename to internal/printer/__printer_js__/transition_persist_uses_transition_name_if_defined.snap diff --git a/internal/printer/__snapshots__/type_import.snap b/internal/printer/__printer_js__/type_import.snap similarity index 100% rename from internal/printer/__snapshots__/type_import.snap rename to internal/printer/__printer_js__/type_import.snap diff --git a/internal/printer/__snapshots__/unusual_line_terminator_I.snap b/internal/printer/__printer_js__/unusual_line_terminator_I.snap similarity index 100% rename from internal/printer/__snapshots__/unusual_line_terminator_I.snap rename to internal/printer/__printer_js__/unusual_line_terminator_I.snap diff --git a/internal/printer/__snapshots__/unusual_line_terminator_II.snap b/internal/printer/__printer_js__/unusual_line_terminator_II.snap similarity index 100% rename from internal/printer/__snapshots__/unusual_line_terminator_II.snap rename to internal/printer/__printer_js__/unusual_line_terminator_II.snap diff --git a/internal/printer/__snapshots__/user-defined_`implicit`_is_printed.snap b/internal/printer/__printer_js__/user-defined__implicit__is_printed.snap similarity index 100% rename from internal/printer/__snapshots__/user-defined_`implicit`_is_printed.snap rename to internal/printer/__printer_js__/user-defined__implicit__is_printed.snap diff --git a/internal/printer/__printer_json__/Comment.snap b/internal/printer/__printer_json__/Comment.snap new file mode 100755 index 000000000..e229e982a --- /dev/null +++ b/internal/printer/__printer_json__/Comment.snap @@ -0,0 +1,14 @@ + +[TestPrintToJSON/Comment - 1] +## Input + +``` + +``` + +## Output + +```json +{"type":"root","children":[{"type":"comment","value":"hello"}]} +``` +--- diff --git a/internal/printer/__printer_json__/Comment_preserves_whitespace.snap b/internal/printer/__printer_json__/Comment_preserves_whitespace.snap new file mode 100755 index 000000000..fa89df036 --- /dev/null +++ b/internal/printer/__printer_json__/Comment_preserves_whitespace.snap @@ -0,0 +1,14 @@ + +[TestPrintToJSON/Comment_preserves_whitespace - 1] +## Input + +``` + +``` + +## Output + +```json +{"type":"root","children":[{"type":"comment","value":" hello "}]} +``` +--- diff --git a/internal/printer/__printer_json__/Component.snap b/internal/printer/__printer_json__/Component.snap new file mode 100755 index 000000000..b0c833fc7 --- /dev/null +++ b/internal/printer/__printer_json__/Component.snap @@ -0,0 +1,14 @@ + +[TestPrintToJSON/Component - 1] +## Input + +``` + +``` + +## Output + +```json +{"type":"root","children":[{"type":"component","name":"Component","attributes":[],"children":[]}]} +``` +--- diff --git a/internal/printer/__printer_json__/Doctype.snap b/internal/printer/__printer_json__/Doctype.snap new file mode 100755 index 000000000..feaedfd9e --- /dev/null +++ b/internal/printer/__printer_json__/Doctype.snap @@ -0,0 +1,14 @@ + +[TestPrintToJSON/Doctype - 1] +## Input + +``` + +``` + +## Output + +```json +{"type":"root","children":[{"type":"doctype","value":"html"}]} +``` +--- diff --git a/internal/printer/__printer_json__/Fragment_Literal.snap b/internal/printer/__printer_json__/Fragment_Literal.snap new file mode 100755 index 000000000..326e337db --- /dev/null +++ b/internal/printer/__printer_json__/Fragment_Literal.snap @@ -0,0 +1,14 @@ + +[TestPrintToJSON/Fragment_Literal - 1] +## Input + +``` +World +``` + +## Output + +```json +{"type":"root","children":[{"type":"fragment","name":"Fragment","attributes":[],"children":[{"type":"text","value":"World"}]}]} +``` +--- diff --git a/internal/printer/__printer_json__/Fragment_Shorthand.snap b/internal/printer/__printer_json__/Fragment_Shorthand.snap new file mode 100755 index 000000000..01023c606 --- /dev/null +++ b/internal/printer/__printer_json__/Fragment_Shorthand.snap @@ -0,0 +1,14 @@ + +[TestPrintToJSON/Fragment_Shorthand - 1] +## Input + +``` +<>Hello +``` + +## Output + +```json +{"type":"root","children":[{"type":"fragment","name":"","attributes":[],"children":[{"type":"text","value":"Hello"}]}]} +``` +--- diff --git a/internal/printer/__printer_json__/Frontmatter.snap b/internal/printer/__printer_json__/Frontmatter.snap new file mode 100755 index 000000000..69f6875e3 --- /dev/null +++ b/internal/printer/__printer_json__/Frontmatter.snap @@ -0,0 +1,17 @@ + +[TestPrintToJSON/Frontmatter - 1] +## Input + +``` +/-/-/-/ +const a = "hey" +/-/-/-/ +
{a}
+``` + +## Output + +```json +{"type":"root","children":[{"type":"frontmatter","value":"\nconst a = \"hey\"\n"},{"type":"element","name":"div","attributes":[],"children":[{"type":"expression","children":[{"type":"text","value":"a"}]}]}]} +``` +--- diff --git a/internal/printer/__printer_json__/JSON_escape.snap b/internal/printer/__printer_json__/JSON_escape.snap new file mode 100755 index 000000000..876b4117a --- /dev/null +++ b/internal/printer/__printer_json__/JSON_escape.snap @@ -0,0 +1,19 @@ + +[TestPrintToJSON/JSON_escape - 1] +## Input + +``` +/-/-/-/ +const a = "\n" +const b = "\"" +const c = '\'' +/-/-/-/ +{a + b + c} +``` + +## Output + +```json +{"type":"root","children":[{"type":"frontmatter","value":"\nconst a = \"\\n\"\nconst b = \"\\\"\"\nconst c = '\\''\n"},{"type":"expression","children":[{"type":"text","value":"a + b + c"}]}]} +``` +--- diff --git a/internal/printer/__printer_json__/Preserve_namespaces.snap b/internal/printer/__printer_json__/Preserve_namespaces.snap new file mode 100755 index 000000000..034f752a0 --- /dev/null +++ b/internal/printer/__printer_json__/Preserve_namespaces.snap @@ -0,0 +1,14 @@ + +[TestPrintToJSON/Preserve_namespaces - 1] +## Input + +``` + +``` + +## Output + +```json +{"type":"root","children":[{"type":"element","name":"svg","attributes":[{"type":"attribute","kind":"quoted","name":"xmlns","value":"http://www.w3.org/2000/svg","raw":"\"http://www.w3.org/2000/svg\""},{"type":"attribute","kind":"quoted","name":"xmlns:xlink","value":"http://www.w3.org/1999/xlink","raw":"\"http://www.w3.org/1999/xlink\""}],"children":[{"type":"element","name":"rect","attributes":[{"type":"attribute","kind":"quoted","name":"xlink:href","value":"#id","raw":"\"#id\""}],"children":[]}]}]} +``` +--- diff --git a/internal/printer/__printer_json__/basic.snap b/internal/printer/__printer_json__/basic.snap new file mode 100755 index 000000000..a52e1917d --- /dev/null +++ b/internal/printer/__printer_json__/basic.snap @@ -0,0 +1,14 @@ + +[TestPrintToJSON/basic - 1] +## Input + +``` +

Hello world!

+``` + +## Output + +```json +{"type":"root","children":[{"type":"element","name":"h1","attributes":[],"children":[{"type":"text","value":"Hello world!"}]}]} +``` +--- diff --git a/internal/printer/__printer_json__/custom-element.snap b/internal/printer/__printer_json__/custom-element.snap new file mode 100755 index 000000000..ddeb7e459 --- /dev/null +++ b/internal/printer/__printer_json__/custom-element.snap @@ -0,0 +1,14 @@ + +[TestPrintToJSON/custom-element - 1] +## Input + +``` + +``` + +## Output + +```json +{"type":"root","children":[{"type":"custom-element","name":"custom-element","attributes":[],"children":[]}]} +``` +--- diff --git a/internal/printer/__printer_json__/element_with_unterminated_double_quote_attribute.snap b/internal/printer/__printer_json__/element_with_unterminated_double_quote_attribute.snap new file mode 100755 index 000000000..d2668807d --- /dev/null +++ b/internal/printer/__printer_json__/element_with_unterminated_double_quote_attribute.snap @@ -0,0 +1,14 @@ + +[TestPrintToJSON/element_with_unterminated_double_quote_attribute - 1] +## Input + +``` +
+``` + +## Output + +```json +{"type":"root","children":[{"type":"element","name":"main","attributes":[{"type":"attribute","kind":"template-literal","name":"id","value":"gotcha","raw":"`gotcha"}],"children":[]}]} +``` +--- diff --git a/internal/printer/__printer_json__/expression.snap b/internal/printer/__printer_json__/expression.snap new file mode 100755 index 000000000..53836cfa5 --- /dev/null +++ b/internal/printer/__printer_json__/expression.snap @@ -0,0 +1,14 @@ + +[TestPrintToJSON/expression - 1] +## Input + +``` +

Hello {world}

+``` + +## Output + +```json +{"type":"root","children":[{"type":"element","name":"h1","attributes":[],"children":[{"type":"text","value":"Hello "},{"type":"expression","children":[{"type":"text","value":"world"}]}]}]} +``` +--- diff --git a/internal/printer/__printer_json__/style_after_body_with_component_in_head_and_body.snap b/internal/printer/__printer_json__/style_after_body_with_component_in_head_and_body.snap new file mode 100755 index 000000000..53a5ce900 --- /dev/null +++ b/internal/printer/__printer_json__/style_after_body_with_component_in_head_and_body.snap @@ -0,0 +1,14 @@ + +[TestPrintToJSON/style_after_body_with_component_in_head_and_body - 1] +## Input + +``` +
+``` + +## Output + +```json +{"type":"root","children":[{"type":"element","name":"html","attributes":[{"type":"attribute","kind":"quoted","name":"lang","value":"en","raw":"\"en\""}],"children":[{"type":"element","name":"head","attributes":[],"children":[{"type":"component","name":"BaseHead","attributes":[],"children":[]}]},{"type":"element","name":"body","attributes":[],"children":[{"type":"component","name":"Header","attributes":[],"children":[]}]},{"type":"element","name":"style","attributes":[],"children":[{"type":"text","value":"@use \"../styles/global.scss\";"}]}]}]} +``` +--- diff --git a/internal/printer/__printer_json__/style_after_empty_html.snap b/internal/printer/__printer_json__/style_after_empty_html.snap new file mode 100755 index 000000000..f7345940e --- /dev/null +++ b/internal/printer/__printer_json__/style_after_empty_html.snap @@ -0,0 +1,14 @@ + +[TestPrintToJSON/style_after_empty_html - 1] +## Input + +``` + +``` + +## Output + +```json +{"type":"root","children":[{"type":"element","name":"html","attributes":[],"children":[]},{"type":"element","name":"style","attributes":[],"children":[]}]} +``` +--- diff --git a/internal/printer/__printer_json__/style_after_html.snap b/internal/printer/__printer_json__/style_after_html.snap new file mode 100755 index 000000000..6c15b8474 --- /dev/null +++ b/internal/printer/__printer_json__/style_after_html.snap @@ -0,0 +1,14 @@ + +[TestPrintToJSON/style_after_html - 1] +## Input + +``` +

Hello world!

+``` + +## Output + +```json +{"type":"root","children":[{"type":"element","name":"html","attributes":[],"children":[{"type":"element","name":"body","attributes":[],"children":[{"type":"element","name":"h1","attributes":[],"children":[{"type":"text","value":"Hello world!"}]}]}]},{"type":"element","name":"style","attributes":[],"children":[]}]} +``` +--- diff --git a/internal/printer/__printer_json__/style_after_html_with_component_in_head.snap b/internal/printer/__printer_json__/style_after_html_with_component_in_head.snap new file mode 100755 index 000000000..41fd3c33b --- /dev/null +++ b/internal/printer/__printer_json__/style_after_html_with_component_in_head.snap @@ -0,0 +1,14 @@ + +[TestPrintToJSON/style_after_html_with_component_in_head - 1] +## Input + +``` + +``` + +## Output + +```json +{"type":"root","children":[{"type":"element","name":"html","attributes":[{"type":"attribute","kind":"quoted","name":"lang","value":"en","raw":"\"en\""}],"children":[{"type":"element","name":"head","attributes":[],"children":[{"type":"component","name":"BaseHead","attributes":[],"children":[]}]}]},{"type":"element","name":"style","attributes":[],"children":[{"type":"text","value":"@use \"../styles/global.scss\";"}]}]} +``` +--- diff --git a/internal/printer/__printer_json__/style_after_html_with_component_in_head_and_body.snap b/internal/printer/__printer_json__/style_after_html_with_component_in_head_and_body.snap new file mode 100755 index 000000000..4feedcbdc --- /dev/null +++ b/internal/printer/__printer_json__/style_after_html_with_component_in_head_and_body.snap @@ -0,0 +1,14 @@ + +[TestPrintToJSON/style_after_html_with_component_in_head_and_body - 1] +## Input + +``` +
+``` + +## Output + +```json +{"type":"root","children":[{"type":"element","name":"html","attributes":[{"type":"attribute","kind":"quoted","name":"lang","value":"en","raw":"\"en\""}],"children":[{"type":"element","name":"head","attributes":[],"children":[{"type":"component","name":"BaseHead","attributes":[],"children":[]}]},{"type":"element","name":"body","attributes":[],"children":[{"type":"component","name":"Header","attributes":[],"children":[]}]}]},{"type":"element","name":"style","attributes":[],"children":[{"type":"text","value":"@use \"../styles/global.scss\";"}]}]} +``` +--- diff --git a/internal/printer/__printer_json__/style_before_html.snap b/internal/printer/__printer_json__/style_before_html.snap new file mode 100755 index 000000000..aa1f40a8b --- /dev/null +++ b/internal/printer/__printer_json__/style_before_html.snap @@ -0,0 +1,14 @@ + +[TestPrintToJSON/style_before_html - 1] +## Input + +``` +

Hello world!

+``` + +## Output + +```json +{"type":"root","children":[{"type":"element","name":"style","attributes":[],"children":[]},{"type":"element","name":"html","attributes":[],"children":[{"type":"element","name":"body","attributes":[],"children":[{"type":"element","name":"h1","attributes":[],"children":[{"type":"text","value":"Hello world!"}]}]}]}]} +``` +--- diff --git a/internal/printer/__printer_json__/style_in_body.snap b/internal/printer/__printer_json__/style_in_body.snap new file mode 100755 index 000000000..cedebcd7d --- /dev/null +++ b/internal/printer/__printer_json__/style_in_body.snap @@ -0,0 +1,14 @@ + +[TestPrintToJSON/style_in_body - 1] +## Input + +``` +

Hello world!

+``` + +## Output + +```json +{"type":"root","children":[{"type":"element","name":"html","attributes":[],"children":[{"type":"element","name":"body","attributes":[],"children":[{"type":"element","name":"h1","attributes":[],"children":[{"type":"text","value":"Hello world!"}]},{"type":"element","name":"style","attributes":[],"children":[]}]}]}]} +``` +--- diff --git a/internal/printer/__printer_json__/style_in_html.snap b/internal/printer/__printer_json__/style_in_html.snap new file mode 100755 index 000000000..ab1e6941d --- /dev/null +++ b/internal/printer/__printer_json__/style_in_html.snap @@ -0,0 +1,14 @@ + +[TestPrintToJSON/style_in_html - 1] +## Input + +``` +

Hello world!

+``` + +## Output + +```json +{"type":"root","children":[{"type":"element","name":"html","attributes":[],"children":[{"type":"element","name":"body","attributes":[],"children":[{"type":"element","name":"h1","attributes":[],"children":[{"type":"text","value":"Hello world!"}]}]},{"type":"element","name":"style","attributes":[],"children":[]}]}]} +``` +--- diff --git a/internal/printer/printer_css_test.go b/internal/printer/printer_css_test.go index 78e554b4a..25d8ff12d 100644 --- a/internal/printer/printer_css_test.go +++ b/internal/printer/printer_css_test.go @@ -13,7 +13,6 @@ import ( type testcase_css struct { name string source string - want string scopedStyleStrategy string } @@ -34,7 +33,6 @@ func TestPrinterCSS(t *testing.T) {

Page Title

I’m a page

`, - want: ".title:where(.astro-dpohflym){font-family:fantasy;font-size:28px}.body:where(.astro-dpohflym){font-size:1em}", }, { name: "scopedStyleStrategy: 'class'", @@ -52,7 +50,6 @@ func TestPrinterCSS(t *testing.T) {

Page Title

I’m a page

`, scopedStyleStrategy: "class", - want: ".title.astro-dpohflym{font-family:fantasy;font-size:28px}.body.astro-dpohflym{font-size:1em}", }, { name: "scopedStyleStrategy: 'attribute'", @@ -70,7 +67,6 @@ func TestPrinterCSS(t *testing.T) {

Page Title

I’m a page

`, scopedStyleStrategy: "attribute", - want: ".title[data-astro-cid-dpohflym]{font-family:fantasy;font-size:28px}.body[data-astro-cid-dpohflym]{font-size:1em}", }, } @@ -102,12 +98,15 @@ func TestPrinterCSS(t *testing.T) { output += string(bytes) } - toMatch := tt.want - - // compare to expected string, show diff if mismatch - if diff := test_utils.ANSIDiff(test_utils.Dedent(toMatch), test_utils.Dedent(output)); diff != "" { - t.Errorf("mismatch (-want +got):\n%s", diff) - } + test_utils.MakeSnapshot( + &test_utils.SnapshotOptions{ + Testing: t, + TestCaseName: tt.name, + Input: code, + Output: output, + Kind: test_utils.CssOutput, + FolderName: "__printer_css__", + }) }) } } diff --git a/internal/printer/printer_test.go b/internal/printer/printer_test.go index 2c2e6af8d..0089ea34f 100644 --- a/internal/printer/printer_test.go +++ b/internal/printer/printer_test.go @@ -2,12 +2,9 @@ package printer import ( "fmt" - "regexp" - "strconv" "strings" "testing" - "github.com/gkampitakis/go-snaps/snaps" astro "github.com/withastro/compiler/internal" "github.com/withastro/compiler/internal/handler" types "github.com/withastro/compiler/internal/t" @@ -82,13 +79,11 @@ type testcase struct { transitions bool transformOptions transform.TransformOptions filename string - want want } type jsonTestcase struct { name string source string - want []ASTNode only bool } @@ -102,107 +97,62 @@ func TestPrinter(t *testing.T) { { name: "text only", source: `Foo`, - want: want{ - code: `Foo`, - }, }, { name: "unusual line terminator I", source: `Pre-set & Time-limited \u2028holiday campaigns`, - want: want{ - code: `Pre-set & Time-limited \\u2028holiday campaigns`, - }, }, { name: "unusual line terminator II", source: `Pre-set & Time-limited 
holiday campaigns`, - want: want{ - code: `Pre-set & Time-limited 
holiday campaigns`, - }, }, { name: "basic (no frontmatter)", source: ``, - want: want{ - code: `${$$maybeRenderHead($$result)}`, - }, }, { name: "basic renderHead", source: `Ah`, - want: want{ - code: `Ah` + RENDER_HEAD_RESULT + ``, - }, }, { name: "head inside slot", source: ``, - want: want{ - code: `${$$renderSlot($$result,$$slots["default"],$$render` + BACKTICK + `` + RENDER_HEAD_RESULT + `` + BACKTICK + `)}`, - }, }, { name: "head slot", source: ``, - want: want{ - code: `${$$renderSlot($$result,$$slots["default"])}` + RENDER_HEAD_RESULT + ``, - }, }, { name: "head slot II", source: ``, - want: want{ - code: `${$$renderSlot($$result,$$slots["default"])}` + RENDER_HEAD_RESULT + ``, - }, }, { name: "head slot III", source: ``, - want: want{ - code: `${$$renderSlot($$result,$$slots["baseHeadExtension"],$$render` + BACKTICK + `` + BACKTICK + `)}` + RENDER_HEAD_RESULT + ``, - }, }, { name: "ternary component", source: `{special ?

Special

:

Not special

}`, - want: want{ - code: `${special ? $$render` + BACKTICK + `${$$renderComponent($$result,'ChildDiv',ChildDiv,{},{"default": () => $$render` + BACKTICK + `${$$maybeRenderHead($$result)}

Special

` + BACKTICK + `,})}` + BACKTICK + ` : $$render` + BACKTICK + `

Not special

` + BACKTICK + `}`, - }, }, { name: "ternary layout", source: `{toggleError ?

SITE: {Astro.site}

: <>

SITE: {Astro.site}

}`, - want: want{ - code: `${toggleError ? $$render` + BACKTICK + `${$$renderComponent($$result,'BaseLayout',BaseLayout,{},{"default": () => $$render` + BACKTICK + `${$$maybeRenderHead($$result)}

SITE: ${Astro.site}

` + BACKTICK + `,})}` + BACKTICK + ` : $$render` + BACKTICK + `${$$renderComponent($$result,'Fragment',Fragment,{},{"default": () => $$render` + BACKTICK + `

SITE: ${Astro.site}

` + BACKTICK + `,})}` + BACKTICK + `}`, - }, }, { name: "orphan slot", source: ``, - want: want{ - code: `${$$renderSlot($$result,$$slots["default"])}`, - }, }, { name: "conditional slot", source: `{value &&
foo
}
`, - want: want{ - code: "${$$renderComponent($$result,'Component',Component,{},{\"test\": () => $$render`${value && $$render`${$$maybeRenderHead($$result)}
foo
`}`,})}", - }, }, { name: "ternary slot", source: `{Math.random() > 0.5 ?
A
:
B
}
`, - want: want{ - code: "${$$renderComponent($$result,'Component',Component,{},$$mergeSlots({},Math.random() > 0.5 ? {\"a\": () => $$render`${$$maybeRenderHead($$result)}
A
`} : {\"b\": () => $$render`
B
`}))}", - }, }, { name: "function expression slots I", source: "\n{() => { switch (value) {\ncase 'a': return
A
\ncase 'b': return
B
\ncase 'c': return
C
\n}\n}}\n
", - want: want{ - code: "${$$renderComponent($$result,'Component',Component,{},$$mergeSlots({},() => { switch (value) {\ncase 'a': return {\"a\": () => $$render`${$$maybeRenderHead($$result)}
A
`}\ncase 'b': return {\"b\": () => $$render`
B
`}\ncase 'c': return {\"c\": () => $$render`
C
`}}\n}))}", - }, }, { name: "function expression slots II (#959)", @@ -220,62 +170,30 @@ func TestPrinter(t *testing.T) {
`, - want: want{ - code: `${$$renderComponent($$result,'Layout',Layout,{"title":"Welcome to Astro."},{"default": () => $$render` + BACKTICK + ` - ${$$maybeRenderHead($$result)}
- ${$$renderComponent($$result,'Layout',Layout,{"title":"switch bug"},{"default": () => $$render` + BACKTICK + `${components.map((component, i) => { - switch(component) { - case "Hero": - return $$render` + BACKTICK + `
Hero
` + BACKTICK + ` - case "Component2": - return $$render` + BACKTICK + `
Component2
` + BACKTICK + ` - } - })}` + BACKTICK + `,})} -
-` + BACKTICK + `,})}`, - }, }, { name: "expression slot", source: `{true &&
A
}{false &&
B
}
`, - want: want{ - code: "${$$renderComponent($$result,'Component',Component,{},{\"a\": () => $$render`${true && $$render`${$$maybeRenderHead($$result)}
A
`}`,\"b\": () => $$render`${false && $$render`
B
`}`,})}", - }, }, { name: "preserve is:inline slot", source: ``, - want: want{ - code: `${$$maybeRenderHead($$result)}`, - }, }, { name: "preserve is:inline slot II", source: ``, - want: want{ - code: `${$$maybeRenderHead($$result)}`, - }, }, { name: "slot with fallback", source: `

Hello world!

`, - want: want{ - code: `${$$maybeRenderHead($$result)}${$$renderSlot($$result,$$slots["default"],$$render` + BACKTICK + `

Hello world!

` + BACKTICK + `)}`, - }, }, { name: "slot with fallback II", source: `

Hello world!

`, - want: want{ - code: `${$$renderSlot($$result,$$slots["test"],$$render` + BACKTICK + `${$$maybeRenderHead($$result)}

Hello world!

` + BACKTICK + `)}`, - }, }, { name: "slot with fallback III", source: `

Fallback

`, - want: want{ - code: `${$$maybeRenderHead($$result)}
${$$renderSlot($$result,$$slots["test"],$$render` + BACKTICK + `

Fallback

` + BACKTICK + `)}
`, - }, }, { name: "Preserve slot whitespace", @@ -283,39 +201,22 @@ func TestPrinter(t *testing.T) {

Paragraph 1

Paragraph 2

`, - want: want{ - code: `${$$renderComponent($$result,'Component',Component,{},{"default": () => $$render` + BACKTICK + ` - ${$$maybeRenderHead($$result)}

Paragraph 1

-

Paragraph 2

` + BACKTICK + `,})}`, - }, }, { name: "text only", source: "Hello!", - want: want{ - code: "Hello!", - }, }, { name: "custom-element", source: "{show && }", - want: want{ - code: "${show && $$render`${$$renderComponent($$result,'client-only-element','client-only-element',{})}`}", - }, }, { name: "attribute with template literal", source: "Home", - want: want{ - code: "${$$maybeRenderHead($$result)}Home", - }, }, { name: "attribute with template literal interpolation", source: "Home", - want: want{ - code: "${$$maybeRenderHead($$result)}Home", - }, }, { name: "basic (frontmatter)", @@ -323,10 +224,6 @@ func TestPrinter(t *testing.T) { const href = '/about'; --- About`, - want: want{ - frontmatter: []string{"", "const href = '/about';"}, - code: `${$$maybeRenderHead($$result)}About`, - }, }, { name: "getStaticPaths (basic)", @@ -336,12 +233,6 @@ export const getStaticPaths = async () => { } ---
`, - want: want{ - getStaticPaths: `export const getStaticPaths = async () => { - return { paths: [] } -}`, - code: `${$$maybeRenderHead($$result)}
`, - }, }, { name: "getStaticPaths (hoisted)", @@ -352,13 +243,6 @@ export const getStaticPaths = async () => { } ---
`, - want: want{ - frontmatter: []string{"", `const a = 0;`}, - getStaticPaths: `export const getStaticPaths = async () => { - return { paths: [] } -}`, - code: `${$$maybeRenderHead($$result)}
`, - }, }, { name: "getStaticPaths (hoisted II)", @@ -370,15 +254,6 @@ export async function getStaticPaths() { const b = 0; ---
`, - want: want{ - frontmatter: []string{"", `const a = 0; - -const b = 0;`}, - getStaticPaths: `export async function getStaticPaths() { - return { paths: [] } -}`, - code: `${$$maybeRenderHead($$result)}
`, - }, }, { name: "export member does not panic", @@ -386,10 +261,6 @@ const b = 0;`}, mod.export(); ---
`, - want: want{ - frontmatter: []string{``, `mod.export();`}, - code: `${$$maybeRenderHead($$result)}
`, - }, }, { name: "export comments I", @@ -399,10 +270,6 @@ export const foo = 0 /* */ ---`, - want: want{ - frontmatter: []string{"", "// hmm\n/*\n*/"}, - getStaticPaths: "export const foo = 0", - }, }, { name: "export comments II", @@ -412,10 +279,6 @@ export const foo = 0; /* */ ---`, - want: want{ - frontmatter: []string{"", "// hmm\n/*\n*/"}, - getStaticPaths: "export const foo = 0;", - }, }, { name: "import assertions", @@ -423,12 +286,6 @@ export const foo = 0; import data from "test" assert { type: 'json' }; --- `, - want: want{ - frontmatter: []string{ - `import data from "test" assert { type: 'json' };`, - }, - metadata: metadata{modules: []string{`{ module: $$module1, specifier: 'test', assert: {type:'json'} }`}}, - }, }, { name: "import to identifier named assert", @@ -436,19 +293,10 @@ import data from "test" assert { type: 'json' }; source: `--- import assert from 'test'; ---`, - want: want{ - frontmatter: []string{ - `import assert from 'test';`, - }, - metadata: metadata{modules: []string{`{ module: $$module1, specifier: 'test', assert: {} }`}}, - }, }, { name: "no expressions in math", source: `

Hello, world! This is a buggy formula: f ⁣:XR2xf\colon X \to \mathbb R^{2x}

`, - want: want{ - code: `${$$maybeRenderHead($$result)}

Hello, world! This is a buggy formula: f ⁣:XR2xf\\colon X \\to \\mathbb R^{2x}

`, - }, }, { name: "import order", @@ -460,14 +308,6 @@ import data from "test";
{data}
`, - want: want{ - frontmatter: []string{ - `import data from "test";`, - "let testWord = \"Test\"\n// comment", - }, - metadata: metadata{modules: []string{`{ module: $$module1, specifier: 'test', assert: {} }`}}, - code: "${$$maybeRenderHead($$result)}
${data}
", - }, }, { name: "type import", @@ -477,19 +317,10 @@ import type data from "test"
{data}
`, - want: want{ - frontmatter: []string{ - `import type data from "test"`, - }, - code: "${$$maybeRenderHead($$result)}
${data}
", - }, }, { name: "no expressions in math", source: `

Hello, world! This is a buggy formula: f ⁣:XR2xf\colon X \to \mathbb R^{2x}

`, - want: want{ - code: `${$$maybeRenderHead($$result)}

Hello, world! This is a buggy formula: f ⁣:XR2xf\\colon X \\to \\mathbb R^{2x}

`, - }, }, { @@ -498,32 +329,18 @@ import type data from "test" import './styles.css'; --- `, - want: want{ - frontmatter: []string{ - `import './styles.css';`, - }, - }, }, { name: "solidus in template literal expression", source: "
", - want: want{ - code: "${$$maybeRenderHead($$result)}
", - }, }, { name: "nested template literal expression", source: "
", - want: want{ - code: "${$$maybeRenderHead($$result)}
", - }, }, { name: "component in expression with its child expression before its child element", source: "{list.map(() => ({name}))}", - want: want{ - code: "${list.map(() => ($$render`${$$renderComponent($$result,'Component',Component,{},{\"default\": () => $$render`${name}`,})}`))}", - }, }, { name: "expression returning multiple elements", @@ -550,32 +367,6 @@ import type data from "test" }
`, - - want: want{ - code: `${$$renderComponent($$result,'Layout',Layout,{"title":"Welcome to Astro."},{"default": () => $$render` + BACKTICK + ` - ${$$maybeRenderHead($$result)}
-

Welcome to Astro

- ${ - Object.entries(DUMMY_DATA).map(([dummyKey, dummyValue]) => { - return ( - $$render` + BACKTICK + `

- onlyp ${dummyKey} -

-

- onlyh2 ${dummyKey} -

-
-

div+h2 ${dummyKey}

-
-

-

p+h2 ${dummyKey}

- ` + BACKTICK + ` - ); - }) - } -
-` + BACKTICK + `,})}`, - }, }, { name: "nested template literal expression", @@ -585,21 +376,10 @@ import type data from "test" {Object.keys(importedAuthors).map(author =>

{author}

)} `, - want: want{ - code: ` -${$$maybeRenderHead($$result)} -${Object.keys(importedAuthors).map(author => $$render` + BACKTICK + `

hello
` + BACKTICK + `)} -${Object.keys(importedAuthors).map(author => $$render` + BACKTICK + `

${author}
` + BACKTICK + `)} - -`, - }, }, { name: "complex nested template literal expression", source: "
", - want: want{ - code: "${$$maybeRenderHead($$result)}
", - }, }, { name: "component", @@ -614,20 +394,6 @@ import VueComponent from '../components/Vue.vue'; `, - want: want{ - frontmatter: []string{ - `import VueComponent from '../components/Vue.vue';`, - }, - metadata: metadata{modules: []string{`{ module: $$module1, specifier: '../components/Vue.vue', assert: {} }`}}, - code: ` - - Hello world - ` + RENDER_HEAD_RESULT + ` - - ${` + RENDER_COMPONENT + `($$result,'VueComponent',VueComponent,{})} - - `, - }, }, { name: "dot component", @@ -642,46 +408,22 @@ import * as ns from '../components'; `, - want: want{ - frontmatter: []string{`import * as ns from '../components';`}, - metadata: metadata{modules: []string{`{ module: $$module1, specifier: '../components', assert: {} }`}}, - code: ` - - Hello world - ` + RENDER_HEAD_RESULT + ` - - ${` + RENDER_COMPONENT + `($$result,'ns.Component',ns.Component,{})} - - `, - }, }, { name: "component with quoted attributes", source: ``, - want: want{ - code: `${` + RENDER_COMPONENT + `($$result,'Component',Component,{"is":"\"cool\""})}`, - }, }, { name: "slot with quoted attributes", source: `
`, - want: want{ - code: `${` + RENDER_COMPONENT + `($$result,'Component',Component,{},{"\"name\"": () => $$render` + BACKTICK + `${$$maybeRenderHead($$result)}
` + BACKTICK + `,})}`, - }, }, { name: "#955 ternary slot with text", source: `Hello{isLeaf ?

Leaf

:

Branch

}world
`, - want: want{ - code: `${` + RENDER_COMPONENT + `($$result,'Component',Component,{},{"default": () => $$render` + BACKTICK + `Hello${isLeaf ? $$render` + BACKTICK + `${$$maybeRenderHead($$result)}

Leaf

` + BACKTICK + ` : $$render` + BACKTICK + `

Branch

` + BACKTICK + `}world` + BACKTICK + `,})}`, - }, }, { name: "#955 ternary slot with elements", source: `
{isLeaf ?

Leaf

:

Branch

}
`, - want: want{ - code: `${` + RENDER_COMPONENT + `($$result,'Component',Component,{},{"default": () => $$render` + BACKTICK + `${$$maybeRenderHead($$result)}
${isLeaf ? $$render` + BACKTICK + `

Leaf

` + BACKTICK + ` : $$render` + BACKTICK + `

Branch

` + BACKTICK + `}
` + BACKTICK + `,})}`, - }, }, { name: "noscript component", @@ -694,37 +436,18 @@ import * as ns from '../components'; `, - want: want{ - code: ` - ` + RENDER_HEAD_RESULT + ` - - - - `, - }, }, { name: "noscript styles", source: ``, - want: want{ - code: `${$$maybeRenderHead($$result)}`, - }, }, { name: "noscript deep styles", source: ``, - want: want{ - code: `${$$maybeRenderHead($$result)}`, - }, }, { name: "noscript only", source: ``, - want: want{ - code: `${$$maybeRenderHead($$result)}`, - }, }, { name: "client:only component (default)", @@ -739,21 +462,6 @@ import Component from '../components'; `, - want: want{ - frontmatter: []string{"import Component from '../components';"}, - metadata: metadata{ - hydrationDirectives: []string{"only"}, - clientOnlyComponents: []string{"../components"}, - }, - // Specifically do NOT render any metadata here, we need to skip this import - code: ` - - Hello world - ` + RENDER_HEAD_RESULT + ` - - ${` + RENDER_COMPONENT + `($$result,'Component',null,{"client:only":true,"client:component-hydration":"only","client:component-path":($$metadata.resolvePath("../components")),"client:component-export":"default"})} - `, - }, }, { name: "client:only component (named)", @@ -768,21 +476,6 @@ import { Component } from '../components'; `, - want: want{ - frontmatter: []string{"import { Component } from '../components';"}, - metadata: metadata{ - hydrationDirectives: []string{"only"}, - clientOnlyComponents: []string{"../components"}, - }, - // Specifically do NOT render any metadata here, we need to skip this import - code: ` - - Hello world - ` + RENDER_HEAD_RESULT + ` - - ${` + RENDER_COMPONENT + `($$result,'Component',null,{"client:only":true,"client:component-hydration":"only","client:component-path":($$metadata.resolvePath("../components")),"client:component-export":"Component"})} - `, - }, }, { name: "client:only component (namespace)", @@ -797,21 +490,6 @@ import * as components from '../components'; `, - want: want{ - frontmatter: []string{"import * as components from '../components';"}, - metadata: metadata{ - hydrationDirectives: []string{"only"}, - clientOnlyComponents: []string{"../components"}, - }, - // Specifically do NOT render any metadata here, we need to skip this import - code: ` - - Hello world - ` + RENDER_HEAD_RESULT + ` - - ${` + RENDER_COMPONENT + `($$result,'components.A',null,{"client:only":true,"client:component-hydration":"only","client:component-path":($$metadata.resolvePath("../components")),"client:component-export":"A"})} - `, - }, }, { name: "client:only component (namespaced default)", @@ -826,21 +504,6 @@ import defaultImport from '../components/ui-1'; `, - want: want{ - frontmatter: []string{"import defaultImport from '../components/ui-1';"}, - metadata: metadata{ - hydrationDirectives: []string{"only"}, - clientOnlyComponents: []string{"../components/ui-1"}, - }, - // Specifically do NOT render any metadata here, we need to skip this import - code: ` - - Hello world - ` + RENDER_HEAD_RESULT + ` - - ${` + RENDER_COMPONENT + `($$result,'defaultImport.Counter1',null,{"client:only":true,"client:component-hydration":"only","client:component-path":($$metadata.resolvePath("../components/ui-1")),"client:component-export":"default.Counter1"})} - `, - }, }, { name: "client:only component (namespaced named)", @@ -855,21 +518,6 @@ import { namedImport } from '../components/ui-2'; `, - want: want{ - frontmatter: []string{"import { namedImport } from '../components/ui-2';"}, - metadata: metadata{ - hydrationDirectives: []string{"only"}, - clientOnlyComponents: []string{"../components/ui-2"}, - }, - // Specifically do NOT render any metadata here, we need to skip this import - code: ` - - Hello world - ` + RENDER_HEAD_RESULT + ` - - ${` + RENDER_COMPONENT + `($$result,'namedImport.Counter2',null,{"client:only":true,"client:component-hydration":"only","client:component-path":($$metadata.resolvePath("../components/ui-2")),"client:component-export":"namedImport.Counter2"})} - `, - }, }, { name: "client:only component (multiple)", @@ -886,58 +534,26 @@ import Component from '../components'; `, - want: want{ - frontmatter: []string{"import Component from '../components';"}, - metadata: metadata{ - hydrationDirectives: []string{"only"}, - clientOnlyComponents: []string{"../components"}, - }, - // Specifically do NOT render any metadata here, we need to skip this import - code: ` - - Hello world - ` + RENDER_HEAD_RESULT + ` - - ${` + RENDER_COMPONENT + `($$result,'Component',null,{"test":"a","client:only":true,"client:component-hydration":"only","client:component-path":($$metadata.resolvePath("../components")),"client:component-export":"default"})} - ${` + RENDER_COMPONENT + `($$result,'Component',null,{"test":"b","client:only":true,"client:component-hydration":"only","client:component-path":($$metadata.resolvePath("../components")),"client:component-export":"default"})} - ${` + RENDER_COMPONENT + `($$result,'Component',null,{"test":"c","client:only":true,"client:component-hydration":"only","client:component-path":($$metadata.resolvePath("../components")),"client:component-export":"default"})} - `, - }, }, { name: "iframe", source: `", - }, }, { name: "conditional render", source: `{false ?
#f
:
#t
}`, - want: want{ - code: "${$$maybeRenderHead($$result)}${false ? $$render`
#f
` : $$render`
#t
`}", - }, }, { name: "conditional noscript", source: `{mode === "production" && }`, - want: want{ - code: "${mode === \"production\" && $$render`${$$maybeRenderHead($$result)}`}", - }, }, { name: "conditional iframe", source: `{bool && }`, - want: want{ - code: "${bool && $$render`${$$maybeRenderHead($$result)}`}", - }, }, { name: "simple ternary", source: `{link ? {link} :
no link
}`, - want: want{ - code: fmt.Sprintf(`${$$maybeRenderHead($$result)}${link ? $$render%s${link}%s : $$render%s
no link
%s}`, BACKTICK, BACKTICK, BACKTICK, BACKTICK), - }, }, { name: "map basic", @@ -949,28 +565,14 @@ const items = [0, 1, 2]; return
  • {item}
  • ; })} `, - want: want{ - frontmatter: []string{"", "const items = [0, 1, 2];"}, - code: fmt.Sprintf(`${$$maybeRenderHead($$result)}
      - ${items.map(item => { - return $$render%s
    • ${item}
    • %s; - })} -
    `, BACKTICK, BACKTICK), - }, }, { name: "map without component", source: `
    `, - want: want{ - code: fmt.Sprintf(`${$$maybeRenderHead($$result)}
    `, BACKTICK, BACKTICK), - }, }, { name: "map with component", source: `
    `, - want: want{ - code: fmt.Sprintf(`${$$maybeRenderHead($$result)}
    ${$$renderComponent($$result,'Hello',Hello,{})}
    `, BACKTICK, BACKTICK), - }, }, { name: "map nested", @@ -986,95 +588,50 @@ const groups = [[0, 1, 2], [3, 4, 5]]; } })}
    `, - want: want{ - frontmatter: []string{"", "const groups = [[0, 1, 2], [3, 4, 5]];"}, - code: fmt.Sprintf(`${$$maybeRenderHead($$result)}
    - ${groups.map(items => { - return %s
      ${ - items.map(item => { - return %s
    • ${item}
    • %s; - }) - }
    %s - })} -
    `, "$$render"+BACKTICK, "$$render"+BACKTICK, BACKTICK, BACKTICK), - }, }, { name: "backtick in HTML comment", source: "", - want: want{ - code: "${$$maybeRenderHead($$result)}", - }, }, { name: "HTML comment in component inside expression I", source: "{(() => )}", - want: want{ - code: "${(() => $$render`${$$renderComponent($$result,'Component',Component,{},{})}`)}", - }, }, { name: "HTML comment in component inside expression II", source: "{list.map(() => )}", - want: want{ - code: "${list.map(() => $$render`${$$renderComponent($$result,'Component',Component,{},{})}`)}", - }, }, { name: "nested expressions", source: ``, - want: want{ - code: `${$$maybeRenderHead($$result)}
    ${(previous || next) && $$render` + BACKTICK + `` + BACKTICK + `}
    `, - }, }, { name: "nested expressions II", source: ``, - want: want{ - code: `${$$maybeRenderHead($$result)}
    ${(previous || next) && $$render` + BACKTICK + `` + BACKTICK + `}
    `, - }, }, { name: "nested expressions III", source: `
    {x.map((x) => x ?
    {true ? {x} : null}
    :
    {false ? null : {x}}
    )}
    `, - want: want{ - code: "${$$maybeRenderHead($$result)}
    ${x.map((x) => x ? $$render`
    ${true ? $$render`${x}` : null}
    ` : $$render`
    ${false ? null : $$render`${x}`}
    `)}
    ", - }, }, { name: "nested expressions IV", source: `
    {() => { if (value > 0.25) { return Default } else if (value > 0.5) { return Another } else if (value > 0.75) { return Other } return Yet Other }}
    `, - want: want{ - code: "${$$maybeRenderHead($$result)}
    ${() => { if (value > 0.25) { return $$render`Default` } else if (value > 0.5) { return $$render`Another` } else if (value > 0.75) { return $$render`Other` } return $$render`Yet Other` }}
    ", - }, }, { name: "nested expressions V", source: `

    title

    {list.map(group =>

    {group.label}

    {group.items.map(item => {item})}
    )}
    `, - want: want{ - code: "${$$maybeRenderHead($$result)}

    title

    ${list.map(group => $$render`${$$renderComponent($$result,'Fragment',Fragment,{},{\"default\": () => $$render`

    ${group.label}

    ${group.items.map(item => $$render`${item}`)}`,})}`)}
    ", - }, }, { name: "nested expressions VI", source: `
    {()=>{ if (true) { return
    ;} if (true) { return ;}}}
    `, - want: want{ - code: "${$$maybeRenderHead($$result)}
    ${()=>{ if (true) { return $$render`
    `;} if (true) { return $$render``;}}}
    ", - }, }, { name: "nested expressions VII", source: `
    {() => { if (value > 0.25) { return
    ;} else if (value > 0.5) { return
    ;} else if (value > 0.75) { return
    ;} return
    Yaaay
    ;}
    `, - want: want{ - code: "${$$maybeRenderHead($$result)}
    ${() => { if (value > 0.25) { return $$render`
    `;} else if (value > 0.5) { return $$render`
    `;} else if (value > 0.75) { return $$render`
    `;} return $$render`
    Yaaay
    `;}}
    ", - }, }, { name: "nested expressions VIII", source: `
    { items.map(({ type, ...data }) => { switch (type) { case 'card': { return ( ); } case 'paragraph': { return (

    {data.body}

    );}}})}
    `, - want: want{ - code: "${$$maybeRenderHead($$result)}
    ${ items.map(({ type, ...data }) => { switch (type) { case 'card': { return ( $$render`${$$renderComponent($$result,'Card',Card,{...(data)})}` ); } case 'paragraph': { return ( $$render`

    ${data.body}

    `);}}})}
    ", - }, }, { name: "expressions with JS comments", @@ -1090,18 +647,6 @@ const items = ['red', 'yellow', 'blue']; /* foo < > < } */
    color
    ))}
    `, - want: want{ - frontmatter: []string{"", "const items = ['red', 'yellow', 'blue'];"}, - code: `${$$maybeRenderHead($$result)}
    - ${items.map((item) => ( - // foo < > < } - $$render` + "`" + `color
    ` + "`" + ` - ))} - ${items.map((item) => ( - /* foo < > < } */ $$render` + "`" + `color` + "`" + ` - ))} -`, - }, }, { name: "expressions with multiple curly braces", @@ -1117,19 +662,6 @@ const items = ['red', 'yellow', 'blue']; } } `, - want: want{ - code: `${$$maybeRenderHead($$result)}
    -${ - () => { - let generate = (input) => { - let a = () => { return; }; - let b = () => { return; }; - let c = () => { return; }; - }; - } -} -
    `, - }, }, { name: "slots (basic)", @@ -1140,11 +672,6 @@ import Component from "test";
    Default
    Named
    `, - want: want{ - frontmatter: []string{`import Component from "test";`}, - metadata: metadata{modules: []string{`{ module: $$module1, specifier: 'test', assert: {} }`}}, - code: `${$$renderComponent($$result,'Component',Component,{},{"default": () => $$render` + "`" + ` ${$$maybeRenderHead($$result)}
    Default
    ` + "`" + `,"named": () => $$render` + "`" + `
    Named
    ` + "`" + `,})}`, - }, }, { name: "slots (no comments)", @@ -1156,11 +683,6 @@ import Component from 'test';
    Named
    `, - want: want{ - frontmatter: []string{`import Component from 'test';`}, - metadata: metadata{modules: []string{`{ module: $$module1, specifier: 'test', assert: {} }`}}, - code: `${$$renderComponent($$result,'Component',Component,{},{"default": () => $$render` + "`" + ` ${$$maybeRenderHead($$result)}
    Default
    ` + "`" + `,"named": () => $$render` + "`" + `
    Named
    ` + "`" + `,})}`, - }, }, { name: "slots (expression)", @@ -1168,9 +690,6 @@ import Component from 'test'; {items.map(item =>
    {item}
    )}
    `, - want: want{ - code: `${$$renderComponent($$result,'Component',Component,{"data":(data)},{"default": () => $$render` + BACKTICK + `${items.map(item => $$render` + BACKTICK + `${$$maybeRenderHead($$result)}
    ${item}
    ` + BACKTICK + `)}` + BACKTICK + `,})}`, - }, }, { name: "head expression", @@ -1185,17 +704,6 @@ const name = "world";
    `, - want: want{ - frontmatter: []string{``, `const name = "world";`}, - code: ` - - Hello ${name} - ` + RENDER_HEAD_RESULT + ` - -
    - - `, - }, }, { name: "head expression and conditional rendering of fragment", @@ -1212,18 +720,6 @@ const testBool = true;
    `, - want: want{ - frontmatter: []string{``, `const testBool = true;`}, - code: ` - - - ${testBool ? "Hey" : "Bye"} - ${testBool && ($$render` + BACKTICK + `${$$renderComponent($$result,'Fragment',Fragment,{},{"default": () => $$render` + BACKTICK + `` + BACKTICK + `,})}` + BACKTICK + `)} - ` + RENDER_HEAD_RESULT + ` - -
    - `, - }, }, { name: "conditional rendering of title containing expression", @@ -1236,17 +732,6 @@ const testBool = true; ) }`, - want: want{ - code: `${ - props.title && ( - $$render` + BACKTICK + `${$$renderComponent($$result,'Fragment',Fragment,{},{"default": () => $$render` + BACKTICK + ` - ${props.title} - - - ` + BACKTICK + `,})}` + BACKTICK + ` - ) -}`, - }, }, { name: "styles (no frontmatter)", @@ -1263,10 +748,6 @@ const testBool = true;

    Page Title

    I’m a page

    `, - want: want{ - code: "\n\n\t\t" + `${$$maybeRenderHead($$result)}

    Page Title

    -

    I’m a page

    `, - }, }, { name: "html5 boilerplate", @@ -1300,36 +781,6 @@ const testBool = true; `, - want: want{ - code: ` - - - - - A Basic HTML5 Template - - - - - - - - - - - - - - - -` + RENDER_HEAD_RESULT + ` - - - - - -`, - }, }, { name: "React framework example", @@ -1378,36 +829,6 @@ const someProps = { `, - want: want{ - frontmatter: []string{`import Counter from '../components/Counter.jsx'`, - `// Component Imports -const someProps = { - count: 0, -} - -// Full Astro Component Syntax: -// https://docs.astro.build/core-concepts/astro-components/`}, - metadata: metadata{ - modules: []string{`{ module: $$module1, specifier: '../components/Counter.jsx', assert: {} }`}, - hydratedComponents: []string{`Counter`}, - hydrationDirectives: []string{"visible"}, - }, - code: ` - - - - - - ` + RENDER_HEAD_RESULT + ` - -
    - ${$$renderComponent($$result,'Counter',Counter,{...(someProps),"client:visible":true,"client:component-hydration":"visible","client:component-path":("../components/Counter.jsx"),"client:component-export":("default"),"class":"astro-hmnnhvcq"},{"default": () => $$render` + "`" + ` -

    Hello React!

    - ` + "`" + `,})} -
    - - `, - }, }, { name: "script in ", @@ -1419,30 +840,12 @@ import Widget2 from '../components/Widget2.astro'; `, - want: want{ - frontmatter: []string{`import Widget from '../components/Widget.astro'; -import Widget2 from '../components/Widget2.astro';`}, - metadata: metadata{ - modules: []string{ - `{ module: $$module1, specifier: '../components/Widget.astro', assert: {} }`, - `{ module: $$module2, specifier: '../components/Widget2.astro', assert: {} }`}, - }, - code: ` - - - ` + RENDER_HEAD_RESULT + ``, - }, }, { name: "script hoist with frontmatter", source: `--- --- `, - want: want{ - frontmatter: []string{""}, - metadata: metadata{hoisted: []string{fmt.Sprintf(`{ type: 'inline', value: %sconsole.log("Hello");%s }`, BACKTICK, BACKTICK)}}, - code: ``, - }, }, { name: "script hoist without frontmatter", @@ -1450,40 +853,22 @@ import Widget2 from '../components/Widget2.astro';`},
    `, - want: want{ - metadata: metadata{hoisted: []string{fmt.Sprintf(`{ type: 'inline', value: %sconsole.log("Hello");%s }`, BACKTICK, BACKTICK)}}, - code: "${$$maybeRenderHead($$result)}
    \n" + - "
    ", - }, }, { - name: "script inline", + name: "scriptinline", source: `
    `, - want: want{ - code: `${$$maybeRenderHead($$result)}
    `, - }, }, { name: "script define:vars I", source: ``, - want: want{ - code: ``, - }, }, { name: "script define:vars II", source: ``, - want: want{ - code: ``, - }, }, { name: "script before elements", source: `
    `, - want: want{ - metadata: metadata{hoisted: []string{fmt.Sprintf(`{ type: 'inline', value: %sHere%s }`, BACKTICK, BACKTICK)}}, - code: `${$$maybeRenderHead($$result)}
    `, - }, }, { name: "script (renderScript: true)", @@ -1492,10 +877,6 @@ import Widget2 from '../components/Widget2.astro';`}, RenderScript: true, }, filename: "/src/pages/index.astro", - want: want{ - metadata: metadata{hoisted: []string{fmt.Sprintf(`{ type: 'inline', value: %sconsole.log("Hello");%s }`, BACKTICK, BACKTICK)}}, - code: `${$$maybeRenderHead($$result)}
    ${$$renderScript($$result,"/src/pages/index.astro?astro&type=script&index=0&lang.ts")}
    `, - }, }, { name: "script multiple (renderScript: true)", @@ -1504,15 +885,6 @@ import Widget2 from '../components/Widget2.astro';`}, RenderScript: true, }, filename: "/src/pages/index.astro", - want: want{ - metadata: metadata{ - hoisted: []string{ - fmt.Sprintf(`{ type: 'inline', value: %sconsole.log("World");%s }`, BACKTICK, BACKTICK), - fmt.Sprintf(`{ type: 'inline', value: %sconsole.log("Hello");%s }`, BACKTICK, BACKTICK), - }, - }, - code: `${$$maybeRenderHead($$result)}
    ${$$renderScript($$result,"/src/pages/index.astro?astro&type=script&index=0&lang.ts")}${$$renderScript($$result,"/src/pages/index.astro?astro&type=script&index=1&lang.ts")}
    `, - }, }, { name: "script external (renderScript: true)", @@ -1521,10 +893,6 @@ import Widget2 from '../components/Widget2.astro';`}, RenderScript: true, }, filename: "/src/pages/index.astro", - want: want{ - metadata: metadata{hoisted: []string{`{ type: 'external', src: './hello.js' }`}}, - code: `${$$maybeRenderHead($$result)}
    ${$$renderScript($$result,"/src/pages/index.astro?astro&type=script&index=0&lang.ts")}
    `, - }, }, { name: "script inline (renderScript: true)", @@ -1532,9 +900,6 @@ import Widget2 from '../components/Widget2.astro';`}, transformOptions: transform.TransformOptions{ RenderScript: true, }, - want: want{ - code: `${$$maybeRenderHead($$result)}
    `, - }, }, { name: "script mixed handled and inline (renderScript: true)", @@ -1543,24 +908,14 @@ import Widget2 from '../components/Widget2.astro';`}, RenderScript: true, }, filename: "/src/pages/index.astro", - want: want{ - metadata: metadata{hoisted: []string{fmt.Sprintf(`{ type: 'inline', value: %sconsole.log("Hello");%s }`, BACKTICK, BACKTICK)}}, - code: `${$$maybeRenderHead($$result)}
    ${$$renderScript($$result,"/src/pages/index.astro?astro&type=script&index=0&lang.ts")}
    `, - }, }, { name: "text after title expression", source: `a {expr} b`, - want: want{ - code: `a ${expr} b`, - }, }, { name: "text after title expressions", source: `a {expr} b {expr} c`, - want: want{ - code: `a ${expr} b ${expr} c`, - }, }, { name: "slots (dynamic name)", @@ -1571,11 +926,6 @@ const name = 'named';
    Named
    `, - want: want{ - frontmatter: []string{`import Component from 'test';`, `const name = 'named';`}, - metadata: metadata{modules: []string{`{ module: $$module1, specifier: 'test', assert: {} }`}}, - code: `${$$renderComponent($$result,'Component',Component,{},{[name]: () => $$render` + "`" + `${$$maybeRenderHead($$result)}
    Named
    ` + "`" + `,})}`, - }, }, { name: "slots (named only)", @@ -1584,23 +934,14 @@ const name = 'named'; B C `, - want: want{ - code: `${$$renderComponent($$result,'Slotted',Slotted,{},{"a": () => $$render` + BACKTICK + `${$$maybeRenderHead($$result)}A` + BACKTICK + `,"b": () => $$render` + BACKTICK + `B` + BACKTICK + `,"c": () => $$render` + BACKTICK + `C` + BACKTICK + `,})}`, - }, }, { name: "condition expressions at the top-level", source: `{cond && }{cond && }`, - want: want{ - code: "${cond && $$render`${$$maybeRenderHead($$result)}`}${cond && $$render``}", - }, }, { name: "condition expressions at the top-level with head content", source: `{cond && }{cond && My title}`, - want: want{ - code: "${cond && $$render``}${cond && $$render`My title`}", - }, }, { name: "custom elements", @@ -1608,11 +949,6 @@ const name = 'named'; import 'test'; --- `, - want: want{ - frontmatter: []string{`import 'test';`}, - metadata: metadata{modules: []string{`{ module: $$module1, specifier: 'test', assert: {} }`}}, - code: `${$$renderComponent($$result,'my-element','my-element',{})}`, - }, }, { name: "gets all potential hydrated components", @@ -1626,73 +962,34 @@ const name = 'world'; `, - want: want{ - frontmatter: []string{`import One from 'one'; -import Two from 'two'; -import 'custom-element';`, - `const name = 'world';`}, - metadata: metadata{ - modules: []string{ - `{ module: $$module1, specifier: 'one', assert: {} }`, - `{ module: $$module2, specifier: 'two', assert: {} }`, - `{ module: $$module3, specifier: 'custom-element', assert: {} }`, - }, - hydratedComponents: []string{"'my-element'", "Two", "One"}, - hydrationDirectives: []string{"load"}, - }, - code: `${$$renderComponent($$result,'One',One,{"client:load":true,"client:component-hydration":"load","client:component-path":("one"),"client:component-export":("default")})} -${$$renderComponent($$result,'Two',Two,{"client:load":true,"client:component-hydration":"load","client:component-path":("two"),"client:component-export":("default")})} -${$$renderComponent($$result,'my-element','my-element',{"client:load":true,"client:component-hydration":"load"})}`, - }, }, { name: "Component siblings are siblings", source: ``, - want: want{ - code: `${$$renderComponent($$result,'BaseHead',BaseHead,{})}`, - }, }, { name: "Self-closing components siblings are siblings", source: ``, - want: want{ - code: `${$$renderComponent($$result,'BaseHead',BaseHead,{})}`, - }, }, { name: "Self-closing script in head works", source: `` + RENDER_HEAD_RESULT + ``, - }, }, { name: "Self-closing title", source: ``, - want: want{ - code: `<title>`, - }, }, { name: "Self-closing title II", source: `</head><body></body></html>`, - want: want{ - code: `<html><head><title>` + RENDER_HEAD_RESULT + ``, - }, }, { name: "Self-closing components in head can have siblings", source: ``, - want: want{ - code: `${$$renderComponent($$result,'BaseHead',BaseHead,{})}` + RENDER_HEAD_RESULT + ``, - }, }, { name: "Self-closing formatting elements", source: `
    `, - want: want{ - code: `${$$maybeRenderHead($$result)}
    `, - }, }, { name: "Self-closing formatting elements 2", @@ -1701,13 +998,6 @@ ${$$renderComponent($$result,'my-element','my-element',{"client:load":true,"clie
    `, - want: want{ - code: `${$$maybeRenderHead($$result)} -
    -
    -
    -`, - }, }, { name: "Nested HTML in expressions, wrapped in parens", @@ -1716,11 +1006,6 @@ const image = './penguin.png'; const canonicalURL = new URL('http://example.com'); --- {image && ()}`, - want: want{ - frontmatter: []string{"", `const image = './penguin.png'; -const canonicalURL = new URL('http://example.com');`}, - code: "${image && ($$render``)}", - }, }, { name: "Use of interfaces within frontmatter", @@ -1733,15 +1018,6 @@ interface MarkdownFrontmatter { let allPosts = Astro.fetchContent('./post/*.md'); ---
    testing
    `, - want: want{ - frontmatter: []string{"", `interface MarkdownFrontmatter { - date: number; - image: string; - author: string; -} -let allPosts = Astro.fetchContent('./post/*.md');`}, - code: "${$$maybeRenderHead($$result)}
    testing
    ", - }, }, { name: "dynamic import", @@ -1750,11 +1026,7 @@ const markdownDocs = await Astro.glob('../markdown/*.md') const article2 = await import('../markdown/article2.md') ---
    -`, want: want{ - frontmatter: []string{"", `const markdownDocs = await Astro.glob('../markdown/*.md') -const article2 = await import('../markdown/article2.md')`}, - code: "${$$maybeRenderHead($$result)}
    ", - }, +`, }, { name: "Component names A-Z", @@ -1767,21 +1039,6 @@ import ZComponent from '../components/ZComponent.jsx'; `, - want: want{ - frontmatter: []string{ - `import AComponent from '../components/AComponent.jsx'; -import ZComponent from '../components/ZComponent.jsx';`}, - metadata: metadata{ - modules: []string{ - `{ module: $$module1, specifier: '../components/AComponent.jsx', assert: {} }`, - `{ module: $$module2, specifier: '../components/ZComponent.jsx', assert: {} }`, - }, - }, - code: `${$$maybeRenderHead($$result)} - ${` + RENDER_COMPONENT + `($$result,'AComponent',AComponent,{})} - ${` + RENDER_COMPONENT + `($$result,'ZComponent',ZComponent,{})} -`, - }, }, { name: "Parser can handle files > 4096 chars", @@ -1793,16 +1050,10 @@ import ZComponent from '../components/ZComponent.jsx';`}, srcSet="https://images.unsplash.com/photo-1469854523086-cc02fe5d8800?w=1200&q=75 800w,https://images.unsplash.com/photo-1469854523086-cc02fe5d8800?w=1200&q=75 1200w,https://images.unsplash.com/photo-1469854523086-cc02fe5d8800?w=1600&q=75 1600w,https://images.unsplash.com/photo-1469854523086-cc02fe5d8800?w=2400&q=75 2400w" sizes="(max-width: 800px) 800px, (max-width: 1200px) 1200px, (max-width: 1600px) 1600px, (max-width: 2400px) 2400px, 1200px" >`, - want: want{ - code: `${$$maybeRenderHead($$result)}` + longRandomString + ``, - }, }, { name: "SVG styles", source: ``, - want: want{ - code: `${$$maybeRenderHead($$result)}`, - }, }, { name: "svg expressions", @@ -1810,10 +1061,6 @@ import ZComponent from '../components/ZComponent.jsx';`}, const title = 'icon'; --- {title ?? null}`, - want: want{ - frontmatter: []string{"", "const title = 'icon';"}, - code: `${$$maybeRenderHead($$result)}${title ?? null}`, - }, }, { name: "advanced svg expression", @@ -1821,25 +1068,14 @@ const title = 'icon'; const title = 'icon'; --- {title ? {title} : null}`, - want: want{ - frontmatter: []string{"", "const title = 'icon';"}, - code: `${$$maybeRenderHead($$result)}${title ? $$render` + BACKTICK + `${title}` + BACKTICK + ` : null}`, - }, }, { name: "Empty script", source: ``, - want: want{ - code: ``, - }, }, { name: "Empty style", source: ``, - want: want{ - definedVars: []string{`{ color: "Gainsboro" }`}, - code: ``, - }, }, { name: "No extra script tag", @@ -1884,48 +1120,6 @@ const title = 'icon'; gtag('js', new Date()); gtag('config', 'G-TEL60V1WM9'); -->`, - want: want{ - code: ` - - - - - - - - - - - - - - - - - - - - - - - - -`, - }, }, { name: "All components", @@ -1941,11 +1135,6 @@ import { Container, Col, Row } from 'react-bootstrap'; `, - want: want{ - frontmatter: []string{`import { Container, Col, Row } from 'react-bootstrap';`}, - metadata: metadata{modules: []string{`{ module: $$module1, specifier: 'react-bootstrap', assert: {} }`}}, - code: "${$$renderComponent($$result,'Container',Container,{},{\"default\": () => $$render`\n ${$$renderComponent($$result,'Row',Row,{},{\"default\": () => $$render`\n ${$$renderComponent($$result,'Col',Col,{},{\"default\": () => $$render`\n ${$$maybeRenderHead($$result)}

    Hi!

    \n `,})}\n `,})}`,})}", - }, }, { name: "Mixed style siblings", @@ -1955,142 +1144,82 @@ import { Container, Col, Row } from 'react-bootstrap';
    `, - want: want{ - code: "\n\n\n\n\n\n\n" + RENDER_HEAD_RESULT + "\n
    ", - }, }, { name: "spread with double quotation marks", source: `
    `, - want: want{ - code: `${$$maybeRenderHead($$result)}
    `, - }, }, { name: "class with spread", source: `
    `, - want: want{ - code: `${$$maybeRenderHead($$result)}
    `, - }, }, { name: "class:list with spread", source: `
    `, - want: want{ - code: `${$$maybeRenderHead($$result)}
    `, - }, }, { name: "class list", source: `
    `, - want: want{ - code: `${$$maybeRenderHead($$result)}
    `, - }, }, { name: "class and class list simple array", source: `
    `, - want: want{ - code: `${$$maybeRenderHead($$result)}
    `, - }, }, { name: "class and class list object", source: `
    `, - want: want{ - code: `${$$maybeRenderHead($$result)}
    `, - }, }, { name: "class and class list set", source: `
    `, - want: want{ - code: `${$$maybeRenderHead($$result)}
    `, - }, }, { name: "spread without style or class", source: `
    `, - want: want{ - code: `${$$maybeRenderHead($$result)}
    `, - }, }, { name: "spread with style but no explicit class", source: `
    `, - want: want{ - code: `${$$maybeRenderHead($$result)}
    `, - }, }, { name: "Fragment", source: `
    Default
    Named
    `, - want: want{ - code: `${$$maybeRenderHead($$result)}${$$renderComponent($$result,'Fragment',Fragment,{},{"default": () => $$render` + BACKTICK + `
    Default
    Named
    ` + BACKTICK + `,})}`, - }, }, { name: "Fragment shorthand", source: `<>
    Default
    Named
    `, - want: want{ - code: `${$$maybeRenderHead($$result)}${$$renderComponent($$result,'Fragment',Fragment,{},{"default": () => $$render` + BACKTICK + `
    Default
    Named
    ` + BACKTICK + `,})}`, - }, }, { name: "Fragment shorthand only", source: `<>Hello`, - want: want{ - code: `${$$renderComponent($$result,'Fragment',Fragment,{},{"default": () => $$render` + BACKTICK + `Hello` + BACKTICK + `,})}`, - }, }, { name: "Fragment literal only", source: `world`, - want: want{ - code: `${$$renderComponent($$result,'Fragment',Fragment,{},{"default": () => $$render` + BACKTICK + `world` + BACKTICK + `,})}`, - }, }, { name: "Fragment slotted", source: `<>
    Default
    Named
    `, - want: want{ - code: `${$$maybeRenderHead($$result)}${$$renderComponent($$result,'Component',Component,{},{"default": () => $$render` + BACKTICK + `${$$renderComponent($$result,'Fragment',Fragment,{},{"default": () => $$render` + BACKTICK + `
    Default
    Named
    ` + BACKTICK + `,})}` + BACKTICK + `,})}`, - }, }, { name: "Fragment slotted with name", source: `
    Default
    Named
    `, - want: want{ - code: `${$$maybeRenderHead($$result)}${$$renderComponent($$result,'Component',Component,{},{"named": () => $$render` + BACKTICK + `${$$renderComponent($$result,'Fragment',Fragment,{"slot":"named"},{"default": () => $$render` + BACKTICK + `
    Default
    Named
    ` + BACKTICK + `,})}` + BACKTICK + `,})}`, - }, }, { name: "Preserve slots inside custom-element", source: `
    Name
    Default
    `, - want: want{ - code: `${$$maybeRenderHead($$result)}${$$renderComponent($$result,'my-element','my-element',{},{"default": () => $$render` + BACKTICK + `
    Name
    Default
    ` + BACKTICK + `,})}`, - }, }, { name: "Preserve namespaces", source: ``, - want: want{ - code: `${$$maybeRenderHead($$result)}`, - }, }, { name: "Preserve namespaces in expressions", source: ``, - want: want{ - code: `${$$maybeRenderHead($$result)}`, - }, }, { name: "Preserve namespaces for components", source: ``, - want: want{ - code: `${$$renderComponent($$result,'Component',Component,{"some:thing":"foobar"})}`, - }, }, { name: "import.meta.env", @@ -2137,55 +1266,6 @@ const { product } = Astro.props;
    `, BACKTICK, BACKTICK), - want: want{ - code: ` - - - - Shoperoni | Buy ${product.node.title} - - - -` + RENDER_HEAD_RESULT + ` - - ${$$renderComponent($$result,'Header',Header,{})} -
    -
    - ${$$renderComponent($$result,'ProductPageContent',ProductPageContent,{"client:visible":true,"product":(product.node),"client:component-hydration":"visible","client:component-path":("../../components/ProductPageContent.jsx"),"client:component-export":("default")})} -
    -
    - ${$$renderComponent($$result,'Footer',Footer,{})} - -`, - frontmatter: []string{ - `import Header from '../../components/Header.jsx' -import Footer from '../../components/Footer.astro' -import ProductPageContent from '../../components/ProductPageContent.jsx';`, - "const { product } = Astro.props;", - }, - getStaticPaths: fmt.Sprintf(`export async function getStaticPaths() { - let products = await fetch(%s${import.meta.env.PUBLIC_NETLIFY_URL}/.netlify/functions/get-product-list%s) - .then(res => res.json()).then((response) => { - console.log('--- built product pages ---') - return response.products.edges - }); - - return products.map((p, i) => { - return { - params: {pid: p.node.handle}, - props: {product: p}, - }; - }); -}`, BACKTICK, BACKTICK), - metadata: metadata{ - modules: []string{`{ module: $$module1, specifier: '../../components/Header.jsx', assert: {} }`, - `{ module: $$module2, specifier: '../../components/Footer.astro', assert: {} }`, - `{ module: $$module3, specifier: '../../components/ProductPageContent.jsx', assert: {} }`, - }, - hydratedComponents: []string{`ProductPageContent`}, - hydrationDirectives: []string{"visible"}, - }, - }, }, { name: "import.meta", @@ -2194,18 +1274,10 @@ const components = import.meta.glob("../components/*.astro", { import: 'default' }); ---`, - want: want{ - frontmatter: []string{"", `const components = import.meta.glob("../components/*.astro", { - import: 'default' -});`}, - }, }, { name: "doctype", source: `
    `, - want: want{ - code: `${$$maybeRenderHead($$result)}
    `, - }, }, { name: "select option expression", @@ -2213,10 +1285,6 @@ const components = import.meta.glob("../components/*.astro", { const value = 'test'; --- `, - want: want{ - frontmatter: []string{"", "const value = 'test';"}, - code: `${$$maybeRenderHead($$result)}`, - }, }, { name: "select nested option", @@ -2224,17 +1292,10 @@ const value = 'test'; const value = 'test'; --- `, - want: want{ - frontmatter: []string{"", "const value = 'test';"}, - code: `${$$maybeRenderHead($$result)}`, - }, }, { name: "select map expression", source: `
    Hello world!
    `, - want: want{ - code: `${$$maybeRenderHead($$result)}
    Hello world!
    `, - }, }, { name: "textarea", @@ -2242,17 +1303,10 @@ const value = 'test'; const value = 'test'; --- `, - want: want{ - frontmatter: []string{"", "const value = 'test';"}, - code: `${$$maybeRenderHead($$result)}`, - }, }, { name: "textarea inside expression", source: `{bool && } {!bool && }`, - want: want{ - code: `${bool && $$render` + BACKTICK + `${$$maybeRenderHead($$result)}` + BACKTICK + `} ${!bool && $$render` + BACKTICK + `` + BACKTICK + `}`, - }, }, { name: "table simple case", @@ -2277,25 +1331,6 @@ const content = "lol"; `, - want: want{ - frontmatter: []string{"", `const content = "lol";`}, - code: ` - ${$$maybeRenderHead($$result)} - - - - - ${ - ( - $$render` + BACKTICK + ` - - ` + BACKTICK + ` - ) - } -
    ${content}
    1
    Hello - -`, - }, }, { name: "complex table", @@ -2343,52 +1378,6 @@ const content = "lol";
    `, - want: want{ - code: ` - - - - Astro Multi Table - ${$$renderHead($$result)} - -
    -
    - ${Array(3).fill(false).map((item, idx) => $$render` + BACKTICK + `
    -
    - ${'a'} - - - - ${$$renderComponent($$result,'Fragment',Fragment,{},{"default": () => $$render` + BACKTICK + `${Array(7).fill(false).map((entry, index) => $$render` + BACKTICK + `` + BACKTICK + `)}` + BACKTICK + `,})} - - - - - -
    A
    -
    -
    ` + BACKTICK + `)} -
    -
    -
    - - - - - - - - - - - -
    BBB
    -
    -
    -
    - -`, - }, }, { name: "table with expression in 'th'", @@ -2438,51 +1427,6 @@ console.log(tables); } `, - want: want{ - frontmatter: []string{``, `const { title, footnotes, tables } = Astro.props; - -interface Table { - title: string; - data: any[]; - showTitle: boolean; - footnotes: string; -} -console.log(tables);`}, - code: `${$$maybeRenderHead($$result)}
    -
    -

    - ${title} -

    - ${ - tables.map((table: Table) => ( - $$render` + BACKTICK + `${$$renderComponent($$result,'Fragment',Fragment,{},{"default": () => $$render` + BACKTICK + ` -
    -

    ${table.title}

    - - - ${Object.keys(table.data[0]).map((thead) => ( - $$render` + BACKTICK + `` + BACKTICK + ` - ))} - - - ${table.data.map((trow) => ( - $$render` + BACKTICK + ` - ${Object.values(trow).map((cell, index) => ( - $$render` + BACKTICK + `` + BACKTICK + ` - ))} - ` + BACKTICK + ` - ))} - -
    ${thead}
    - ${cell} -
    -
    - ` + BACKTICK + `,})}` + BACKTICK + ` - )) - } -
    -
    `, - }, }, { name: "table expressions (no implicit tbody)", @@ -2490,24 +1434,14 @@ console.log(tables);`}, const items = ["Dog", "Cat", "Platipus"]; --- {items.map(item => ())}
    {item}
    `, - want: want{ - frontmatter: []string{"", `const items = ["Dog", "Cat", "Platipus"];`}, - code: `${$$maybeRenderHead($$result)}${items.map(item => ($$render` + BACKTICK + `` + BACKTICK + `))}
    ${item}
    `, - }, }, { name: "table caption expression", source: `
    {title}
    Hello
    `, - want: want{ - code: `${$$maybeRenderHead($$result)}
    ${title}
    Hello
    `, - }, }, { name: "table expression with trailing div", source: `
    {title}
    Div
    `, - want: want{ - code: `${$$maybeRenderHead($$result)}
    ${title}
    Div
    `, - }, }, { name: "tbody expressions", @@ -2515,10 +1449,6 @@ const items = ["Dog", "Cat", "Platipus"]; const items = ["Dog", "Cat", "Platipus"]; --- {items.map(item => ())}
    Name
    {item}
    `, - want: want{ - frontmatter: []string{"", `const items = ["Dog", "Cat", "Platipus"];`}, - code: `${$$maybeRenderHead($$result)}${items.map(item => ($$render` + BACKTICK + `` + BACKTICK + `))}
    Name
    ${item}
    `, - }, }, { name: "tbody expressions 2", @@ -2526,136 +1456,78 @@ const items = ["Dog", "Cat", "Platipus"]; const items = ["Dog", "Cat", "Platipus"]; --- {items.map(item => ())}
    Name
    {item}{item + 's'}
    `, - want: want{ - frontmatter: []string{"", `const items = ["Dog", "Cat", "Platipus"];`}, - code: `${$$maybeRenderHead($$result)}${items.map(item => ($$render` + BACKTICK + `` + BACKTICK + `))}
    Name
    ${item}${item + 's'}
    `, - }, }, { name: "tbody expressions 3", source: `{rows.map(row => ())}
    {row}
    `, - want: want{ - code: `${$$maybeRenderHead($$result)}${rows.map(row => ($$render` + BACKTICK + `` + BACKTICK + `))}
    ${row}
    `, - }, }, { name: "td expressions", source: `

    Row 1

    {title}
    `, - want: want{ - code: `${$$maybeRenderHead($$result)}

    Row 1

    ${title}
    `, - }, }, { name: "td expressions II", source: `{data.map(row => {row.map(cell => )})}
    {cell}
    `, - want: want{ - code: "${$$maybeRenderHead($$result)}${data.map(row => $$render`${row.map(cell => $$render``)}`)}
    ${cell}
    ", - }, }, { name: "self-closing td", source: `{data.map(row => {row.map(cell => )}
    )}
    `, - want: want{ - code: "${$$maybeRenderHead($$result)}${data.map(row => $$render`${row.map(cell => $$render``)}`)}
    ${$$unescapeHTML(cell)}
    ", - }, }, { name: "th expressions", source: `
    {title}
    `, - want: want{ - code: `${$$maybeRenderHead($$result)}
    ${title}
    `, - }, }, { name: "tr only", source: `col 1col 2{foo}`, - want: want{ - code: `${$$maybeRenderHead($$result)}col 1col 2${foo}`, - }, }, { name: "caption only", source: `Hello world!`, - want: want{ - code: `${$$maybeRenderHead($$result)}Hello world!`, - }, }, { name: "anchor expressions", source: `{expr}`, - want: want{ - code: `${$$maybeRenderHead($$result)}${expr}`, - }, }, { name: "anchor inside expression", source: `{true && expr}`, - want: want{ - code: `${true && $$render` + BACKTICK + `${$$maybeRenderHead($$result)}expr` + BACKTICK + `}`, - }, }, { name: "anchor content", source: `

    • {expr}
    `, - want: want{ - code: `${$$maybeRenderHead($$result)}

    • ${expr}
    `, - }, }, { name: "small expression", source: `
    {a}{data.map(a => )}
    `, - want: want{ - code: `${$$maybeRenderHead($$result)}
    ${a}${data.map(a => $$render` + BACKTICK + `${$$renderComponent($$result,'Component',Component,{"value":(a)})}` + BACKTICK + `)}
    `, - }, }, { name: "division inside expression", source: `
    {16 / 4}
    `, - want: want{ - code: `${$$maybeRenderHead($$result)}
    ${16 / 4}
    `, - }, }, { name: "escaped entity", source: `A person saying "hello"`, - want: want{ - code: `${$$maybeRenderHead($$result)}A person saying "hello"`, - }, }, { name: "textarea in form", source: `
    `, - want: want{ - code: `${$$renderComponent($$result,'Component',Component,{},{"default": () => $$render` + BACKTICK + `${$$maybeRenderHead($$result)}
    ` + BACKTICK + `,})}`, - }, }, { name: "select in form", source: `
    `, - want: want{ - code: `${$$maybeRenderHead($$result)}
    `, - }, }, { name: "Expression in form followed by other sibling forms", source: "

    No expression here. So the next form will render.

    {data.formLabelA}

    {data.formLabelB}

    No expression here, but the last form before me had an expression, so my form didn't render.

    {data.formLabelC}

    Here is some in-between content

    {data.formLabelD}

    ", - want: want{ - code: "${$$maybeRenderHead($$result)}

    No expression here. So the next form will render.

    ${data.formLabelA}

    ${data.formLabelB}

    No expression here, but the last form before me had an expression, so my form didn't render.

    ${data.formLabelC}

    Here is some in-between content

    ${data.formLabelD}

    ", - }, }, { name: "slot inside of Base", source: `
    Hello
    `, - want: want{ - code: `${$$renderComponent($$result,'Base',Base,{"title":"Home"},{"default": () => $$render` + BACKTICK + `${$$maybeRenderHead($$result)}
    Hello
    ` + BACKTICK + `,})}`, - }, }, { name: "user-defined `implicit` is printed", source: ``, - want: want{ - code: ``, - }, }, { name: "css comment doesn’t produce semicolon", @@ -2663,10 +1535,6 @@ const items = ["Dog", "Cat", "Platipus"]; padding: 2rem; }
    My Text
    `, - - want: want{ - code: `${$$maybeRenderHead($$result)}
    My Text
    `, - }, }, { name: "sibling expressions", @@ -2677,99 +1545,54 @@ const items = ["Dog", "Cat", "Platipus"]; {true ? (Row 3) : null} `, - want: want{ - code: fmt.Sprintf(`${$$maybeRenderHead($$result)} - - ${true ? ($$render%s%s) : null} - ${true ? ($$render%s%s) : null} - ${true ? ($$render%s%s) : null} -
    Row 1
    Row 2
    Row 3
    -`, BACKTICK, BACKTICK, BACKTICK, BACKTICK, BACKTICK, BACKTICK), - }, }, { name: "table", source: "{[0,1,2].map(x => ())}
    {x}
    ", - want: want{ - code: "${$$maybeRenderHead($$result)}${[0,1,2].map(x => ($$render``))}
    ${x}
    ", - }, }, { name: "table II", source: "{['Hey','Ho'].map((item)=> )}
    {item}
    ", - want: want{ - code: "${$$maybeRenderHead($$result)}${['Hey','Ho'].map((item)=> $$render``)}
    ${item}
    ", - }, }, { name: "table III", source: "
    Cell
    ", - want: want{ - code: "${$$maybeRenderHead($$result)}${$$renderComponent($$result,'Cell',Cell,{})}${$$renderComponent($$result,'Cell',Cell,{})}${$$renderComponent($$result,'Cell',Cell,{})}
    Cell
    ", - }, }, { name: "table IV", source: "
    hello world
    ", - want: want{ - code: "${$$maybeRenderHead($$result)}
    hello world
    ", - }, }, { name: "table slot I", source: "
    ", - want: want{ - code: "${$$maybeRenderHead($$result)}${$$renderSlot($$result,$$slots[\"default\"])}
    ", - }, }, { name: "table slot II", source: "
    ", - want: want{ - code: "${$$maybeRenderHead($$result)}${$$renderSlot($$result,$$slots[\"default\"])}
    ", - }, }, { name: "table slot III", source: "
    ", - want: want{ - code: "${$$maybeRenderHead($$result)}
    ${$$renderSlot($$result,$$slots[\"default\"])}
    ", - }, }, { name: "table slot IV", source: "
    ", - want: want{ - code: "${$$maybeRenderHead($$result)}${$$renderSlot($$result,$$slots[\"default\"])}
    ", - }, }, { name: "table slot V", source: "
    ", - want: want{ - code: "${$$maybeRenderHead($$result)}${$$renderSlot($$result,$$slots[\"default\"])}
    ", - }, }, { name: "XElement", source: `{onLoadString ? : null }`, - want: want{ - code: fmt.Sprintf(`${$$renderComponent($$result,'XElement',XElement,{...(attrs)})}${onLoadString ? $$render%s%s : null }`, BACKTICK, BACKTICK), - }, }, { name: "Empty expression", source: "({})", - want: want{ - code: `${$$maybeRenderHead($$result)}(${(void 0)})`, - }, }, { name: "Empty expression with whitespace", source: "({ })", - want: want{ - code: `${$$maybeRenderHead($$result)}(${(void 0) })`, - }, }, { name: "expression with leading whitespace", @@ -2781,508 +1604,288 @@ const items = ["Dog", "Cat", "Platipus"]; } `, - want: want{ - code: "${$$maybeRenderHead($$result)}
    \n
      \n\t${\n\n\t\t$$render`
    • Build: ${ new Date().toISOString() }
    • \n\t\t
    • NODE_VERSION: ${ process.env.NODE_VERSION }
    • `\n\t}\n
    \n
    ", - }, }, { name: "Empty attribute expression", source: "", - want: want{ - code: `${$$maybeRenderHead($$result)}`, - }, }, { name: "is:raw", source: "
    <% awesome %>
    ", - want: want{ - code: `${$$maybeRenderHead($$result)}
    <% awesome %>
    `, - }, }, { name: "Component is:raw", source: "{<% awesome %>}", - want: want{ - code: "${$$renderComponent($$result,'Component',Component,{},{\"default\": () => $$render`{<% awesome %>}`,})}", - }, }, { name: "set:html", source: "
    ", - want: want{ - code: `${$$maybeRenderHead($$result)}
    ${$$unescapeHTML(content)}
    `, - }, }, { name: "set:html with quoted attribute", source: `
    `, - want: want{ - code: `${$$maybeRenderHead($$result)}
    ${"content"}
    `, - }, }, { name: "set:html with template literal attribute without variable", source: `
    `, - want: want{ - code: `${$$maybeRenderHead($$result)}
    ${` + BACKTICK + `content` + BACKTICK + `}
    `, - }, }, { name: "set:html with template literal attribute with variable", source: `
    `, - want: want{ - code: `${$$maybeRenderHead($$result)}
    ${` + BACKTICK + `${content}` + BACKTICK + `}
    `, - }, }, { name: "set:text", source: "
    ", - want: want{ - code: `${$$maybeRenderHead($$result)}
    ${content}
    `, - }, }, { name: "set:text with quoted attribute", source: `
    `, - want: want{ - code: `${$$maybeRenderHead($$result)}
    content
    `, - }, }, { name: "set:text with template literal attribute without variable", source: `
    `, - want: want{ - code: `${$$maybeRenderHead($$result)}
    ${` + BACKTICK + `content` + BACKTICK + `}
    `, - }, }, { name: "set:text with template literal attribute with variable", source: `
    `, - want: want{ - code: `${$$maybeRenderHead($$result)}
    ${` + BACKTICK + `${content}` + BACKTICK + `}
    `, - }}, + }, { name: "set:html on Component", source: ``, - want: want{ - code: `${$$renderComponent($$result,'Component',Component,{},{"default": () => $$render` + "`${$$unescapeHTML(content)}`," + `})}`, - }, }, { name: "set:html on Component with quoted attribute", source: ``, - want: want{ - code: `${$$renderComponent($$result,'Component',Component,{},{"default": () => $$render` + BACKTICK + `${"content"}` + BACKTICK + `,})}`, - }, }, { name: "set:html on Component with template literal attribute without variable", source: ``, - want: want{ - code: `${$$renderComponent($$result,'Component',Component,{},{"default": () => $$render` + BACKTICK + `${` + BACKTICK + `content` + BACKTICK + `}` + BACKTICK + `,})}`, - }, }, { name: "set:html on Component with template literal attribute with variable", source: ``, - want: want{ - code: `${$$renderComponent($$result,'Component',Component,{},{"default": () => $$render` + BACKTICK + `${` + BACKTICK + `${content}` + BACKTICK + `}` + BACKTICK + `,})}`, - }, }, { name: "set:text on Component", source: "", - want: want{ - code: `${$$renderComponent($$result,'Component',Component,{},{"default": () => $$render` + "`${content}`," + `})}`, - }, }, { name: "set:text on Component with quoted attribute", source: ``, - want: want{ - code: `${$$renderComponent($$result,'Component',Component,{},{"default": () => $$render` + BACKTICK + `content` + BACKTICK + `,})}`, - }, }, { name: "set:text on Component with template literal attribute without variable", source: ``, - want: want{ - code: `${$$renderComponent($$result,'Component',Component,{},{"default": () => $$render` + BACKTICK + `${` + BACKTICK + `content` + BACKTICK + `}` + BACKTICK + `,})}`, - }, }, { name: "set:text on Component with template literal attribute with variable", source: ``, - want: want{ - code: `${$$renderComponent($$result,'Component',Component,{},{"default": () => $$render` + BACKTICK + `${` + BACKTICK + `${content}` + BACKTICK + `}` + BACKTICK + `,})}`, - }, }, { name: "set:html on custom-element", source: "", - want: want{ - code: `${$$renderComponent($$result,'custom-element','custom-element',{},{"default": () => $$render` + "`${$$unescapeHTML(content)}`," + `})}`, - }, }, { name: "set:html on custom-element with quoted attribute", source: ``, - want: want{ - code: `${$$renderComponent($$result,'custom-element','custom-element',{},{"default": () => $$render` + BACKTICK + `${"content"}` + BACKTICK + `,})}`, - }, }, { name: "set:html on custom-element with template literal attribute without variable", source: ``, - want: want{ - code: `${$$renderComponent($$result,'custom-element','custom-element',{},{"default": () => $$render` + BACKTICK + `${` + BACKTICK + `content` + BACKTICK + `}` + BACKTICK + `,})}`, - }, }, { name: "set:html on custom-element with template literal attribute with variable", source: ``, - want: want{ - code: `${$$renderComponent($$result,'custom-element','custom-element',{},{"default": () => $$render` + BACKTICK + `${` + BACKTICK + `${content}` + BACKTICK + `}` + BACKTICK + `,})}`, - }, }, { name: "set:text on custom-element", source: "", - want: want{ - code: `${$$renderComponent($$result,'custom-element','custom-element',{},{"default": () => $$render` + "`${content}`," + `})}`, - }, }, { name: "set:text on custom-element with quoted attribute", source: ``, - want: want{ - code: `${$$renderComponent($$result,'custom-element','custom-element',{},{"default": () => $$render` + BACKTICK + `content` + BACKTICK + `,})}`, - }, }, { name: "set:text on custom-element with template literal attribute without variable", source: ``, - want: want{ - code: `${$$renderComponent($$result,'custom-element','custom-element',{},{"default": () => $$render` + BACKTICK + `${` + BACKTICK + `content` + BACKTICK + `}` + BACKTICK + `,})}`, - }, }, { name: "set:text on custom-element with template literal attribute with variable", source: ``, - want: want{ - code: `${$$renderComponent($$result,'custom-element','custom-element',{},{"default": () => $$render` + BACKTICK + `${` + BACKTICK + `${content}` + BACKTICK + `}` + BACKTICK + `,})}`, - }, }, { name: "set:html on self-closing tag", source: "
    ", - want: want{ - code: `${$$maybeRenderHead($$result)}
    ${$$unescapeHTML(content)}
    `, - }, }, { name: "set:html on self-closing tag with quoted attribute", source: `
    `, - want: want{ - code: `${$$maybeRenderHead($$result)}
    ${"content"}
    `, - }, }, { name: "set:html on self-closing tag with template literal attribute without variable", source: `
    `, - want: want{ - code: `${$$maybeRenderHead($$result)}
    ${` + BACKTICK + `content` + BACKTICK + `}
    `, - }, }, { name: "set:html on self-closing tag with template literal attribute with variable", source: `
    `, - want: want{ - code: `${$$maybeRenderHead($$result)}
    ${` + BACKTICK + `${content}` + BACKTICK + `}
    `, - }, }, { name: "set:html with other attributes", source: "
    ", - want: want{ - code: `${$$maybeRenderHead($$result)}
    ${$$unescapeHTML(content)}
    `, - }, }, { name: "set:html with quoted attribute and other attributes", source: `
    `, - want: want{ - code: `${$$maybeRenderHead($$result)}
    ${"content"}
    `, - }, }, { name: "set:html with template literal attribute without variable and other attributes", source: `
    `, - want: want{ - code: `${$$maybeRenderHead($$result)}
    ${` + BACKTICK + `content` + BACKTICK + `}
    `, - }, }, { name: "set:html with template literal attribute with variable and other attributes", source: `
    `, - want: want{ - code: `${$$maybeRenderHead($$result)}
    ${` + BACKTICK + `${content}` + BACKTICK + `}
    `, - }, }, { name: "set:html on empty tag", source: "
    ", - want: want{ - code: `${$$maybeRenderHead($$result)}
    ${$$unescapeHTML(content)}
    `, - }, }, { name: "set:html on empty tag with quoted attribute", source: `
    `, - want: want{ - code: `${$$maybeRenderHead($$result)}
    ${"content"}
    `, - }, }, { name: "set:html on empty tag with template literal attribute without variable", source: `
    `, - want: want{ - code: `${$$maybeRenderHead($$result)}
    ${` + BACKTICK + `content` + BACKTICK + `}
    `, - }, }, { name: "set:html on empty tag with template literal attribute with variable", source: `
    `, - want: want{ - code: `${$$maybeRenderHead($$result)}
    ${` + BACKTICK + `${content}` + BACKTICK + `}
    `, - }, }, { // If both "set:*" directives are passed, we only respect the first one name: "set:html and set:text", source: "
    ", - want: want{ - code: `${$$maybeRenderHead($$result)}
    ${$$unescapeHTML(content)}
    `, - }, }, // { name: "set:html on tag with children", source: "
    !!!
    ", - want: want{ - code: `${$$maybeRenderHead($$result)}
    ${$$unescapeHTML(content)}
    `, - }, }, { name: "set:html on tag with children and quoted attribute", source: `
    !!!
    `, - want: want{ - code: `${$$maybeRenderHead($$result)}
    ${"content"}
    `, - }, }, { name: "set:html on tag with children and template literal attribute without variable", source: `
    !!!
    `, - want: want{ - code: `${$$maybeRenderHead($$result)}
    ${` + BACKTICK + `content` + BACKTICK + `}
    `, - }, }, { name: "set:html on tag with children and template literal attribute with variable", source: `
    !!!
    `, - want: want{ - code: `${$$maybeRenderHead($$result)}
    ${` + BACKTICK + `${content}` + BACKTICK + `}
    `, - }, }, { name: "set:html on tag with empty whitespace", source: "
    ", - want: want{ - code: `${$$maybeRenderHead($$result)}
    ${$$unescapeHTML(content)}
    `, - }, }, { name: "set:html on tag with empty whitespace and quoted attribute", source: `
    `, - want: want{ - code: `${$$maybeRenderHead($$result)}
    ${"content"}
    `, - }, }, { name: "set:html on tag with empty whitespace and template literal attribute without variable", source: `
    `, - want: want{ - code: `${$$maybeRenderHead($$result)}
    ${` + BACKTICK + `content` + BACKTICK + `}
    `, - }, }, { name: "set:html on tag with empty whitespace and template literal attribute with variable", source: `
    `, - want: want{ - code: `${$$maybeRenderHead($$result)}
    ${` + BACKTICK + `${content}` + BACKTICK + `}
    `, - }, }, { name: "set:html on script", source: "`, - }, }, { name: "set:html on script with quoted attribute", source: ``, - }, }, { name: "set:html on script with template literal attribute without variable", source: ``, - }, }, { name: "set:html on script with template literal attribute with variable", source: ``, - }, }, { name: "set:html on style", source: "`, - }, }, { name: "set:html on style with quoted attribute", source: ``, - }, }, { name: "set:html on style with template literal attribute without variable", source: ``, - }, }, { name: "set:html on style with template literal attribute with variable", source: ``, - }, }, { name: "set:html on Fragment", source: "<i>This should NOT be italic</i>

    \"} />", - want: want{ - code: "${$$renderComponent($$result,'Fragment',Fragment,{},{\"default\": () => $$render`${$$unescapeHTML(\"

    <i>This should NOT be italic</i>

    \")}`,})}", - }, }, { name: "set:html on Fragment with quoted attribute", source: "<i>This should NOT be italic</i>

    \" />", - want: want{ - code: "${$$renderComponent($$result,'Fragment',Fragment,{},{\"default\": () => $$render`${\"

    This should NOT be italic

    \"}`,})}", - }, }, { name: "set:html on Fragment with template literal attribute without variable", source: "<i>This should NOT be italic</i>

    ` />", - want: want{ - code: "${$$renderComponent($$result,'Fragment',Fragment,{},{\"default\": () => $$render`${`

    This should NOT be italic

    `}`,})}", - }, }, { name: "set:html on Fragment with template literal attribute with variable", source: ``, - want: want{ - code: `${$$renderComponent($$result,'Fragment',Fragment,{},{"default": () => $$render` + BACKTICK + `${` + BACKTICK + `${content}` + BACKTICK + `}` + BACKTICK + `,})}`, - }, }, { name: "template literal attribute on component", source: ``, - want: want{ - code: `${$$renderComponent($$result,'Component',Component,{"class":` + BACKTICK + `red` + BACKTICK + `})}`, - }, }, { name: "template literal attribute with variable on component", source: ``, - want: want{ - code: `${$$renderComponent($$result,'Component',Component,{"class":` + BACKTICK + `${color}` + BACKTICK + `})}`, - }, }, { name: "define:vars on style", source: "

    testing

    ", - want: want{ - code: `${$$maybeRenderHead($$result)}

    testing

    `, - definedVars: []string{"{color:'green'}"}, - }, }, { name: "define:vars on style tag with style shorthand attribute on element", source: "

    testing

    ", - want: want{ - code: `${$$maybeRenderHead($$result)}testing`, - definedVars: []string{"{color:'green'}"}, - }, }, { name: "define:vars on style tag with style expression attribute on element", source: "

    testing

    ", - want: want{ - code: `${$$maybeRenderHead($$result)}testing`, - definedVars: []string{"{color:'green'}"}, - }, }, { name: "define:vars on style tag with style empty attribute on element", source: "

    testing

    ", - want: want{ - code: `${$$maybeRenderHead($$result)}testing`, - definedVars: []string{"{color:'green'}"}, - }, }, { name: "define:vars on style tag with style quoted attribute on element", source: "

    testing

    ", - want: want{ - code: `${$$maybeRenderHead($$result)}testing`, - definedVars: []string{"{color:'green'}"}, - }, }, { name: "define:vars on style tag with style template literal attribute on element", source: "

    testing

    ", - want: want{ - code: `${$$maybeRenderHead($$result)}testing`, - definedVars: []string{"{color:'green'}"}, - }, }, { name: "multiple define:vars on style", source: "

    foo

    bar

    ", - want: want{ - code: `${$$maybeRenderHead($$result)}

    foo

    bar

    `, - definedVars: []string{"{color:'red'}", "{color:'green'}"}, - }, }, { name: "define:vars on non-root elements", source: "{true ?

    foo

    :

    bar

    }", - want: want{ - code: `${true ? $$render` + BACKTICK + `${$$maybeRenderHead($$result)}

    foo

    ` + BACKTICK + ` : $$render` + BACKTICK + `

    bar

    ` + BACKTICK + `}`, - definedVars: []string{"{color:'green'}"}, - }, }, { name: "define:vars on script with StaticExpression turned on", @@ -3291,48 +1894,27 @@ const items = ["Dog", "Cat", "Platipus"]; // 3. A define:vars hoisted script // 4. A define:vars inline script source: ``, - want: want{ - code: ``, - metadata: metadata{ - hoisted: []string{"{ type: 'inline', value: `var two = 'two';` }"}, - }, - }, }, { name: "define:vars on a module script with imports", // Should not wrap with { } scope. source: ``, - want: want{ - code: ``, - }, }, { name: "comments removed from attribute list", source: `

    Hello

    `, - want: want{ - code: `${$$maybeRenderHead($$result)}

    Hello

    ${$$renderComponent($$result,'Component',Component,{"value":"1",})}
    `, - }, }, { name: "includes comments for shorthand attribute", source: `

    Hello

    `, - want: want{ - code: `${$$maybeRenderHead($$result)}
    Hello${$$renderComponent($$result,'Component',Component,{"id":(/* comment 1 */ id /* comment 2 */)})}
    `, - }, }, { name: "includes comments for expression attribute", source: `

    Hello

    `, - want: want{ - code: `${$$maybeRenderHead($$result)}
    Hello${$$renderComponent($$result,'Component',Component,{"attr":(/* comment 1 */ isTrue ? 1 : 2 /* comment 2 */)})}
    `, - }, }, { name: "comment only expressions are removed I", source: `{/* a comment 1 */}

    {/* a comment 2*/}Hello

    `, - want: want{ - code: `${$$maybeRenderHead($$result)}

    Hello

    `, - }, }, { name: "comment only expressions are removed II", @@ -3345,13 +1927,6 @@ const items = ["Dog", "Cat", "Platipus"];
    )) }`, - want: want{ - code: `${ - list.map((i) => ( - $$render` + BACKTICK + `${$$renderComponent($$result,'Component',Component,{},{})}` + BACKTICK + ` - )) -}`, - }, }, { name: "comment only expressions are removed III", @@ -3364,78 +1939,45 @@ const items = ["Dog", "Cat", "Platipus"];
    )) }`, - want: want{ - code: `${ - list.map((i) => ( - $$render` + BACKTICK + `${$$renderComponent($$result,'Component',Component,{},{})}` + BACKTICK + ` - )) -}`, - }, }, { name: "component with only a script", source: "", - want: want{ - code: ``, - metadata: metadata{hoisted: []string{"{ type: 'inline', value: `console.log('hello world');` }"}}, - }, }, { name: "passes filename into createComponent if passed into the compiler options", source: `
    test
    `, filename: "/projects/app/src/pages/page.astro", - want: want{ - code: `${$$maybeRenderHead($$result)}
    test
    `, - }, }, { name: "passes escaped filename into createComponent if it contains single quotes", source: `
    test
    `, filename: "/projects/app/src/pages/page-with-'-quotes.astro", - want: want{ - code: `${$$maybeRenderHead($$result)}
    test
    `, - }, }, { name: "maybeRenderHead not printed for hoisted scripts", source: ``, filename: "/projects/app/src/pages/page.astro", - want: want{ - code: `${$$renderComponent($$result,'Layout',Layout,{})}`, - }, }, { name: "complex recursive component", source: `{(` + BACKTICK + `} />{Node.children.map((child) => ())}` + BACKTICK + `} />)}`, filename: "/projects/app/src/components/RenderNode.astro", - want: want{ - code: `${($$render` + BACKTICK + `${$$renderComponent($$result,'Fragment',Fragment,{},{"default": () => $$render` + BACKTICK + `${$$renderComponent($$result,'Fragment',Fragment,{},{"default": () => $$render` + BACKTICK + `${$$unescapeHTML(` + BACKTICK + `<${Node.tag} ${stringifyAttributes(Node.attributes)}>` + BACKTICK + `)}` + BACKTICK + `,})}${Node.children.map((child) => ($$render` + BACKTICK + `${$$renderComponent($$result,'Astro.self',Astro.self,{"node":(child)})}` + BACKTICK + `))}${$$renderComponent($$result,'Fragment',Fragment,{},{"default": () => $$render` + BACKTICK + `${$$unescapeHTML(` + BACKTICK + `` + BACKTICK + `)}` + BACKTICK + `,})}` + BACKTICK + `,})}` + BACKTICK + `)}`, - }, }, { name: "multibyte character + style", source: ``, - want: want{ - code: `${$$maybeRenderHead($$result)}`, - }, }, { name: "multibyte characters", source: `--- ---

    こんにちは

    `, - want: want{ - code: `${$$maybeRenderHead($$result)}

    こんにちは

    `, - }, }, { name: "multibyte character + script", source: ``, - want: want{ - code: `${$$maybeRenderHead($$result)}`, - metadata: metadata{hoisted: []string{fmt.Sprintf(`{ type: 'inline', value: %sconsole.log('foo')%s }`, BACKTICK, BACKTICK)}}, - }, }, { @@ -3443,67 +1985,43 @@ const items = ["Dog", "Cat", "Platipus"]; source: `
    `, filename: "/projects/app/src/pages/page.astro", transitions: true, - want: want{ - code: `${$$maybeRenderHead($$result)}`, - }, }, { name: "transition:name with an template literal", source: "
    ", filename: "/projects/app/src/pages/page.astro", transitions: true, - want: want{ - code: `${$$maybeRenderHead($$result)}`, - }, }, { name: "transition:animate with an expression", source: "
    ", filename: "/projects/app/src/pages/page.astro", transitions: true, - want: want{ - code: `${$$maybeRenderHead($$result)}`, - }, }, { name: "transition:animate on Component", source: ``, filename: "/projects/app/src/pages/page.astro", transitions: true, - want: want{ - code: `${$$renderComponent($$result,'Component',Component,{"class":"bar","data-astro-transition-scope":($$renderTransition($$result, "wkm5vset", "morph", ""))})}`, - }, }, { name: "transition:persist converted to a data attribute", source: `
    `, transitions: true, - want: want{ - code: `${$$maybeRenderHead($$result)}`, - }, }, { name: "transition:persist uses transition:name if defined", source: `
    `, transitions: true, - want: want{ - code: `${$$maybeRenderHead($$result)}
    `, - }, }, { name: "transition:persist-props converted to a data attribute", source: ``, transitions: true, - want: want{ - code: `${$$renderComponent($$result,'my-island','my-island',{"data-astro-transition-persist-props":"false","data-astro-transition-persist":($$createTransitionScope($$result, "otghnj5u"))})}`, - }, }, { name: "trailing expression", source: `{}`, - want: want{ - code: `${$$renderComponent($$result,'Component',Component,{})}${(void 0)}`, - }, }, { name: "nested head content stays in the head", @@ -3525,13 +2043,8 @@ const meta = { title: 'My App' };

    My App

    `, - want: want{ - frontmatter: []string{"", `const meta = { title: 'My App' };`}, - code: ` ${ meta && $$render` + BACKTICK + `${meta.title}` + BACKTICK + ` } ${$$renderHead($$result)}

    My App

    `, - }, }, } - for _, tt := range tests { if tt.only { tests = make([]testcase, 0) @@ -3570,158 +2083,16 @@ const meta = { title: 'My App' }; }, h) output := string(result.Output) - // The compiler prints Astro global code only if it's loosely used - printAstroGlobal := strings.Contains(tt.source, "Astro") - toMatch := INTERNAL_IMPORTS - if strings.Count(tt.source, "transition:") > 0 { - toMatch += `import "transitions.css";` - } - if len(tt.want.frontmatter) > 0 { - toMatch += test_utils.Dedent(tt.want.frontmatter[0]) - } - moduleSpecRe := regexp.MustCompile(`specifier:\s*('[^']+'),\s*assert:\s*([^}]+\})`) - if len(tt.want.metadata.modules) > 0 { - toMatch += "\n\n" - for i, m := range tt.want.metadata.modules { - spec := moduleSpecRe.FindSubmatch([]byte(m)) // 0: full match, 1: submatch - asrt := "" - if string(spec[2]) != "{}" { - asrt = " assert " + string(spec[2]) - } - toMatch += fmt.Sprintf("import * as $$module%s from %s%s;\n", strconv.Itoa(i+1), string(spec[1]), asrt) - } - } - // build metadata object from provided strings - metadata := "{ " - // metadata.modules - metadata += "modules: [" - if len(tt.want.metadata.modules) > 0 { - for i, m := range tt.want.metadata.modules { - if i > 0 { - metadata += ", " - } - metadata += m - } - } - metadata += "]" - // metadata.hydratedComponents - metadata += ", hydratedComponents: [" - if len(tt.want.metadata.hydratedComponents) > 0 { - for i, c := range tt.want.hydratedComponents { - if i > 0 { - metadata += ", " - } - metadata += c - } - } - metadata += "]" - // metadata.clientOnlyComponents - metadata += ", clientOnlyComponents: [" - if len(tt.want.metadata.clientOnlyComponents) > 0 { - for i, c := range tt.want.clientOnlyComponents { - if i > 0 { - metadata += ", " - } - metadata += fmt.Sprintf("'%s'", c) - } - } - metadata += "]" - // directives - metadata += ", hydrationDirectives: new Set([" - if len(tt.want.hydrationDirectives) > 0 { - for i, c := range tt.want.hydrationDirectives { - if i > 0 { - metadata += ", " - } - metadata += fmt.Sprintf("'%s'", c) - } - } - metadata += "])" - // metadata.hoisted - metadata += ", hoisted: [" - if len(tt.want.metadata.hoisted) > 0 { - for i, h := range tt.want.hoisted { - if i > 0 { - metadata += ", " - } - metadata += h - } - } - metadata += "] }" - - patharg := "import.meta.url" - if tt.filename != "" { - escapedFilename := strings.ReplaceAll(tt.filename, "'", "\\'") - patharg = fmt.Sprintf("\"%s\"", escapedFilename) - } - toMatch += "\n\n" + fmt.Sprintf("export const %s = %s(%s, %s);\n\n", METADATA, CREATE_METADATA, patharg, metadata) - if printAstroGlobal { - toMatch += test_utils.Dedent(CREATE_ASTRO_CALL) + "\n" - } - if len(tt.want.getStaticPaths) > 0 { - toMatch += strings.TrimSpace(test_utils.Dedent(tt.want.getStaticPaths)) + "\n\n" - } - if strings.Contains(tt.source, "await") { - toMatch += test_utils.Dedent(PRELUDE_WITH_ASYNC) - } else { - toMatch += test_utils.Dedent(PRELUDE) - } - if printAstroGlobal { - toMatch += test_utils.Dedent(PRELUDE_ASTRO_GLOBAL) - } - toMatch += "\n" - if len(tt.want.frontmatter) > 1 { - toMatch += strings.TrimSpace(test_utils.Dedent(tt.want.frontmatter[1])) - } - toMatch += "\n" - if len(tt.want.definedVars) > 0 { - toMatch = toMatch + "const $$definedVars = $$defineStyleVars([" - for i, d := range tt.want.definedVars { - if i > 0 { - toMatch += "," - } - toMatch += d - } - toMatch += "]);\n" - } - // code - toMatch += test_utils.Dedent(fmt.Sprintf("%s%s", RETURN, tt.want.code)) - // HACK: add period to end of test to indicate significant preceding whitespace (otherwise stripped by dedent) - if strings.HasSuffix(toMatch, ".") { - toMatch = strings.TrimRight(toMatch, ".") - } - - if len(tt.filename) > 0 { - escapedFilename := strings.ReplaceAll(tt.filename, "'", "\\'") - toMatch += suffixWithFilename(escapedFilename, tt.transitions) - toMatch = strings.Replace(toMatch, "$$Component", getComponentName(tt.filename), -1) - } else if tt.transitions { - toMatch += SUFFIX_EXP_TRANSITIONS - } else { - toMatch += SUFFIX - } - - // compare to expected string, show diff if mismatch - if diff := test_utils.ANSIDiff(test_utils.RemoveNewlines(test_utils.Dedent(toMatch)), test_utils.RemoveNewlines(test_utils.Dedent(output))); diff != "" { - t.Errorf("mismatch (-want +got):\n%s", diff) - } + test_utils.MakeSnapshot( + &test_utils.SnapshotOptions{ + Testing: t, + TestCaseName: tt.name, + Input: code, + Output: output, + Kind: test_utils.JsOutput, + FolderName: "__printer_js__", + }) - snapshotName := strings.ReplaceAll(tt.name, "#", "_") - snapshotName = strings.ReplaceAll(snapshotName, "<", "_") - snapshotName = strings.ReplaceAll(snapshotName, ">", "_") - snapshotName = strings.ReplaceAll(snapshotName, ")", "_") - snapshotName = strings.ReplaceAll(snapshotName, "(", "_") - snapshotName = strings.ReplaceAll(snapshotName, ":", "_") - snapshotName = strings.ReplaceAll(snapshotName, " ", "_") - snapshotName = strings.ReplaceAll(snapshotName, "#", "_") - - s := snaps.WithConfig( - snaps.Filename(snapshotName), - ) - - snapshot := fmt.Sprintf("%s%s%s%s%s%s%s%s", "## Input\n\n", "```\n", test_utils.Dedent(code), "\n```", "\n\n## Output\n\n", "```js\n", test_utils.Dedent(output), "\n```") - - s.MatchSnapshot(t, snapshot) }) } } @@ -3731,47 +2102,38 @@ func TestPrintToJSON(t *testing.T) { { name: "basic", source: `

    Hello world!

    `, - want: []ASTNode{{Type: "element", Name: "h1", Children: []ASTNode{{Type: "text", Value: "Hello world!"}}}}, }, { name: "expression", source: `

    Hello {world}

    `, - want: []ASTNode{{Type: "element", Name: "h1", Children: []ASTNode{{Type: "text", Value: "Hello "}, {Type: "expression", Children: []ASTNode{{Type: "text", Value: "world"}}}}}}, }, { name: "Component", source: ``, - want: []ASTNode{{Type: "component", Name: "Component"}}, }, { name: "custom-element", source: ``, - want: []ASTNode{{Type: "custom-element", Name: "custom-element"}}, }, { name: "Doctype", source: ``, - want: []ASTNode{{Type: "doctype", Value: "html"}}, }, { name: "Comment", source: ``, - want: []ASTNode{{Type: "comment", Value: "hello"}}, }, { name: "Comment preserves whitespace", source: ``, - want: []ASTNode{{Type: "comment", Value: " hello "}}, }, { name: "Fragment Shorthand", source: `<>Hello`, - want: []ASTNode{{Type: "fragment", Name: "", Children: []ASTNode{{Type: "text", Value: "Hello"}}}}, }, { name: "Fragment Literal", source: `World`, - want: []ASTNode{{Type: "fragment", Name: "Fragment", Children: []ASTNode{{Type: "text", Value: "World"}}}}, }, { name: "Frontmatter", @@ -3779,7 +2141,6 @@ func TestPrintToJSON(t *testing.T) { const a = "hey" ---
    {a}
    `, - want: []ASTNode{{Type: "frontmatter", Value: "\nconst a = \"hey\"\n"}, {Type: "element", Name: "div", Children: []ASTNode{{Type: "expression", Children: []ASTNode{{Type: "text", Value: "a"}}}}}}, }, { name: "JSON escape", @@ -3789,67 +2150,54 @@ const b = "\"" const c = '\'' --- {a + b + c}`, - want: []ASTNode{{Type: "frontmatter", Value: "\nconst a = \"\\n\"\nconst b = \"\\\"\"\nconst c = '\\''\n"}, {Type: "expression", Children: []ASTNode{{Type: "text", Value: "a + b + c"}}}}, }, { name: "Preserve namespaces", source: ``, - want: []ASTNode{{Type: "element", Name: "svg", Attributes: []ASTNode{{Type: "attribute", Kind: "quoted", Name: "xmlns", Value: "http://www.w3.org/2000/svg", Raw: `"http://www.w3.org/2000/svg"`}, {Type: "attribute", Kind: "quoted", Name: "xmlns:xlink", Value: "http://www.w3.org/1999/xlink", Raw: `"http://www.w3.org/1999/xlink"`}}, Children: []ASTNode{{Type: "element", Name: "rect", Attributes: []ASTNode{{Type: "attribute", Kind: "quoted", Name: "xlink:href", Value: "#id", Raw: `"#id"`}}}}}}, }, { name: "style before html", source: `

    Hello world!

    `, - want: []ASTNode{{Type: "element", Name: "style"}, {Type: "element", Name: "html", Children: []ASTNode{{Type: "element", Name: "body", Children: []ASTNode{{Type: "element", Name: "h1", Children: []ASTNode{{Type: "text", Value: "Hello world!"}}}}}}}}, }, { name: "style after html", source: `

    Hello world!

    `, - want: []ASTNode{{Type: "element", Name: "html", Children: []ASTNode{{Type: "element", Name: "body", Children: []ASTNode{{Type: "element", Name: "h1", Children: []ASTNode{{Type: "text", Value: "Hello world!"}}}}}}}, {Type: "element", Name: "style"}}, }, { name: "style after empty html", source: ``, - want: []ASTNode{{Type: "element", Name: "html"}, {Type: "element", Name: "style"}}, }, { name: "style after html with component in head", source: ``, - want: []ASTNode{{Type: "element", Name: "html", Attributes: []ASTNode{{Type: "attribute", Kind: "quoted", Name: "lang", Value: "en", Raw: "\"en\""}}, Children: []ASTNode{{Type: "element", Name: "head", Children: []ASTNode{{Type: "component", Name: "BaseHead"}}}}}, {Type: "element", Name: "style", Children: []ASTNode{{Type: "text", Value: "@use \"../styles/global.scss\";"}}}}, }, { name: "style after html with component in head and body", source: `
    `, - want: []ASTNode{{Type: "element", Name: "html", Attributes: []ASTNode{{Type: "attribute", Kind: "quoted", Name: "lang", Value: "en", Raw: "\"en\""}}, Children: []ASTNode{{Type: "element", Name: "head", Children: []ASTNode{{Type: "component", Name: "BaseHead"}}}, {Type: "element", Name: "body", Children: []ASTNode{{Type: "component", Name: "Header"}}}}}, {Type: "element", Name: "style", Children: []ASTNode{{Type: "text", Value: "@use \"../styles/global.scss\";"}}}}, }, { name: "style after body with component in head and body", source: `
    `, - want: []ASTNode{{Type: "element", Name: "html", Attributes: []ASTNode{{Type: "attribute", Kind: "quoted", Name: "lang", Value: "en", Raw: "\"en\""}}, Children: []ASTNode{{Type: "element", Name: "head", Children: []ASTNode{{Type: "component", Name: "BaseHead"}}}, {Type: "element", Name: "body", Children: []ASTNode{{Type: "component", Name: "Header"}}}, {Type: "element", Name: "style", Children: []ASTNode{{Type: "text", Value: "@use \"../styles/global.scss\";"}}}}}}, }, { name: "style in html", source: `

    Hello world!

    `, - want: []ASTNode{{Type: "element", Name: "html", Children: []ASTNode{{Type: "element", Name: "body", Children: []ASTNode{{Type: "element", Name: "h1", Children: []ASTNode{{Type: "text", Value: "Hello world!"}}}}}, {Type: "element", Name: "style"}}}}, }, { name: "style in body", source: `

    Hello world!

    `, - want: []ASTNode{{Type: "element", Name: "html", Children: []ASTNode{{Type: "element", Name: "body", Children: []ASTNode{{Type: "element", Name: "h1", Children: []ASTNode{{Type: "text", Value: "Hello world!"}}}, {Type: "element", Name: "style"}}}}}}, }, { name: "element with unterminated double quote attribute", source: `
    `, - want: []ASTNode{{Type: "element", Name: "main", Attributes: []ASTNode{{Type: "attribute", Kind: "template-literal", Name: "id", Value: "gotcha", Raw: "`gotcha"}}}}, }, } @@ -3872,14 +2220,17 @@ const c = '\'' t.Error(err) } - root := ASTNode{Type: "root", Children: tt.want} - toMatch := root.String() - result := PrintToJSON(code, doc, types.ParseOptions{Position: false}) - if diff := test_utils.ANSIDiff(test_utils.Dedent(string(toMatch)), test_utils.Dedent(string(result.Output))); diff != "" { - t.Errorf("mismatch (-want +got):\n%s", diff) - } + test_utils.MakeSnapshot( + &test_utils.SnapshotOptions{ + Testing: t, + TestCaseName: tt.name, + Input: code, + Output: string(result.Output), + Kind: test_utils.JsonOutput, + FolderName: "__printer_json__", + }) }) } } diff --git a/internal/test_utils/test_utils.go b/internal/test_utils/test_utils.go index 76937c50e..67c186fac 100644 --- a/internal/test_utils/test_utils.go +++ b/internal/test_utils/test_utils.go @@ -3,7 +3,9 @@ package test_utils import ( "fmt" "strings" + "testing" + "github.com/gkampitakis/go-snaps/snaps" "github.com/google/go-cmp/cmp" "github.com/lithammer/dedent" ) @@ -41,3 +43,84 @@ func ANSIDiff(x, y interface{}, opts ...cmp.Option) string { } return strings.Join(ss, "\n") } + +// Removes unsupported characters from the test case name, because it will be used as name for the snapshot +func RedactTestName(testCaseName string) string { + snapshotName := strings.ReplaceAll(testCaseName, "#", "_") + snapshotName = strings.ReplaceAll(snapshotName, "<", "_") + snapshotName = strings.ReplaceAll(snapshotName, ">", "_") + snapshotName = strings.ReplaceAll(snapshotName, ")", "_") + snapshotName = strings.ReplaceAll(snapshotName, "(", "_") + snapshotName = strings.ReplaceAll(snapshotName, ":", "_") + snapshotName = strings.ReplaceAll(snapshotName, " ", "_") + snapshotName = strings.ReplaceAll(snapshotName, "#", "_") + snapshotName = strings.ReplaceAll(snapshotName, "'", "_") + snapshotName = strings.ReplaceAll(snapshotName, "\"", "_") + snapshotName = strings.ReplaceAll(snapshotName, "@", "_") + snapshotName = strings.ReplaceAll(snapshotName, "`", "_") + snapshotName = strings.ReplaceAll(snapshotName, "+", "_") + return snapshotName +} + +type OutputKind int + +const ( + JsOutput = iota + JsonOutput + CssOutput + HtmlOutput + JsxOutput +) + +var outputKind = map[OutputKind]string{ + JsOutput: "js", + JsonOutput: "json", + CssOutput: "css", + HtmlOutput: "html", + JsxOutput: "jsx", +} + +type SnapshotOptions struct { + // The testing instances + Testing *testing.T + // The name of the test case + TestCaseName string + // The initial source code that needs to be tested + Input string + // The final output + Output string + // The kind of **markdown block** that the output will be wrapped + Kind OutputKind + // The folder name that the snapshots will be stored + FolderName string +} + +// It creates a snapshot for the given test case, the snapshot will include the input and the output of the test case +func MakeSnapshot(options *SnapshotOptions) { + t := options.Testing + testCaseName := options.TestCaseName + input := options.Input + output := options.Output + kind := options.Kind + + folderName := "__snapshots__" + if options.FolderName != "" { + folderName = options.FolderName + } + snapshotName := RedactTestName(testCaseName) + + s := snaps.WithConfig( + snaps.Filename(snapshotName), + snaps.Dir(folderName), + ) + + snapshot := "## Input\n\n```\n" + snapshot += Dedent(input) + snapshot += "\n```\n\n## Output\n\n" + snapshot += "```" + outputKind[kind] + "\n" + snapshot += Dedent(output) + snapshot += "\n```" + + s.MatchSnapshot(t, snapshot) + +} diff --git a/internal/transform/scope-html_test.go b/internal/transform/scope-html_test.go index 95b231de8..5b39405ea 100644 --- a/internal/transform/scope-html_test.go +++ b/internal/transform/scope-html_test.go @@ -120,6 +120,7 @@ func TestScopeHTML(t *testing.T) { if err != nil { t.Error(err) } + ScopeElement(nodes[0], TransformOptions{Scope: "xxxxxx"}) astro.PrintToSource(&b, nodes[0]) }) diff --git a/internal/transform/transform_test.go b/internal/transform/transform_test.go index a52dc11b6..4f3e4b8d7 100644 --- a/internal/transform/transform_test.go +++ b/internal/transform/transform_test.go @@ -528,6 +528,7 @@ func TestAnnotation(t *testing.T) { if tt.want != got { t.Errorf("\nFAIL: %s\n want: %s\n got: %s", tt.name, tt.want, got) } + }) } }