anselmh / object-fit

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

Fix array-detection of arguments to objectFill.init. #10

Closed xax closed 10 years ago

xax commented 10 years ago

You want to enable the passing of an array of selector / fittype definitions to objectFit.polyfill. If a lone object { selector: 'img', fittype: 'cover' }is passed, you wrap the object into an array.

As code to determin if it is an array already that is passed, in .init you use if (typeof args !== 'Array') {… – but that won't do it, as a JS array has typeof [] === 'object'. Thus I propose tio change the test to … instanceof Array.

(There are some EOL-whitespace diffs in this pull request – sorry about that.)

anselmh commented 10 years ago

Thank you! Merged via f3b68bedf8ae5e0bd190606c0f2ed2f766c83793. I also fixed the whitespace issues and added a small notice into CHANGELOG. Thanks for contributing this, if you want to avoid the small issues with coding guidelines, let your editor use the editorconfig file :)