Re: Scoped absolute paths in querySelector/All

On Fri, Sep 6, 2013 at 6:13 PM, Brett Zamir <brettz9@gmail.com> wrote:
> I am wondering whether thought has been given to allowing selectors
> beginning with ">" for use with querySelector/All such as:
>
>     " > .sharedClass"
>
> Sometimes one wishes to resolve a precise hierarchy but relative to the
> current element. Currently, to do so with precision, one must either specify
> a path starting from the document root, a unique ID, or use other scripting
> methods.

Selectors API 2 provides this ability through the .find() and
.findAll() functions:
<http://dev.w3.org/2006/webapi/selectors-api2/#findelements-relative>.

> (Although the use case would be far less common, a path might also begin
> with ">" when run against documents to allow usage with XML documents where
> a path was desired relative to the root but without committing to a specific
> root element.)

That's what the :root pseudoclass is for, by the way:
<http://dev.w3.org/csswg/selectors/#the-root-pseudo>

> It would also be nice to be able to modify the element or elements--e.g., if
> there were a removeSelector(sel) analogue to the ability to use "delete
> obj.prop.prop2" on a JSON object, a replaceSelector(sel, el) convenience
> method, etc..

I don't understand what this would do, from your description.

~TJ

Received on Saturday, 7 September 2013 01:20:34 UTC