Skip to content

Commit

Permalink
update docs according to changes in AST
Browse files Browse the repository at this point in the history
  • Loading branch information
lahmatiy committed Feb 7, 2017
1 parent 4245247 commit 259aa85
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 35 deletions.
51 changes: 20 additions & 31 deletions docs/ast.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ Pending changes in AST:
- `Progid` is subject to be removed
- `Space` will be extended to store actual whitespaces
- `Space` may to be renamed into `WhiteSpace`
- `Type`, `Universal`, `Id`, `Class`, `Attribute`, `PseudoClass` and `PseudoElement` may to be renamed to add a `Selector` suffix
- `Type` and `Universal` to be joined into single type `Type`

Other node types are stable enough.

Expand All @@ -23,18 +21,18 @@ Node types:
- [AnPlusB](#anplusb)
- [Atrule](#atrule)
- [AtruleExpression](#atruleexpression)
- [Attribute](#attribute)
- [AttributeSelector](#attributeselector)
- [Block](#block)
- [Brackets](#brackets)
- [Class](#class)
- [ClassSelector](#classselector)
- [Combinator](#combinator)
- [Comment](#comment)
- [Declaration](#declaration)
- [DeclarationList](#declarationlist)
- [Dimension](#dimension)
- [Function](#function)
- [Hash](#hash)
- [Id](#id)
- [IdSelector](#idselector)
- [Identifier](#identifier)
- [MediaFeature](#mediafeature)
- [MediaQuery](#mediaquery)
Expand All @@ -45,8 +43,8 @@ Node types:
- [Parentheses](#parentheses)
- [Percentage](#percentage)
- [Progid](#progid)
- [PseudoClass](#pseudoclass)
- [PseudoElement](#pseudoelement)
- [PseudoClassSelector](#pseudoclassselector)
- [PseudoElementSelector](#pseudoelementselector)
- [Ratio](#ratio)
- [Raw](#raw)
- [Rule](#rule)
Expand All @@ -55,9 +53,8 @@ Node types:
- [Space](#space)
- [String](#string)
- [StyleSheet](#stylesheet)
- [Type](#type)
- [TypeSelector](#typeselector)
- [UnicodeRange](#unicoderange)
- [Universal](#universal)
- [Url](#url)
- [Value](#value)

Expand Down Expand Up @@ -97,11 +94,11 @@ Used to represent [the An+B microsyntax](https://drafts.csswg.org/css-syntax/#an
}
```

## Attribute
## AttributeSelector

```
{
"type": "Attribute",
"type": "AttributeSelector",
"name": string,
"operator": string | null,
"value": <String> | <Identifier> | null,
Expand All @@ -127,11 +124,11 @@ Used to represent [the An+B microsyntax](https://drafts.csswg.org/css-syntax/#an
}
```

## Class
## ClassSelector

```
{
"type": "Class",
"type": "ClassSelector",
"name": string
}
```
Expand Down Expand Up @@ -203,11 +200,11 @@ Used to represent [the An+B microsyntax](https://drafts.csswg.org/css-syntax/#an
}
```

## Id
## IdSelector

```
{
"type": "Id",
"type": "IdSelector",
"name": string
}
```
Expand Down Expand Up @@ -304,21 +301,21 @@ Used to represent [the An+B microsyntax](https://drafts.csswg.org/css-syntax/#an
}
```

## PseudoClass
## PseudoClassSelector

```
{
"type": "PseudoClass",
"type": "PseudoClassSelector",
"name": string,
"children": List | null
}
```

## PseudoElement
## PseudoElementSelector

```
{
"type": "PseudoElement",
"type": "PseudoElementSelector",
"name": string,
"children": List | null
}
Expand Down Expand Up @@ -375,7 +372,8 @@ Used to represent [the An+B microsyntax](https://drafts.csswg.org/css-syntax/#an

```
{
"type": "Space"
"type": "Space",
"value": string
}
```

Expand All @@ -397,11 +395,11 @@ Used to represent [the An+B microsyntax](https://drafts.csswg.org/css-syntax/#an
}
```

## Type
## TypeSelector

```
{
"type": "Type",
"type": "TypeSelector",
"name": string
}
```
Expand All @@ -415,15 +413,6 @@ Used to represent [the An+B microsyntax](https://drafts.csswg.org/css-syntax/#an
}
```

## Universal

```
{
"type": "Universal",
"name": string
}
```

## Url

```
Expand Down
8 changes: 4 additions & 4 deletions docs/traversal.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ csstree.walk(csstree.parse('.a { color: red; }'), function(node) {
// Rule
// SelectorList
// Selector
// Class
// ClassSelector
// Block
// Declaration
// Value
Expand All @@ -47,7 +47,7 @@ Context for handler an object, that contains references to some parent nodes:
- `selector` – refers to `SelectorList` node if any
- `block` - refers to closest `Block` node if any
- `declaration` – refers to `Declaration` node if any
- `function` – refers to closest `Function`, `PseudoClass` or `PseudoElement` node if current node inside one of them
- `function` – refers to closest `Function`, `PseudoClassSelector` or `PseudoElementSelector` node if current node inside one of them

```js
// collect all urls in declarations
Expand Down Expand Up @@ -90,7 +90,7 @@ csstree.walk(ast, function(node) {
// Rule
// SelectorList
// Selector
// Class
// ClassSelector
// Block
// Declaration
// Value
Expand All @@ -99,7 +99,7 @@ csstree.walk(ast, function(node) {
csstree.walkUp(ast, function(node) {
console.log(node.type);
});
// Class
// ClassSelector
// Selector
// SelectorList
// Identifier
Expand Down

0 comments on commit 259aa85

Please sign in to comment.