Bug 17731

Summary: Node.querySelectorAll() scopes selection incorrectly
Product: WebKit Reporter: Borgar ├×orsteinsson <borgar>
Component: WebCore JavaScriptAssignee: Nobody <webkit-unassigned>
Severity: Normal    
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Mac   
OS: OS X 10.5   

Description Borgar ├×orsteinsson 2008-03-09 07:56:53 PDT
Calling document.getElementById('scope').querySelectorAll('body p') returns all paragraphs within context (#scope). I would have expected it to return an empty set.

querySelectorAll seems to be currently selecting all paragraphs within context node, and then checking which are within the scope. Or it finds all paragraphs within context and tries to match them to the selector. However the method, this causes false positives as there are no body tags within the scope.

I would have expected document.getElementById('scope').querySelectorAll('body p') to work exactly like document.querySelectorAll('#scope body p'). This is how all the js engines work, and how IE8 has implemented it.

I'm seeing failures on a lot of other selectors but it's completely consistent with this example.
Comment 1 Sam Weinig 2008-03-09 08:14:31 PDT

*** This bug has been marked as a duplicate of 17461 ***
Comment 2 Borgar ├×orsteinsson 2008-03-09 08:24:27 PDT
I would like to correct my statement that IE8 behaves as I expected, it does not. This was me messing up my test. IE8 and WebKit behave in the same way.