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:
Andrew Kaster 2024-09-30 17:52:30 -06:00 committed by Andreas Kling
parent b3f8d63372
commit 7aa0165fe7
Notes: github-actions[bot] 2024-10-01 09:05:13 +00:00
5 changed files with 63 additions and 0 deletions

View file

@ -2863,6 +2863,9 @@ void HTMLTokenizer::will_emit(HTMLToken& token)
auto is_start_or_end_tag = token.type() == HTMLToken::Type::StartTag || token.type() == HTMLToken::Type::EndTag;
token.set_end_position({}, nth_last_position(is_start_or_end_tag ? 1 : 0));
if (is_start_or_end_tag)
token.normalize_attributes();
}
bool HTMLTokenizer::current_end_tag_token_is_appropriate() const