Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Remove leading space: how'd that get there?
  • Loading branch information
dmsnell committed Feb 14, 2023
commit 6a3080c0c2dcac8252e5817eb2b3c8fc23e083e7
44 changes: 22 additions & 22 deletions src/wp-includes/html-api/class-wp-html-spec.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,27 @@

class WP_HTML_Spec {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❤️

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is something I've meant to create in the HTML processor branches I've been working in. the idea is to move utilities which related to HTML-defined terminology into here.

that would be:

  • is_void_element()
  • is_html_element()
  • is_format_element()
  • etc…

is_html_element() will be important for HTML parsing because foreign elements may be self-closing, but HTML elements may not be, and therefore we have to ignore the trailing / in something like an <img /> tag and look for a closing tag if it's not a void element, such as with <div /> (because while it looks like a self-closer it isn't), but <wp-self-closer /> is due to it being a foreign element.

/**
* @see https://html.spec.whatwg.org/#elements-2
*/
public static function is_void_element( $tag_name ) {
switch ( strtoupper( $tag_name ) ) {
case 'AREA':
case 'BASE':
case 'BR':
case 'COL':
case 'EMBED':
case 'HR':
case 'IMG':
case 'INPUT':
case 'LINK':
case 'META':
case 'SOURCE':
case 'TRACK':
case 'WBR':
return true;
* @see https://html.spec.whatwg.org/#elements-2
*/
public static function is_void_element( $tag_name ) {
switch ( strtoupper( $tag_name ) ) {
case 'AREA':
case 'BASE':
case 'BR':
case 'COL':
case 'EMBED':
case 'HR':
case 'IMG':
case 'INPUT':
case 'LINK':
case 'META':
case 'SOURCE':
case 'TRACK':
case 'WBR':
return true;

default:
return false;
}
}
default:
return false;
}
}
}