Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deprecate finders scope option #626

Open
ro0gr opened this issue Oct 4, 2023 · 0 comments
Open

deprecate finders scope option #626

ro0gr opened this issue Oct 4, 2023 · 0 comments

Comments

@ro0gr
Copy link
Collaborator

ro0gr commented Oct 4, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant