(offset, count, data)
| 65 | // https://dom.spec.whatwg.org/#dom-characterdata-replacedata |
| 66 | // https://dom.spec.whatwg.org/#concept-cd-replace |
| 67 | replaceData(offset, count, data) { |
| 68 | const { length } = this; |
| 69 | |
| 70 | if (offset > length) { |
| 71 | throw DOMException.create(this._globalObject, [ |
| 72 | "The index is not in the allowed range.", |
| 73 | "IndexSizeError" |
| 74 | ]); |
| 75 | } |
| 76 | |
| 77 | if (offset + count > length) { |
| 78 | count = length - offset; |
| 79 | } |
| 80 | |
| 81 | queueMutationRecord(MUTATION_TYPE.CHARACTER_DATA, this, null, null, this._data, [], [], null, null); |
| 82 | |
| 83 | const start = this._data.slice(0, offset); |
| 84 | const end = this._data.slice(offset + count); |
| 85 | this._data = start + data + end; |
| 86 | |
| 87 | for (const range of this._liveRanges()) { |
| 88 | const { _start, _end } = range; |
| 89 | |
| 90 | if (_start.node === this && _start.offset > offset && _start.offset <= offset + count) { |
| 91 | range._setLiveRangeStart(this, offset); |
| 92 | } |
| 93 | |
| 94 | if (_end.node === this && _end.offset > offset && _end.offset <= offset + count) { |
| 95 | range._setLiveRangeEnd(this, offset); |
| 96 | } |
| 97 | |
| 98 | if (_start.node === this && _start.offset > offset + count) { |
| 99 | range._setLiveRangeStart(this, _start.offset + data.length - count); |
| 100 | } |
| 101 | |
| 102 | if (_end.node === this && _end.offset > offset + count) { |
| 103 | range._setLiveRangeEnd(this, _end.offset + data.length - count); |
| 104 | } |
| 105 | } |
| 106 | |
| 107 | if (this.nodeType === TEXT_NODE && this.parentNode) { |
| 108 | this.parentNode._childTextContentChangeSteps(); |
| 109 | } |
| 110 | } |
| 111 | } |
| 112 | |
| 113 | mixin(CharacterDataImpl.prototype, NonDocumentTypeChildNodeImpl.prototype); |
no test coverage detected