- From: Sean Hogan <shogun70@westnet.com.au>
- Date: Wed, 24 Sep 2014 06:05:42 +1000
- To: Anne van Kesteren <annevk@annevk.nl>
- CC: Boris Zbarsky <bzbarsky@mit.edu>, "Tab Atkins Jr." <jackalmage@gmail.com>, "www-style@w3.org" <www-style@w3.org>, "www-dom@w3.org" <www-dom@w3.org>, David Håsäther <hasather@gmail.com>
On 23/09/14 5:32 PM, Anne van Kesteren wrote:
> On Mon, Sep 22, 2014 at 11:54 AM, Sean Hogan <shogun70@westnet.com.au> wrote:
>> No. I am also saying that if there is no explicit scope reference node
>> passed in then the implied scope reference node is document (or some
>> equivalent for elements not in document). I believe that currently the
>> implied scope reference node is the element itself.
>>
>> Currently:
>> E.matches(':scope') -> true
>> E.matches(':scope ul li') -> false
>>
>> Should be:
>> E.matches(':scope') -> false
>> E.matches(':scope ul li') -> true if E.matches('ul li') is true
> Why would that be better? As far as the :scope pseudo-element is
> concerned, the current semantics seem much more intuitive. I could see
> how you maybe want to rebind :scope, or restrict the tree traversed,
> but not why you want to change the way :scope works.
>
>
E.matches(':scope')
E.closest(':has(:scope)')
are not selectors anyone would write.
They do not have to be useful.
They should be consistent. e.g.
A.query(':scope > li > a[href]').matches(':scope > li > a[href]',
A); // potentially true
document.query(':scope body').matches(':scope body'); // probably true
Scoping is defining a boundary (not a reference node).
In the DOM, a single node can define a boundary for all the nodes
*below* it.
That's why in
A.queryAll(':scope > li > a[href]')
A.queryAll('> li > a[href]')
the scope is naturally A, because queryAll() can find all nodes *below* A.
Similarly in
document.queryAll(':scope body')
the scope is naturally document because it can find all nodes *below*
document.
SImilarly in
E.closest(':scope > li > a[href]', A);
the scope is naturally A, because the search can find an element *below* A.
Similarly in
E.closest('li > a[href]')
the scope is naturally *document* because the search can find an element
*below* document.
This is the same in
E.closest(':scope body')
where the scope is document.
Similarly it follows that in
E.matches(':scope > li > a[href], A);
the scope is A.
Similarly it follows that in
E.matches(':scope body')
the scope is document.
If there is a need for for pseudo-class in E.matches() that references
E, then it should be a new pseudo-class, say :ref-node.
regards,
Sean
Received on Tuesday, 23 September 2014 20:06:23 UTC