From 5586334549a7612381d8d53481e7829ab9266683 Mon Sep 17 00:00:00 2001 From: Kevin Jahns Date: Tue, 19 Dec 2017 17:37:04 +0100 Subject: [PATCH] fix initial content in y-array --- src/Type/YArray.js | 8 ++++++-- src/Type/y-xml/YXmlHook.js | 5 +++++ src/Type/y-xml/utils.js | 2 +- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/Type/YArray.js b/src/Type/YArray.js index 37eb2c6c..da67de64 100644 --- a/src/Type/YArray.js +++ b/src/Type/YArray.js @@ -207,8 +207,12 @@ export default class YArray extends Type { prevJsonIns._content.push(c) } } - if (prevJsonIns !== null && y !== null) { - prevJsonIns._integrate(y) + if (prevJsonIns !== null) { + if (y !== null) { + prevJsonIns._integrate(y) + } else if (prevJsonIns._left === null) { + this._start = prevJsonIns + } } }) } diff --git a/src/Type/y-xml/YXmlHook.js b/src/Type/y-xml/YXmlHook.js index 86d28283..adef4368 100644 --- a/src/Type/y-xml/YXmlHook.js +++ b/src/Type/y-xml/YXmlHook.js @@ -24,6 +24,11 @@ export default class YXmlHook extends YMap { } return this._dom } + _unbindFromDom () { + this._dom._yxml = null + this._yxml = null + // TODO: cleanup hook? + } _fromBinary (y, decoder) { const missing = super._fromBinary(y, decoder) this.hookName = decoder.readVarString() diff --git a/src/Type/y-xml/utils.js b/src/Type/y-xml/utils.js index 984553ff..0e1b23d0 100644 --- a/src/Type/y-xml/utils.js +++ b/src/Type/y-xml/utils.js @@ -174,7 +174,7 @@ export function reflectChangesOnDom (events, _document) { // let anchorViewPosition = getAnchorViewPosition(yxml._scrollElement) if (yxml.constructor === YXmlText) { yxml._dom.nodeValue = yxml.toString() - } else { + } else if (event.attributesChanged !== undefined) { // update attributes event.attributesChanged.forEach(attributeName => { const value = yxml.getAttribute(attributeName)