paulcpederson / focusin

Focusin/focusout polyfill for Firefox
ISC License
5 stars 1 forks source link

expose polyfill as function #1

Closed jamiebuilds closed 8 years ago

jamiebuilds commented 8 years ago

I'm currently trying to use this polyfill for a package of mine that needs to be able to run in both the browser and in node.js. I was wondering if you'd be willing to change the interface of this package so that it is wrapped in a function somehow:

require('focusin');
require('focusin').polyfill();

This way I could lazily polyfill it when it is necessary. Other polyfills do this as well.

Related to: https://github.com/thejameskyle/react-modal2/issues/2

paulcpederson commented 8 years ago

@thejameskyle yeah, this sounds like a good idea. It's a breaking change, but that's what major version numbers are for. I'll try to do this today.

jamiebuilds commented 8 years ago

I'll make a PR real quick for you

paulcpederson commented 8 years ago

I'm working on it locally right now, but I'll do it in a branch and open a pr on master when I'll point you to so we make sure it meets your needs.

jamiebuilds commented 8 years ago

Oh sorry, tunnel vision kicked in and I just did it

paulcpederson commented 8 years ago

ha, beat me to it! We did this almost identically. The only difference is that I created a new file which automatically calls the polyfill for the minified version. That way people can still just load a js script in the client if they need to.

Take a look at #3 and see if that would work!

paulcpederson commented 8 years ago

ok. pushed 2.0.0. Tested and works well.

For posterity if you don't want to call the method (ie, using es6 module syntax, or something) you can also just require the focusin/focusin-polyfill.js file and it will automatically run the polyfill:

import 'focusin/focusin-polyfill.js'
paulcpederson commented 8 years ago

@thejameskyle feel free to close after you've installed and made sure this works for you.

jamiebuilds commented 8 years ago

Works great, thanks