diff --git a/src/dom/parse.js b/src/dom/parse.js index b14acc6..b23493a 100644 --- a/src/dom/parse.js +++ b/src/dom/parse.js @@ -80,10 +80,15 @@ wysihtml5.dom.parse = (function() { var context = config.context || elementOrHtml.ownerDocument || document, fragment = context.createDocumentFragment(), isString = typeof(elementOrHtml) === "string", + clearInternals = false, element, newNode, firstChild; + if (config.clearInternals === true) { + clearInternals = true; + } + if (config.uneditableClass) { uneditableClass = config.uneditableClass; } @@ -96,7 +101,7 @@ wysihtml5.dom.parse = (function() { while (element.firstChild) { firstChild = element.firstChild; - newNode = _convert(firstChild, config.cleanUp); + newNode = _convert(firstChild, config.cleanUp, clearInternals); if (newNode) { fragment.appendChild(newNode); } @@ -114,7 +119,7 @@ wysihtml5.dom.parse = (function() { return isString ? wysihtml5.quirks.getCorrectInnerHTML(element) : element; } - function _convert(oldNode, cleanUp) { + function _convert(oldNode, cleanUp, clearInternals) { var oldNodeType = oldNode.nodeType, oldChilds = oldNode.childNodes, oldChildsLength = oldChilds.length, @@ -124,12 +129,14 @@ wysihtml5.dom.parse = (function() { newNode, newChild; + // Passes directly elemets with uneditable class if (uneditableClass && oldNodeType === 1 && wysihtml5.dom.hasClass(oldNode, uneditableClass)) { return oldNode; } - newNode = method && method(oldNode); + newNode = method && method(oldNode, clearInternals); + // Remove or unwrap node in case of return value null or false if (!newNode) { if (newNode === false) { // false defines that tag should be removed but contents should remain (unwrap) @@ -137,7 +144,7 @@ wysihtml5.dom.parse = (function() { for (i = oldChildsLength; i--;) { if (oldChilds[i]) { - newChild = _convert(oldChilds[i], cleanUp); + newChild = _convert(oldChilds[i], cleanUp, clearInternals); if (newChild) { if (oldChilds[i] === newChild) { i--; @@ -167,13 +174,15 @@ wysihtml5.dom.parse = (function() { } return fragment; } else { - return null; + // Remove + return null; } } + // Converts all childnodes for (i=0; i1").fire("beforecommand:composer"); that.triggerUndo(editor); - equal(editor.getValue(), "1"); + equal(editor.getValue(false, false), "1"); that.triggerRedo(editor); - equal(editor.getValue(), "1"); + equal(editor.getValue(false, false), "1"); that.triggerUndo(editor); that.triggerUndo(editor); - equal(editor.getValue(), "1"); + equal(editor.getValue(false, false), "1"); start(); });