Snugug / eq.js

Lightweight JavaScript powered element queries
http://eqjs.io/
MIT License
526 stars 34 forks source link

fixes #65 #67

Closed FezVrasta closed 8 years ago

FezVrasta commented 8 years ago

fixes #65

jonscottclark commented 8 years ago

This breaks IE8, as its getBoundingClientRect() object does not return width and height properties. eq.js supports IE8 with the included polyfills, so I think this won't be merged unless a fallback to this method is added.

Couldn't find an easy drop-in polyfill, but here's an implementation that should work in older browsers: https://github.com/zeroclipboard/zeroclipboard/blob/be4573579f9dbccad4280bd06e2e72c896fa5c66/ZeroClipboard.js#L124-L155

Snugug commented 8 years ago

As @jonscottclark said, as I'm trying to keep IE8 compatibility, can't use getBoundingClientRect without a suitable polyfill available (and pulled in during the build process)

FezVrasta commented 8 years ago

What about https://github.com/inexorabletash/polyfill/blob/master/cssom.js ?

vampolo commented 8 years ago

@FezVrasta your suggested polyfill is based on Object.defineProperties which seem to be supported from IE9+. Thus i dunno if the comment in the suggested snippet is correct.

As a solution to this, there is a polyfill for Object.defineProperties on the mozilla MDN.

jonscottclark commented 8 years ago

The polyfill I linked seems to do what getBoundingClientRect does within the browser, but man.. it's really long.

vampolo commented 8 years ago

Why don't just do:

var rect = el.getBoundingClientRect();
var width = rect.width;
if (width === undefined) {
    width = rect.right - rect.left;
}

Or something similar ?

FezVrasta commented 8 years ago

I think it could work... well, obviously we'll still have the the problem fixed by this PR on IE8, but it's still an improvement.

FezVrasta commented 8 years ago

closing in favor of #71