Skip to content

Commit a7676a6

Browse files
committed
wip
1 parent 2ef92c9 commit a7676a6

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

packages/signals/signals/src/core/signal-generators/dom-gen/element-parser.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,8 @@ export const parseElement = (el: HTMLElement): AnyParsedElement => {
113113

114114
// This exists because of a bug in react-hook-form, where 'name', if used as the field registration name overrides the native element name value to reference itself.
115115
// This is a very weird scenario where a property was on the element, but not in the attributes map.
116-
// Only using this
117-
const getPropertyOrFallback = (prop: string): string | undefined => {
116+
// This probably only needs to be run on name, but running this on some other fields out of caution.
117+
const getSanitizedProp = (prop: string): string | undefined => {
118118
if (!(prop in el)) {
119119
return undefined
120120
}
@@ -126,15 +126,15 @@ export const parseElement = (el: HTMLElement): AnyParsedElement => {
126126
const base: ParsedElementBase = {
127127
attributes: parsedAttributes,
128128
classList: [...el.classList],
129-
id: getPropertyOrFallback('id') || '',
129+
id: getSanitizedProp('id') || '',
130130
labels,
131131
label: labels[0],
132-
name: getPropertyOrFallback('name'),
132+
name: getSanitizedProp('name'),
133133
nodeName: el.nodeName,
134134
tagName: el.tagName,
135-
title: getPropertyOrFallback('title') || '',
136-
type: getPropertyOrFallback('type'),
137-
value: getPropertyOrFallback('value'),
135+
title: getSanitizedProp('title') || '',
136+
type: getSanitizedProp('type'),
137+
value: getSanitizedProp('value'),
138138
textContent: (el.textContent && cleanText(el.textContent)) ?? undefined,
139139
innerText: (el.innerText && cleanText(el.innerText)) ?? undefined,
140140
describedBy: (describedBy && parseToLabel(describedBy)) ?? undefined,

0 commit comments

Comments
 (0)