mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-06 15:58:39 +09:00
Issue #2225 - Implement Element.replaceChildren
This accounts for refactoring changes (e.g. avoids RemoveChild* changes). Partially based on https://bugzilla.mozilla.org/show_bug.cgi?id=1626015
This commit is contained in:
parent
a1f787fc8c
commit
ae50e9e01d
3 changed files with 37 additions and 0 deletions
|
|
@ -1963,6 +1963,40 @@ nsINode::Append(const Sequence<OwningNodeOrString>& aNodes,
|
|||
AppendChild(*node, aRv);
|
||||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#dom-parentnode-replacechildren
|
||||
void nsINode::ReplaceChildren(const Sequence<OwningNodeOrString>& aNodes,
|
||||
ErrorResult& aRv) {
|
||||
nsCOMPtr<nsIDocument> doc = OwnerDoc();
|
||||
nsCOMPtr<nsINode> node = ConvertNodesOrStringsIntoNode(aNodes, doc, aRv);
|
||||
if (aRv.Failed()) {
|
||||
return;
|
||||
}
|
||||
|
||||
EnsurePreInsertionValidity(*node, nullptr, aRv);
|
||||
if (aRv.Failed()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Needed when used in combination with contenteditable (maybe)
|
||||
mozAutoDocUpdate updateBatch(doc, UPDATE_CONTENT_MODEL, true);
|
||||
|
||||
nsAutoMutationBatch mb(this, true, false);
|
||||
|
||||
// Replace all with node within this.
|
||||
while (mFirstChild) {
|
||||
int32_t index = IndexOf(mFirstChild);
|
||||
if (index == -1) {
|
||||
NS_ASSERTION(index != -1, "First child must have an index");
|
||||
return;
|
||||
}
|
||||
RemoveChildAt(index, true);
|
||||
}
|
||||
mb.RemovalDone();
|
||||
|
||||
AppendChild(*node, aRv);
|
||||
mb.NodesAdded();
|
||||
}
|
||||
|
||||
void
|
||||
nsINode::doRemoveChildAt(uint32_t aIndex, bool aNotify,
|
||||
nsIContent* aKid, nsAttrAndChildArray& aChildArray)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue