querySelectorAll method

279 views
Skip to first unread message

Josh Pearce

unread,
Sep 1, 2010, 4:46:37 PM9/1/10
to SVG Web
I'm working to patch jQuery to support svgweb. So far, Ive been making
good progress. Today, while digging through the jQuery code, I found
that jQuery seems to use a native browser method, querySelectorAll, in
place of the Sizzle selector query engine, if querySelectorAll exists.

Since my patches are against Sizzle, I have to set
document.querySelectorAll = null to force jQuery to use Sizzle.
https://developer.mozilla.org/en/DOM/document.querySelectorAll

Do you guys have any thoughts on the document.querySelectorAll method
as it relates to svgweb?

Jeff Schiller

unread,
Sep 1, 2010, 4:55:16 PM9/1/10
to svg...@googlegroups.com
Josh,

Let me second the idea of supporting querySelector in SVG Web.  Can you open a bug?

Jeff


--
You received this message because you are subscribed to the Google Groups "SVG Web" group.
To post to this group, send email to svg...@googlegroups.com.
To unsubscribe from this group, send email to svg-web+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/svg-web?hl=en.


Bradley Neuberg

unread,
Sep 1, 2010, 5:01:57 PM9/1/10
to svg...@googlegroups.com
Has anyone done any tests to see how the native querySelector and querySelectorAll works on SVG elements in three scenarios:
 
* SVG dynamically added to an HTML document
* SVG in an SVG document
* SVG in an HTML5 document (Firefox 4 and IE 9 only for now)
 
It's unclear how to specify namespaces using the CSS selector format for querySelector.

Best,
  Brad Neuberg

Jeff Schiller

unread,
Sep 1, 2010, 5:50:25 PM9/1/10
to svg...@googlegroups.com
Brad,

I have not thoroughly tested querySelector in SVG, but I know it's worked in some scenarios.

I can't see as how it would make a difference how the element is included - the elements are still in the SVG namespace in all three instances you describe, but you bring up a good point overall re: namespaces.  


I haven't really thought this through in detail yet, but I suspect the following behavior:

  * document.querySelectorAll(".foo") - will return all elements in the document that have the class 'foo' (regardless of namespace)

  * someSvgElement.querySelector('circle') - will return all child SVG <circle> elements under someSvgElement.  If you're querying on an SVG element, you are already *in* the SVG namespace and thus do not need to include any namespace prefix.

  * anHtml5Element.querySelector('rect') - I'm not sure if this should return all child SVG <rect> elements in an HTML5 document or if some namespacing mechanism is actually required

Regards,
Jeff
Reply all
Reply to author
Forward
0 new messages