@@ -190,38 +190,6 @@ export const fn = (root, params) => {
190
190
}
191
191
}
192
192
193
- // Removes hidden elements
194
- // https://www.w3schools.com/cssref/pr_class_visibility.asp
195
- const computedStyle = computeStyle ( stylesheet , node ) ;
196
- if (
197
- isHidden &&
198
- computedStyle . visibility &&
199
- computedStyle . visibility . type === 'static' &&
200
- computedStyle . visibility . value === 'hidden' &&
201
- // keep if any descendant enables visibility
202
- querySelector ( node , '[visibility=visible]' ) == null
203
- ) {
204
- removeElement ( node , parentNode ) ;
205
- return ;
206
- }
207
-
208
- // display="none"
209
- //
210
- // https://www.w3.org/TR/SVG11/painting.html#DisplayProperty
211
- // "A value of display: none indicates that the given element
212
- // and its children shall not be rendered directly"
213
- if (
214
- displayNone &&
215
- computedStyle . display &&
216
- computedStyle . display . type === 'static' &&
217
- computedStyle . display . value === 'none' &&
218
- // markers with display: none still rendered
219
- node . name !== 'marker'
220
- ) {
221
- removeElement ( node , parentNode ) ;
222
- return ;
223
- }
224
-
225
193
// Circles with zero radius
226
194
//
227
195
// https://www.w3.org/TR/SVG11/shapes.html#CircleElementRAttribute
@@ -363,32 +331,6 @@ export const fn = (root, params) => {
363
331
return ;
364
332
}
365
333
366
- // Path with empty data
367
- //
368
- // https://www.w3.org/TR/SVG11/paths.html#DAttribute
369
- //
370
- // <path d=""/>
371
- if ( pathEmptyD && node . name === 'path' ) {
372
- if ( node . attributes . d == null ) {
373
- removeElement ( node , parentNode ) ;
374
- return ;
375
- }
376
- const pathData = parsePathData ( node . attributes . d ) ;
377
- if ( pathData . length === 0 ) {
378
- removeElement ( node , parentNode ) ;
379
- return ;
380
- }
381
- // keep single point paths for markers
382
- if (
383
- pathData . length === 1 &&
384
- computedStyle [ 'marker-start' ] == null &&
385
- computedStyle [ 'marker-end' ] == null
386
- ) {
387
- removeElement ( node , parentNode ) ;
388
- return ;
389
- }
390
- }
391
-
392
334
// Polyline with empty points
393
335
//
394
336
// https://www.w3.org/TR/SVG11/shapes.html#PolylineElementPointsAttribute
@@ -417,6 +359,64 @@ export const fn = (root, params) => {
417
359
return ;
418
360
}
419
361
362
+ // Removes hidden elements
363
+ // https://www.w3schools.com/cssref/pr_class_visibility.asp
364
+ const computedStyle = computeStyle ( stylesheet , node ) ;
365
+ if (
366
+ isHidden &&
367
+ computedStyle . visibility &&
368
+ computedStyle . visibility . type === 'static' &&
369
+ computedStyle . visibility . value === 'hidden' &&
370
+ // keep if any descendant enables visibility
371
+ querySelector ( node , '[visibility=visible]' ) == null
372
+ ) {
373
+ removeElement ( node , parentNode ) ;
374
+ return ;
375
+ }
376
+
377
+ // display="none"
378
+ //
379
+ // https://www.w3.org/TR/SVG11/painting.html#DisplayProperty
380
+ // "A value of display: none indicates that the given element
381
+ // and its children shall not be rendered directly"
382
+ if (
383
+ displayNone &&
384
+ computedStyle . display &&
385
+ computedStyle . display . type === 'static' &&
386
+ computedStyle . display . value === 'none' &&
387
+ // markers with display: none still rendered
388
+ node . name !== 'marker'
389
+ ) {
390
+ removeElement ( node , parentNode ) ;
391
+ return ;
392
+ }
393
+
394
+ // Path with empty data
395
+ //
396
+ // https://www.w3.org/TR/SVG11/paths.html#DAttribute
397
+ //
398
+ // <path d=""/>
399
+ if ( pathEmptyD && node . name === 'path' ) {
400
+ if ( node . attributes . d == null ) {
401
+ removeElement ( node , parentNode ) ;
402
+ return ;
403
+ }
404
+ const pathData = parsePathData ( node . attributes . d ) ;
405
+ if ( pathData . length === 0 ) {
406
+ removeElement ( node , parentNode ) ;
407
+ return ;
408
+ }
409
+ // keep single point paths for markers
410
+ if (
411
+ pathData . length === 1 &&
412
+ computedStyle [ 'marker-start' ] == null &&
413
+ computedStyle [ 'marker-end' ] == null
414
+ ) {
415
+ removeElement ( node , parentNode ) ;
416
+ return ;
417
+ }
418
+ }
419
+
420
420
for ( const [ name , value ] of Object . entries ( node . attributes ) ) {
421
421
const ids = findReferences ( name , value ) ;
422
422
0 commit comments