mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 18:27:35 +00:00
LibWeb: Implement CharacterData.{append,insert,delete}Data
This commit is contained in:
parent
af5b4ae1c4
commit
ee719870c8
3 changed files with 27 additions and 0 deletions
|
@ -103,4 +103,25 @@ ExceptionOr<void> CharacterData::replace_data(size_t offset, size_t count, Strin
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// https://dom.spec.whatwg.org/#dom-characterdata-appenddata
|
||||||
|
ExceptionOr<void> CharacterData::append_data(String const& data)
|
||||||
|
{
|
||||||
|
// The appendData(data) method steps are to replace data with node this, offset this’s length, count 0, and data data.
|
||||||
|
return replace_data(m_data.length(), 0, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
// https://dom.spec.whatwg.org/#dom-characterdata-insertdata
|
||||||
|
ExceptionOr<void> CharacterData::insert_data(size_t offset, String const& data)
|
||||||
|
{
|
||||||
|
// The insertData(offset, data) method steps are to replace data with node this, offset offset, count 0, and data data.
|
||||||
|
return replace_data(offset, 0, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
// https://dom.spec.whatwg.org/#dom-characterdata-deletedata
|
||||||
|
ExceptionOr<void> CharacterData::delete_data(size_t offset, size_t count)
|
||||||
|
{
|
||||||
|
// The deleteData(offset, count) method steps are to replace data with node this, offset offset, count count, and data the empty string.
|
||||||
|
return replace_data(offset, count, String::empty());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,6 +28,9 @@ public:
|
||||||
unsigned length() const { return m_data.length(); }
|
unsigned length() const { return m_data.length(); }
|
||||||
|
|
||||||
ExceptionOr<String> substring_data(size_t offset, size_t count) const;
|
ExceptionOr<String> substring_data(size_t offset, size_t count) const;
|
||||||
|
ExceptionOr<void> append_data(String const&);
|
||||||
|
ExceptionOr<void> insert_data(size_t offset, String const&);
|
||||||
|
ExceptionOr<void> delete_data(size_t offset, size_t count);
|
||||||
ExceptionOr<void> replace_data(size_t offset, size_t count, String const&);
|
ExceptionOr<void> replace_data(size_t offset, size_t count, String const&);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
|
@ -7,6 +7,9 @@ interface CharacterData : Node {
|
||||||
readonly attribute unsigned long length;
|
readonly attribute unsigned long length;
|
||||||
|
|
||||||
DOMString substringData(unsigned long offset, unsigned long count);
|
DOMString substringData(unsigned long offset, unsigned long count);
|
||||||
|
undefined appendData(DOMString data);
|
||||||
|
undefined insertData(unsigned long offset, DOMString data);
|
||||||
|
undefined deleteData(unsigned long offset, unsigned long count);
|
||||||
undefined replaceData(unsigned long offset, unsigned long count, DOMString data);
|
undefined replaceData(unsigned long offset, unsigned long count, DOMString data);
|
||||||
|
|
||||||
readonly attribute Element? nextElementSibling;
|
readonly attribute Element? nextElementSibling;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue