-
Notifications
You must be signed in to change notification settings - Fork 815
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
Selectors should be case insensitive #1047
Comments
davep
added a commit
to davep/textual
that referenced
this issue
Oct 31, 2022
Under the hood this now creates and holds a lower-cased version of the ID and always compares against that. The query tests have also been updated to throw in some mixed-case IDs to test with. See Textualize#1041 and Textualize#1047.
After implementing this, and then having a chat about it in the office, we've decided that we'll follow the Web and do the opposite: case sensitivity will be fully-enforced for IDs (we should also check this for classes, etc, but for the moment this is about IDs). |
Did we solve your problem? Glad we could help! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It looks like selectors insist on being lower-case, which means that if you use upper case in an ID it won't match. Possibly true of classes as well. Need to investigate.
Discussed in #1041
Originally posted by mindset-team October 28, 2022
There's seems to be some case sensitivity issue with query/query_one. Here's an example app where widget id must be lower-cased in order to return a valid query result (vs. a
NoMatches
exception). The query selector seems to be case-insensitive.Above,
on_key
is simply used to trigger the query event andtextual console
opened in another terminal to monitor print output.The code above fails with
NoMatches: No nodes match <DOMQuery GridLayoutExample(title='GridLayoutExample') filter='#One'
However, changing
id=One
toid=one
(in compose method yielding the static widget) works, no exception raised and console printout is valid:Is this behavior expected? It seems counter-intuitive that a selector would be case insensitive, but id would be coerced to be lower-cased for a query to work. I couldn't find any reference to case-[in]sensitivity in the textualize.io guide, or on github (after a quick review of the textual css parsing code and def query).
Not sure this elevates to a bug (and anyway maintaining all ID's in lower-case would avoid this issue) but since many of the examples have
#One, #Two
identifiers throughout the docs, the issue seems to merit a discussion here, a clear instruction in the docs, or designating as a bug to fix. Thoughts?The text was updated successfully, but these errors were encountered: