Skip to content

Commit

Permalink
Add layer & supports into @media
Browse files Browse the repository at this point in the history
  • Loading branch information
lahmatiy committed Sep 27, 2023
1 parent 05ecd09 commit 34e1ee0
Show file tree
Hide file tree
Showing 3 changed files with 439 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -2,6 +2,7 @@

- Added support for the `@container` at-rule
- Added support for the `@layer` at-rule
- Added support for `layer`, `layer()` and `supports()` in the `@media` at-rule
- Added `Layer` and `LayerList` node types
- Bumped `mdn/data` to `2.1.0`
- Added `TokenStream#lookupTypeNonSC()` method
Expand Down
367 changes: 367 additions & 0 deletions fixtures/ast/atrule/atrule/import.json
Expand Up @@ -112,6 +112,373 @@
"block": null
}
},
"with anonymous layer": {
"source": "@import url(test) layer;",
"generate": "@import url(test)layer;",
"ast": {
"type": "Atrule",
"name": "import",
"prelude": {
"type": "AtrulePrelude",
"children": [
{
"type": "Url",
"value": "test"
},
{
"type": "Identifier",
"name": "layer"
}
]
},
"block": null
}
},
"with layer()": {
"source": "@import url(test) layer(foo);",
"generate": "@import url(test)layer(foo);",
"ast": {
"type": "Atrule",
"name": "import",
"prelude": {
"type": "AtrulePrelude",
"children": [
{
"type": "Url",
"value": "test"
},
{
"type": "Function",
"name": "layer",
"children": [
{
"type": "Layer",
"name": "foo"
}
]
}
]
},
"block": null
}
},
"with bad layer()": [
{
"source": "@import url(test) layer();",
"generate": "@import url(test)layer();",
"ast": {
"type": "Atrule",
"name": "import",
"prelude": {
"type": "AtrulePrelude",
"children": [
{
"type": "Url",
"value": "test"
},
{
"type": "Function",
"name": "layer",
"children": []
}
]
},
"block": null
}
},
{
"source": "@import url(test) layer( 2px );",
"generate": "@import url(test)layer(2px);",
"ast": {
"type": "Atrule",
"name": "import",
"prelude": {
"type": "AtrulePrelude",
"children": [
{
"type": "Url",
"value": "test"
},
{
"type": "Function",
"name": "layer",
"children": [
{
"type": "Raw",
"value": "2px"
}
]
}
]
},
"block": null
}
}
],
"with supports(declaration)": {
"source": "@import url(test) supports(foo:1);",
"generate": "@import url(test)supports(foo:1);",
"ast": {
"type": "Atrule",
"name": "import",
"prelude": {
"type": "AtrulePrelude",
"children": [
{
"type": "Url",
"value": "test"
},
{
"type": "Function",
"name": "supports",
"children": [
{
"type": "Declaration",
"important": false,
"property": "foo",
"value": {
"type": "Value",
"children": [
{
"type": "Number",
"value": "1"
}
]
}
}
]
}
]
},
"block": null
}
},
"with supports(condition)": {
"source": "@import url(test) supports(not (foo:1));",
"generate": "@import url(test)supports(not (foo:1));",
"ast": {
"type": "Atrule",
"name": "import",
"prelude": {
"type": "AtrulePrelude",
"children": [
{
"type": "Url",
"value": "test"
},
{
"type": "Function",
"name": "supports",
"children": [
{
"type": "Condition",
"kind": "supports",
"children": [
{
"type": "Identifier",
"name": "not"
},
{
"type": "SupportsDeclaration",
"declaration": {
"type": "Declaration",
"important": false,
"property": "foo",
"value": {
"type": "Value",
"children": [
{
"type": "Number",
"value": "1"
}
]
}
}
}
]
}
]
}
]
},
"block": null
}
},
"with bad supports()": [
{
"source": "@import url(test) supports();",
"generate": "@import url(test)supports();",
"ast": {
"type": "Atrule",
"name": "import",
"prelude": {
"type": "AtrulePrelude",
"children": [
{
"type": "Url",
"value": "test"
},
{
"type": "Function",
"name": "supports",
"children": []
}
]
},
"block": null
}
},
{
"source": "@import url(test) supports( 2px );",
"generate": "@import url(test)supports(2px);",
"ast": {
"type": "Atrule",
"name": "import",
"prelude": {
"type": "AtrulePrelude",
"children": [
{
"type": "Url",
"value": "test"
},
{
"type": "Function",
"name": "supports",
"children": [
{
"type": "Raw",
"value": "2px"
}
]
}
]
},
"block": null
}
}
],
"with layer & supports": {
"source": "@import url(test) layer(name) supports(foo:1);",
"generate": "@import url(test)layer(name) supports(foo:1);",
"ast": {
"type": "Atrule",
"name": "import",
"prelude": {
"type": "AtrulePrelude",
"children": [
{
"type": "Url",
"value": "test"
},
{
"type": "Function",
"name": "layer",
"children": [
{
"type": "Layer",
"name": "name"
}
]
},
{
"type": "Function",
"name": "supports",
"children": [
{
"type": "Declaration",
"important": false,
"property": "foo",
"value": {
"type": "Value",
"children": [
{
"type": "Number",
"value": "1"
}
]
}
}
]
}
]
},
"block": null
}
},
"with layer & supports & media": {
"source": "@import url(test) layer(name) supports(foo:1) screen and (min-width: 100px);",
"generate": "@import url(test)layer(name) supports(foo:1) screen and (min-width:100px);",
"ast": {
"type": "Atrule",
"name": "import",
"prelude": {
"type": "AtrulePrelude",
"children": [
{
"type": "Url",
"value": "test"
},
{
"type": "Function",
"name": "layer",
"children": [
{
"type": "Layer",
"name": "name"
}
]
},
{
"type": "Function",
"name": "supports",
"children": [
{
"type": "Declaration",
"important": false,
"property": "foo",
"value": {
"type": "Value",
"children": [
{
"type": "Number",
"value": "1"
}
]
}
}
]
},
{
"type": "MediaQueryList",
"children": [
{
"type": "MediaQuery",
"modifier": null,
"mediaType": "screen",
"condition": {
"type": "Condition",
"kind": "media",
"children": [
{
"type": "Feature",
"kind": "media",
"name": "min-width",
"value": {
"type": "Dimension",
"value": "100",
"unit": "px"
}
}
]
}
}
]
}
]
},
"block": null
}
},
"@import with block is not an error": {
"source": "@import 'test' {}",
"generate": "@import \"test\"{}",
Expand Down

0 comments on commit 34e1ee0

Please sign in to comment.