Skip to content

Commit

Permalink
Prevent possible errors when uneditable is passed through in parser
Browse files Browse the repository at this point in the history
  • Loading branch information
Oliver Pulges committed Jun 16, 2014
1 parent 11751e1 commit 8e36a6e
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions src/dom/parse.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,12 @@ wysihtml5.dom.parse = (function() {
while (element.firstChild) {
firstChild = element.firstChild;
newNode = _convert(firstChild, config.cleanUp);
element.removeChild(firstChild);
if (newNode) {
fragment.appendChild(newNode);
}
if (firstChild !== newNode) {
element.removeChild(firstChild);
}
}

// Clear element contents
Expand Down Expand Up @@ -134,9 +136,11 @@ wysihtml5.dom.parse = (function() {
fragment = oldNode.ownerDocument.createDocumentFragment();

for (i = oldChildsLength; i--;) {
newChild = _convert(oldChilds[i], cleanUp);
if (newChild) {
fragment.insertBefore(newChild, fragment.firstChild);
if (oldChilds[i]) {
newChild = _convert(oldChilds[i], cleanUp);
if (newChild) {
fragment.insertBefore(newChild, fragment.firstChild);
}
}
}

Expand Down Expand Up @@ -165,9 +169,11 @@ wysihtml5.dom.parse = (function() {
}

for (i=0; i<oldChildsLength; i++) {
newChild = _convert(oldChilds[i], cleanUp);
if (newChild) {
newNode.appendChild(newChild);
if (oldChilds[i]) {
newChild = _convert(oldChilds[i], cleanUp);
if (newChild) {
newNode.appendChild(newChild);
}
}
}

Expand Down

0 comments on commit 8e36a6e

Please sign in to comment.