Skip to content

Commit 1884210

Browse files
committed
Merge pull request #572 from lexich/gradient-fix
Fix: range outbound bug
2 parents 5d7eb63 + 01097c2 commit 1884210

File tree

4 files changed

+15
-5
lines changed

4 files changed

+15
-5
lines changed

lib/hacks/gradient.coffee

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,8 @@ class Gradient extends Value
5151
newDirection: (params) ->
5252
return params if params[0].value == 'to'
5353
return params unless isDirection.test(params[0].value)
54-
5554
params.unshift({ type: 'word', value: 'to' }, { type: 'space', value: ' ' })
56-
for i in [2..params.length]
55+
for i in [2...params.length]
5756
if params[i].type == 'div'
5857
break
5958
if params[i].type == 'word'
@@ -75,7 +74,7 @@ class Gradient extends Value
7574
# Replace `to top left` to `bottom right`
7675
fixDirection: (params) ->
7776
params.splice(0, 2)
78-
for i in [0..params.length]
77+
for i in [0...params.length]
7978
if params[i].type == 'div'
8079
break
8180
if params[i].type == 'word'
@@ -94,7 +93,7 @@ class Gradient extends Value
9493
first = params[0]
9594
second = []
9695

97-
for i in [4..params.length]
96+
for i in [4...params.length]
9897
if params[i].type == 'div'
9998
break
10099
else

test/autoprefixer.coffee

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ commons = ['transition', 'values', 'keyframes', 'gradient', 'flex-rewrite',
7878
'custom-prefix', 'cascade', 'double', 'multicolumn', '3d-transform',
7979
'background-size', 'supports', 'viewport', 'resolution', 'logical',
8080
'appearance', 'advanced-filter', 'element', 'image-set',
81-
'image-rendering', 'mask-border', 'writing-mode', 'cross-fade']
81+
'image-rendering', 'mask-border', 'writing-mode', 'cross-fade', 'gradient-fix']
8282

8383
describe 'autoprefixer()', ->
8484

@@ -117,6 +117,7 @@ describe 'Autoprefixer', ->
117117

118118
it 'removes unnecessary prefixes', ->
119119
for type in commons
120+
continue if type == 'gradient-fix'
120121
continue if type == 'cascade'
121122
continue if type == 'mistakes'
122123
continue if type == 'flex-rewrite'

test/cases/gradient-fix.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.test {
2+
background-image: -webkit-linear-gradient(yellow 50%, red 50%);
3+
background-image: linear-gradient(to , red 50%);
4+
}

test/cases/gradient-fix.out.css

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
.test {
2+
background-image: -webkit-linear-gradient(yellow 50%, red 50%);
3+
background-image: -webkit-linear-gradient(red 50%);
4+
background-image: -o-linear-gradient(red 50%);
5+
background-image: linear-gradient(to , red 50%);
6+
}

0 commit comments

Comments
 (0)