anselmh / object-fit

Polyfill (mostly IE) for CSS object-fit property to fill-in/fit-in images into containers.
MIT License
996 stars 93 forks source link

Usage of objectfit as global variable in module context #26

Open feeela opened 9 years ago

feeela commented 9 years ago

In src/polyfill.getMatchedCSSRules.js you are using objectfit as a global variable, which is not set, if the polyfill is loaded via an AMD module loader.

Code that throws the exception "ReferenceError: objectFit is not defined": if (objectFit.disableCrossDomain == 'true')

Currently the polyfill is not usable when using an AMD loader…

anselmh commented 9 years ago

Thank for reporting. You’re right. If you have time, feel free to submit a Pull Request with a fix. Otherwise I’ll try to fix it as soon as possible.

gpbl commented 9 years ago

If you are using webpack (it works also for AMD modules) you can use the expose-loader to set the global variable:

require('expose?objectFit!object-fit/dist/polyfill.object-fit.js');
mjsarfatti commented 9 years ago

Any progress on this? I cannot seem to be able to load object-fit with requireJS. I am willing to spend some time coding a fix for it, but my knowledge of AMD is way too basic. If you could point me into some direction it would be great.

anselmh commented 9 years ago

Ah, damn it. Had really no time in the past weeks. Actually I hope to fix this in the next week, ultimately the week after. Sorry about the hassle.

man-oi commented 9 years ago

yeah, this would be great!