mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 02:37:36 +00:00
LibWeb: Use HTML-uppercased qualified name for the Element node name
For regular elements, this is just the qualified name. However, for HTML elements in HTML documents, it is the qualified name uppercased. This is used by jQuery to determine the document is an HTML document. Not having this made jQuery assume the document was XML, causing weird behaviour. To do this, an internal string of qualified name is created. This is to prevent constantly regenerating it. This is allowed by the spec. This is the same for the HTML-uppercased qualified name.
This commit is contained in:
parent
7c6c7ca542
commit
19731fc14c
3 changed files with 34 additions and 1 deletions
|
@ -17,16 +17,33 @@ public:
|
|||
, m_prefix(prefix)
|
||||
, m_namespace(namespace_)
|
||||
{
|
||||
make_internal_string();
|
||||
}
|
||||
|
||||
const FlyString& local_name() const { return m_local_name; }
|
||||
const FlyString& prefix() const { return m_prefix; }
|
||||
const FlyString& namespace_() const { return m_namespace; }
|
||||
|
||||
const String& as_string() const { return m_as_string; }
|
||||
|
||||
private:
|
||||
FlyString m_local_name;
|
||||
FlyString m_prefix;
|
||||
FlyString m_namespace;
|
||||
String m_as_string;
|
||||
|
||||
// https://dom.spec.whatwg.org/#concept-attribute-qualified-name
|
||||
// https://dom.spec.whatwg.org/#concept-element-qualified-name
|
||||
void make_internal_string()
|
||||
{
|
||||
// This is possible to do according to the spec: "User agents could have this as an internal slot as an optimization."
|
||||
if (m_prefix.is_null()) {
|
||||
m_as_string = m_local_name;
|
||||
return;
|
||||
}
|
||||
|
||||
m_as_string = String::formatted("{}:{}", m_prefix, m_local_name);
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue