corset
corset copied to clipboard
[request/suggestion] data-corset-props attr instead of many data-corset-prop-* attrs
Assuming the data-corset-prop-* attrs are there individually just for an internal query selector and not a deeper need, would you consider changing it to be all contained in one data-corset-props
and use the ~= attr selector instead like [data-corset-props~=--corset-prop]
Current:
Proposed:
Ty! 💜
Oh, I like this idea a lot! Yeah, it just exists to do el.closest(selector)
to find the nearest ancestor with the prop. I think your idea could work, and would be nicer to look at and likely even fix #155 since we have to try and make the vars be valid attribute names.
I would want to add a benchmark first (something that's needed anyways). This is a part of the code that runs fairly frequently and I'm not sure what the perf of =~ is. But assuming it's acceptable, I like this change a lot.
I'm prototyping this.
I worked on this and couldn't see a perf difference so I'm going to implement it.
Since stores and item/index use a lot of the same code I'm going to need to refactor them to use this sort of method as well. It will probably be something like data-corset-props
, data-corset-stores
and data-corset-scope
to represent each of these concepts, so a max of 3 corset attributes on an element if you happen to use all of these features on the same element.
awesome, thank you so much
Corset is awesome, really enjoy using it
Released in https://github.com/matthewp/corset/releases/tag/v2.1.0