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

Major selector enhancements #388

Merged
merged 7 commits into from
Apr 20, 2020
Merged

Major selector enhancements #388

merged 7 commits into from
Apr 20, 2020

Conversation

mtdowling
Copy link
Member

This commit adds several new features to selectors, updates its grammar, and rewrites the parser to be more adaptable to change.

  • Add support for numeric attribute comparators. You can match values that are parsed as numbers using >, >=, <, <=. This can be used to find out things like [trait|httpError >= 500].
  • Add support for != to check if an attribute exists but isn't equal to the given value.
    The "!=" attribute comparator is used to find shapes that have an attribute, but the attribute is not equal to a given value. For example, the following selector: [trait|error!=client], is a simplification of the following:
    [trait|error]:not([trait|error=client])
  • Add support for CSV values in attribute selectors. This enables checking if a resolved attribute value matches one or more comparison values, allowing for things like [trait|httpError = 500, 501].
  • Fix "~=" in docs to properly reference "^=". The docs previously documented the wrong comparator.
  • Adds support for numbers in attribute selectors. You no longer need to quote numbers in selector attribute values.
  • Shape IDs with members must be quoted. This is to remove a parsing ambiguity with the $= comparator.
  • Add support for selecting nested trait properties. Nested trait properties can be selected using a "|" delimited syntax. Values or lists and objects can be "projected" using the special (values) property. Keys of objects can be projected using the special (keys) property.
  • pseudo-properties are now formalized in the grammar and parser as"(" identifier ")", allowing us to add more in the future as needed.
  • This commit updates selectors to tolerate unknown functions and renames the ":each" selector to ":is" to match the CSS4 name of ":is", which is the same functionality. Support for ":each" is still present and functions as an alias.

This commit updates selectors to tolerate unknown functions and renames
the ":each" selector to ":is" to match the CSS4 name of ":is", which is
the same functionality. Support for ":each" is still present and
functions as an alias.
The "!=" attribute comparator is used to find shapes that have an
attribute, but the attribute is not equal to a given value.

For example, the following selector:

```
[trait|error!=client]
```

Is a simplification of the following:

```
[trait|error]:not([trait|error=client])
```
Nested trait properties can be selected using a "|" delimited syntax.
Values or lists and objects can be "projected" using the special
`(values)` property. Keys of objects can be projected using the
special `(keys)` property.
* Fix "~=" in docs to properly reference "^=".
* Rewrite Selector parser to be more restrictive and fix several bugs.
* Adds support for numbers in attribute selectors.
* Shape IDs with members must be quoted.
* The parser and grammar are more resilient to unknown attributes,
  functions, and attribute paths.
* pseudo-properties are now formalized in the grammar and parser as
  `"(" identifier ")"`, allowing us to add more in the future as needed.
@mtdowling mtdowling requested a review from kstich April 20, 2020 04:11
docs/source/spec/core/selectors.rst Outdated Show resolved Hide resolved
docs/source/spec/core/selectors.rst Outdated Show resolved Hide resolved
docs/source/spec/core/selectors.rst Outdated Show resolved Hide resolved
@mtdowling mtdowling requested a review from kstich April 20, 2020 17:34
@mtdowling mtdowling merged commit 0a29e85 into 0.10 Apr 20, 2020
@mtdowling mtdowling deleted the selectors-updates branch April 23, 2020 02:17
@kstich kstich mentioned this pull request Apr 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants