[4.0.6] Utils.GetData

Now that there’s a system to cache and retrieve data attributes using Utils.GetData and Utils.SetData is it no longer possible for us to publicly access data attributes directly?

Although there’s a fallback in Utils.GetData to get from the data attribute if the cache is empty, there’s nothing that actually sets the data attribute in the first place.

What I’m trying to do is access what was equivalent to:

var instance = $element.data('select2');

But this no longer seems to be possible.

Is there a public way of accessing the GetData or SetData functions?

I was originally treating this as a bug fix, not a new feature, which is why I merged it for a patch release.

But it looks like this is a breaking change, so as we discussed on the GH issue, we might need to revert this if it can’t be introduced in a backwards-compatible way.

1 Like