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

Experimental: Language tag canonicalization #159

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

facelessuser
Copy link
Owner

@facelessuser facelessuser commented Sep 8, 2019

There is talk about potentially having the CSS level 4 :lang() pseudo-class canonicalizing tags and ranges to better help in situations such as: :lang(yue, zh-yue, zh-HK). The idea is you could then just do something like: :lang(yue). For best matches, it is recommended to canonicalize both the range used in the pseudo-class and the tag it is comparing. Canonicalization would also output in the extlang form.

Generally * are ignored in ranges except when at the start: *-yue. Things like en-*-US resolve to en-US, though implicit matching between tags will still match en-xxx-US with en-US.

Currently, in this pull, we have canonicalization implemented according to RFC5646, but there are still some questions:

  1. Should we abandon canonicalization, like we are currently doing, when the tag is invalid? Or do we just canonicalize the valid parts and ignore the failing parts?

  2. As mentioned above, ranges can use *, so we strip out non-essential *s and them canonicalize the range. This seems like the only sane approach, but am I misunderstanding something?

  3. It is only suggested that we MAY order variants to improve matching. We decided to go ahead and do this. Should we though? We have also omitted any failures if the required prefixes for a given variant are not found in the tag. This is to help ensure that both the the tag variant order is the same as the range's variant order, as specified range may not explicitly define all required ranges and rely on implicit matching to grab those. This seems reasonable, but should we abort canonicalization if the prefixes are not found? It is not a MUST requirement in the spec, only a SHOULD.

Anyways, some things to think about. Technically we could merge this as is and simply disable the canonicalization and it should behave exactly how it did before. We could also enable this functionality under an experimental flag if we wanted. Right now, we are simply waiting to see what is decided for the official level 4 CSS spec.

@facelessuser facelessuser added the S: work-in-progress A partial solution. More changes will be coming. label Sep 8, 2019
@facelessuser facelessuser force-pushed the lang-canonicalize branch 2 times, most recently from adb96af to db36b41 Compare September 8, 2019 15:07
This work may not be used depending on what is decided in the level 4
selector spec, but if it is potentially done, we should hopefully be
ready. Tests are still needed to ensure we are doing things as expected.
Also, I am not entirely certain how ranges are supposed to be handled vs
tags, but I think I am handling them as expected.
Only include keys we actively care about.
Ignore in registry.py as while covered, the information is not helpful.
Ignore coverage in Canonicalization as there are no real are no tests
for this currently, and we simply want to make sure we are covering
all the pre-canonicalization logic.
@github-actions github-actions bot added C: css-matching Related to CSS matching. C: docs Related to documentation. C: infrastructure Related to project infrastructure. selectors C: tests Related to testing. labels Oct 20, 2019
@gir-bot gir-bot removed the selectors label Nov 1, 2019
@facelessuser
Copy link
Owner Author

This still hasn't formally made it into the spec. It may never. We wanted to get the jump on this, but there seems to be very little interest from the CSS spec team to decide on what they want to do. We will continue to hold on this as it is still not clear if this is the direction they will take.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C: css-matching Related to CSS matching. C: docs Related to documentation. C: infrastructure Related to project infrastructure. C: tests Related to testing. S: work-in-progress A partial solution. More changes will be coming.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants