Comparing version 1.0.0-alpha17 to 1.0.0-alpha18
@@ -51,2 +51,4 @@ # Parsing CSS into AST | ||
- `atruleExpression` – at-rule expression (`screen, print` for example above) | ||
- `mediaQueryList` – used to parse comma separated media query list | ||
- `mediaQuery` – used to parse media query | ||
- `rule` – rule (e.g. `.foo, .bar:hover { color: red; border: 1px solid black; }`) | ||
@@ -53,0 +55,0 @@ - `selectorList` – selector group (`.foo, .bar:hover` for rule example) |
@@ -15,4 +15,3 @@ # API | ||
- [Tokenizer](Tokenizer.md) | ||
- [Parser](Parser.md) | ||
- [Lexer](Lexer.md) | ||
- [List](List.md) |
@@ -0,1 +1,8 @@ | ||
## 1.0.0-alpha18 (April 3, 2017) | ||
- Added `atrule` walk context (#39) | ||
- Changed a result of generate method for `AnPlusB`, `AttributeSelector`, `Function`, `MediaFeature` and `Ratio` ([1e95877](https://github.com/csstree/csstree/commit/1e9587710efa8e9338bcf0bc794b4b45f286231d)) | ||
- Fixed typo in `List` exception messages (@strarsis, #42) | ||
- Improved tokenizer to convert an input to a string | ||
## 1.0.0-alpha17 (March 13, 2017) | ||
@@ -2,0 +9,0 @@ |
@@ -155,25 +155,26 @@ var cmpChar = require('../../tokenizer').cmpChar; | ||
generate: function(node) { | ||
var result = ''; | ||
var a = node.a !== null && node.a !== undefined; | ||
var b = node.b !== null && node.b !== undefined; | ||
var result; | ||
if (a) { | ||
result += node.a === '+1' || node.a === '1' ? 'n' : | ||
node.a === '-1' ? '-n' : | ||
node.a + 'n'; | ||
} | ||
result = | ||
node.a === '+1' || node.a === '1' ? 'n' : | ||
node.a === '-1' ? '-n' : | ||
node.a + 'n'; | ||
if (a && b) { | ||
if (String(node.b).charAt(0) !== '-' && | ||
String(node.b).charAt(0) !== '+') { | ||
result += '+'; | ||
if (b) { | ||
b = String(node.b); | ||
if (b.charAt(0) === '-' || b.charAt(0) === '+') { | ||
result = [result, b.charAt(0), b.substr(1)]; | ||
} else { | ||
result = [result, '+', b]; | ||
} | ||
} | ||
} else { | ||
result = String(node.b); | ||
} | ||
if (b) { | ||
result += node.b; | ||
} | ||
return result; | ||
} | ||
}; |
@@ -96,3 +96,4 @@ var TYPE = require('../../tokenizer').TYPE; | ||
return result; | ||
} | ||
}, | ||
walkContext: 'atrule' | ||
}; |
@@ -154,3 +154,3 @@ var TYPE = require('../../tokenizer').TYPE; | ||
if (node.flags !== null) { | ||
result.push(flagsPrefix + node.flags); | ||
result.push(flagsPrefix, node.flags); | ||
} | ||
@@ -157,0 +157,0 @@ |
@@ -36,5 +36,5 @@ var TYPE = require('../../tokenizer').TYPE; | ||
generate: function(node) { | ||
return [].concat(node.name, '(', this.each(node.children), ')'); | ||
return [].concat(node.name + '(', this.each(node.children), ')'); | ||
}, | ||
walkContext: 'function' | ||
}; |
@@ -66,5 +66,5 @@ var TYPE = require('../../tokenizer').TYPE; | ||
return node.value !== null | ||
? ['(' + node.name + ':', this.generate(node.value), ')'] | ||
: '(' + node.name + ')'; | ||
? ['(', node.name, ':', this.generate(node.value), ')'] | ||
: ['(', node.name, ')']; | ||
} | ||
}; |
@@ -53,4 +53,4 @@ var isNumber = require('../../tokenizer').isNumber; | ||
generate: function(node) { | ||
return node.left + '/' + node.right; | ||
return [node.left, '/', node.right]; | ||
} | ||
}; |
@@ -197,3 +197,3 @@ 'use strict'; | ||
this.setSource(source || '', startOffset, startLine, startColumn); | ||
this.setSource(source, startOffset, startLine, startColumn); | ||
}; | ||
@@ -203,5 +203,6 @@ | ||
setSource: function(source, startOffset, startLine, startColumn) { | ||
var start = firstCharOffset(source); | ||
var safeSource = String(source || ''); | ||
var start = firstCharOffset(safeSource); | ||
this.source = source; | ||
this.source = safeSource; | ||
this.startOffset = typeof startOffset === 'undefined' ? 0 : startOffset; | ||
@@ -218,3 +219,3 @@ this.startLine = typeof startLine === 'undefined' ? 1 : startLine; | ||
tokenLayout(this, source, start); | ||
tokenLayout(this, safeSource, start); | ||
this.next(); | ||
@@ -221,0 +222,0 @@ }, |
@@ -333,3 +333,3 @@ 'use strict'; | ||
if (this.head !== before) { | ||
throw new Error('before doesn\'t below to list'); | ||
throw new Error('before doesn\'t belong to list'); | ||
} | ||
@@ -368,3 +368,3 @@ | ||
if (this.head !== item) { | ||
throw new Error('item doesn\'t below to list'); | ||
throw new Error('item doesn\'t belong to list'); | ||
} | ||
@@ -379,3 +379,3 @@ | ||
if (this.tail !== item) { | ||
throw new Error('item doesn\'t below to list'); | ||
throw new Error('item doesn\'t belong to list'); | ||
} | ||
@@ -382,0 +382,0 @@ |
@@ -16,3 +16,8 @@ 'use strict'; | ||
if (node.block !== null) { | ||
var oldAtrule = this.atrule; | ||
this.atrule = node; | ||
walkRules.call(this, node.block); | ||
this.atrule = oldAtrule; | ||
} | ||
@@ -58,3 +63,8 @@ | ||
if (node.block !== null) { | ||
var oldAtrule = this.atrule; | ||
this.atrule = node; | ||
walkRulesRight.call(this, node.block); | ||
this.atrule = oldAtrule; | ||
} | ||
@@ -100,3 +110,8 @@ | ||
if (node.block !== null) { | ||
var oldAtrule = this.atrule; | ||
this.atrule = node; | ||
walkDeclarations.call(this, node.block); | ||
this.atrule = oldAtrule; | ||
} | ||
@@ -133,2 +148,3 @@ break; | ||
stylesheet: null, | ||
atrule: null, | ||
atruleExpression: null, | ||
@@ -135,0 +151,0 @@ rule: null, |
{ | ||
"name": "css-tree", | ||
"version": "1.0.0-alpha17", | ||
"version": "1.0.0-alpha18", | ||
"description": "Fast detailed CSS parser", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -22,8 +22,2 @@ <img align="right" width="111" height="111" | ||
- [Utils to work with AST](docs/utils.md) | ||
- [Working with syntax](docs/syntax.md) | ||
- API references: | ||
- [Tokenizer](docs/Tokenizer.md) | ||
- [Parser](docs/Parser.md) | ||
- [Lexer](docs/Lexer.md) | ||
- [List](docs/List.md) | ||
@@ -30,0 +24,0 @@ Docs and tools: |
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
658236
13477
66