mirror of
https://github.com/fergalmoran/ladybird.git
synced 2025-12-22 09:19:03 +00:00
LibWeb: Deduplicate attributes when emitting start and end tags
The HTML tokenizer specification says that we're supposed to do this when leaving the Attribute name or when emitting the token, as appropriate. Hopefully 'as appropriate' can mean only when emitting the token, as that's the easiest place to insert this logic without complicating the tokenizer any more.
This commit is contained in:
committed by
Andreas Kling
parent
b3f8d63372
commit
7aa0165fe7
@@ -0,0 +1,8 @@
|
||||
divs[0].id: fred
|
||||
divs[0].className: math
|
||||
divs[1].id: spaghetti
|
||||
divs[1].className:
|
||||
divs[2].getAttribute("grape"): foo
|
||||
divs[0].numAttributes: 2
|
||||
divs[1].numAttributes: 2
|
||||
divs[2].numAttributes: 1
|
||||
@@ -0,0 +1,21 @@
|
||||
<!DOCTYPE html>
|
||||
<script src="include.js"></script>
|
||||
<div id="fred"id="barney" class="math"></div>
|
||||
<div class class=1"foo" id="spaghetti" id></div>
|
||||
<div grape="foo" grape grape="bar" grape grape grape=baz></div>
|
||||
<script>
|
||||
test(() => {
|
||||
let divs = document.getElementsByTagName("div");
|
||||
|
||||
// Per the HTML spec, the first attribute wins.
|
||||
println(`divs[0].id: ${divs[0].id}`);
|
||||
println(`divs[0].className: ${divs[0].className}`);
|
||||
println(`divs[1].id: ${divs[1].id}`);
|
||||
println(`divs[1].className: ${divs[1].className}`);
|
||||
println(`divs[2].getAttribute("grape"): ${divs[2].getAttribute("grape")}`);
|
||||
|
||||
println(`divs[0].numAttributes: ${divs[0].attributes.length}`); // 2
|
||||
println(`divs[1].numAttributes: ${divs[1].attributes.length}`); // 2
|
||||
println(`divs[2].numAttributes: ${divs[2].attributes.length}`); // 1
|
||||
});
|
||||
</script>
|
||||
Reference in New Issue
Block a user