Created
August 23, 2011 22:47
-
-
Save mattheworiordan/1166821 to your computer and use it in GitHub Desktop.
Fix for :focus pseudo selector when browser does not have focus
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* JQuery tries to use native CSS selectors instead of the Sizzle selector | |
* engine for performance reasons. | |
* | |
* This causes problems when trying to test intefaces using the | |
* :focus pseudo selector as unless the web page and browser window | |
* has the focus, all elements are considered to be without focus. | |
* Checking for :focus in Selenium or Capybara tests therefore fail if | |
* using JQuery or Sizzle. | |
* | |
* Sizzle will however return true for a :focus element even if the | |
* window itself has lost focus if we force it not use the native selector functions | |
* This script forces Sizzle to use its own engine over native selectors. | |
* | |
* This file MUST be included before JQuery or Sizzle is loaded | |
* | |
* Refer to http://blog.mattheworiordan.com/post/9308775285 for more info | |
* | |
**/ | |
/* Prevent use of native find selector */ | |
document.querySelectorAll = false; | |
/* Prevent use of native matches selector */ | |
document.documentElement.matchesSelector = false; | |
document.documentElement.mozMatchesSelector = false; | |
document.documentElement.webkitMatchesSelector = false; | |
document.documentElement.msMatchesSelector = false; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment