-
Notifications
You must be signed in to change notification settings - Fork 7.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
\Dom\HTMLDocument querySelector attribute name is case sensitive in HTML #17802
Comments
Good find. It's of course more complex in the spec than one would hope... Relevant part of spec: https://html.spec.whatwg.org/#case-sensitivity-of-selectors Basically, the CSS selector attribute name must be converted to lowercase in HTML elements, and then compared case-sensitive to the attribute name in the element... Also likely an issue in upstream Lexbor as the CSS selector code was adapted from there... |
…se sensitive in HTML According to https://html.spec.whatwg.org/#case-sensitivity-of-selectors, the CSS selector attribute name must be converted to lowercase in HTML elements, and then compared case-sensitive to the attribute name in the element. We implement this not by doing the explicit conversion, but by a manual loop using a function that first converts the rhs characters to lowercase and keeps the lhs characters the same, achieving the same effect.
thanks for working on a fix. Not sure if I understood correctly what you said, but does your fix also work for this ? $text = <<<TEXT
<html>
<head>
<meta charset="Windows-1252">
</head>
<body>
</body>
</html>
TEXT;
$dom = \Dom\HTMLDocument::createFromString($text, options: LIBXML_NOERROR);
var_dump($dom->querySelector('meta[charseT="windows-1252"]')); |
Ah great, even more exceptions to the rule 🤔
|
Should be good now |
* PHP-8.4: Fix lowercase HTML attribute exceptions Fix GH-17802: \Dom\HTMLDocument querySelector attribute name is case sensitive in HTML
Description
I don't see any mention on it on the different Dom rfc(the doc is incomplete), but querySelector/querySelectorAll are case sensitive on php, while on browsers like firefox, it is case insensitive
The following code:
Resulted in this output:
But I expected this output instead:
PHP Version
8.4.4
Operating System
No response
The text was updated successfully, but these errors were encountered: