Compare commits
No commits in common. "cf238ae6442dd5507afe45ddf6a110cfbb750abe" and "02b74baa6f8eb745b6031682653b6a07ee318b8f" have entirely different histories.
cf238ae644
...
02b74baa6f
@ -23,15 +23,7 @@
|
|||||||
|
|
||||||
class CustomSelect {
|
class CustomSelect {
|
||||||
constructor(selectEl) {
|
constructor(selectEl) {
|
||||||
// Guard against double-wrapping. The ENHANCED symbol is per-element, but a
|
if (selectEl[ENHANCED]) return;
|
||||||
// re-render race (the app config form re-renders on every tab switch) could
|
|
||||||
// slip a second enhancement through and nest a .custom-select inside another
|
|
||||||
// — showing the dropdown twice, one atop the other. The class + wrapper
|
|
||||||
// checks below survive that (they live on the DOM, not a JS symbol), so a
|
|
||||||
// select that's already enhanced or already inside a wrapper is never wrapped again.
|
|
||||||
if (selectEl[ENHANCED]
|
|
||||||
|| selectEl.classList.contains('custom-select-native')
|
|
||||||
|| selectEl.closest('.custom-select')) return;
|
|
||||||
selectEl[ENHANCED] = true;
|
selectEl[ENHANCED] = true;
|
||||||
this.select = selectEl;
|
this.select = selectEl;
|
||||||
this.build();
|
this.build();
|
||||||
@ -308,10 +300,6 @@
|
|||||||
function shouldEnhance(el) {
|
function shouldEnhance(el) {
|
||||||
if (!(el instanceof HTMLSelectElement)) return false;
|
if (!(el instanceof HTMLSelectElement)) return false;
|
||||||
if (el[ENHANCED]) return false;
|
if (el[ENHANCED]) return false;
|
||||||
// Already enhanced or already inside a wrapper — never nest a second widget
|
|
||||||
// (see the constructor). DOM-based so it survives a lost ENHANCED symbol.
|
|
||||||
if (el.classList.contains('custom-select-native')) return false;
|
|
||||||
if (el.closest('.custom-select')) return false;
|
|
||||||
if (el.multiple) return false; // multi-selects need different UX
|
if (el.multiple) return false; // multi-selects need different UX
|
||||||
if (el.hasAttribute('data-no-enhance')) return false;
|
if (el.hasAttribute('data-no-enhance')) return false;
|
||||||
return ENHANCE_CLASSES.some(c => el.classList.contains(c));
|
return ENHANCE_CLASSES.some(c => el.classList.contains(c));
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user