-
Notifications
You must be signed in to change notification settings - Fork 956
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sizzle.matches passes null context, causes document to be set to global document #311
Comments
Thanks for opening an issue. We actually had a discussion about this recently and meant to open one. |
Yeah, one of my coworkers started that discussion, but I was the one writing our workarounds for it and I needed a URL to use to refer to this problem in my commit messages :) I've also noticed anecdotally that if you do something like |
Implementation discussion here. @gibson042 or I will get to it as soon as one of us is free. |
To avoid triggering state thrashing in Sizzle ( jquery/sizzle#311 ) Also account for the fact that missing attributes are returned as undefined by jQuery but null by .getAttribute(). Bug: T87416 Change-Id: Ib3bc7971920c084568abb6ea0bd822d763b276f2
Avoiding a Sizzle context switch, see jquery/sizzle#311 Bug: T87416 Change-Id: I40dd2cb17f9c3d14d0ee1aa5b542263775feedb7
Copy DOM elements into the target document before processing them, rather than after. This means the processing is done not in the input document, but in the view document. The latter is likely to be the main document, and so we avoid running into jquery/sizzle#311 causing a lot of state thrashing in Sizzle. Bug: T87416 Change-Id: I3fbc83ebd5c07e4040b8f22a4eff9f0e1b1d7601
Related to #292
If you call, say,
$foo.children( 'a' )
, checking which children of$foo
match the'a'
selector is done byjQuery.filter
. If$foo
has exactly one child,jQuery.filter
will callSizzle.matchesSelector
which invokessetDocument( elem.ownerDocument )
if necessary, and then passes that document to theSizzle
constructor.However, if the number of children of
$foo
isn't exactly one,jQuery.filter
will callSizzle.matches
instead, which just calls theSizzle
constructor directly, passing innull
for the context, causing an invocation ofsetDocument( window.document )
regardless of what document$foo
is really in.This means that the following code causes the document context to thrash:
setDocument
is invoked from every.children()
call, which is detrimental to performance, sincesetDocument
contains 300+ lines of feature/bug detection code.The text was updated successfully, but these errors were encountered: