-
-
Notifications
You must be signed in to change notification settings - Fork 9.8k
Closed
Labels
Description
Just a note/heads up for others that find themselves here...
I upgraded to v7.4.0-BETA1 - ran my unit tests, which worked in 7.3.x - and now they fail :)
Messages like:
Warning: DOMDocument::loadXML(): Failed to parse QName ':class' in Entity, line: 17 in /Users/phil/Sites/symfony-7.4-alpine-reproducer/vendor/symfony/dom-crawler/Crawler.php on line 1116
Warning: DOMDocument::loadXML(): error parsing attribute name in Entity, line: 21 in /Users/phil/Sites/symfony-7.4-alpine-reproducer/vendor/symfony/dom-crawler/Crawler.php on line 1116
A reproducer is here https://github.com/PhilETaylor/symfony-7.4-alpine-reproducer
I think this is a wont fix ...
Originally posted by @PhilETaylor in #61475 (comment)
Alpine JS is well known for not having valid HTML tags :( alpinejs/alpine#433
The Issue
PHP 8.4+ introduced a native HTML5 DOM parser. Symfony 7.4 automatically uses this native parser instead of the masterminds/html5 library.
However, the native parser is stricter about XML syntax and throws warnings when encountering Alpine.js shorthand attributes:
@click→error parsing attribute name:class→Failed to parse QName ':class'@keydown.enter→error parsing attribute name- Other Alpine.js shorthands → Various XML parsing errors
Why This Matters
In PHPUnit integration tests with failOnWarning="true":
- Test uses
KernelBrowserto request a page - Response contains HTML with Alpine.js attributes
- Symfony's
AbstractBrowserautomatically createsCrawlerfrom response - PHP 8.4's DOM parser emits warnings about Alpine.js attributes
- PHPUnit converts warnings → test failures ❌
garak, dmaicher and rynhndrcksn