Skip to content

Commit e424f89

Browse files
committed
Implement case-insensitivity for text decoration
1 parent cf45ffc commit e424f89

File tree

4 files changed

+18
-4
lines changed

4 files changed

+18
-4
lines changed

src/index.test.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -620,6 +620,20 @@ it('transforms text-decoration with none as part of multiple terms', () =>
620620
textDecorationColor: 'yellow',
621621
}))
622622

623+
it('transforms text-decoration with none in capitals', () =>
624+
runTest([['text-decoration', 'yellow NONE']], {
625+
textDecorationLine: 'none',
626+
textDecorationStyle: 'solid',
627+
textDecorationColor: 'yellow',
628+
}))
629+
630+
it('transforms text-decoration with style in capitals', () =>
631+
runTest([['text-decoration', 'yellow UNDERLINE LINE-THROUGH']], {
632+
textDecorationLine: 'underline line-through',
633+
textDecorationStyle: 'solid',
634+
textDecorationColor: 'yellow',
635+
}))
636+
623637
it('does not transform text-decoration if multiple colors are used', () => {
624638
expect(() =>
625639
transformCss([['text-decoration', 'underline red yellow']])

src/tokenTypes.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,5 +67,5 @@ module.exports.tokens = {
6767
IDENT: regExpToken(identRe),
6868
STRING: matchString,
6969
COLOR: matchColor,
70-
LINE: regExpToken(/^(none|underline|line-through)$/),
70+
LINE: regExpToken(/^(none|underline|line-through)$/i),
7171
}

src/transforms/textDecoration.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,15 @@ module.exports = tokenStream => {
1818
if (didParseFirst) tokenStream.expect(SPACE)
1919

2020
if (line === undefined && tokenStream.matches(LINE)) {
21-
const lines = [tokenStream.lastValue]
21+
const lines = [tokenStream.lastValue.toLowerCase()]
2222

2323
tokenStream.saveRewindPoint()
2424
if (
2525
lines[0] !== 'none' &&
2626
tokenStream.matches(SPACE) &&
2727
tokenStream.matches(LINE)
2828
) {
29-
lines.push(tokenStream.lastValue)
29+
lines.push(tokenStream.lastValue.toLowerCase())
3030
// Underline comes before line-through
3131
lines.sort().reverse()
3232
} else {

src/transforms/textDecorationLine.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ module.exports = tokenStream => {
99
while (tokenStream.hasTokens()) {
1010
if (didParseFirst) tokenStream.expect(SPACE)
1111

12-
lines.push(tokenStream.expect(LINE))
12+
lines.push(tokenStream.expect(LINE).toLowerCase())
1313

1414
didParseFirst = true
1515
}

0 commit comments

Comments
 (0)