diff --git a/.changeset/fluffy-poets-happen.md b/.changeset/fluffy-poets-happen.md new file mode 100644 index 00000000..591f6ed5 --- /dev/null +++ b/.changeset/fluffy-poets-happen.md @@ -0,0 +1,5 @@ +--- +'preact-render-to-string': patch +--- + +Follow up fixes to #278 diff --git a/src/util.js b/src/util.js index bb761980..db59ed19 100644 --- a/src/util.js +++ b/src/util.js @@ -66,14 +66,15 @@ export function styleObjToCss(s) { (JS_TO_CSS[prop] = prop.replace(CSS_REGEX, '-$1').toLowerCase()); let suffix = ';'; - if (SUFFIX_CACHE[name]) { - suffix = 'px'; + let isNumber = typeof val === 'number'; + if (isNumber && SUFFIX_CACHE[name]) { + suffix = 'px;'; } else if ( - typeof val === 'number' && + isNumber && IS_NON_DIMENSIONAL.test(prop.toLowerCase()) === false ) { SUFFIX_CACHE[name] = true; - suffix = 'px'; + suffix = 'px;'; } str = str + name + ':' + val + suffix; }