Bug 227391
| Summary: | MobileSafari cannot parse `@supports selector(…)` | ||
|---|---|---|---|
| Product: | WebKit | Reporter: | Bramus <bramus> |
| Component: | CSS | Assignee: | Nobody <webkit-unassigned> |
| Status: | RESOLVED INVALID | ||
| Severity: | Normal | CC: | ap |
| Priority: | P2 | ||
| Version: | Other | ||
| Hardware: | iPhone / iPad | ||
| OS: | Unspecified | ||
Bramus
Safari/MobileSafari currently are the only browsers that support the `:nth-child(An+B [of S]?)` selector.
When checking for support for `:nth-child(An+B [of S]?)` using @supports, only Safari on Desktop claims it does; MobileSafari does not understand the rule.
```
@supports selector(:nth-child(1 of x)) { /* BUG: Only targets Desktop Safari, although MobileSafari also supports the selector … */
…
}
```
See demo at https://codepen.io/bramus/pen/3c476384f0adadd65a0b53db15f86cf4
- Safari: The background is hotpink
- MobileSafari: The background remains the default color
Further findings:
1. MobileSafari's parsing breaks on `selector(:nth-child(1 of x))`. Extending the @supports rule with a check for `-webkit-touch-callout: none` (which MobileSafari does understand) does nothing.
```
@supports selector(:nth-child(1 of x)) or (-webkit-touch-callout: none) {
…
}
```
2. When adding extra parens around the `selector()` MobileSafari does seem to be able to parse the expression:
```
@supports (selector(:nth-child(1 of x))) or (-webkit-touch-callout: none) {
…
}
```
3. Singling out `selector()` with extra parens added also doesn't work on MobileSafari:
```
@supports (selector(:nth-child(1 of x))) {
…
}
```
It is expected that MobileSafari understands all code examples shown, whereas now it only understands the syntax used in the "Further Findings 2" example.
| Attachments | ||
|---|---|---|
| Add attachment proposed patch, testcase, etc. |
Bramus
By extension, after some further testing: MobileSafari simply does not understand `@supports selector(…)`.
See https://codepen.io/bramus/pen/2abd4b7e1d411fa687295f0697e294d4 for a demo.
Alexey Proskuryakov
I cannot reproduce this on iOS 14.6 or iOS 15 beta.
Not sure what could be different in your testing. Any chance that you were using an older iOS version?
Bramus
I see that my phone still was on iOS 14.4. Testing on 14.6 indeed confirms it works. Thanks!