mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 05:27:43 +00:00
LibWeb: Make Range.setStart and Range.setEnd spec compliant
These functions are way more involved than simply setting their respective boundary points :^)
This commit is contained in:
parent
af3c866898
commit
46ce50f74e
6 changed files with 185 additions and 11 deletions
|
@ -973,4 +973,21 @@ String Node::debug_description() const
|
|||
return builder.to_string();
|
||||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#concept-node-length
|
||||
size_t Node::length() const
|
||||
{
|
||||
// 1. If node is a DocumentType or Attr node, then return 0.
|
||||
if (is_document_type() || is_attribute())
|
||||
return 0;
|
||||
|
||||
// 2. If node is a CharacterData node, then return node’s data’s length.
|
||||
if (is_character_data()) {
|
||||
auto* character_data_node = verify_cast<CharacterData>(this);
|
||||
return character_data_node->data().length();
|
||||
}
|
||||
|
||||
// 3. Return the number of node’s children.
|
||||
return child_count();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue