mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 23:50:19 +00:00
LibWeb: Remove FIXMe's for HTML attribute serialization steps
As far as I can tell all of these steps are just equivalent to using the qualified name. Add some tests which cover some of these cases, and remove the FIXME's.
This commit is contained in:
parent
96fc1741b5
commit
87a4a5b302
Notes:
sideshowbarker
2024-07-18 02:13:10 +09:00
Author: https://github.com/shannonbooth Commit: https://github.com/SerenityOS/serenity/commit/87a4a5b302 Pull-request: https://github.com/SerenityOS/serenity/pull/21880
3 changed files with 44 additions and 21 deletions
10
Tests/LibWeb/Text/expected/HTML/get-innerHTML.txt
Normal file
10
Tests/LibWeb/Text/expected/HTML/get-innerHTML.txt
Normal file
|
@ -0,0 +1,10 @@
|
|||
|
||||
<ol reversed="" xml:myattribute=""></ol>
|
||||
<ol xmlns:somename=""></ol>
|
||||
<svg xmlns="http://www.w3.org/2000/svg">
|
||||
<script xlink:href="test"></script>
|
||||
<script href="test"></script>
|
||||
<script id="script" madeup:thing="test" xmlns="5"></script>
|
||||
</svg>
|
||||
<label xml:lang="en-US" class="struct"></label>
|
||||
|
17
Tests/LibWeb/Text/input/HTML/get-innerHTML.html
Normal file
17
Tests/LibWeb/Text/input/HTML/get-innerHTML.html
Normal file
|
@ -0,0 +1,17 @@
|
|||
<div id="id1">
|
||||
<ol reversed xml:myattribute></ol>
|
||||
<ol xmlns:somename></ol>
|
||||
<svg xmlns="http://www.w3.org/2000/svg">
|
||||
<script xlink:href="test"></script>
|
||||
<script href="test"></script>
|
||||
<script id="script" madeup:thing="test"></script>
|
||||
</svg>
|
||||
<label xml:lang="en-US" class="struct"></label>
|
||||
</div>
|
||||
<script src="../include.js"></script>
|
||||
<script>
|
||||
test(() => {
|
||||
document.getElementById('script').setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns", "5");
|
||||
println(document.getElementById('id1').innerHTML);
|
||||
});
|
||||
</script>
|
|
@ -4303,33 +4303,29 @@ String HTMLParser::serialize_html_fragment(DOM::Node const& node)
|
|||
// 4. For each attribute that the element has, append a U+0020 SPACE character, the attribute's serialized name as described below, a U+003D EQUALS SIGN character (=),
|
||||
// a U+0022 QUOTATION MARK character ("), the attribute's value, escaped as described below in attribute mode, and a second U+0022 QUOTATION MARK character (").
|
||||
// NOTE: The order of attributes is implementation-defined. The only constraint is that the order must be stable.
|
||||
element.for_each_attribute([&](auto& name, auto& value) {
|
||||
element.for_each_attribute([&](auto const& attribute) {
|
||||
builder.append(' ');
|
||||
|
||||
// An attribute's serialized name for the purposes of the previous paragraph must be determined as follows:
|
||||
|
||||
// FIXME: -> If the attribute has no namespace:
|
||||
// The attribute's serialized name is the attribute's local name.
|
||||
// (We currently always do this)
|
||||
builder.append(name);
|
||||
|
||||
// FIXME: -> If the attribute is in the XML namespace:
|
||||
// The attribute's serialized name is the string "xml:" followed by the attribute's local name.
|
||||
|
||||
// FIXME: -> If the attribute is in the XMLNS namespace and the attribute's local name is xmlns:
|
||||
// The attribute's serialized name is the string "xmlns".
|
||||
|
||||
// FIXME: -> If the attribute is in the XMLNS namespace and the attribute's local name is not xmlns:
|
||||
// The attribute's serialized name is the string "xmlns:" followed by the attribute's local name.
|
||||
|
||||
// FIXME: -> If the attribute is in the XLink namespace:
|
||||
// The attribute's serialized name is the string "xlink:" followed by the attribute's local name.
|
||||
|
||||
// FIXME: -> If the attribute is in some other namespace:
|
||||
// The attribute's serialized name is the attribute's qualified name.
|
||||
// NOTE: As far as I can tell, these steps are equivalent to just using the qualified name.
|
||||
//
|
||||
// -> If the attribute has no namespace:
|
||||
// The attribute's serialized name is the attribute's local name.
|
||||
// -> If the attribute is in the XML namespace:
|
||||
// The attribute's serialized name is the string "xml:" followed by the attribute's local name.
|
||||
// -> If the attribute is in the XMLNS namespace and the attribute's local name is xmlns:
|
||||
// The attribute's serialized name is the string "xmlns".
|
||||
// -> If the attribute is in the XMLNS namespace and the attribute's local name is not xmlns:
|
||||
// The attribute's serialized name is the string "xmlns:" followed by the attribute's local name.
|
||||
// -> If the attribute is in the XLink namespace:
|
||||
// The attribute's serialized name is the string "xlink:" followed by the attribute's local name.
|
||||
// -> If the attribute is in some other namespace:
|
||||
// The attribute's serialized name is the attribute's qualified name.
|
||||
builder.append(attribute.name());
|
||||
|
||||
builder.append("=\""sv);
|
||||
builder.append(escape_string(value, AttributeMode::Yes));
|
||||
builder.append(escape_string(attribute.value(), AttributeMode::Yes));
|
||||
builder.append('"');
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in a new issue