Bug 227391 - MobileSafari cannot parse `@supports selector(…)`
Summary: MobileSafari cannot parse `@supports selector(…)`
Status: RESOLVED INVALID
Alias: None
Product: WebKit
Classification: Unclassified
Component: CSS (show other bugs)
Version: Other
Hardware: iPhone / iPad Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-06-25 02:29 PDT by Bramus
Modified: 2021-06-25 15:06 PDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Bramus 2021-06-25 02:29:43 PDT
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.
Comment 1 Bramus 2021-06-25 02:40:19 PDT
By extension, after some further testing: MobileSafari simply does not understand `@supports selector(…)`.

See https://codepen.io/bramus/pen/2abd4b7e1d411fa687295f0697e294d4 for a demo.
Comment 2 Alexey Proskuryakov 2021-06-25 11:35:54 PDT
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?
Comment 3 Bramus 2021-06-25 15:06:20 PDT
I see that my phone still was on iOS 14.4. Testing on 14.6 indeed confirms it works. Thanks!