1
0
mirror of https://github.com/svg/svgo.git synced 2025-08-01 18:46:52 +03:00

Process “foreignObject”: cleanup editors content and remove itself if is empty.

Remove doctype with entities.
Fixes #533
This commit is contained in:
GreLI
2016-04-24 21:29:01 +03:00
parent b35d828d49
commit 65efced355
4 changed files with 11 additions and 14 deletions

View File

@ -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'],

View File

@ -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;
};

View File

@ -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 &&