Skip to content

"every key" and "every value" modifiers are broken for html #591

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

Closed
pokey opened this issue Mar 7, 2022 · 6 comments
Closed

"every key" and "every value" modifiers are broken for html #591

pokey opened this issue Mar 7, 2022 · 6 comments
Labels
bug Something isn't working

Comments

@pokey
Copy link
Member

pokey commented Mar 7, 2022

<!DOCTYPE html>
<html style="foo" class="bar"></html>

Neither "clear every key fine" nor "clear every value fine" work as expected

@pokey pokey added the bug Something isn't working label Mar 7, 2022
@Will-Sommers
Copy link
Collaborator

It looks like the match for each is too permissive and not traversing to the proper level here before returning.

In the debugger, adding an extra parent returns the correct match.

parent.parent.namedChildren
      .flatMap((sibling) => nodeMatcher(selection, sibling))

@pokey
Copy link
Member Author

pokey commented Mar 14, 2022

Interesting. Any ideas for an easy way to fix this one?

Fwiw @wenkokke is working on a more sophisticated version of our pattern language so that we can specify both the node we're looking for and its parent for "each". That's going to be a bit more work, so if you have an idea for an easy fix here in the meantime lmk

@Will-Sommers
Copy link
Collaborator

Sounds super cool.

I need to look at it a bit more. I think this might be a generalized problem with "!imporant" as a matcher. It is great that we're looking at a way to specify.

What is happening is that most languages have the key/value defined as fields of a pair node type. This means that pair[key] won't match on the node's children, key and value, and so it goes up a layer.

I think the issue with html is that we want to select attribute_name as the selection. However, that node's parent is attribute which will then immediately match on attribute_name rather than moving up a level.

@pokey
Copy link
Member Author

pokey commented Mar 14, 2022

Right yeah my guess is that a lot of these "every" bugs are due to needing to iterate grandchildren rather than children

@pokey
Copy link
Member Author

pokey commented Jun 8, 2022

I think the idea will be to address this one using #616

@AndreasArvidsson
Copy link
Member

This works fine today

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants