Skip to content

Commit f999ed8

Browse files
authored
Remove modules deprecated in 4.0.0 (select2#5815)
* Remove legacy support for `<input />` tags This never actually really worked, and since we thought this commit was coming sooner, we never actually fixed it. Now we can just remove it and accept the fact that Select2 currently only works for `<select>` boxes, the things it advertises itself as being a replacement for. Closes select2#3294. * Removed tests for legacy features These features will be removed in upcoming commits. * Remove legacy support for `initSelection` * Remove legacy support for `query` * Remove old `select2/compat/matcher` module * Promote containerCss and dropdownCss to core plugins These were originally slate to be deprecated and removed during the 4.1.0 release, but it has been determined that they should still remain in the core. These will be stripped down to only the essentials before the 4.1.0 release, sincce we don't want to have to continue supporting another 6 options on top of the ones we already have. * Remove dropdownCss and adaptDropdownCssClass This removes the two options that were specific to the CSS for a dropdown. These two options were not well documented and as a result are not widely used. * dropdownCss - Allowed for custom CSS styles to be injected on the dropdown container. Had an undocumented feature where the CSS could be customized per element by passing in a function as the option. There is no immediate replacement for this option since Select2 will only allow custom CSS classes going forward. The best option is to create a new CSS class which covers the properties that were previously being injected. * adaptDropdownCssClass - Allowed for the CSS classes which were present on the original element to be cloned into the set of CSS classes which were on the dropdown container. This was only documented as a possible option but the rest of the documentation was left blank, probably because nobody knew what this did. Internally this was used to make the `:all:` helper function within the `dropdownCssClass` option. The suggested replacement for this is to change the CSS classes on the original element prior to initializing Select2, and to use the `:all:` helper to copy those classes over. The `:all:` helper will remain as a supported option going forward. * Remove containerCss and adaptContainerCssClass This removes the two options that were specific to the CSS for a selection container. These two options were not well documented and as a result are not widely used. * containerCss - Allowed for custom CSS styles to be injected on the selection container. Had an undocumented feature where the CSS could be customized per element by passing in a function as the option. There is no immediate replacement for this option since Select2 will only allow custom CSS classes going forward. The best option is to create a new CSS class which covers the properties that were previously being injected. * adaptContainerCssClass - Allowed for the CSS classes which were present on the original element to be cloned into the set of CSS classes which were on the selection container. This was only documented as a possible option but the rest of the documentation was left blank, probably because nobody knew what this did. Internally this was used to make the `:all:` helper function within the `containerCssClass` option. The suggested replacement for this is to change the CSS classes on the original element prior to initializing Select2, and to use the `:all:` helper to copy those classes over. The `:all:` helper will remain as a supported option going forward. * Updated list of options in docs Removed `adaptContainerCssClass`, `adaptDropdownCssClass`, `containerCss`, and `dropdownCss` which are now no longer supported with the promotion of `dropdownCssClass` and `selectionCssClass` to the core builds. Renamed `containerCssClass` to `selectionCssClass` to reflect the new name. Documented the `dir` option and pointed to the MDN documentation on the `dir` attribute. Removed `initSelection` and `query` which were used with the now-removed support of `<input />` tags. * Removed `amdBase` option Now that we are not dynamically loading in any modules for the full builds, we do not need the ability to override the AMD base path to search for these additional modules at. The `amdLanguageBase` option is still needed to handle dynamically loading in the additional lanugage files, though we acknowledge that nobody appears to be using this option. * Remove support for *CssClass being a function This was an undocumented feature that we are dropping to ease the the maintenance burden now that the `dropdownCssClass` and `selectionCssClass` options are being included in all builds. * Rename containerCssClass to selectionCssClass This should help alleviate much of the confusion that comes from people who used Select2 3.x and were used to these classes being injected at the container which wrapped the selection container instead of on the selection container itself. Now this makes it more clear what container these classes are being applied to. * Internally rename ContainerCSS to SelectionCSS * Clean up unused adapter logic for *CssClass * Simplify internal logic for copying CSS classes * Fixed issue copying classes with *CssClass We were lacking a test that verified that original classes were not copied unless `:all:` was actually specified.
1 parent 284f6bb commit f999ed8

22 files changed

Lines changed: 152 additions & 1039 deletions

Gruntfile.js

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,6 @@ module.exports = function (grunt) {
1212
fullIncludes = [
1313
'jquery',
1414

15-
'select2/compat/containerCss',
16-
'select2/compat/dropdownCss',
17-
18-
'select2/compat/initSelection',
19-
'select2/compat/inputData',
20-
'select2/compat/matcher',
21-
'select2/compat/query',
22-
2315
'select2/dropdown/attachContainer',
2416
'select2/dropdown/stopPropagation',
2517

docs/pages/03.configuration/01.options-api/docs.md

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,31 +4,24 @@ taxonomy:
44
category: docs
55
---
66

7-
This is a list of all the Select 2 configuration options.
7+
This is a list of all the Select2 configuration options.
88

9-
| Option | Type | Default | Description |
9+
| Option | Type | Default | Description |
1010
| ------ | ---- | ------- | ----------- |
11-
| `adaptContainerCssClass` | | | |
12-
| `adaptDropdownCssClass` | | | |
1311
| `ajax` | object | `null` | Provides support for [ajax data sources](/data-sources/ajax). |
1412
| `allowClear` | boolean | `false` | Provides support for [clearable selections](/selections#clearable-selections). |
15-
| `amdBase` | string | `./` | See [Using Select2 with AMD or CommonJS loaders](/builds-and-modules#using-select2-with-amd-or-commonjs-loaders). |
1613
| `amdLanguageBase` | string | `./i18n/` | See [Using Select2 with AMD or CommonJS loaders](/builds-and-modules#using-select2-with-amd-or-commonjs-loaders). |
1714
| `closeOnSelect` | boolean | `true` | Controls whether the dropdown is [closed after a selection is made](/dropdown#forcing-the-dropdown-to-remain-open-after-selection). |
18-
| `containerCss` | object | null | Adds custom CSS to the container. Expects key-value pairs: `{ 'css-property': 'value' }` |
19-
| `containerCssClass` | string | `''` | |
2015
| `data` | array of objects | `null` | Allows rendering dropdown options from an [array](/data-sources/arrays). |
2116
| `dataAdapter` | | `SelectAdapter` | Used to override the built-in [DataAdapter](/advanced/default-adapters/data). |
2217
| `debug` | boolean | `false` | Enable debugging messages in the browser console. |
23-
| `dir` | | |
18+
| `dir` | string | `ltr` | Sets the [`dir` attribute](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/dir) on the selection and dropdown containers to indicate the direction of the text. |
2419
| `disabled` | boolean | `false` | When set to `true`, the select control will be disabled. |
2520
| `dropdownAdapter` | | `DropdownAdapter` | Used to override the built-in [DropdownAdapter](/advanced/default-adapters/dropdown) |
2621
| `dropdownAutoWidth` | boolean | `false` | |
27-
| `dropdownCss` | object | null | Adds custom CSS to the dropdown. Expects key-value pairs: `{ 'css-property': 'value' }` |
28-
| `dropdownCssClass` | string | `''` | |
22+
| `dropdownCssClass` | string | `''` | Adds additional CSS classes to the dropdown container. The helper `:all:` can be used to add all CSS classes present on the original `<select>` element. |
2923
| `dropdownParent` | jQuery selector or DOM node | `$(document.body)` | Allows you to [customize placement](/dropdown#dropdown-placement) of the dropdown. |
3024
| `escapeMarkup` | callback | `Utils.escapeMarkup` | Handles [automatic escaping of content rendered by custom templates](/dropdown#built-in-escaping). |
31-
| `initSelection` | callback | | See [`initSelection`](/upgrading/migrating-from-35#removed-the-requirement-of-initselection). **This option was deprecated in Select2 v4.0, and will be removed in v4.1.** |
3225
| `language` | string or object | `EnglishTranslation` | Specify the [language used for Select2 messages](/i18n#message-translations). |
3326
| `matcher` | A callback taking search `params` and the `data` object. | | Handles custom [search matching](/searching#customizing-how-results-are-matched). |
3427
| `maximumInputLength` | integer | `0` | [Maximum number of characters](/searching#maximum-search-term-length) that may be provided for a search term. |
@@ -37,9 +30,9 @@ This is a list of all the Select 2 configuration options.
3730
| `minimumResultsForSearch` | integer | `0` | The minimum number of results required to [display the search box](/searching#limiting-display-of-the-search-box-to-large-result-sets). |
3831
| `multiple` | boolean | `false` | This option enables multi-select (pillbox) mode. Select2 will automatically map the value of the `multiple` HTML attribute to this option during initialization. |
3932
| `placeholder` | string or object | `null` | Specifies the [placeholder](/placeholders) for the control. |
40-
| `query` | A function taking `params` (including a `callback`) | `Query` | **This option was deprecated in Select2 v4.0, and will be removed in v4.1.** |
4133
| `resultsAdapter` | | `ResultsAdapter` | Used to override the built-in [ResultsAdapter](/advanced/default-adapters/results). |
4234
| `selectionAdapter` | | `SingleSelection` or `MultipleSelection`, depending on the value of `multiple`. | Used to override the built-in [SelectionAdapter](/advanced/default-adapters/selection). |
35+
| `selectionCssClass` | string | `''` | Adds additional CSS classes to the selection container. The helper `:all:` can be used to add all CSS classes present on the original `<select>` element. |
4336
| `selectOnClose` | boolean | `false` | Implements [automatic selection](/dropdown#automatic-selection) when the dropdown is closed. |
4437
| `sorter` | callback | | |
4538
| `tags` | boolean / array of objects | `false` | Used to enable [free text responses](/tagging). |

src/js/select2/compat/containerCss.js

Lines changed: 0 additions & 56 deletions
This file was deleted.

src/js/select2/compat/dropdownCss.js

Lines changed: 0 additions & 56 deletions
This file was deleted.

src/js/select2/compat/initSelection.js

Lines changed: 0 additions & 42 deletions
This file was deleted.

src/js/select2/compat/inputData.js

Lines changed: 0 additions & 128 deletions
This file was deleted.

src/js/select2/compat/matcher.js

Lines changed: 0 additions & 42 deletions
This file was deleted.

0 commit comments

Comments
 (0)