Select2 now clears the internal ID when it is destroyed#5587
Merged
Conversation
This fixes a bug where if you cloned a Select2, the internal ID used for mapping elements (specifically the `<select>`) to the in-memory data store would be cloned as well, causing issues when you tried to initialize Select2 on the cloned element. This was because we did not properly clear all of the internal data and all of the internal attributes that Select2 uses when we destroyed it. The internal `data-select2-id` attribute was not being cleared, and this was the attribute being used for the internal mapping. Now we properly clear the `data-select2-id` attribute from the element when we call `RemoveData` on the element. This aligns with what we were trying to do, since we previously cleared out the internal store for that ID, and fixes the issue we were seeing when cloning. Fixes #5247
This was referenced Apr 8, 2020
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request includes a
The following changes were made
data-select2-idattribute whenRemoveDatais calledIf this is related to an existing ticket, include a link to it as well.
Fixes #5247