1
1
'use strict' ;
2
2
3
3
const { computeStyle } = require ( '../lib/style.js' ) ;
4
+ const { pathElems } = require ( './_collections.js' ) ;
5
+ const { path2js, js2path, applyTransforms } = require ( './_path.js' ) ;
6
+ const { cleanupOutData } = require ( '../lib/svgo/tools' ) ;
4
7
5
8
exports . type = 'perItem' ;
6
9
@@ -30,17 +33,11 @@ exports.params = {
30
33
forceAbsolutePath : false ,
31
34
} ;
32
35
33
- var pathElems = require ( './_collections.js' ) . pathElems ,
34
- path2js = require ( './_path.js' ) . path2js ,
35
- js2path = require ( './_path.js' ) . js2path ,
36
- applyTransforms = require ( './_path.js' ) . applyTransforms ,
37
- cleanupOutData = require ( '../lib/svgo/tools' ) . cleanupOutData ,
38
- roundData ,
39
- precision ,
40
- error ,
41
- arcThreshold ,
42
- arcTolerance ,
43
- hasMarkerMid ;
36
+ let roundData ;
37
+ let precision ;
38
+ let error ;
39
+ let arcThreshold ;
40
+ let arcTolerance ;
44
41
45
42
/**
46
43
* Convert absolute Path to relative,
@@ -69,7 +66,7 @@ exports.fn = function (item, params) {
69
66
arcThreshold = params . makeArcs . threshold ;
70
67
arcTolerance = params . makeArcs . tolerance ;
71
68
}
72
- hasMarkerMid = item . hasAttr ( 'marker-mid' ) ;
69
+ const hasMarkerMid = computedStyle [ 'marker-mid' ] != null ;
73
70
74
71
const maybeHasStroke =
75
72
computedStyle . stroke &&
@@ -93,6 +90,7 @@ exports.fn = function (item, params) {
93
90
94
91
data = filters ( data , params , {
95
92
maybeHasStrokeAndLinecap,
93
+ hasMarkerMid,
96
94
} ) ;
97
95
98
96
if ( params . utilizeAbsolute ) {
@@ -256,7 +254,7 @@ function convertToRelative(path) {
256
254
* @param {Object } params plugin params
257
255
* @return {Array } output path data
258
256
*/
259
- function filters ( path , params , { maybeHasStrokeAndLinecap } ) {
257
+ function filters ( path , params , { maybeHasStrokeAndLinecap, hasMarkerMid } ) {
260
258
var stringify = data2Path . bind ( null , params ) ,
261
259
relSubpoint = [ 0 , 0 ] ,
262
260
pathBase = [ 0 , 0 ] ,
@@ -499,7 +497,7 @@ function filters(path, params, { maybeHasStrokeAndLinecap }) {
499
497
// h 20 h 30 -> h 50
500
498
if (
501
499
params . collapseRepeated &&
502
- ! hasMarkerMid &&
500
+ hasMarkerMid === false &&
503
501
'mhv' . indexOf ( instruction ) > - 1 &&
504
502
prev . instruction &&
505
503
instruction == prev . instruction . toLowerCase ( ) &&
0 commit comments