platypicker 1.0.8 → 1.0.9
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/package.json +4 -1
- package/src/platypicker.js +6 -5
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "platypicker",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.9",
|
|
4
4
|
"private": false,
|
|
5
5
|
"main": "dist/platypicker.min.js",
|
|
6
6
|
"files": [
|
|
@@ -11,6 +11,9 @@
|
|
|
11
11
|
"exports": {
|
|
12
12
|
".": "./dist/platypicker.min.js"
|
|
13
13
|
},
|
|
14
|
+
"dependencies": {
|
|
15
|
+
"bootstrap": "^5.3.8"
|
|
16
|
+
},
|
|
14
17
|
"devDependencies": {
|
|
15
18
|
"clean-css-cli": "^5.6.3",
|
|
16
19
|
"terser": "^5.46.0"
|
package/src/platypicker.js
CHANGED
|
@@ -173,15 +173,16 @@ export default class Platypicker {
|
|
|
173
173
|
}, true);
|
|
174
174
|
|
|
175
175
|
// Watch the select element's options for additions or removals, mirroring the structure every time.
|
|
176
|
-
this.#optionsChangeMutationObserver = new MutationObserver(() => {
|
|
176
|
+
this.#optionsChangeMutationObserver = new MutationObserver(Platypicker.#debounce(() => {
|
|
177
177
|
// If the options count has changed (added/removed options) or it has stayed the same, but some options
|
|
178
178
|
// have been swapped (detected by the custom selectMenuOption property), regenerate the list items.
|
|
179
179
|
// This helps to not needlessly regenerate every time the slightest change is made, or the options
|
|
180
180
|
// have been manually regenerated by calling the #setListItems() method.
|
|
181
|
-
if (this.#select.options.length !== this.#select.length ||
|
|
181
|
+
if (this.#select.options.length !== this.#select.length ||
|
|
182
|
+
[...this.#select.options].some(o => !o["option"]))
|
|
182
183
|
this.#setListItems();
|
|
183
|
-
});
|
|
184
|
-
this.#optionsChangeMutationObserver.observe(selectElement, { childList: true });
|
|
184
|
+
}, 100));
|
|
185
|
+
this.#optionsChangeMutationObserver.observe(selectElement, { childList: true, subtree: true });
|
|
185
186
|
|
|
186
187
|
Platypicker.#selects.set(this.#select, this);
|
|
187
188
|
}
|
|
@@ -447,7 +448,7 @@ export default class Platypicker {
|
|
|
447
448
|
}
|
|
448
449
|
}
|
|
449
450
|
|
|
450
|
-
|
|
451
|
+
destroy() {
|
|
451
452
|
if (!Platypicker.#selects.has(this.#select)) return;
|
|
452
453
|
|
|
453
454
|
this.#select.removeEventListener("change", this.#selectChangeListener);
|