1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 13:48:12 +00:00

LibWeb: Add namespaces to Attribute selectors

For now, we parse these, but don't actually consider the namespace when
matching them. `DOM::Element` does not (yet) store attribute namespaces
so we can't check what they are.
This commit is contained in:
Sam Atkins 2023-08-08 16:19:20 +01:00 committed by Sam Atkins
parent 1858f06881
commit debf38ee9d
5 changed files with 51 additions and 36 deletions

View file

@ -155,10 +155,15 @@ ErrorOr<String> Selector::SimpleSelector::serialize() const
// 1. Append "[" (U+005B) to s.
TRY(s.try_append('['));
// FIXME: 2. If the namespace prefix maps to a namespace that is not the null namespace (not in a namespace) append the serialization of the namespace prefix as an identifier, followed by a "|" (U+007C) to s.
// 2. If the namespace prefix maps to a namespace that is not the null namespace (not in a namespace)
// append the serialization of the namespace prefix as an identifier, followed by a "|" (U+007C) to s.
if (attribute.qualified_name.namespace_type == QualifiedName::NamespaceType::Named) {
TRY(serialize_an_identifier(s, attribute.qualified_name.namespace_));
TRY(s.try_append('|'));
}
// 3. Append the serialization of the attribute name as an identifier to s.
TRY(serialize_an_identifier(s, attribute.name));
TRY(serialize_an_identifier(s, attribute.qualified_name.name.name));
// 4. If there is an attribute value specified, append "=", "~=", "|=", "^=", "$=", or "*=" as appropriate (depending on the type of attribute selector),
// followed by the serialization of the attribute value as a string, to s.