Skip to content

Commit 1e61099

Browse files
author
shuaige.zsg
committed
Fix style values containing upper-case characters
1 parent e89bba4 commit 1e61099

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

src/utils/inlineStyleToObject.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@ export default function InlineStyleToObject(inlineStyle = '') {
2020
let [property, value] = stylePropertyValue
2121
.split(/^([^:]+):/)
2222
.filter((val, i) => i > 0)
23-
.map(item => item.trim().toLowerCase());
24-
23+
.map(item => item.trim());
2524
// if there is no value (i.e. no : in the style) then ignore it
2625
if (value === undefined) {
2726
return styleObject;
@@ -33,6 +32,7 @@ export default function InlineStyleToObject(inlineStyle = '') {
3332
// e.g. -ms-style-property = msStyleProperty
3433
// -webkit-style-property = WebkitStyleProperty
3534
property = property
35+
.toLowerCase()
3636
.replace(/^-ms-/, 'ms-')
3737
.replace(/-(.)/g, (_, character) => character.toUpperCase());
3838

test/unit/utils/inlineStyleToObject.spec.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,12 @@ describe('Testing `utils/inlineStyleToObject', () => {
4242
expect(inlineStyleToObject(inlineStyle)).toEqual(expectedStyleObject);
4343
});
4444

45+
it('should parse style values containing upper-case characters correctly', () => {
46+
const inlineStyle = 'background:url(https://test.com/IMAGE.png);';
47+
const expectedStyleObject = {
48+
background: 'url(https://test.com/IMAGE.png)',
49+
};
50+
expect(inlineStyleToObject(inlineStyle)).toEqual(expectedStyleObject);
51+
});
52+
4553
});

0 commit comments

Comments
 (0)