autoprefixer icon indicating copy to clipboard operation
autoprefixer copied to clipboard

Bug in gradient.coffee, array out bounds

Open lexich opened this issue 11 years ago • 6 comments

https://github.com/postcss/autoprefixer/blob/master/lib/hacks/gradient.coffee#L78

# Replace `to top left` to `bottom right`
  fixDirection: (params) ->
    params.splice(0, 2)
    for i in [0..params.length - 1]  #!!!!!FIX
      if params[i].type == 'div'
        break
      if params[i].type == 'word'
        params[i].value = @revertDirection(params[i].value)

http://coffeescript.org/#try:params%20%3D%20%5B1%2C2%2C3%5D%0Afor%20i%20in%20%5B0..params.length%5D%0A%20%20console.log(%22PRINT%22%2C%20params%5Bi%5D)

Output:

PRINT 1
PRINT 2
PRINT 3
PRINT undefined

lexich avatar Nov 30 '15 11:11 lexich

for i in [0..params.length] → for i in [0...params.length] is nicer than adding - 1 :)

lydell avatar Nov 30 '15 11:11 lydell

@lydell Sorry but you write the same, but this bug crush my workflow

ERROR in ./~/css-loader?sourceMap!./~/postcss-loader!./~/sass-loader?outputStyle=expanded&includePaths[]=%2FUsers%2Flexich%2Fcode%2Favi%2F24slash6%2Fapp%2Fstyles&includePaths[]=%2FUsers%2Flexich%2Fcode%2Favi%2F24slash6%2Fbower_components!./bower_components/card/src/scss/card.scss
Module build failed: TypeError: Cannot read property 'type' of undefined
  at Gradient.fixDirection (.../node_modules/autoprefixer/lib/hacks/gradient.js:115:22)
.....

lexich avatar Nov 30 '15 11:11 lexich

@lexich No, I've added an extra . ;)

lydell avatar Nov 30 '15 12:11 lydell

Very tricky dots, didn't see :)

lexich avatar Nov 30 '15 12:11 lexich

Continue in #572

lexich avatar Nov 30 '15 13:11 lexich

Release in 6.1.2

ai avatar Nov 30 '15 19:11 ai