dialog-polyfill
dialog-polyfill copied to clipboard
Support for imports from isomorphic scripts
As pointed out in https://github.com/GoogleChrome/dialog-polyfill/issues/230, imports on isomorphic scripts fail without any handlers for server-side code. This PR addresses that concern.
EDIT: It's worth noting that the diffs picked up far more than I actually changed. Feel free to confirm, but for sanity, here's the only difference:
var dialogPolyfill = {}; // This condition assures imports don't break for isomorphic scripts, // while also preventing unexpected uses of this package on the server side. if (typeof window === 'undefined') { function getServerSideThrower(name, isProp) { var error = ''; if (isProp) { error = 'Cannot access property `dialogPolyfill.' + name + '` on the server side.'; } else { error = 'Cannot execute `dialogPolyfill.' + name + '()` on the server side.'; } return function() { throw new Error(error); } } dialogPolyfill.registerDialog = getServerSideThrower('registerDialog'); dialogPolyfill.forceRegisterDialog = getServerSideThrower('forceRegisterDialog'); dialogPolyfill.reposition = getServerSideThrower('reposition'); dialogPolyfill.isInlinePositionSetByStylesheet = getServerSideThrower('isInlinePositionSetByStylesheet'); dialogPolyfill.needsCentering = getServerSideThrower('needsCentering'); dialogPolyfill.DialogManager = getServerSideThrower('DialogManager'); Object.defineProperties(dialogPolyfill, { dm: { get: getServerSideThrower('dm', true) }, formSubmitter: { get: getServerSideThrower('formSubmitter', true) }, imagemapUseValue: { get: getServerSideThrower('imagemapUseValue', true) } }); } else { /* ... the original contents here ... */ } export default dialogPolyfill;
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).
For more information, open the CLA check for this pull request.
Can this please be merged