diff --git a/lib/svgo/plugins.js b/lib/svgo/plugins.js index dad3ace0..4e0308da 100644 --- a/lib/svgo/plugins.js +++ b/lib/svgo/plugins.js @@ -46,7 +46,7 @@ function perItem(data, plugins, reverse) { items.content = items.content.filter(function(item) { // reverse pass - if (reverse && item.content && item.elem != 'foreignObject') { + if (reverse && item.content) { monkeys(item); } @@ -62,7 +62,7 @@ function perItem(data, plugins, reverse) { } // direct pass - if (!reverse && item.content && item.elem != 'foreignObject') { + if (!reverse && item.content) { monkeys(item); } diff --git a/plugins/_collections.js b/plugins/_collections.js index 46f94bb1..e33695fd 100644 --- a/plugins/_collections.js +++ b/plugins/_collections.js @@ -8,7 +8,7 @@ exports.elemsGroups = { structural: ['defs', 'g', 'svg', 'symbol', 'use'], paintServer: ['solidColor', 'linearGradient', 'radialGradient', 'meshGradient', 'pattern', 'hatch'], nonRendering: ['linearGradient', 'radialGradient', 'pattern', 'clipPath', 'mask', 'marker', 'symbol', 'filter', 'solidColor'], - container: ['a', 'defs', 'g', 'marker', 'mask', 'missing-glyph', 'pattern', 'svg', 'switch', 'symbol'], + container: ['a', 'defs', 'g', 'marker', 'mask', 'missing-glyph', 'pattern', 'svg', 'switch', 'symbol', 'foreignObject'], textContent: ['altGlyph', 'altGlyphDef', 'altGlyphItem', 'glyph', 'glyphRef', 'textPath', 'text', 'tref', 'tspan'], textContentChild: ['altGlyph', 'textPath', 'tref', 'tspan'], lightSource: ['feDiffuseLighting', 'feSpecularLighting', 'feDistantLight', 'fePointLight', 'feSpotLight'], diff --git a/plugins/removeDoctype.js b/plugins/removeDoctype.js index da19adf0..8a6a10f0 100644 --- a/plugins/removeDoctype.js +++ b/plugins/removeDoctype.js @@ -33,10 +33,6 @@ exports.description = 'removes doctype declaration'; */ exports.fn = function(item) { - // remove doctype only if custom XML entities declaration block does not presents - // http://en.wikipedia.org/wiki/Document_Type_Definition#Entity_declarations - if (item.doctype && item.doctype.substr(-1) !== ']') { - return false; - } + return false; }; diff --git a/plugins/removeUnknownsAndDefaults.js b/plugins/removeUnknownsAndDefaults.js index c7130c84..11d7c3c8 100644 --- a/plugins/removeUnknownsAndDefaults.js +++ b/plugins/removeUnknownsAndDefaults.js @@ -36,7 +36,7 @@ for (var elem in elems) { if (groupDefaults) { elem.defaults = elem.defaults || {}; - for(var attrName in groupDefaults) { + for (var attrName in groupDefaults) { elem.defaults[attrName] = groupDefaults[attrName]; } } @@ -74,18 +74,18 @@ exports.fn = function(item, params) { if ( params.unknownContent && !item.isEmpty() && - elems[elem] && //make sure we know of this element before checking its children - elem !== 'foreignObject'//Don't check foreignObject + elems[elem] && // make sure we know of this element before checking its children + elem !== 'foreignObject' // Don't check foreignObject ) { item.content.forEach(function(content, i) { if ( content.isElem() && - !content.prefix && + !content.prefix && ( ( elems[elem].content && // Do we have a record of its permitted content? elems[elem].content.indexOf(content.elem) === -1 - ) || + ) || ( !elems[elem].content && // we dont know about its permitted content !elems[content.elem] // check that we know about the element at all @@ -120,7 +120,8 @@ exports.fn = function(item, params) { elems[elem].defaults[attr.name] === attr.value && ( attrsInheritable.indexOf(attr.name) < 0 || !item.parentNode.computedAttr(attr.name) - )) || + ) + ) || // useless overrides ( params.uselessOverrides &&