From 1ace7f4b7349e09d6adaa691e9499517575f74e7 Mon Sep 17 00:00:00 2001 From: Kevin Jahns Date: Mon, 7 May 2018 11:41:45 +0200 Subject: [PATCH] fix parentNode binding in case parent doesn't fire MO --- src/Bindings/DomBinding/domObserver.js | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/src/Bindings/DomBinding/domObserver.js b/src/Bindings/DomBinding/domObserver.js index 48929dfa..3c1b274d 100644 --- a/src/Bindings/DomBinding/domObserver.js +++ b/src/Bindings/DomBinding/domObserver.js @@ -90,21 +90,20 @@ export default function domObserver (mutations, _document) { mutations.forEach(mutation => { const dom = mutation.target const yxml = this.domToType.get(dom) - if (yxml === false || yxml === undefined || yxml.constructor === YXmlHook) { - // dom element is filtered - if (yxml === undefined) { // In case yxml is undefined, we double check if we forgot to bind the dom - console.error('Yjs DomBinding: Reconstructing DomBinding, please report how to reproduce this.') - let parent - let yParent - do { - parent = dom.parentNode - yParent = this.domToType.get(parent) - } while (yParent === undefined) - if (yParent !== false && yParent !== undefined && yParent.constructor !== YXmlHook) { - diffChildren.add(parent) - } + if (yxml === undefined) { // In case yxml is undefined, we double check if we forgot to bind the dom + let parent + let yParent + do { + parent = dom.parentNode + yParent = this.domToType.get(parent) + } while (yParent === undefined && parent !== null) + if (yParent !== false && yParent !== undefined && yParent.constructor !== YXmlHook) { + diffChildren.add(parent) } return + } else if (yxml === false || yxml.constructor === YXmlHook) { + // dom element is filtered / a dom hook + return } switch (mutation.type) { case 'characterData':