Skip to content

Commit

Permalink
Remove modules deprecated in 4.0.0 (select2#5815)
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
kevin-brown authored Apr 19, 2020
1 parent 284f6bb commit f999ed8
Show file tree
Hide file tree
Showing 22 changed files with 152 additions and 1,039 deletions.
8 changes: 0 additions & 8 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,6 @@ module.exports = function (grunt) {
fullIncludes = [
'jquery',

'select2/compat/containerCss',
'select2/compat/dropdownCss',

'select2/compat/initSelection',
'select2/compat/inputData',
'select2/compat/matcher',
'select2/compat/query',

'select2/dropdown/attachContainer',
'select2/dropdown/stopPropagation',

Expand Down
17 changes: 5 additions & 12 deletions docs/pages/03.configuration/01.options-api/docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,24 @@ taxonomy:
category: docs
---

This is a list of all the Select 2 configuration options.
This is a list of all the Select2 configuration options.

| Option | Type | Default | Description |
| Option | Type | Default | Description |
| ------ | ---- | ------- | ----------- |
| `adaptContainerCssClass` | | | |
| `adaptDropdownCssClass` | | | |
| `ajax` | object | `null` | Provides support for [ajax data sources](/data-sources/ajax). |
| `allowClear` | boolean | `false` | Provides support for [clearable selections](/selections#clearable-selections). |
| `amdBase` | string | `./` | See [Using Select2 with AMD or CommonJS loaders](/builds-and-modules#using-select2-with-amd-or-commonjs-loaders). |
| `amdLanguageBase` | string | `./i18n/` | See [Using Select2 with AMD or CommonJS loaders](/builds-and-modules#using-select2-with-amd-or-commonjs-loaders). |
| `closeOnSelect` | boolean | `true` | Controls whether the dropdown is [closed after a selection is made](/dropdown#forcing-the-dropdown-to-remain-open-after-selection). |
| `containerCss` | object | null | Adds custom CSS to the container. Expects key-value pairs: `{ 'css-property': 'value' }` |
| `containerCssClass` | string | `''` | |
| `data` | array of objects | `null` | Allows rendering dropdown options from an [array](/data-sources/arrays). |
| `dataAdapter` | | `SelectAdapter` | Used to override the built-in [DataAdapter](/advanced/default-adapters/data). |
| `debug` | boolean | `false` | Enable debugging messages in the browser console. |
| `dir` | | |
| `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. |
| `disabled` | boolean | `false` | When set to `true`, the select control will be disabled. |
| `dropdownAdapter` | | `DropdownAdapter` | Used to override the built-in [DropdownAdapter](/advanced/default-adapters/dropdown) |
| `dropdownAutoWidth` | boolean | `false` | |
| `dropdownCss` | object | null | Adds custom CSS to the dropdown. Expects key-value pairs: `{ 'css-property': 'value' }` |
| `dropdownCssClass` | string | `''` | |
| `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. |
| `dropdownParent` | jQuery selector or DOM node | `$(document.body)` | Allows you to [customize placement](/dropdown#dropdown-placement) of the dropdown. |
| `escapeMarkup` | callback | `Utils.escapeMarkup` | Handles [automatic escaping of content rendered by custom templates](/dropdown#built-in-escaping). |
| `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.** |
| `language` | string or object | `EnglishTranslation` | Specify the [language used for Select2 messages](/i18n#message-translations). |
| `matcher` | A callback taking search `params` and the `data` object. | | Handles custom [search matching](/searching#customizing-how-results-are-matched). |
| `maximumInputLength` | integer | `0` | [Maximum number of characters](/searching#maximum-search-term-length) that may be provided for a search term. |
Expand All @@ -37,9 +30,9 @@ This is a list of all the Select 2 configuration options.
| `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). |
| `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. |
| `placeholder` | string or object | `null` | Specifies the [placeholder](/placeholders) for the control. |
| `query` | A function taking `params` (including a `callback`) | `Query` | **This option was deprecated in Select2 v4.0, and will be removed in v4.1.** |
| `resultsAdapter` | | `ResultsAdapter` | Used to override the built-in [ResultsAdapter](/advanced/default-adapters/results). |
| `selectionAdapter` | | `SingleSelection` or `MultipleSelection`, depending on the value of `multiple`. | Used to override the built-in [SelectionAdapter](/advanced/default-adapters/selection). |
| `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. |
| `selectOnClose` | boolean | `false` | Implements [automatic selection](/dropdown#automatic-selection) when the dropdown is closed. |
| `sorter` | callback | | |
| `tags` | boolean / array of objects | `false` | Used to enable [free text responses](/tagging). |
Expand Down
56 changes: 0 additions & 56 deletions src/js/select2/compat/containerCss.js

This file was deleted.

56 changes: 0 additions & 56 deletions src/js/select2/compat/dropdownCss.js

This file was deleted.

42 changes: 0 additions & 42 deletions src/js/select2/compat/initSelection.js

This file was deleted.

128 changes: 0 additions & 128 deletions src/js/select2/compat/inputData.js

This file was deleted.

42 changes: 0 additions & 42 deletions src/js/select2/compat/matcher.js

This file was deleted.

Loading

0 comments on commit f999ed8

Please sign in to comment.