This adds back the `dropdownAutoWidth` option, so the dropdown can
have a width that is automatically determined by the browser. This
works best for smaller dropdowns that contain options with large
amounts of text.
This closes https://github.com/select2/select2/issues/3103.
This closes https://github.com/select2/select2/pull/3113.
Signed-off-by: Kevin Brown <kevin@kevin-brown.com>
The old functionality where classes were directly copied to the
container can be done by setting `dropdownCssClass: ':all:'` when
initializing Select2.
This closes https://github.com/select2/select2/issues/2879.
This improves a regression added in b9b55cec44
that reduced performance for large number of options when using a
jQuery collection object to append multiple options instead of
using a bare array containing the jQuery elements.
As `$.fn.add` is only required for jQuery 1.7.x, we can use a
utility function that only falls back to it for that specific
version of jQuery, and uses `$.fn.append` with an array for all
other versions.
This closes https://github.com/select2/select2/issues/3230.
Since Select2 methods should not be called on an element where
Select2 has not yet been initialized, this raises an error when it
happens. This does not silence the original error, but it does
provide the user with some more context about why they are seeing
a TypeError.
This closes https://github.com/select2/select2/issues/3173.
We now check that the `abort` method actually exists before aborting
the request, as JSONP does not include the `abort` method because
a JSONP request technically cannot be aborted.
This closes https://github.com/select2/select2/issues/3217.
This adds back keyboard support, so you can now clear a selected
item using either the backspace or delete key. This only work when
the container is closed, to prevent issues with the selection being
clear while a user is searching.
This was a regression in accessibility from 3.x.
This closes https://github.com/select2/select2/issues/3224.
Slight performance hit as we are no longer using `qurySelectorAll`,
but it handles the situation a bit more cleanly and prevent future
issues with special characters.
This closes https://github.com/select2/select2/issues/3157.
This fixes the results display so they prefer the `selected`
property on objects over checking if the `id` matches the value of
the underlying select.
We only ignore the `selected` property if it is null, at that point
we compare against the `id` property.
This closes https://github.com/select2/select2/issues/3163.
This also fixes an issue where we were using the `full_name` for
the value instead of the `id` in the example, which technically
wasn't correct.
This closes https://github.com/select2/select2/issues/3148.
Now we can use relative paths in the calls to `require`, so those
using relative builds don't have to worry about modules not being
imported properly. This also makes it considerably easier in the
future when we look to cut down the build sizes and have a custom
builder, as we don't have to worry as much about the paths being
incorrect.
This fixes https://github.com/select2/select2/issues/3014 finally.
Now we do not have separate AMD builds, instead we use a UMD wrapper
to support both AMD and CommonJS environments along with the browser.
This has been tested with RequireJS and it correctly imports Select2
and hooks into jQuery.
This means that all builds will include the Almond AMD loader, but
this isn't that much of an issue when you consider the file sizes.
The loader is namespaced so RequireJS and other AMD builders don't
complain about `require` and `define` existing. This is also done
so AMD loaders don't conflict, as Select2's AMD loader should
operate independently of others.
There are now two layers of wrappers that are applied to files,
only one of which is used for the translation files. This allows
us to only load in the internal Select2 modules once, and in
general makes most things cleaner. These have also been pulled out
into individual JS files instead of being stored in JSON files,
allowing us to add comments and make things look readable.
Because we use a few hacks, these files are heavily commented as well.
This closes https://github.com/select2/select2/issues/2945.
This closes https://github.com/select2/select2/issues/2946.
This finally fixes and adds some integration tests to make sure
that `select2('data')` works as we are expecting. This also adds
tests for `select2('val')` and fixes undefined variable issues
that were spotted because of these tests.
We also no longer date stamp distribution builds.
This closes https://github.com/select2/select2/issues/3104.
This moves the clear icon to the top of the DOM from the bottom to
ensure that it is always visible on top of the selection.
This closes https://github.com/select2/select2/issues/3089.
We don't need to update the dates on these every time that grunt
is called. This gives it a much more basic banner that is similar
to the minified version.
As jQuery 1.7.2 is the lowest version of jQuery supported by Select2,
it makes sense to run the tests on it. For the most part, we can
assume that the newer versions of Select2 are backwards compatible
enough such that this isn't an issue.
The recommended version of jQuery to use is the latest though, which
is why the jQuery file is only included in the tests.
This revealed a few issues with our data fallbacks and `.append`
functionality that was introduced in jQuery 1.8.
This strips whitespace in tags by default, so multiple tags cannot
be created with only whitespace as the difference in the id.
A test has been added to ensure that this remains fixed in the future.
This closes https://github.com/select2/select2/issues/3076.
This fixes an issue with `select2('data')` that caused it to not
work as intended. Because we were using `Select2.data` for the
data adapter, it was overriding the `Select2.data()` method which
was supposed to be used.
This just renames the `Select2.data` property to
`Select2.dataAdapter` to prevent the naming collision.
This closes https://github.com/select2/select2/issues/3104.
This fixes an issue when using a `<select>` where the elements were
created with XHTML-encoded characters to prevent any injection, as
they would be double-encoded and display incorrectly.
When using a `<select>`, we can assume that the data has already
been encoded because any XSS will have already run before we get to
it. Because of this, we can just use `.text()` instead of `.html()`
to avoid any issues.
This also includes a test to ensure that this does not become an
issue in the future.
This closes https://github.com/select2/select2/issues/3115.
This fixes an issue where the dropdown would not automatically
open when something was typed in the search box on a multiple
select. This was most noticeable when the dropdown closed and
the search box was focused and the user started to type, as the
text would appear in the search box, queries would be sent out to
retrieve results, but the dropdown would not be opened to display
the results.
This also fixes an issue introduced in a recent commit where search
queries would be sent out twice on modern browsers that supported
both the `keyup` and `input` event. The `keyup` event is now
properly debounced for these browsers and the queries are only
going out once.
This closes https://github.com/select2/select2/issues/3036.