11'use strict' ;
22
33const { 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' ) ;
47
58exports . type = 'perItem' ;
69
@@ -30,17 +33,11 @@ exports.params = {
3033 forceAbsolutePath : false ,
3134} ;
3235
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 ;
4441
4542/**
4643 * Convert absolute Path to relative,
@@ -69,7 +66,7 @@ exports.fn = function (item, params) {
6966 arcThreshold = params . makeArcs . threshold ;
7067 arcTolerance = params . makeArcs . tolerance ;
7168 }
72- hasMarkerMid = item . hasAttr ( 'marker-mid' ) ;
69+ const hasMarkerMid = computedStyle [ 'marker-mid' ] != null ;
7370
7471 const maybeHasStroke =
7572 computedStyle . stroke &&
@@ -93,6 +90,7 @@ exports.fn = function (item, params) {
9390
9491 data = filters ( data , params , {
9592 maybeHasStrokeAndLinecap,
93+ hasMarkerMid,
9694 } ) ;
9795
9896 if ( params . utilizeAbsolute ) {
@@ -256,7 +254,7 @@ function convertToRelative(path) {
256254 * @param {Object } params plugin params
257255 * @return {Array } output path data
258256 */
259- function filters ( path , params , { maybeHasStrokeAndLinecap } ) {
257+ function filters ( path , params , { maybeHasStrokeAndLinecap, hasMarkerMid } ) {
260258 var stringify = data2Path . bind ( null , params ) ,
261259 relSubpoint = [ 0 , 0 ] ,
262260 pathBase = [ 0 , 0 ] ,
@@ -499,7 +497,7 @@ function filters(path, params, { maybeHasStrokeAndLinecap }) {
499497 // h 20 h 30 -> h 50
500498 if (
501499 params . collapseRepeated &&
502- ! hasMarkerMid &&
500+ hasMarkerMid === false &&
503501 'mhv' . indexOf ( instruction ) > - 1 &&
504502 prev . instruction &&
505503 instruction == prev . instruction . toLowerCase ( ) &&
0 commit comments