Skip to content

Commit aa32526

Browse files
committed
Merge remote-tracking branch 'origin/master' into text-shadow
2 parents abebccd + 1c0abd2 commit aa32526

File tree

2 files changed

+26
-15
lines changed

2 files changed

+26
-15
lines changed

src/index.test.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -582,13 +582,27 @@ it('transforms text-decoration in different order', () =>
582582
textDecorationColor: 'red',
583583
}))
584584

585+
it('transforms text-decoration with ine in different order', () =>
586+
runTest([['text-decoration', 'line-through underline']], {
587+
textDecorationLine: 'underline line-through',
588+
textDecorationStyle: 'solid',
589+
textDecorationColor: 'black',
590+
}))
591+
585592
it('transforms text-decoration with none', () =>
586593
runTest([['text-decoration', 'none']], {
587594
textDecorationLine: 'none',
588595
textDecorationStyle: 'solid',
589596
textDecorationColor: 'black',
590597
}))
591598

599+
it('transforms text-decoration with none as part of multiple terms', () =>
600+
runTest([['text-decoration', 'yellow none']], {
601+
textDecorationLine: 'none',
602+
textDecorationStyle: 'solid',
603+
textDecorationColor: 'yellow',
604+
}))
605+
592606
it('does not transform text-decoration if multiple colors are used', () => {
593607
expect(() =>
594608
transformCss([['text-decoration', 'underline red yellow']])

src/transforms/textDecoration.js

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { regExpToken, tokens } from '../tokenTypes'
22

3-
const { NONE, SPACE, COLOR } = tokens
3+
const { SPACE, COLOR } = tokens
44

55
const STYLE = regExpToken(/^(solid|double|dotted|dashed)$/)
66
const LINE = regExpToken(/^(none|underline|line-through)$/)
@@ -14,30 +14,27 @@ module.exports = tokenStream => {
1414
let style
1515
let color
1616

17-
if (tokenStream.matches(NONE)) {
18-
tokenStream.expectEmpty()
19-
return {
20-
$merge: {
21-
textDecorationLine: defaultTextDecorationLine,
22-
textDecorationStyle: defaultTextDecorationStyle,
23-
textDecorationColor: defaultTextDecorationColor,
24-
},
25-
}
26-
}
27-
2817
let didParseFirst = false
2918
while (tokenStream.hasTokens()) {
3019
if (didParseFirst) tokenStream.expect(SPACE)
3120

3221
if (line === undefined && tokenStream.matches(LINE)) {
33-
line = tokenStream.lastValue
22+
const lines = [tokenStream.lastValue]
3423

3524
tokenStream.saveRewindPoint()
36-
if (tokenStream.matches(SPACE) && tokenStream.matches(LINE)) {
37-
line += ` ${tokenStream.lastValue}`
25+
if (
26+
lines[0] !== 'none' &&
27+
tokenStream.matches(SPACE) &&
28+
tokenStream.matches(LINE)
29+
) {
30+
lines.push(tokenStream.lastValue)
31+
// Underline comes before line-through
32+
lines.sort().reverse()
3833
} else {
3934
tokenStream.rewind()
4035
}
36+
37+
line = lines.join(' ')
4138
} else if (style === undefined && tokenStream.matches(STYLE)) {
4239
style = tokenStream.lastValue
4340
} else if (color === undefined && tokenStream.matches(COLOR)) {

0 commit comments

Comments
 (0)