jridgewell / babel-plugin-transform-incremental-dom

Turn JSX into IncrementalDOM
MIT License
145 stars 12 forks source link

Allow suppressing of Key order errors. #83

Closed mthadley closed 7 years ago

mthadley commented 7 years ago

In the newest release, errors are now thrown if key is not the first computed attribute. I understand how this can be quite the 'gotcha' if you are mutating keys, since the compiler will change the order of execution. However, I wonder if maybe this is something we can disable assuming we understand what is going on?

I think mutating the key in other computed properties seems like a corner case, and probably a bad pattern anyways. This change will probably break most uses of this plugin, and while the fix is easy, it can be annoying to have to treat key differently in this way, especially if one has never been affected by this behavior.

I know from our use case that by habit we already sort all of our attributes in alphabetical order, so this error makes doing that quite a bit more tedious as well.

So would it make sense to allow disabling of this error? or maybe even make it some kind of warning instead? It could still be thrown by default, though.

Any thoughts? Thanks in advance!