Skip to content

Commit 1a64a90

Browse files
committed
Fix style values containing upper-case characters
1 parent e89bba4 commit 1a64a90

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/utils/inlineStyleToObject.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +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());
23+
.map(item => item.trim());
2424

2525
// if there is no value (i.e. no : in the style) then ignore it
2626
if (value === undefined) {
@@ -33,6 +33,7 @@ export default function InlineStyleToObject(inlineStyle = '') {
3333
// e.g. -ms-style-property = msStyleProperty
3434
// -webkit-style-property = WebkitStyleProperty
3535
property = property
36+
.toLowerCase()
3637
.replace(/^-ms-/, 'ms-')
3738
.replace(/-(.)/g, (_, character) => character.toUpperCase());
3839

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)