Skip to content

deprecate finders scope option #626

@ro0gr

Description

@ro0gr

Cause it seems to behave in a counter-intuitive way.

A query like:

const node = create({ scope: '.one' });
 
findOne(node, '.two', { scope: '.three' });

generates a selector like .one .three .two.

If a selector like this is really needed, it's possible to do it in a simpler way like:

findOne(node, '.three .two');

I think the rationale for the scope option was to support finder signatures without a string selector argument, like

findOne(node, { scope: '.three .two' });

However, as shown above, in its 3-argument form it looks broken.

Implementation plan

In order to support the 2-argument signature with options, let's implement the new option called selector.
This would be only allowed in the 2-argument signature form:

findOne(node, { selector: '.two' }); 
// => `.one .two`

// together with the `scope` the works exactly like it works today
findOne(node, { selector: '.two', scope: '.three' });  
// => `.one .three .two`

// WRONG: passing 2 selectors should not be possible
findOne(node, '.two', { selector: '.boom' });  
// => Throw!

Then we can deprecate the scope, and remove it at some point.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions