Skip to content

Commit

Permalink
Fixes bug in behavior processing.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
hcayless committed Aug 29, 2019
1 parent c3d8600 commit c99f087
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/CETEI.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
}
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit c99f087

Please sign in to comment.