* @param {Transaction} transaction
(transaction)
| 83 | * @param {Transaction} transaction |
| 84 | */ |
| 85 | delete (transaction) { |
| 86 | let item = this.type._start |
| 87 | while (item !== null) { |
| 88 | if (!item.deleted) { |
| 89 | item.delete(transaction) |
| 90 | } else if (!transaction.insertSet.hasId(item.id)) { |
| 91 | // This will be gc'd later and we want to merge it if possible |
| 92 | // We try to merge all deleted items after each transaction, |
| 93 | // but we have no knowledge about that this needs to be merged |
| 94 | // since it is not in transaction.ds. Hence we add it to transaction._mergeStructs |
| 95 | transaction._mergeStructs.push(item) |
| 96 | } |
| 97 | item = item.right |
| 98 | } |
| 99 | this.type._map.forEach(item => { |
| 100 | if (!item.deleted) { |
| 101 | item.delete(transaction) |
| 102 | } else if (!transaction.insertSet.hasId(item.id)) { |
| 103 | // same as above |
| 104 | transaction._mergeStructs.push(item) |
| 105 | } |
| 106 | }) |
| 107 | transaction.changed.delete(this.type) |
| 108 | } |
| 109 | |
| 110 | /** |
| 111 | * @param {Transaction} tr |