Skip to content

Commit abebccd

Browse files
committed
Revert change enforcing color to be defined for text/box shadows
1 parent ba73205 commit abebccd

File tree

3 files changed

+23
-23
lines changed

3 files changed

+23
-23
lines changed

src/index.test.js

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -489,6 +489,14 @@ it('transforms box-shadow without blur-radius', () =>
489489
shadowOpacity: 1,
490490
}))
491491

492+
it('transforms box-shadow without color', () =>
493+
runTest([['box-shadow', '10px 20px']], {
494+
shadowOffset: { width: 10, height: 20 },
495+
shadowRadius: 0,
496+
shadowColor: 'black',
497+
shadowOpacity: 1,
498+
}))
499+
492500
it('transforms box-shadow with rgb color', () =>
493501
runTest([['box-shadow', '10px 20px rgb(100, 100, 100)']], {
494502
shadowOffset: { width: 10, height: 20 },
@@ -524,24 +532,12 @@ it('transforms box-shadow with hsla color', () =>
524532
it('transforms box-shadow and throws if multiple colors are used', () => {
525533
expect(() =>
526534
transformCss([['box-shadow', '0 0 0 red yellow green blue']])
527-
).toThrow(
528-
'Failed to parse declaration "boxShadow: 0 0 0 red yellow green blue"'
529-
)
535+
).toThrow()
530536
})
531537

532538
it('transforms box-shadow enforces offset to be present', () => {
533-
expect(() => transformCss([['box-shadow', 'red']])).toThrow(
534-
'Failed to parse declaration "boxShadow: red"'
535-
)
536-
})
537-
538-
it('transforms box-shadow and enforces offset-x and offset-y', () => {
539-
expect(() => transformCss([['box-shadow', 'black']])).toThrow()
540-
expect(() => transformCss([['box-shadow', '10px black']])).toThrow()
541-
})
542-
543-
it('transforms box-shadow and enforces color', () => {
544-
expect(() => transformCss([['text-decoration', '10px 20px 30px']])).toThrow()
539+
expect(() => transformCss([['box-shadow', 'red']])).toThrow()
540+
expect(() => transformCss([['box-shadow', '10px red']])).toThrow()
545541
})
546542

547543
it('transforms text-decoration into text-decoration- properties', () =>

src/transforms/__tests__/textShadow.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,14 @@ it('textShadow omitting blur', () => {
1616
})
1717
})
1818

19+
it('textShadow omitting color', () => {
20+
expect(transformCss([['text-shadow', '10px 20px black']])).toEqual({
21+
textShadowOffset: { width: 10, height: 20 },
22+
textShadowRadius: 0,
23+
textShadowColor: 'black',
24+
})
25+
})
26+
1927
it('textShadow omitting blur, offset-y', () => {
2028
expect(transformCss([['text-shadow', '10px 20px red']])).toEqual({
2129
textShadowOffset: { width: 10, height: 20 },
@@ -28,7 +36,3 @@ it('textShadow enforces offset-x and offset-y', () => {
2836
expect(() => transformCss([['text-shadow', 'red']])).toThrow()
2937
expect(() => transformCss([['text-shadow', '10px red']])).toThrow()
3038
})
31-
32-
it('textShadow enforces color', () => {
33-
expect(() => transformCss([['text-shadow', '10px 20px']])).toThrow()
34-
})

src/transforms/util.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ module.exports.shadowOffsetFactory = () => tokenStream => {
8080
module.exports.parseShadow = tokenStream => {
8181
let offsetX
8282
let offsetY
83-
let radius = 0
83+
let radius
8484
let color
8585

8686
if (tokenStream.matches(NONE)) {
@@ -116,11 +116,11 @@ module.exports.parseShadow = tokenStream => {
116116
didParseFirst = true
117117
}
118118

119-
if (offsetX === undefined || color === undefined) tokenStream.throw()
119+
if (offsetX === undefined) tokenStream.throw()
120120

121121
return {
122122
offset: { width: offsetX, height: offsetY },
123-
radius,
124-
color,
123+
radius: radius !== undefined ? radius : 0,
124+
color: color !== undefined ? color : 'black',
125125
}
126126
}

0 commit comments

Comments
 (0)