From 5c72d54309ec14ef3d16cd7e9fd2d658af7b5414 Mon Sep 17 00:00:00 2001 From: Garry Tan Date: Sun, 28 Jul 2013 17:56:28 -0700 Subject: [PATCH] fix check_attribute parser rule to only set attribute if already set --- src/dom/parse.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/dom/parse.js b/src/dom/parse.js index f7868f94..8e3fde1e 100644 --- a/src/dom/parse.js +++ b/src/dom/parse.js @@ -231,15 +231,18 @@ wysihtml5.dom.parse = (function() { attributes = wysihtml5.lang.object(setAttributes).clone(); } - if (checkAttributes) { + if (checkAttributes) { for (attributeName in checkAttributes) { method = attributeCheckMethods[checkAttributes[attributeName]]; if (!method) { continue; } - newAttributeValue = method(_getAttribute(oldNode, attributeName)); - if (typeof(newAttributeValue) === "string") { - attributes[attributeName] = newAttributeValue; + oldAttribute = _getAttribute(oldNode, attributeName); + if (oldAttribute) { + newAttributeValue = method(oldAttribute); + if (typeof(newAttributeValue) === "string") { + attributes[attributeName] = newAttributeValue; + } } } }