Make WordPress Core

Opened 9 months ago

Closed 9 months ago

Last modified 9 months ago

#60390 closed enhancement (invalid)

HTML API: Indicate if a given tag name represents an HTML tag.

Reported by: dmsnell's profile dmsnell Owned by:
Milestone: Priority: normal
Severity: normal Version: 6.5
Component: HTML API Keywords:
Focuses: Cc:

Description

The HTML5 living specification defines three kinds of elements:

  • HTML elements.
  • Foreign elements, those which are part of MathML and SVG content.
  • Custom elements.

The HTML API should be able to indicate if a given tag name is possibly an HTML element or not, so that dependent functions can make appropriate decisions for self-closing elements.

HTML treats the self-closing flag differently for HTML and foreign elements. In HTML elements the flag is ignored, but in foreign content the flag indicates that the tag is self-closing or void. HTML itself does not contain self-closing elements; only some void elements.

Change History (3)

This ticket was mentioned in PR #5981 on WordPress/wordpress-develop by @dmsnell.


9 months ago
#1

  • Keywords has-patch added

Trac ticket: Core-60390

## Questions

  • How do we keep this list updated? Since HTML adds new tags…

## Description

The HTML5 living specification defines three kinds of elements:

  • HTML elements.
  • Foreign elements, those which are part of MathML and SVG content.
  • Custom elements.

The HTML API should be able to indicate if a given tag name is possibly an HTML element or not, so that dependent functions can make appropriate decisions for self-closing elements.

HTML treats the self-closing flag differently for HTML and foreign elements. In HTML elements the flag is ignored, but in foreign content the flag indicates that the tag is self-closing or void. HTML itself does not contain self-closing elements; only some void elements.

This patch introduces WP_HTML_Processor::is_html_tag( $tag_name ) to answer this question.

#2 @dmsnell
9 months ago

  • Keywords has-patch removed
  • Milestone Awaiting Review deleted
  • Resolution set to invalid
  • Status changed from new to closed

This may not be necessary; based on what I'm seeing in the spec, what matters isn't whether an element is an HTML element, but whether we're inside foreign content.

https://html.spec.whatwg.org/#parsing-main-inforeign

So maybe this shouldn't appear and instead we need to push ahead on supporting foreign content.

@dmsnell commented on PR #5981:


9 months ago
#3

This should be handled by the parsing rules for foreign content, and not by the tag name.

https://html.spec.whatwg.org/#parsing-main-inforeign

Note: See TracTickets for help on using tickets.