Change internal data ID generation to be more unique#5840
Merged
kevin-brown merged 1 commit intodevelopfrom Apr 26, 2020
Merged
Change internal data ID generation to be more unique#5840kevin-brown merged 1 commit intodevelopfrom
kevin-brown merged 1 commit intodevelopfrom
Conversation
This changes the internal generation of the ID used to uniquely identify an element to be more resistant to collisions. Previously it was an incremented integer or the exact ID used on the element, which for most cases was unique enough. Unfortunately if any elements used by Select2 also had an ID that was a low number, it was almost guaranteed to collide with an internal ID that Select2 generated. The internal generation now relies on a prefix when the ID already exists, similar to what we do with core IDs. It also uses a set of 4 random characters along with the incrementing ID to reduce the chance of collisions even further. It is definitely still possible for a collision to occur, especially if two elements exist but one has a prefix of `data-` already, but the chances have been greatly reduced. We'll accept it for now.
anttikuuskoski
pushed a commit
to anttikuuskoski/select2
that referenced
this pull request
Mar 29, 2022
This changes the internal generation of the ID used to uniquely identify an element to be more resistant to collisions. Previously it was an incremented integer or the exact ID used on the element, which for most cases was unique enough. Unfortunately if any elements used by Select2 also had an ID that was a low number, it was almost guaranteed to collide with an internal ID that Select2 generated. The internal generation now relies on a prefix when the ID already exists, similar to what we do with core IDs. It also uses a set of 4 random characters along with the incrementing ID to reduce the chance of collisions even further. It is definitely still possible for a collision to occur, especially if two elements exist but one has a prefix of `data-` already, but the chances have been greatly reduced. We'll accept it for now.
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
If this is related to an existing ticket, include a link to it as well.
Fixes #5810