Re: [selectors-api] Why no querySelector(All) on DocumentFragments?

2008-03-19 Thread Lachlan Hunt


Boris Zbarsky wrote:
Is there a reason why querySelector(All) is not supported on 
DocumentFragment nodes?  It seems to me that such support could be 
useful...  It's already supported on disconnected subtrees rooted by an 
Element, as far as I can tell, so it doesn't seem like the 
DocumentFragment case would be all that different.


It is now defined that DocumentFragments will also implement the new 
NodeSelector interface.


--
Lachlan Hunt - Opera Software
http://lachy.id.au/
http://www.opera.com/



Re: [selectors-api] Why no querySelector(All) on DocumentFragments?

2008-03-15 Thread Anne van Kesteren


On Sat, 15 Mar 2008 00:30:52 +0100, Boris Zbarsky [EMAIL PROTECTED] wrote:

Anne van Kesteren wrote:
If :scope needs to work matching in implementations might need to  
change by the way. Currently matching is only against the subtree. So  
div.querySelector(div) would only match descendant div elements.


I see no reason for this to change with :scope introduced, to be  
honest.  Am I missing something?


No, I guess you're right. With style scoped it would match the subtree  
root element as well though (parent of style), but I suppose that case  
is slightly different anyway.



--
Anne van Kesteren
http://annevankesteren.nl/
http://www.opera.com/



RE: [selectors-api] Why no querySelector(All) on DocumentFragments?

2008-03-14 Thread Travis Leithead

I had this conversation with Lachlan awhile back (but I can't find the thread 
to dig up). I believe it was his intention for these APIs to work on 
DocumentFragments.

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Robert Sayre
Sent: Thursday, March 13, 2008 8:30 PM
To: Ian Hickson
Cc: Boris Zbarsky; liorean; Web APIs WG (public)
Subject: Re: [selectors-api] Why no querySelector(All) on DocumentFragments?


On Thu, Mar 13, 2008 at 11:24 PM, Ian Hickson [EMAIL PROTECTED] wrote:

  Yeah, I was just jumping in to clarify the :root thing. Personally I think
  you're right, it would be useful to have the method on DocumentFragment,

I agree.

  but that's up to Lachlan. :-)

Fully disagree.

--

Robert Sayre

I would have written a shorter letter, but I did not have the time.





Re: [selectors-api] Why no querySelector(All) on DocumentFragments?

2008-03-14 Thread Maciej Stachowiak



On Mar 12, 2008, at 12:25 PM, Boris Zbarsky wrote:



Is there a reason why querySelector(All) is not supported on  
DocumentFragment nodes?  It seems to me that such support could be  
useful...  It's already supported on disconnected subtrees rooted by  
an Element, as far as I can tell, so it doesn't seem like the  
DocumentFragment case would be all that different.


I'd have no objection to supporting these methods on DocumentFragment  
too, although it does not seem terribly important.


I think ability to do element-rooted selector queries (either through  
a new method or a :scope pseudo-element) is more important, since it's  
needed to replicate the feature set of JS query libraries.


Regards,
Maciej




Re: [selectors-api] Why no querySelector(All) on DocumentFragments?

2008-03-14 Thread Boris Zbarsky


Jonas Sicking wrote:
If we merge DocumentSelector and ElementSelector into simply 
NodeSelector we'll more or less automatically get the functions on 
DocumentFragments.


Not necessarily.  I'm not advocating that all Nodes be castable to 
NodeSelector.  Just that whatever nodes querySelector(All) work on are.


We'd also get it for attribute nodes which might be less desirable. 


I don't think it's desirable at all.

Though we could say that the interface is only required to be 
implemented on Documents, Elements and DocumentFragments.


That would be my suggestion, yes.  ;)

If we could get a :scope pseudo-element that would be an excellent 
solution IMHO, and would be great with scoped stylesheets as has been 
pointed out elsewhere in the last few days.


Agreed.

That said, is there interest in getting this spec to CR quickly, since 
it seems some UAs are planning to ship it in the near future even though 
it's a Working Draft?  Or are said UAs willing to make changes to their 
implementation after shipping as the spec changes?


The alternative, defining another set of methods would be something that 
we could do, but that solution feels a lot less appealing.


Again, agreed.

-Boris




Re: [selectors-api] Why no querySelector(All) on DocumentFragments?

2008-03-14 Thread Maciej Stachowiak



On Mar 14, 2008, at 1:56 PM, Jonas Sicking wrote:



I think ability to do element-rooted selector queries (either  
through a new method or a :scope pseudo-element) is more important,  
since it's needed to replicate the feature set of JS query libraries.


If we could get a :scope pseudo-element that would be an excellent  
solution IMHO, and would be great with scoped stylesheets as has  
been pointed out elsewhere in the last few days.


Is that something that should be defined by this WG? It would suck  
to have to wait for Level 4 Selectors. Other WGs have defined  
selectors, but I'm not sure how good of an idea that is.


I would prefer to see it in the Selectors spec, but it would have to  
come out of CR for that. Perhaps the editor of the Selectors spec  
(Hixie) would like to weigh in. Alternately, we could temporarily  
define the pseudo-element in the Selectors API spec.


The alternative, defining another set of methods would be something  
that we could do, but that solution feels a lot less appealing.


I agree, :scope seems more elegant, and parallel methods can't handle  
the  span immediate children use case very nicely.


Regards,
Maciej




Re: [selectors-api] Why no querySelector(All) on DocumentFragments?

2008-03-14 Thread Maciej Stachowiak



On Mar 14, 2008, at 2:25 PM, Boris Zbarsky wrote:



Jonas Sicking wrote:
If we merge DocumentSelector and ElementSelector into simply  
NodeSelector we'll more or less automatically get the functions on  
DocumentFragments.


Not necessarily.  I'm not advocating that all Nodes be castable to  
NodeSelector.  Just that whatever nodes querySelector(All) work on  
are.



We'd also get it for attribute nodes which might be less desirable.


I don't think it's desirable at all.

Though we could say that the interface is only required to be  
implemented on Documents, Elements and DocumentFragments.


That would be my suggestion, yes.  ;)

If we could get a :scope pseudo-element that would be an excellent  
solution IMHO, and would be great with scoped stylesheets as has  
been pointed out elsewhere in the last few days.


Agreed.

That said, is there interest in getting this spec to CR quickly,  
since it seems some UAs are planning to ship it in the near future  
even though it's a Working Draft?  Or are said UAs willing to make  
changes to their implementation after shipping as the spec changes?


UAs are also planning to ship HTML5 features, and that's nowhere near  
CR. For Safari/WebKit we are willing to keep up with changes but we  
hope and assume there wouldn't be gratuitous incompatibilities  
created. For example, extending the interface to DocumentFragment,  
adding :scope, or adding parallel methods for element-rooted queries  
would both be reasonable changes from our point of view. Because this  
API is driven to a large extent by a desire to replace AJAX library  
functionality with more performance native versions, I think it's  
important to make sure we actually satisfy their use cases, and we're  
learning about that from the existing early implementations as JS  
library authors play with them.


The main thing I'd like to see ASAP is a good test suite, and we don't  
need to wait for CR to start building that.


Cheers,
Maciej




Re: [selectors-api] Why no querySelector(All) on DocumentFragments?

2008-03-14 Thread Anne van Kesteren


On Sat, 15 Mar 2008 00:04:34 +0100, Maciej Stachowiak [EMAIL PROTECTED]  
wrote:

On Mar 14, 2008, at 1:56 PM, Jonas Sicking wrote:
The alternative, defining another set of methods would be something  
that we could do, but that solution feels a lot less appealing.


I agree, :scope seems more elegant, and parallel methods can't handle  
the  span immediate children use case very nicely.


If :scope needs to work matching in implementations might need to change  
by the way. Currently matching is only against the subtree. So  
div.querySelector(div) would only match descendant div elements.


(An alternative idea might be to make :root match the subtree root in case  
of scoped selectors.)



--
Anne van Kesteren
http://annevankesteren.nl/
http://www.opera.com/



Re: [selectors-api] Why no querySelector(All) on DocumentFragments?

2008-03-14 Thread Boris Zbarsky


Anne van Kesteren wrote:
If :scope needs to work matching in implementations might need to change 
by the way. Currently matching is only against the subtree. So 
div.querySelector(div) would only match descendant div elements.


I see no reason for this to change with :scope introduced, to be honest.  Am I 
missing something?


-Boris



Re: [selectors-api] Why no querySelector(All) on DocumentFragments?

2008-03-14 Thread Lachlan Hunt


Anne van Kesteren wrote:
If :scope needs to work matching in implementations might need to change 
by the way. Currently matching is only against the subtree. So 
div.querySelector(div) would only match descendant div elements.


That just means that it will only return elements that are descendants, 
but selects are still evaluated in the context of the entire tree.


  div.querySelector(:scope);

won't return anything, since the the selecor is referring to the element 
itself and is therefore quite a useless thing to do, but:


  div.querySelector(:scopespan)

will return only span elements that are children of that div element.

--
Lachlan Hunt - Opera Software
http://lachy.id.au/
http://www.opera.com/



Re: [selectors-api] Why no querySelector(All) on DocumentFragments?

2008-03-14 Thread Ian Hickson

On Fri, 14 Mar 2008, Maciej Stachowiak wrote:
 On Mar 14, 2008, at 1:56 PM, Jonas Sicking wrote:
  
   I think ability to do element-rooted selector queries (either 
   through a new method or a :scope pseudo-element) is more important, 
   since it's needed to replicate the feature set of JS query 
   libraries.
  
  If we could get a :scope pseudo-element that would be an excellent 
  solution IMHO, and would be great with scoped stylesheets as has been 
  pointed out elsewhere in the last few days.
  
  Is that something that should be defined by this WG? It would suck to 
  have to wait for Level 4 Selectors. Other WGs have defined selectors, 
  but I'm not sure how good of an idea that is.
 
 I would prefer to see it in the Selectors spec, but it would have to 
 come out of CR for that. Perhaps the editor of the Selectors spec 
 (Hixie) would like to weigh in. Alternately, we could temporarily define 
 the pseudo-element in the Selectors API spec.

(It would be a pseudo-class, not a pseudo-element.)

The :matches() proposal uses # for the concept of context node.

XBL2 uses :bound-element for a similar concept.

I don't think this feature is critical to the selectors API. I would 
recommend going ahead with the API as it is now, and moving this extension 
to a second version, or possibly to the next version of the Selectors 
spec. I think it would be a good idea for someone to start working on the 
next Selectors spec anyway, to spec out :matches(), the DOM attributes 
stuff ([#textContent*='...'], [#col=4], [#row2], etc), this, and the 
various other new ideas that have been suggested since Selectors last had 
new features suggested.

-- 
Ian Hickson   U+1047E)\._.,--,'``.fL
http://ln.hixie.ch/   U+263A/,   _.. \   _\  ;`._ ,.
Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'



Re: [selectors-api] Why no querySelector(All) on DocumentFragments?

2008-03-13 Thread Ian Hickson

On Wed, 12 Mar 2008, Boris Zbarsky wrote:
 
 javascript:var n = 
 document.createElement(div);n.appendChild(document.createElement(span));alert(n.querySelector(:root
  
 span));
 
 Webkit nightly returns null.  IE throws (no :root support).  Gecko 
 prototype implementation returns the span, since :root will match any 
 node with no ancestors.

Webkit is correct. The Selectors spec defines :root as:

   The :root pseudo-class represents an element that is the root of the 
   document.

...and here, the span is not the root of the document, it's just an 
unconnected element owned by the document.

Thus it is possible for an element to match neither *  * nor :root.

-- 
Ian Hickson   U+1047E)\._.,--,'``.fL
http://ln.hixie.ch/   U+263A/,   _.. \   _\  ;`._ ,.
Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'



Re: [selectors-api] Why no querySelector(All) on DocumentFragments?

2008-03-13 Thread Boris Zbarsky


Ian Hickson wrote:

Webkit is correct. The Selectors spec defines :root as:

   The :root pseudo-class represents an element that is the root of the 
   document.


OK.  It wasn't obvious to me whether that was because people hadn't considered 
matching against disconnected subtrees or whether they'd considered it and 
rejected it.  I should note that it's not obvious what document the document 
is here, by the way...


None of which much affects my initial question about DocumentFragment.

-Boris



Re: [selectors-api] Why no querySelector(All) on DocumentFragments?

2008-03-13 Thread Ian Hickson

On Thu, 13 Mar 2008, Boris Zbarsky wrote:

 Ian Hickson wrote:
  Webkit is correct. The Selectors spec defines :root as:
  
 The :root pseudo-class represents an element that is the root of the
  document.
 
 OK.  It wasn't obvious to me whether that was because people hadn't 
 considered matching against disconnected subtrees or whether they'd 
 considered it and rejected it.  I should note that it's not obvious what 
 document the document is here, by the way...

Yeah, it really should say a document. I'm not sure who's editing that 
document any more these days.


 None of which much affects my initial question about DocumentFragment.

Yeah, I was just jumping in to clarify the :root thing. Personally I think 
you're right, it would be useful to have the method on DocumentFragment, 
but that's up to Lachlan. :-)

-- 
Ian Hickson   U+1047E)\._.,--,'``.fL
http://ln.hixie.ch/   U+263A/,   _.. \   _\  ;`._ ,.
Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'



Re: [selectors-api] Why no querySelector(All) on DocumentFragments?

2008-03-13 Thread Robert Sayre

On Thu, Mar 13, 2008 at 11:24 PM, Ian Hickson [EMAIL PROTECTED] wrote:

  Yeah, I was just jumping in to clarify the :root thing. Personally I think
  you're right, it would be useful to have the method on DocumentFragment,

I agree.

  but that's up to Lachlan. :-)

Fully disagree.

-- 

Robert Sayre

I would have written a shorter letter, but I did not have the time.



Re: [selectors-api] Why no querySelector(All) on DocumentFragments?

2008-03-13 Thread Boris Zbarsky


www-style: the discussion is about the :root selector in the Selectors 
specification.


 Yeah, it really should say a document.

That doesn't solve the problem, in some ways, since it might mean that multiple 
nodes being rendered in the same window match :root, depending on what 
transclusion technologies people come up with.  Perhaps that's desirable.


What would make the most sense to me, I guess, would be to have it that an 
element matches :root if it is the documentElement of its ownerDocument.


-Boris



[selectors-api] Why no querySelector(All) on DocumentFragments?

2008-03-12 Thread Boris Zbarsky


Is there a reason why querySelector(All) is not supported on 
DocumentFragment nodes?  It seems to me that such support could be 
useful...  It's already supported on disconnected subtrees rooted by an 
Element, as far as I can tell, so it doesn't seem like the 
DocumentFragment case would be all that different.


-Boris



Re: [selectors-api] Why no querySelector(All) on DocumentFragments?

2008-03-12 Thread Boris Zbarsky


liorean wrote:

As a disconnected node would not be in the node tree from document,
can it match a query at all?


That's a really good question!   It seems to match in the webkit nightly 
I just tried here, as well as in IE8.  Simple testcase:


javascript:var n = 
document.createElement(div);n.appendChild(document.createElement(span));alert(n.querySelector(span).tagName);


Paste this into your URL bar of choice.

A naive implementation in Gecko would also match such nodes unless they 
are purposefully excluded.


If the intent is that these nodes not match, the spec obviously needs to 
spell it out a lot more clearly than it currently does.


-Boris