Skip to content

[css-syntax] "Serializing <an+b>" doesn't match what Firefox or Safari do #1504

@jyc

Description

@jyc

The "Serializing <an+b>" matches what Chrome does, but not what Safari or Firefox does. This section is referred to by the "Serializing Selectors" section of CSS OM.

Firefox just writes n when a is 1, while Safari separates fields with spaces.

With the following page, here are some example serializations given by Firefox, Chrome, and Safari:

<style type="text/css">
  :nth-child(X){}
</style>
<script type="text/javascript">
console.log(document.styleSheets[0].cssRules[0].cssText);
</script>
:nth-child(X) Firefox Chrome Safari
1n - 0 n 1n 1n - 0
n + 1 n+1 1n+1 n + 1
-n - 5 -n-5 -1n-5 -n - 5
+1 1 1 +1
-1n-5 -n-5 -1n-5 -1n-5*
-1n -5 -n-5 -1n-5 -1n -5*

* Does this mean Safari doesn't add spaces if you don't add them, but keeps one if you add one or more?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions