custom-attributes
custom-attributes copied to clipboard
Browser Compatibility
Currently custom-attributes doesn't specify what browsers it supports, so thought it might be worth discussing what to aim for.
I've been using it in https://github.com/simplaelements/simpla-paths and that's been running well in everything bar IE - IE11 is missing a few WeakMap / Map features e.g. map.keys()
. I'm also transpiling it, so languages features are all fine.
@matthewp thoughts?
I didn't design it with specific browser targets. MutationObserver is the one thing that we can't live without so I guess IE11 is the absolute minimum. If it's down to Map/WeakMap those can be polyfilled (kinda), so is it just a matter of documenting?
By the way, I don't know how you feel but I'm against libraries shipping with polyfills. I think it adds unnecessary cost that not all usages need. I think it's better just to be upfront and say "will work in IE11 if you include a Map/WeakMap polyfill".
Yeah I agree, generally don't think polyfills should get shipped with libraries. The only features that IE11 doesn't have that are currently needed are keys()
and values()
, which this uses just on Map
. It would be nice to support IE11 out of the box, though I'm guessing using Array lookups would really hurt perf?
Other than that - what do you think about having a transpiled version? Or alternatively update it to use ES5 to support IE11.
Or, obviously other option re: transpilation is just let people transpile themselves when they use it in their own projects.
See https://github.com/matthewp/custom-attributes/pull/13 - that gives support for IE11. I realised that IE11 just has partial support for Map
/ WeakMap
, so it meant tweaking usage slightly to get it to work.
Sounds good. Would be nice to set up SauceLabs or something for browser testing.