Crash at initialization when element has no closest element having a dir HTML attribute
Author: lucasmirloupCreated Jun 18, 2026Updated Jun 25, 2026
Labelsconfirmed bug4.x
During the initialization of a Select2 element, if it has no closest element having a dir HTML attribute, this line crashes:
https://github.com/select2/select2/blob/e42c4732280876216e6871b3e51356b23ca0dcbb/src/js/select2/options.js#L37
with this error:
Uncaught TypeError: $e.closest(...).getAttribute is not a function
Thank you for all your work on Select2!
Source: select2/select2