Skip to content
Myr

fix: Don't kebab case style property values (#1562)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

* fix: don't kebab case style property values * add a test and format * denoify and `denoify-ignore` ---------

authored by Connor White · committed by GitHub · parent 1ed9ce1 · Browse files · 3 files+13 added−5 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Trailers

  • Co-authored-by: Yusuke Wada <yusuke@kamawada.com>

Diff stats

3 files+13 added−5 removed

  • tests:+5 added−1 removed
  • other:+8 added−4 removed

3 files+13 added−5 removed

modified:deno_dist/jsx/index.ts+4 added-2 removed
114 unmodified lines
115 const v = props[key]116 // object to style strings117 if (key === 'style' && typeof v === 'object') {118 const styles = Object.keys(v)119 .map((k) => `${k}:${v[k]}`)119 .map((k) => {120 const property = k.replace(/[A-Z]/g, (match) => `-${match.toLowerCase()}`)121 return `${property}:${v[k]}`122 })123 .join(';')121 .replace(/[A-Z]/g, (match) => `-${match.toLowerCase()}`)124 buffer[0] += ` style="${styles}"`125 } else if (typeof v === 'string') {126 buffer[0] += ` ${key}="`127 escapeToBuffer(v, buffer)
151 unmodified lines
modified:src/jsx/index.test.tsx+5 added-1 removed
1// @denoify-ignore2/* eslint-disable @typescript-eslint/no-explicit-any */3import { html } from '../helper/html'4import { Hono } from '../hono'5// eslint-disable-next-line @typescript-eslint/no-unused-vars
299 unmodified lines
305 <h1306 style={{307 color: 'red',308 fontSize: 'small',309 fontFamily: 'Menlo, Consolas, DejaVu Sans Mono, monospace',310 }}311 >312 Hello313 </h1>314 )313 expect(template.toString()).toBe('<h1 style="color:red;font-size:small">Hello</h1>')315 expect(template.toString()).toBe(316 '<h1 style="color:red;font-size:small;font-family:Menlo, Consolas, DejaVu Sans Mono, monospace">Hello</h1>'317 )318 })319 it('should not convert the strings', () => {320 const template = <h1 style='color:red;font-size:small'>Hello</h1>321 expect(template.toString()).toBe('<h1 style="color:red;font-size:small">Hello</h1>')
171 unmodified lines
modified:src/jsx/index.ts+4 added-2 removed
114 unmodified lines
115 const v = props[key]116 // object to style strings117 if (key === 'style' && typeof v === 'object') {118 const styles = Object.keys(v)119 .map((k) => `${k}:${v[k]}`)119 .map((k) => {120 const property = k.replace(/[A-Z]/g, (match) => `-${match.toLowerCase()}`)121 return `${property}:${v[k]}`122 })123 .join(';')121 .replace(/[A-Z]/g, (match) => `-${match.toLowerCase()}`)124 buffer[0] += ` style="${styles}"`125 } else if (typeof v === 'string') {126 buffer[0] += ` ${key}="`127 escapeToBuffer(v, buffer)
151 unmodified lines