fix several y-xml bugs
This commit is contained in:
parent
0ba97d78f8
commit
445dd3e0da
@ -87,16 +87,18 @@ export default class Item {
|
||||
return this._right
|
||||
}
|
||||
_delete (y, createDelete = true) {
|
||||
this._deleted = true
|
||||
y.ds.markDeleted(this._id, this._length)
|
||||
if (createDelete) {
|
||||
let del = new Delete()
|
||||
del._targetID = this._id
|
||||
del._length = this._length
|
||||
del._integrate(y, true)
|
||||
if (!this._deleted) {
|
||||
this._deleted = true
|
||||
y.ds.markDeleted(this._id, this._length)
|
||||
if (createDelete) {
|
||||
let del = new Delete()
|
||||
del._targetID = this._id
|
||||
del._length = this._length
|
||||
del._integrate(y, true)
|
||||
}
|
||||
transactionTypeChanged(y, this._parent, this._parentSub)
|
||||
y._transaction.deletedStructs.add(this)
|
||||
}
|
||||
transactionTypeChanged(y, this._parent, this._parentSub)
|
||||
y._transaction.deletedStructs.add(this)
|
||||
}
|
||||
/**
|
||||
* This is called right before this struct receives any children.
|
||||
|
@ -56,7 +56,7 @@ export default class YMap extends Type {
|
||||
this._transact(y => {
|
||||
const old = this._map.get(key) || null
|
||||
if (old !== null) {
|
||||
if (old instanceof ItemJSON && old._content[0] === value) {
|
||||
if (old.constructor === ItemJSON && !old._deleted && old._content[0] === value) {
|
||||
// Trying to overwrite with same value
|
||||
// break here
|
||||
return value
|
||||
|
@ -47,6 +47,11 @@ export default class YXmlElement extends YXmlFragment {
|
||||
return dom
|
||||
}
|
||||
}
|
||||
_bindToDom (dom, _document) {
|
||||
_document = _document || document
|
||||
this._dom = dom
|
||||
dom._yxml = this
|
||||
}
|
||||
_fromBinary (y, decoder) {
|
||||
const missing = super._fromBinary(y, decoder)
|
||||
this.nodeName = decoder.readVarString()
|
||||
|
@ -101,9 +101,11 @@ export default class YXmlFragment extends YArray {
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
}
|
||||
/*
|
||||
if (this._domObserver !== null) {
|
||||
this._domObserver.takeRecords()
|
||||
}
|
||||
*/
|
||||
token = true
|
||||
}
|
||||
}
|
||||
@ -216,9 +218,7 @@ export default class YXmlFragment extends YArray {
|
||||
_document = _document || document
|
||||
this._dom = dom
|
||||
dom._yxml = this
|
||||
// TODO: refine this..
|
||||
if ((this.constructor !== YXmlFragment && this._parent !== this._y) || this._parent === null) {
|
||||
// TODO: only top level YXmlFragment can bind. Also allow YXmlElements..
|
||||
if (this._parent === null) {
|
||||
return
|
||||
}
|
||||
this._y.on('beforeTransaction', beforeTransactionSelectionFixer)
|
||||
@ -320,6 +320,9 @@ export default class YXmlFragment extends YArray {
|
||||
}
|
||||
})
|
||||
for (let dom of diffChildren) {
|
||||
if (dom.yOnChildrenChanged !== undefined) {
|
||||
dom.yOnChildrenChanged()
|
||||
}
|
||||
if (dom._yxml != null && dom._yxml !== false) {
|
||||
applyChangesFromDom(dom)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user