Closed GrosSacASac closed 2 years ago
It'd also be great to vend an entrypoint that does the feature detection and global patching for you.
Yes, my motion sensor polyfill does something like that, e.g. it returns the native implementation if it exists or else the polyfilled version:
export const RelativeOrientationSensor = window.RelativeOrientationSensor ||
class RelativeOrientationSensor extends DeviceOrientationMixin(Sensor, 'deviceorientation') { ... }
https://github.com/kenchris/sensor-polyfills/blob/master/src/motion-sensors.js#L159
Would something like that be useful? What do you think @wanderview ?
Any news on this? Thanks!
I am OK with this, so want to do a PR @abdonrd ?
@justinfagnani I didn't follow what you meant with "vend an entrypoint"?
I have a tentative solution to this: https://github.com/kenchris/urlpattern-polyfill/pull/71
This has now been committed, thanks to @justinfagnani for review.
It doesn't use dynamic import, as that seems a user concern. As Justin said it
I personally think that's a bit of a separate concern. You have potentially three things:
- Implementation
- Patching the global
- Dynamic loading the code
A lot of apps will have their own systems for (3) that ensure that app code is run after polyfills load.
urlpattern.js
main source file