Search code examples
javascriptjqueryqunit

jQuery css left, top, z-index


I have a few tests that test if the style params are set properly. For some reason, some tests fail in Chrome. Here are the tests. element is a jQuery Object by the way.

    equal(element.css("left"),  "41px", "left is set properly");
    equal(element.css("top"),  "144px", "top is set properly");
    equal(element.css("z-index"),  "2070", "z-index is set properly");

All three of them pass in Firefox but not in Chrome. When I put a breakpoint on the tests and inspect element.css("left") I get "41px". But the test still fails showing the following error. Does anybody know why ?

enter image description here


Solution

  • It's a known bug, there is pull request that fixes this issue in jquery git repo https://github.com/jquery/jquery/pull/1241

    you can try to clone jquery repo, apply this patch and make custom build