Repository navigation
Conversation
…ces. No test passed class_list() a class value with leading whitespace, only whitespace, a form feed or carriage return separator, or ASCII-like characters that are not separators. No class_list() test covered the attribute-value rules for legacy named character references without a trailing semicolon. Expected values match jsdom's classList for the same markup.
Cite #59209, which introduced class_list(). Drop the `¬-in` case, which repeats the legacy reference before hyphen case.
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
lancewillett
left a comment
There was a problem hiding this comment.
Reviewed the tests against the implementation and existing coverage, including the unit-tests audit. No blocking findings. The affected classes passed locally in randomized order on single site (585 tests) and multisite (585 tests); PHPCS and current CI pass.
AI review · gpt-6
Check leading and trailing whitespace, whitespace-only values, encoded separators, and character-reference boundaries in `class_list()`. Prevent empty class names and incorrect decoding from passing unnoticed. Developed in: #14300 Props jonsurrell. See #65819. git-svn-id: https://develop.svn.wordpress.org/trunk@64453 602fd350-edb4-49c9-b593-d223f7449a82
There was a problem hiding this comment.
🟢 Approval recommended
The test expectations match HTML attribute parsing rules, and no blocking issues were identified.
No open issues 🎉
What changed in this PR
Adds regression coverage for HTML API class_list() behavior ahead of the loop simplification in #8076.
Changes:
- Tests whitespace splitting, including encoded separators and non-separating characters.
- Tests character-reference decoding and duplicate class removal.
| File | Description |
|---|---|
| tests/phpunit/tests/html-api/wpHtmlTagProcessor.php | Adds a data-driven test covering class splitting and character references. |
Review effort: Balanced
|
PR #14300 landed in https://core.trac.wordpress.org/changeset/64453 |
Check leading and trailing whitespace, whitespace-only values, encoded separators, and character-reference boundaries in `class_list()`. Prevent empty class names and incorrect decoding from passing unnoticed. Developed in: WordPress/wordpress-develop#14300 Props jonsurrell. See #65819. Built from https://develop.svn.wordpress.org/trunk@64453 git-svn-id: http://core.svn.wordpress.org/trunk@63603 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Adds
class_list()tests for how a class attribute value is split and decoded. No existing test passesclass_list()orhas_class()a class value that starts with whitespace or contains only whitespace, so a change to the loop's leading-whitespace handling, such as #8076, could yield an empty class name without a test failing.The new cases cover:
class_list()reads the value); encoded spaces; vertical tab and no-break space, which are not separators.=or an ASCII alphanumeric.&-xgives&-x,&xstays&x, and¬instays¬inbecause only its prefix¬is a legacy name. Also names that require a semicolon, unknown names, and numeric references without a semicolon.Expected values match jsdom's
classListfor the same markup. The tests pass on trunk and on #8076; replacing #8076's initial whitespace skip with$at = 0fails four of them.This should land before #8076.
Trac ticket: https://core.trac.wordpress.org/ticket/65819
Use of AI Tools
AI assistance: Yes
Tool(s): Claude Code
Model(s): Claude Opus 5.5
Used for: Choosing cases, writing the tests, checking expected values against jsdom, and drafting this description.
This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.