More JSLint

git-svn-id: http://svg-edit.googlecode.com/svn/trunk@2642 eee81c28-f429-11dd-99c0-75d572ba1ddd
This commit is contained in:
Brett Zamir
2014-01-31 01:05:03 +00:00
parent 0df050aeb4
commit d12694f9fa
5 changed files with 111 additions and 83 deletions

View File

@@ -1,3 +1,5 @@
/*globals $, svgedit*/
/*jslint vars: true, eqeq: true*/
/**
* Package: svgedit.sanitize
*
@@ -12,7 +14,7 @@
// 2) browser.js
// 3) svgutils.js
(function() {
(function() {'use strict';
if (!svgedit.sanitize) {
svgedit.sanitize = {};
@@ -138,12 +140,12 @@ svgedit.sanitize.sanitizeSvg = function(node) {
var allowedAttrs = svgWhiteList_[node.nodeName];
var allowedAttrsNS = svgWhiteListNS_[node.nodeName];
var i;
// if this element is supported, sanitize it
if (typeof allowedAttrs !== 'undefined') {
var seAttrs = [];
var i = node.attributes.length;
i = node.attributes.length;
while (i--) {
// if the attribute is not in our whitelist, then remove it
// could use jQuery's inArray(), but I don't know if that's any better
@@ -173,6 +175,7 @@ svgedit.sanitize.sanitizeSvg = function(node) {
case 'patternTransform':
var val = attr.nodeValue.replace(/(\d)-/g, '$1 -');
node.setAttribute(attrName, val);
break;
}
}
@@ -202,8 +205,7 @@ svgedit.sanitize.sanitizeSvg = function(node) {
var href = svgedit.utilities.getHref(node);
if (href &&
['filter', 'linearGradient', 'pattern',
'radialGradient', 'textPath', 'use'].indexOf(node.nodeName) >= 0)
{
'radialGradient', 'textPath', 'use'].indexOf(node.nodeName) >= 0) {
// TODO: we simply check if the first character is a #, is this bullet-proof?
if (href[0] != '#') {
// remove the attribute (but keep the element)
@@ -248,9 +250,9 @@ svgedit.sanitize.sanitizeSvg = function(node) {
parent.removeChild(node);
// call sanitizeSvg on each of those children
var i = children.length;
i = children.length;
while (i--) { svgedit.sanitize.sanitizeSvg(children[i]); }
}
};
})();
}());