Make WordPress Core

Opened 5 months ago

Closed 5 months ago

Last modified 4 months ago

#61549 closed enhancement (fixed)

HTML API: Add "reset insertion mode appropriately"

Reported by: jonsurrell's profile jonsurrell Owned by: jonsurrell's profile jonsurrell
Milestone: 6.7 Priority: normal
Severity: normal Version:
Component: HTML API Keywords: has-patch has-unit-tests
Focuses: Cc:

Description

The HTML standard describes an algorithm to "reset the insertion mode appropriately" that will be necessary for the HTML API to support a number of different tags such as TABLE or SELECT.

An implementation should be added so that the HTML Processor can continue to add tag support.

Change History (13)

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


5 months ago
#1

  • Keywords has-patch has-unit-tests added

Add an implementation and tests for "reset the insertion mode appropriately".

This unblocks work to support more tags:

Trac ticket: https://core.trac.wordpress.org/ticket/61549

The HTML standard describes an algorithm to "reset the insertion mode appropriately" that will be necessary for the HTML API to support a number of different tags such as TABLE or SELECT.
An implementation should be added so that the HTML Processor can continue to add tag support.

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


5 months ago
#2

Trac ticket: Core-61549

As the HTML Processor starts to support other insertion modes outside of "IN BODY" it needs to be aware of those other modes. This patch introduces the missing insertion modes in preparation for adding that support.

Extracted as necessary prep work to the following more complete change: https://github.com/WordPress/wordpress-develop/pull/6020

Props @sirreal.

#3 @dmsnell
5 months ago

In 58631:

HTML API: Add missing insertion mode constants.

As the HTML Processor starts to support other insertion modes outside of
"IN BODY" it needs to be aware of those other modes. This patch
introduces the missing insertion modes in preparation for adding that
support.

Extracted as necessary prep work to the following more complete change:
https://github.com/WordPress/wordpress-develop/pull/6020

Props jonsurrell.
See #61549.

@dmsnell commented on PR #6020:


5 months ago
#5

@sirreal I've merged in trunk after adding the new insertion modes. I hope that's helpful, as it was clouding the diff for me.

@jonsurrell commented on PR #6020:


5 months ago
#7

At this point I feel pretty good about the implementation and whatever direction you want to take it.

@dmsnell I think you wanted to move it to the HTML Processor, that's fine with me. That's where I put it originally and only moved it so it was easily testable. I'm fine with removing the internals tests and moving the implementation 👍

@dmsnell commented on PR #6020:


5 months ago
#8

Noting that because of the inherent challenges in testing this change, we're going to lean on the existing html5lib test suite, and new tests introduced with additional tag support in order to verify the behavior of the implementation.

The challenge is that this is an internal implementation and it's difficult to ascertain what the tests should be verifying. The test cases are unclear, and testing it in isolation doesn't bear a direct impact on whether the HTML API is working properly or not.

Therefore in order to avoid accidentally encoding incorrect behaviors in a unit test suite on an internal details, and to avoid architecting our code around the ability to test such internal details, we're foregoing specific new tests for this code.

#9 @dmsnell
5 months ago

  • Resolution set to fixed
  • Status changed from assigned to closed

In 58656:

HTML API: Implement the _reset insertion mode appropriately_ algorithm.

In order to add support for the SELECT and TABLE tags in the HTML Processor, it
needs to implement the HTML algorithm named "reset the insertion mode
appropriately".

This patch implements that algorithm to unblock the additional tag support. The
algorithm resets the parsing mode after specific state changes in complicated
situations where alternative rules are in effect (such as rules governing how
the parser handles tags found within a TABLE element).

Developed in https://github.com/WordPress/wordpress-develop/pull/6020
Discussed in https://core.trac.wordpress.org/ticket/61549

Props dmsnell, jonsurrell.
Fixes #61549.

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


4 months ago
#11

  • Make the reset insertion mode appropriately method private.
  • Rename the method from reset_insertion_mode to reset_insertion_mode_appropriately to align with how it is referenced in the specification.

The reset_insertion_mode method was introduced in [58656]. The method's visibility was set to public, but it was never intended to be part of the public interface.

Trac ticket: https://core.trac.wordpress.org/ticket/61549

Follow-up to https://core.trac.wordpress.org/ticket/61549
Follow-up to [58656]

#12 @dmsnell
4 months ago

In 58898:

HTML API: Make "reset insertion mode appropriately" algorithm private.

The algorithm is described and referred to in the specification as
"reset the insertion mode appropriately." This patch renames it to
more accurately reflect the specification, and it turns the public
method private. As an internal algorithm from the HTML specification
it should not be open to extension.

Developed in https://github.com/wordpress/wordpress-develop/pull/7194
Discussed in https://core.trac.wordpress.org/ticket/61549

Follow-up to [28656].
Props jonsurrell.
See #61549.

Note: See TracTickets for help on using tickets.