IssueRaiser

Use void tags for supported elements rather than self-closing

As i'm sure you're aware, there's an ancient (and forever ongoing) issue around customising whether we include the `/` in self closing tags or not. I'm creating this issue to be a bit more explicit and structured around the proposed solution. --- ### Summary Given the following definitions: - "self close" means `<foo />` - "void" means `<foo>` **Given:** `{parser: 'html'}` and a `<!DOCTYPE html>`: - All self-closing elements are transformed into full start/end tags (`<foo />` -> `<foo></foo>`) - _unless_ they are a void tag, then they are transformed into `<foo />` -> `<foo>` - All other elements are left as written by the user **Given:** all other parsers - Leave the syntax as written by the user ### Implementation TBD #### How do you migrate towards this? Obviously we can't just do this and hope all is well. This'd fundamentally change formatting of many, many projects. So some kind of migration plan would be needed. I'm not entirely sure how that'd look yet. ### Notes (IMPORTANT) **This is not an issue for us to debate whether we should include the `/` or not.** If the prettier team is against printing void tags, this issue _and the related issue from 2018_ should be closed. This issue is specifically to spec out and define how we can solve this problem, so someone can hopefully contribute the code from the definition/requirements here.

Posted by 43081j on Aug 30, 2023, 5:40 PM

Tags

Related issues

Raise real-world problems, find people facing the same issue, and discuss solutions.2,000 issues0 comments

github (Other)

Use void tags for supported elements rather than self-closing

43081jAug 30, 2023, 5:40 PM

As i'm sure you're aware, there's an ancient (and forever ongoing) issue around customising whether we include the `/` in self closing tags or not. I'm creating this issue to be a bit more explicit and structured around the proposed solution. --- ### Summary Given the following definitions: - "self close" means `<foo />` - "void" means `<foo>` **Given:** `{parser: 'html'}` and a `<!DOCTYPE html>`: - All self-closing elements are transformed into full start/end tags (`<foo />` -> `<foo></foo>`) - _unless_ they are a void tag, then they are transformed into `<foo />` -> `<foo>` - All other elements are left as written by the user **Given:** all other parsers - Leave the syntax as written by the user ### Implementation TBD #### How do you migrate towards this? Obviously we can't just do this and hope all is well. This'd fundamentally change formatting of many, many projects. So some kind of migration plan would be needed. I'm not entirely sure how that'd look yet. ### Notes (IMPORTANT) **This is not an issue for us to debate whether we should include the `/` or not.** If the prettier team is against printing void tags, this issue _and the related issue from 2018_ should be closed. This issue is specifically to spec out and define how we can solve this problem, so someone can hopefully contribute the code from the definition/requirements here.

Comments (0)

No comments yet. Start the discussion.

Comment on this issue