From c99f08785ddec7ef791492c0b1b6f6c26cb590fa Mon Sep 17 00:00:00 2001 From: Hugh Cayless Date: Thu, 29 Aug 2019 09:18:56 -0400 Subject: [PATCH] Fixes bug in behavior processing. When a behavior function returns undefined (i.e.) it mutates the DOM directly and doesn't return a new element to be appended, it was being double-processed because the element wasn;t being marked as processed initially. --- src/CETEI.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/CETEI.js b/src/CETEI.js index c4a4bd4..befee13 100644 --- a/src/CETEI.js +++ b/src/CETEI.js @@ -430,9 +430,11 @@ class CETEI { } else { let self = this; return function() { - let content = fn.call(self, this); - if (content && !self._childExists(this.firstElementChild, content.nodeName)) { - self._appendBasic(this, content); + if (!this.hasAttribute("data-processed")) { + let content = fn.call(self, this); + if (content && !self._childExists(this.firstElementChild, content.nodeName)) { + self._appendBasic(this, content); + } } } } @@ -632,7 +634,7 @@ class CETEI { str += "/>"; } } - + //TODO: Be smarter about skipping generated content with hidden original for (let node of Array.from(el.childNodes)) { switch (node.nodeType) { case Node.ELEMENT_NODE: