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

Function htmlAttributesToString

packages/serializer/src/utils/dom.ts:23–33  ·  view source on GitHub ↗
(attributes: Record<string, any>)

Source from the content-addressed store, hash-verified

21 * React.HTMLAttributes<HTMLElement> 转换为 attributes 字符串
22 */
23export const htmlAttributesToString = (attributes: Record<string, any>): string => {
24 return Object.keys(attributes).reduce((accumulator, key) => {
25 // transform the key from camelCase to kebab-case
26 const attrKey = kebabCase(key)
27 // remove ' in value
28 const attrValue = String(attributes[key]).replace("'", '')
29 // build the result
30 // you can break the line, add indent for it if you need
31 return `${accumulator}${attrKey}="${attrValue}" `
32 }, '')
33}

Callers 1

createFunction · 0.90

Calls 2

kebabCaseFunction · 0.85
StringFunction · 0.85

Tested by

no test coverage detected