@barefootjs/shared 0.5.2 → 0.5.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dom-prop.d.ts +1 -1
- package/dist/index.js +2 -0
- package/package.json +1 -1
- package/src/__tests__/dom-prop.test.ts +7 -0
- package/src/dom-prop.ts +2 -0
package/dist/dom-prop.d.ts
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* @see https://github.com/piconic-ai/barefootjs/issues/1369
|
|
10
10
|
*/
|
|
11
11
|
export declare const BOOLEAN_ATTRS: ReadonlySet<string>;
|
|
12
|
-
export type DOMPropKind = 'skip' | 'ref' | 'event' | 'style' | 'property' | 'boolean' | 'attr';
|
|
12
|
+
export type DOMPropKind = 'skip' | 'ref' | 'event' | 'style' | 'property' | 'boolean' | 'attr' | 'innerHTML';
|
|
13
13
|
export interface DOMPropClassification {
|
|
14
14
|
kind: DOMPropKind;
|
|
15
15
|
/** HTML attribute name after JSX→DOM mapping (className→class, strokeWidth→stroke-width, etc.) */
|
package/dist/index.js
CHANGED
|
@@ -152,6 +152,8 @@ function classifyDOMProp(key) {
|
|
|
152
152
|
return { kind: "skip", attrName: key };
|
|
153
153
|
if (key === "ref")
|
|
154
154
|
return { kind: "ref", attrName: key };
|
|
155
|
+
if (key === "dangerouslySetInnerHTML")
|
|
156
|
+
return { kind: "innerHTML", attrName: key };
|
|
155
157
|
if (isEventProp(key))
|
|
156
158
|
return { kind: "event", attrName: key };
|
|
157
159
|
const attrName = toHTMLAttrNameRuntime(key);
|
package/package.json
CHANGED
|
@@ -10,6 +10,13 @@ describe('classifyDOMProp', () => {
|
|
|
10
10
|
expect(classifyDOMProp('ref')).toEqual({ kind: 'ref', attrName: 'ref' })
|
|
11
11
|
})
|
|
12
12
|
|
|
13
|
+
test('dangerouslySetInnerHTML → innerHTML', () => {
|
|
14
|
+
expect(classifyDOMProp('dangerouslySetInnerHTML')).toEqual({
|
|
15
|
+
kind: 'innerHTML',
|
|
16
|
+
attrName: 'dangerouslySetInnerHTML',
|
|
17
|
+
})
|
|
18
|
+
})
|
|
19
|
+
|
|
13
20
|
test('onClick → event', () => {
|
|
14
21
|
const c = classifyDOMProp('onClick')
|
|
15
22
|
expect(c.kind).toBe('event')
|
package/src/dom-prop.ts
CHANGED
|
@@ -110,6 +110,7 @@ export type DOMPropKind =
|
|
|
110
110
|
| 'property' // value, checked — must use DOM property, not setAttribute
|
|
111
111
|
| 'boolean' // disabled, hidden, … — presence/absence attribute
|
|
112
112
|
| 'attr' // regular setAttribute target
|
|
113
|
+
| 'innerHTML' // dangerouslySetInnerHTML — { __html } sets el.innerHTML, never an attribute
|
|
113
114
|
|
|
114
115
|
export interface DOMPropClassification {
|
|
115
116
|
kind: DOMPropKind
|
|
@@ -135,6 +136,7 @@ function isEventProp(key: string): boolean {
|
|
|
135
136
|
export function classifyDOMProp(key: string): DOMPropClassification {
|
|
136
137
|
if (key === 'children') return { kind: 'skip', attrName: key }
|
|
137
138
|
if (key === 'ref') return { kind: 'ref', attrName: key }
|
|
139
|
+
if (key === 'dangerouslySetInnerHTML') return { kind: 'innerHTML', attrName: key }
|
|
138
140
|
if (isEventProp(key)) return { kind: 'event', attrName: key }
|
|
139
141
|
|
|
140
142
|
const attrName = toHTMLAttrNameRuntime(key)
|