Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Inherited
lang
attribute should be below the default in the chain
It was pointed out in #5468 that the `lang` attribute, when inherited from a parent element, was above the option set in the global default within the inheritance chain. While this makes sense because of how we inherit other properties, it does not make sense for the `lang` attribute. The inheritance chain for the `language` option has been adjusted to be the following: 1. The `lang` attribute on the original `<select>` element 2. The `data-language` attribute on the original `<select>` element (because of how `data-*` attribute resolution affects options) 3. The `language` option specified when initiailizing Select2 4. The `language` Select2 default 5. The `lang` attribute on a parent of the `<select>` element While this is a breaking change, we believe that this change will have minimal to no impact on real-world usage of Select2, because of how the `lang` attribute is generally used within documents. We believe this will now make setting the default language through JavaScript easier and more reliable, bringing it in line with how we recommend it is done within the documentation. This was implemented through a new method `Defaults.applyFromElement` instead of within the old `Options.fromElement` method because it relies on the global defaults object. While we could have reached in to the internals in order to apply it appropriately, it made more sense to handle the proper resolution through a single consistent place. This was not implemented in the `Defaults.apply` method because that method is not typically passed in a reference to the original `<select>` element that it is applying the options for. Closes #5468
- Loading branch information