python-needle / needle

Automated tests for your CSS.
https://needle.readthedocs.io/
Other
590 stars 50 forks source link

Leverage jQuery to calculate WebElements' dimensions more accurately. #10

Closed jphalip closed 10 years ago

jphalip commented 11 years ago

The dimensions were off in some of my projects. Using jQuery fixed it by providing more accurate dimensions.

acdha commented 11 years ago

Hmmm, I wonder what the relative tradeoffs are for pulling in jQuery all the time versus including just the Max.max block:

https://github.com/jquery/jquery/blob/1.10.2/src/dimensions.js#L23-L29

jphalip commented 11 years ago

Good question :)

I've submitted another pull request to prevent pulling jQuery all the time: https://github.com/bfirsh/needle/pull/11

It'd be great to not use jQuery at all, but jQuery is most reliable for this as it deals with lots of edge cases. In my case, the issue wasn't really with outerWidth/outerHeight but with the offset top/left coordinates — so we'd have to also port some code from https://github.com/jquery/jquery/blob/1.10.2/src/offset.js

What do you think?

bfirsh commented 10 years ago

Looks good. Thanks!