mirror of
https://github.com/svg/svgo.git
synced 2025-08-06 04:22:39 +03:00
Process “foreignObject”: cleanup editors content and remove itself if is empty.
Remove doctype with entities. Fixes #533
This commit is contained in:
@@ -46,7 +46,7 @@ function perItem(data, plugins, reverse) {
|
|||||||
items.content = items.content.filter(function(item) {
|
items.content = items.content.filter(function(item) {
|
||||||
|
|
||||||
// reverse pass
|
// reverse pass
|
||||||
if (reverse && item.content && item.elem != 'foreignObject') {
|
if (reverse && item.content) {
|
||||||
monkeys(item);
|
monkeys(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -62,7 +62,7 @@ function perItem(data, plugins, reverse) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// direct pass
|
// direct pass
|
||||||
if (!reverse && item.content && item.elem != 'foreignObject') {
|
if (!reverse && item.content) {
|
||||||
monkeys(item);
|
monkeys(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -8,7 +8,7 @@ exports.elemsGroups = {
|
|||||||
structural: ['defs', 'g', 'svg', 'symbol', 'use'],
|
structural: ['defs', 'g', 'svg', 'symbol', 'use'],
|
||||||
paintServer: ['solidColor', 'linearGradient', 'radialGradient', 'meshGradient', 'pattern', 'hatch'],
|
paintServer: ['solidColor', 'linearGradient', 'radialGradient', 'meshGradient', 'pattern', 'hatch'],
|
||||||
nonRendering: ['linearGradient', 'radialGradient', 'pattern', 'clipPath', 'mask', 'marker', 'symbol', 'filter', 'solidColor'],
|
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'],
|
textContent: ['altGlyph', 'altGlyphDef', 'altGlyphItem', 'glyph', 'glyphRef', 'textPath', 'text', 'tref', 'tspan'],
|
||||||
textContentChild: ['altGlyph', 'textPath', 'tref', 'tspan'],
|
textContentChild: ['altGlyph', 'textPath', 'tref', 'tspan'],
|
||||||
lightSource: ['feDiffuseLighting', 'feSpecularLighting', 'feDistantLight', 'fePointLight', 'feSpotLight'],
|
lightSource: ['feDiffuseLighting', 'feSpecularLighting', 'feDistantLight', 'fePointLight', 'feSpotLight'],
|
||||||
|
@@ -33,10 +33,6 @@ exports.description = 'removes doctype declaration';
|
|||||||
*/
|
*/
|
||||||
exports.fn = function(item) {
|
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;
|
||||||
}
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@@ -120,7 +120,8 @@ exports.fn = function(item, params) {
|
|||||||
elems[elem].defaults[attr.name] === attr.value && (
|
elems[elem].defaults[attr.name] === attr.value && (
|
||||||
attrsInheritable.indexOf(attr.name) < 0 ||
|
attrsInheritable.indexOf(attr.name) < 0 ||
|
||||||
!item.parentNode.computedAttr(attr.name)
|
!item.parentNode.computedAttr(attr.name)
|
||||||
)) ||
|
)
|
||||||
|
) ||
|
||||||
// useless overrides
|
// useless overrides
|
||||||
(
|
(
|
||||||
params.uselessOverrides &&
|
params.uselessOverrides &&
|
||||||
|
Reference in New Issue
Block a user