Skip to content

Commit 1200644

Browse files
committed
simplify #475
1 parent 0a09194 commit 1200644

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

packages/core/src/fields/inputFields/AbstractInputField.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,8 @@ export abstract class AbstractInputField<
2929
this.plugin,
3030
this.getSvelteComponent(),
3131
value => {
32-
const mappedValue = this.mapValue(value);
33-
this.updateDataAttributes(value, mappedValue);
34-
this.notifySubscription(mappedValue);
32+
this.updateDataAttributes(value);
33+
this.notifySubscription(this.mapValue(value));
3534
},
3635
);
3736

@@ -134,10 +133,15 @@ export abstract class AbstractInputField<
134133
}
135134
}
136135

137-
private updateDataAttributes(internalValue: ComponentValueType, metadataValue: MetadataValueType): void {
136+
/**
137+
* Attaches the internal value to the mount target as a data attribute.
138+
* This way users can style the component based on the internal value.
139+
*
140+
* @param internalValue
141+
*/
142+
private updateDataAttributes(internalValue: ComponentValueType): void {
138143
if (this.mountTarget) {
139144
this.mountTarget.dataset.internalValue = JSON.stringify(internalValue);
140-
this.mountTarget.dataset.metadataValue = JSON.stringify(metadataValue);
141145
}
142146
}
143147

@@ -156,7 +160,7 @@ export abstract class AbstractInputField<
156160
// listener to update data attributes on the target element
157161
this.inputSignal.registerListener({
158162
callback: value => {
159-
this.updateDataAttributes(this.reverseMapValue(value), value);
163+
this.updateDataAttributes(this.reverseMapValue(value));
160164
},
161165
});
162166

0 commit comments

Comments
 (0)