Skip to content
This repository was archived by the owner on Nov 9, 2021. It is now read-only.

Commit e414b1c

Browse files
authored
Merge pull request #5 from Dohxis/master
Fixed stringifyStyle() to replace all capital letters
2 parents f06614c + 86f907a commit e414b1c

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

src/toString.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@ function renderToString(vnode) {
77
var attrs = ""
88
for (var i in attrNames) {
99
var currentAttrName = attrNames[i]
10-
var content = currentAttrName == "style"
11-
? stringifyStyle(vnode.data[currentAttrName])
12-
: vnode.data[currentAttrName]
10+
var content =
11+
currentAttrName == "style"
12+
? stringifyStyle(vnode.data[currentAttrName])
13+
: vnode.data[currentAttrName]
1314

1415
attrs += " " + currentAttrName + '="' + content + '"'
1516
}
@@ -32,7 +33,10 @@ function stringifyStyle(style) {
3233
for (var i in properties) {
3334
var curProp = properties[i]
3435
inlineStyle +=
35-
curProp.replace(/[A-Z]/, "-$&").toLowerCase() + ":" + style[curProp] + ";"
36+
curProp.replace(/[A-Z]/g, "-$&").toLowerCase() +
37+
":" +
38+
style[curProp] +
39+
";"
3640
}
3741

3842
return inlineStyle

test/toString.test.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ test("style", () => {
4444
{
4545
vnode: createVNode({ data: { style: { backgroundColor: "papayawhip" } } }),
4646
html: `<div style="background-color:papayawhip;"></div>`
47+
},
48+
{
49+
vnode: createVNode({ data: { style: { backgroundColor: "papayawhip", borderTopLeftRadius: "10px" } } }),
50+
html: `<div style="background-color:papayawhip;border-top-left-radius:10px;"></div>`
4751
}
4852
])
4953
})

0 commit comments

Comments
 (0)