MCPcopy Index your code
hub / github.com/editablejs/editable / cssStyleToString

Function cssStyleToString

packages/serializer/src/utils/dom.ts:8–18  ·  view source on GitHub ↗
(style: Partial<CSSStyleDeclaration>)

Source from the content-addressed store, hash-verified

6 * CSSStyle 转换为 style 字符串
7 */
8export const cssStyleToString = (style: Partial<CSSStyleDeclaration>): string => {
9 return Object.keys(style).reduce((accumulator, key) => {
10 // transform the key from camelCase to kebab-case
11 const cssKey = kebabCase(key)
12 // remove ' in value
13 const cssValue = (style as Record<string, any>)[key].replace("'", '')
14 // build the result
15 // you can break the line, add indent for it if you need
16 return `${accumulator}${cssKey}:${cssValue};`
17 }, '')
18}
19
20/**
21 * React.HTMLAttributes<HTMLElement> 转换为 attributes 字符串

Callers 1

createFunction · 0.90

Calls 1

kebabCaseFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…