@itenthusiasm/custom-elements 1.0.0 → 1.0.2
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.
|
@@ -1185,9 +1185,11 @@ class ComboboxField extends HTMLElement {
|
|
|
1185
1185
|
const mutation = mutations[i];
|
|
1186
1186
|
|
|
1187
1187
|
// Handle added nodes first. This keeps us from running redundant Deselect Logic if a newly-added node is `selected`.
|
|
1188
|
-
mutation.addedNodes.forEach((
|
|
1189
|
-
if (!(
|
|
1188
|
+
mutation.addedNodes.forEach((n, j) => {
|
|
1189
|
+
if (!(n instanceof ComboboxOption) && n instanceof Element) return n.parentNode?.removeChild(n);
|
|
1190
1190
|
|
|
1191
|
+
// TODO: TypeScript fails to derive the correct type from the above check. Open a GitHub Issue.
|
|
1192
|
+
const node = /** @type {ComboboxOption} */ (n);
|
|
1191
1193
|
if (node.defaultSelected) this.value = node.value;
|
|
1192
1194
|
else if (nullable && this.#value === null && j === 0) {
|
|
1193
1195
|
if (this.valueIs !== "clearable") this.value = node.value;
|
|
@@ -132,11 +132,19 @@ class ComboboxOption extends HTMLElement {
|
|
|
132
132
|
if (!this.#combobox) return;
|
|
133
133
|
const combobox = this.#combobox;
|
|
134
134
|
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
if (combobox.
|
|
138
|
-
if (
|
|
139
|
-
|
|
135
|
+
// Selection
|
|
136
|
+
if (this.selected) {
|
|
137
|
+
if (combobox.value !== this.value) combobox.value = this.value;
|
|
138
|
+
else if (this.value === "" && combobox.text.data !== this.label) combobox.text.data = this.label;
|
|
139
|
+
}
|
|
140
|
+
// Deslection
|
|
141
|
+
else {
|
|
142
|
+
if (combobox.value !== this.value) return;
|
|
143
|
+
|
|
144
|
+
if (combobox.text.data && combobox.acceptsValue(combobox.text.data)) {
|
|
145
|
+
if (combobox.value !== combobox.text.data) combobox.value = combobox.text.data;
|
|
146
|
+
} else if (combobox.acceptsValue("")) combobox.forceEmptyValue();
|
|
147
|
+
else combobox.formResetCallback();
|
|
140
148
|
}
|
|
141
149
|
}
|
|
142
150
|
}
|
package/package.json
CHANGED