diff --git a/plugins/removeEmptyContainers.js b/plugins/removeEmptyContainers.js
index 356a5835..6ef1aac3 100644
--- a/plugins/removeEmptyContainers.js
+++ b/plugins/removeEmptyContainers.js
@@ -25,8 +25,13 @@ var container = require('./_collections').elemsGroups.container;
* @author Kir Belevich
*/
exports.fn = function(item) {
-
- return !(item.isElem(container) && !item.isElem('svg') && item.isEmpty() &&
- (!item.isElem('pattern') || !item.hasAttrLocal('href')));
-
+ return (
+ item.isElem(container) === false ||
+ item.isEmpty() === false ||
+ item.isElem('svg') ||
+ (item.isElem('pattern') && item.hasAttrLocal('href')) ||
+ // The 'g' may not have content, but the filter may cause a rectangle
+ // to be created and filled with pattern.
+ (item.isElem('g') && item.hasAttr('filter'))
+ );
};
diff --git a/test/plugins/removeEmptyContainers.04.svg b/test/plugins/removeEmptyContainers.04.svg
new file mode 100644
index 00000000..fa1698cd
--- /dev/null
+++ b/test/plugins/removeEmptyContainers.04.svg
@@ -0,0 +1,23 @@
+
+
+@@@
+
+