Comparing version 1.0.0-alpha22 to 1.0.0-alpha23
@@ -17,3 +17,3 @@ # AST format | ||
- [Atrule](#atrule) | ||
- [AtruleExpression](#atruleexpression) | ||
- [AtrulePrelude](#atruleprelude) | ||
- [AttributeSelector](#attributeselector) | ||
@@ -79,3 +79,3 @@ - [Block](#block) | ||
"name": String, | ||
"expression": <AtruleExpression> | null, | ||
"prelude": <AtrulePrelude> | null, | ||
"block": <Block> | null | ||
@@ -85,7 +85,7 @@ } | ||
## AtruleExpression | ||
## AtrulePrelude | ||
``` | ||
{ | ||
"type": "AtruleExpression", | ||
"type": "AtrulePrelude", | ||
"children": List | ||
@@ -92,0 +92,0 @@ } |
@@ -34,3 +34,3 @@ # Parsing CSS into AST | ||
- [column](#column) | ||
- [parseAtruleExpression](#parseatruleexpression) | ||
- [parseAtrulePrelude](#parseatruleprelude) | ||
- [parseSelector](#parseselector) | ||
@@ -53,3 +53,3 @@ - [parseValue](#parsevalue) | ||
- `atrule` – at-rule (e.g. `@media screen, print { ... }`) | ||
- `atruleExpression` – at-rule expression (`screen, print` for example above) | ||
- `atrulePrelude` – at-rule prelude (`screen, print` for example above) | ||
- `mediaQueryList` – used to parse comma separated media query list | ||
@@ -70,3 +70,3 @@ - `mediaQuery` – used to parse media query | ||
Using for `atruleExpression` context to apply atrule specific parse rules. | ||
Using for `atrulePrelude` context to apply atrule specific parse rules. | ||
@@ -156,3 +156,3 @@ ### property | ||
### parseAtruleExpression | ||
### parseAtrulePrelude | ||
@@ -162,3 +162,3 @@ Type: `boolean` | ||
Defines to parse a at-rule expression in details (represents as `AtruleExpresion`, `MediaQueryList` or `SelectorList` if any). Otherwise represents expression as `Raw` node. | ||
Defines to parse a at-rule prelude in details (represents as `AtruleExpresion`, `MediaQueryList` or `SelectorList` if any). Otherwise represents prelude as `Raw` node. | ||
@@ -169,4 +169,4 @@ ```js | ||
// "type": "Atrule", | ||
// "expression": { | ||
// "type": "AtruleExpression", | ||
// "prelude": { | ||
// "type": "AtrulePrelude", | ||
// "children": [ | ||
@@ -181,6 +181,6 @@ // { "type": "Number", "value": "1" }, | ||
csstree.parse('@example 1 2;', { parseAtruleExpression: false }); | ||
csstree.parse('@example 1 2;', { parseAtrulePrelude: false }); | ||
// { | ||
// "type": "Atrule", | ||
// "expression": { | ||
// "prelude": { | ||
// "type": "Raw", | ||
@@ -187,0 +187,0 @@ // "value": "1 2" |
@@ -17,3 +17,3 @@ # Supported syntaxes | ||
At-rules with a custom parsing rules. In fact, any at-rule is supported but expression and block are parsing with default rules. Validation support isn't supported for at-rules at the moment. | ||
At-rules with a custom parsing rules. In fact, any at-rule is supported but prelude and block are parsing with default rules. Validation support isn't supported for at-rules at the moment. | ||
@@ -20,0 +20,0 @@ <!-- gen:atrule --> |
@@ -45,3 +45,3 @@ # AST traversal | ||
- `stylesheet` – refers to `StyleSheet` node, usually it's a root node | ||
- `atruleExpression` – refers to `AtruleExpression` node if any | ||
- `atrulePrelude` – refers to `AtrulePrelude` node if any | ||
- `rule` – refers to closest `Rule` node if any | ||
@@ -48,0 +48,0 @@ - `selector` – refers to `SelectorList` node if any |
@@ -0,1 +1,12 @@ | ||
## 1.0.0-alpha23 (September 10, 2017) | ||
- Fixed `Tokenizer#getRawLength()`'s false positive balance match to the end of input in some cases (#56) | ||
- Rename walker's entry point methods to be the as CSSTree methods (i.e. `walk()`, `walkUp` etc) | ||
- Rename at-rule `expression` to `prelude`: | ||
- `AtruleExpression` node type → `AtrulePrelude` | ||
- `Atrule.expression` field → `Atrule.prelude` | ||
- `parseAtruleExpression` parser's option → `parseAtrulePrelude` | ||
- `atruleExpression` parse context → `atrulePrelude` | ||
- `atruleExpression` walk context reference → `atrulePrelude` | ||
## 1.0.0-alpha22 (September 8, 2017) | ||
@@ -2,0 +13,0 @@ |
var List = require('../utils/list'); | ||
module.exports = function createConvertors(walker) { | ||
var walk = walker.all; | ||
var walkUp = walker.allUp; | ||
var walk = walker.walk; | ||
var walkUp = walker.walkUp; | ||
@@ -7,0 +7,0 @@ return { |
@@ -77,3 +77,3 @@ 'use strict'; | ||
onParseError: noop, | ||
parseAtruleExpression: true, | ||
parseAtrulePrelude: true, | ||
parseSelector: true, | ||
@@ -140,3 +140,3 @@ parseValue: true, | ||
parser.onParseError = typeof options.onParseError === 'function' ? options.onParseError : noop; | ||
parser.parseAtruleExpression = 'parseAtruleExpression' in options ? Boolean(options.parseAtruleExpression) : true; | ||
parser.parseAtrulePrelude = 'parseAtrulePrelude' in options ? Boolean(options.parseAtrulePrelude) : true; | ||
parser.parseSelector = 'parseSelector' in options ? Boolean(options.parseSelector) : true; | ||
@@ -143,0 +143,0 @@ parser.parseValue = 'parseValue' in options ? Boolean(options.parseValue) : true; |
module.exports = { | ||
parse: { | ||
expression: null, | ||
prelude: null, | ||
block: function() { | ||
@@ -5,0 +5,0 @@ return this.Block(this.Declaration); |
@@ -11,3 +11,3 @@ var List = require('../../utils/list'); | ||
parse: { | ||
expression: function() { | ||
prelude: function() { | ||
var children = new List(); | ||
@@ -14,0 +14,0 @@ |
@@ -5,3 +5,3 @@ var List = require('../../utils/list'); | ||
parse: { | ||
expression: function() { | ||
prelude: function() { | ||
return new List().appendData( | ||
@@ -8,0 +8,0 @@ this.MediaQueryList() |
@@ -7,3 +7,3 @@ var List = require('../../utils/list'); | ||
parse: { | ||
expression: function() { | ||
prelude: function() { | ||
if (this.scanner.lookupNonWSType(0) === LEFTCURLYBRACKET) { | ||
@@ -10,0 +10,0 @@ return null; |
@@ -59,3 +59,3 @@ var List = require('../../utils/list'); | ||
case FUNCTION: | ||
child = this.Function(consumeRaw, this.scope.AtruleExpression); | ||
child = this.Function(consumeRaw, this.scope.AtrulePrelude); | ||
break; | ||
@@ -68,3 +68,3 @@ | ||
case LEFTPARENTHESIS: | ||
child = this.Parentheses(parentheses, this.scope.AtruleExpression); | ||
child = this.Parentheses(parentheses, this.scope.AtrulePrelude); | ||
break; | ||
@@ -89,3 +89,3 @@ | ||
parse: { | ||
expression: function() { | ||
prelude: function() { | ||
var children = readSequence.call(this); | ||
@@ -92,0 +92,0 @@ |
@@ -6,4 +6,4 @@ module.exports = { | ||
atrule: 'Atrule', | ||
atruleExpression: function(options) { | ||
return this.AtruleExpression(options.atrule ? String(options.atrule) : null); | ||
atrulePrelude: function(options) { | ||
return this.AtrulePrelude(options.atrule ? String(options.atrule) : null); | ||
}, | ||
@@ -10,0 +10,0 @@ mediaQueryList: 'MediaQueryList', |
@@ -43,7 +43,7 @@ var List = require('../utils/list'); | ||
walk: walker.all, | ||
walkUp: walker.allUp, | ||
walkRules: walker.rules, | ||
walkRulesRight: walker.rulesRight, | ||
walkDeclarations: walker.declarations, | ||
walk: walker.walk, | ||
walkUp: walker.walkUp, | ||
walkRules: walker.walkRules, | ||
walkRulesRight: walker.walkRulesRight, | ||
walkDeclarations: walker.walkDeclarations, | ||
@@ -50,0 +50,0 @@ translate: generator.translate, |
@@ -28,3 +28,3 @@ var TYPE = require('../../tokenizer').TYPE; | ||
name: String, | ||
expression: ['AtruleExpression', null], | ||
prelude: ['AtrulePrelude', null], | ||
block: ['Block', null] | ||
@@ -36,3 +36,3 @@ }, | ||
var nameLowerCase; | ||
var expression = null; | ||
var prelude = null; | ||
var block = null; | ||
@@ -46,7 +46,7 @@ | ||
expression = this.AtruleExpression(name); | ||
prelude = this.AtrulePrelude(name); | ||
// turn empty AtruleExpression into null | ||
if (expression.children.head === null) { | ||
expression = null; | ||
// turn empty AtrulePrelude into null | ||
if (prelude.children.head === null) { | ||
prelude = null; | ||
} | ||
@@ -91,3 +91,3 @@ | ||
name: name, | ||
expression: expression, | ||
prelude: prelude, | ||
block: block | ||
@@ -100,5 +100,5 @@ }; | ||
if (node.expression !== null) { | ||
if (node.prelude !== null) { | ||
processChunk(' '); | ||
this.generate(processChunk, node.expression); | ||
this.generate(processChunk, node.prelude); | ||
} | ||
@@ -105,0 +105,0 @@ |
module.exports = { | ||
AnPlusB: require('./AnPlusB'), | ||
Atrule: require('./Atrule'), | ||
AtruleExpression: require('./AtruleExpression'), | ||
AtrulePrelude: require('./AtrulePrelude'), | ||
AttributeSelector: require('./AttributeSelector'), | ||
@@ -6,0 +6,0 @@ Block: require('./Block'), |
module.exports = { | ||
AtruleExpression: require('./atruleExpression'), | ||
AtrulePrelude: require('./atrulePrelude'), | ||
Selector: require('./selector'), | ||
Value: require('./value') | ||
}; |
@@ -288,2 +288,3 @@ 'use strict'; | ||
balance[tokenCount] = sourceLength; | ||
balance[sourceLength] = sourceLength; // prevents false positive balance match with any token | ||
while (balanceStart !== 0) { | ||
@@ -290,0 +291,0 @@ balancePrev = balanceStart & OFFSET_MASK; |
@@ -210,3 +210,3 @@ 'use strict'; | ||
atrule: null, | ||
atruleExpression: null, | ||
atrulePrelude: null, | ||
rule: null, | ||
@@ -246,3 +246,3 @@ selector: null, | ||
return { | ||
all: function(root, fn) { | ||
walk: function(root, fn) { | ||
function walk(node, item, list) { | ||
@@ -259,3 +259,3 @@ fn.call(context, node, item, list); | ||
}, | ||
allUp: function(root, fn) { | ||
walkUp: function(root, fn) { | ||
function walk(node, item, list) { | ||
@@ -272,9 +272,9 @@ if (walkers.hasOwnProperty(node.type)) { | ||
}, | ||
rules: function(root, fn) { | ||
walkRules: function(root, fn) { | ||
walkRules.call(createContext(root, fn), root); | ||
}, | ||
rulesRight: function(root, fn) { | ||
walkRulesRight: function(root, fn) { | ||
walkRulesRight.call(createContext(root, fn), root); | ||
}, | ||
declarations: function(root, fn) { | ||
walkDeclarations: function(root, fn) { | ||
walkDeclarations.call(createContext(root, fn), root); | ||
@@ -281,0 +281,0 @@ } |
{ | ||
"name": "css-tree", | ||
"version": "1.0.0-alpha22", | ||
"version": "1.0.0-alpha23", | ||
"description": "Fast detailed CSS parser", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
572214
7801
1