MCPcopy
hub / github.com/jsdom/jsdom / _replaceAll

Method _replaceAll

lib/jsdom/living/nodes/Node-impl.js:1045–1072  ·  view source on GitHub ↗
(nodeImpl)

Source from the content-addressed store, hash-verified

1043
1044 // https://dom.spec.whatwg.org/#concept-node-replace-all
1045 _replaceAll(nodeImpl) {
1046 if (nodeImpl !== null) {
1047 this._ownerDocument._adoptNode(nodeImpl);
1048 }
1049
1050 const removedNodesImpl = domSymbolTree.childrenToArray(this);
1051
1052 let addedNodesImpl;
1053 if (nodeImpl === null) {
1054 addedNodesImpl = [];
1055 } else if (nodeImpl.nodeType === NODE_TYPE.DOCUMENT_FRAGMENT_NODE) {
1056 addedNodesImpl = domSymbolTree.childrenToArray(nodeImpl);
1057 } else {
1058 addedNodesImpl = [nodeImpl];
1059 }
1060
1061 for (const childImpl of domSymbolTree.childrenIterator(this)) {
1062 this._remove(childImpl, true);
1063 }
1064
1065 if (nodeImpl !== null) {
1066 this._insert(nodeImpl, null, true);
1067 }
1068
1069 if (addedNodesImpl.length > 0 || removedNodesImpl.length > 0) {
1070 queueTreeMutationRecord(this, addedNodesImpl, removedNodesImpl, null, null);
1071 }
1072 }
1073
1074 // https://dom.spec.whatwg.org/#concept-node-pre-remove
1075 _preRemove(childImpl) {

Callers 3

textContentMethod · 0.95
innerHTMLMethod · 0.80
replaceChildrenMethod · 0.80

Calls 4

_removeMethod · 0.95
_insertMethod · 0.95
queueTreeMutationRecordFunction · 0.85
_adoptNodeMethod · 0.80

Tested by

no test coverage detected