misc cleaned up sanitize inconsistent indentation
git-svn-id: http://svg-edit.googlecode.com/svn/trunk@2469 eee81c28-f429-11dd-99c0-75d572ba1dddmaster
parent
71586aa5fe
commit
2c1c5da6de
|
@ -118,12 +118,13 @@ svgedit.sanitize.sanitizeSvg = function(node) {
|
|||
// Trim whitespace
|
||||
node.nodeValue = node.nodeValue.replace(/^\s+|\s+$/g, '');
|
||||
// Remove if empty
|
||||
if(node.nodeValue.length == 0) node.parentNode.removeChild(node);
|
||||
if (node.nodeValue.length === 0) {
|
||||
node.parentNode.removeChild(node);
|
||||
}
|
||||
}
|
||||
|
||||
// We only care about element nodes.
|
||||
// Automatically return for all non-element nodes,
|
||||
// such as comments, etc.
|
||||
// Automatically return for all non-element nodes, such as comments, etc.
|
||||
if (node.nodeType != 1) { // 1 == ELEMENT_NODE
|
||||
return;
|
||||
}
|
||||
|
@ -131,16 +132,17 @@ svgedit.sanitize.sanitizeSvg = function(node) {
|
|||
var doc = node.ownerDocument;
|
||||
var parent = node.parentNode;
|
||||
// can parent ever be null here? I think the root node's parent is the document...
|
||||
if (!doc || !parent) return;
|
||||
if (!doc || !parent) {
|
||||
return;
|
||||
}
|
||||
|
||||
var allowedAttrs = svgWhiteList_[node.nodeName];
|
||||
var allowedAttrsNS = svgWhiteListNS_[node.nodeName];
|
||||
|
||||
// if this element is supported, sanitize it
|
||||
if (allowedAttrs != undefined) {
|
||||
|
||||
var se_attrs = [];
|
||||
if (typeof allowedAttrs !== 'undefined') {
|
||||
|
||||
var seAttrs = [];
|
||||
var i = node.attributes.length;
|
||||
while (i--) {
|
||||
// if the attribute is not in our whitelist, then remove it
|
||||
|
@ -157,8 +159,8 @@ svgedit.sanitize.sanitizeSvg = function(node) {
|
|||
// TODO(codedread): Programmatically add the se: attributes to the NS-aware whitelist.
|
||||
// Bypassing the whitelist to allow se: prefixes.
|
||||
// Is there a more appropriate way to do this?
|
||||
if(attrName.indexOf('se:') == 0) {
|
||||
se_attrs.push([attrName, attr.nodeValue]);
|
||||
if (attrName.indexOf('se:') === 0) {
|
||||
seAttrs.push([attrName, attr.nodeValue]);
|
||||
}
|
||||
node.removeAttributeNS(attrNsURI, attrLocalName);
|
||||
}
|
||||
|
@ -191,7 +193,7 @@ svgedit.sanitize.sanitizeSvg = function(node) {
|
|||
}
|
||||
}
|
||||
|
||||
$.each(se_attrs, function(i, attr) {
|
||||
$.each(seAttrs, function(i, attr) {
|
||||
node.setAttributeNS(NS.SE, attr[0], attr[1]);
|
||||
});
|
||||
|
||||
|
@ -248,9 +250,7 @@ svgedit.sanitize.sanitizeSvg = function(node) {
|
|||
// call sanitizeSvg on each of those children
|
||||
var i = children.length;
|
||||
while (i--) { svgedit.sanitize.sanitizeSvg(children[i]); }
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
})();
|
||||
|
||||
|
|
Loading…
Reference in New Issue