UNPKG

1.8 kBJavaScriptView Raw
1"use strict"
2Object.defineProperty(exports,"__esModule",{value:!0})
3exports.fn=exports.params=exports.description=exports.active=exports.type=exports.name=void 0
4exports.name="removeHiddenElems"
5exports.type="perItem"
6exports.active=!0
7exports.description="removes hidden elements (zero sized, with absent attributes)"
8exports.params={isHidden:!0,displayNone:!0,opacity0:!0,circleR0:!0,ellipseRX0:!0,ellipseRY0:!0,rectWidth0:!0,rectHeight0:!0,patternWidth0:!0,patternHeight0:!0,imageWidth0:!0,imageHeight0:!0,pathEmptyD:!0,polylineEmptyPoints:!0,polygonEmptyPoints:!0}
9const t=/M\s*(?:[-+]?(?:\d*\.\d+|\d+(?:\.|(?!\.)))([eE][-+]?\d+)?(?!\d)\s*,?\s*){2}\D*\d/i
10exports.fn=function(e,i){if(e.elem){if(i.isHidden&&e.hasAttr("visibility","hidden"))return!1
11if(i.displayNone&&e.hasAttr("display","none"))return!1
12if(i.opacity0&&e.hasAttr("opacity","0"))return!1
13if(i.circleR0&&e.isElem("circle")&&e.isEmpty()&&e.hasAttr("r","0"))return!1
14if(i.ellipseRX0&&e.isElem("ellipse")&&e.isEmpty()&&e.hasAttr("rx","0"))return!1
15if(i.ellipseRY0&&e.isElem("ellipse")&&e.isEmpty()&&e.hasAttr("ry","0"))return!1
16if(i.rectWidth0&&e.isElem("rect")&&e.isEmpty()&&e.hasAttr("width","0"))return!1
17if(i.rectHeight0&&i.rectWidth0&&e.isElem("rect")&&e.isEmpty()&&e.hasAttr("height","0"))return!1
18if(i.patternWidth0&&e.isElem("pattern")&&e.hasAttr("width","0"))return!1
19if(i.patternHeight0&&e.isElem("pattern")&&e.hasAttr("height","0"))return!1
20if(i.imageWidth0&&e.isElem("image")&&e.hasAttr("width","0"))return!1
21if(i.imageHeight0&&e.isElem("image")&&e.hasAttr("height","0"))return!1
22if(i.pathEmptyD&&e.isElem("path")&&(!e.hasAttr("d")||!t.test(e.attr("d").value)))return!1
23if(i.polylineEmptyPoints&&e.isElem("polyline")&&!e.hasAttr("points"))return!1
24if(i.polygonEmptyPoints&&e.isElem("polygon")&&!e.hasAttr("points"))return!1}}