-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve compatibility for browsers that do not support `ResizeObserve…
…r` or `:where` selector (#5265) * Add fallback for default styles when `:where` selector is not supported * Add polyfill for ResizeObserver * Add changeset
- Loading branch information
1 parent
2ab56c3
commit 3cf51f4
Showing
6 changed files
with
48 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'slate-react': patch | ||
--- | ||
|
||
Improve compatibility for browsers that do not support ResizeObserver or :where selector |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/** | ||
* Returns a set of rules that use the `:where` selector if it is supported, | ||
* otherwise it falls back to the provided selector on its own. | ||
* | ||
* The `:where` selector is used to give a selector a lower specificity, | ||
* allowing the rule to be overridden by a user-defined stylesheet. | ||
* | ||
* Older browsers do not support the `:where` selector. | ||
* If it is not supported, the selector will be used without `:where`, | ||
* which means that the rule will have a higher specificity and a user-defined | ||
* stylesheet will not be able to override it easily. | ||
*/ | ||
export function whereIfSupported(selector: string, styles: string): string { | ||
return ( | ||
`@supports (selector(:where(${selector}))) {` + | ||
`:where(${selector}) { ${styles} }` + | ||
`}` + | ||
`@supports not (selector(:where(${selector}))) {` + | ||
`${selector} { ${styles} }` + | ||
`}` | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters