fluorjs / fluor

Sprinkle interactivity on your design
https://fluorjs.github.io/
223 stars 6 forks source link

Please consider using dataset attributes #13

Open ljosberinn opened 4 years ago

ljosberinn commented 4 years ago

See https://github.com/alpinejs/alpine/pull/506#issuecomment-632836336 - it's the same situation and problem.

Dataset on top has the advantage of not having to iterate over all attributes of an element, so for most elements, it would be an empty loop.

- for (const attr of element.attributes) {
-   switch(attr.name)

+ for(const key in element.dataset) {
+   switch(key)
madx commented 4 years ago

Thanks for your input! I considered using data attributes at first (I honestly didn't thought about the fact that iteration would be way faster tho) but I'm still a bit concerned that data-f-bind or data-f-html would be excessively verbose compared to f-bind or f-html, especially as we're targeting less tech-inclined people.

The first versions used @html, @text which is even worse so we already did a step in the good direction right?

I'll give it another thought for sure so I'm not closing this. We're still before v1.0.0 so I'm still happy with making breaking changes :smile: