Comparing version 1.0.0-alpha to 1.0.0-alpha2
@@ -1,2 +0,3 @@ | ||
var walkers = require('./utils/walk.js'); | ||
var walkers = require('./utils/walk'); | ||
var names = require('./utils/names'); | ||
@@ -6,2 +7,5 @@ module.exports = { | ||
syntax: require('./syntax'), | ||
property: names.property, | ||
keyword: names.keyword, | ||
parse: require('./parser.js'), | ||
@@ -8,0 +12,0 @@ clone: require('./utils/clone.js'), |
@@ -257,3 +257,3 @@ 'use strict'; | ||
case TokenType.LeftParenthesis: | ||
child = getBraces(SCOPE_ATRULE_EXPRESSION); | ||
child = getParentheses(SCOPE_ATRULE_EXPRESSION); | ||
break; | ||
@@ -533,10 +533,18 @@ | ||
var property = getProperty(); | ||
var important = false; | ||
var value; | ||
eat(TokenType.Colon); | ||
value = getValue(nested, property.name); | ||
if (scanner.token !== null && scanner.token.type === TokenType.ExclamationMark) { | ||
important = getImportant(); | ||
} | ||
return { | ||
type: 'Declaration', | ||
info: info, | ||
important: important, | ||
property: property, | ||
value: getValue(nested, property.name) | ||
value: value | ||
}; | ||
@@ -582,3 +590,2 @@ } | ||
info: getInfo(), | ||
important: false, | ||
sequence: new List() | ||
@@ -621,10 +628,10 @@ }; | ||
case TokenType.LeftParenthesis: | ||
case TokenType.LeftSquareBracket: | ||
child = getBraces(SCOPE_VALUE); | ||
child = getParentheses(SCOPE_VALUE); | ||
break; | ||
case TokenType.ExclamationMark: | ||
node.important = getImportant(); | ||
child = null; | ||
break; | ||
if (nested) { | ||
parseError('Unexpected exclamation mark'); | ||
} | ||
break scan; | ||
@@ -794,22 +801,11 @@ default: | ||
function getBraces(scope) { | ||
var close; | ||
function getParentheses(scope) { | ||
var child = null; | ||
var node = { | ||
type: 'Braces', | ||
type: 'Parentheses', | ||
info: getInfo(), | ||
open: scanner.token.value, | ||
close: null, | ||
sequence: new List() | ||
}; | ||
if (scanner.token.type === TokenType.LeftParenthesis) { | ||
close = TokenType.RightParenthesis; | ||
} else { | ||
close = TokenType.RightSquareBracket; | ||
} | ||
// left brace | ||
scanner.next(); | ||
eat(TokenType.LeftParenthesis); | ||
readSC(); | ||
@@ -820,4 +816,3 @@ | ||
switch (scanner.token.type) { | ||
case close: | ||
node.close = scanner.token.value; | ||
case TokenType.RightParenthesis: | ||
break scan; | ||
@@ -839,4 +834,3 @@ | ||
case TokenType.LeftParenthesis: | ||
case TokenType.LeftSquareBracket: | ||
child = getBraces(scope); | ||
child = getParentheses(scope); | ||
break; | ||
@@ -861,6 +855,4 @@ | ||
removeTrailingSpaces(node.sequence); | ||
eat(TokenType.RightParenthesis); | ||
// right brace | ||
eat(close); | ||
return node; | ||
@@ -1080,4 +1072,3 @@ } | ||
case TokenType.LeftParenthesis: | ||
case TokenType.LeftSquareBracket: | ||
child = getBraces(scope); | ||
child = getParentheses(scope); | ||
break; | ||
@@ -1607,3 +1598,2 @@ | ||
info: getInfo(), | ||
important: false, | ||
sequence: new List() | ||
@@ -1618,6 +1608,2 @@ }; | ||
if (scanner.token !== null && scanner.token.type === TokenType.ExclamationMark) { | ||
node.important = getImportant(); | ||
} | ||
return node; | ||
@@ -1646,6 +1632,6 @@ } | ||
var name = scanner.lookup(offset + 0).value.toLowerCase(); | ||
var alpha = false; | ||
var simpleFunction = false; | ||
if (name === 'alpha') { | ||
alpha = true; | ||
if (name === 'alpha' || name === 'dropshadow') { | ||
simpleFunction = true; | ||
offset++; | ||
@@ -1656,3 +1642,3 @@ } else if (name !== 'progid' || scanner.lookup(offset + 1).type !== TokenType.Colon) { | ||
if (!alpha) { | ||
if (!simpleFunction) { | ||
offset += 2; | ||
@@ -1659,0 +1645,0 @@ offset = checkSC(offset); |
@@ -149,2 +149,14 @@ var names = require('../utils/names.js'); | ||
function numberOneOrGreater(node) { | ||
if (node && (isCalc(node) || node.data.type === 'Number')) { | ||
var value = Number(node.data.value); | ||
if (value >= 1) { | ||
return { | ||
next: node.next, | ||
match: [node.data] | ||
}; | ||
} | ||
} | ||
} | ||
function integer(node) { | ||
@@ -255,2 +267,3 @@ if (node && (isCalc(node) || (node.data.type === 'Number' && node.data.value.indexOf('.') === -1))) { | ||
'number-zero-one': numberZeroOne, | ||
'number-one-or-greater': numberOneOrGreater, | ||
'percentage': percentage, | ||
@@ -257,0 +270,0 @@ 'positive-integer': positiveInteger, |
@@ -67,3 +67,5 @@ function each(list) { | ||
case 'Declaration': | ||
return translate(node.property) + ':' + translate(node.value); | ||
return node.important | ||
? translate(node.property) + ':' + translate(node.value) + '!important' | ||
: translate(node.property) + ':' + translate(node.value); | ||
@@ -74,5 +76,3 @@ case 'Property': | ||
case 'Value': | ||
return node.important | ||
? each(node.sequence) + '!important' | ||
: each(node.sequence); | ||
return each(node.sequence); | ||
@@ -111,4 +111,4 @@ case 'Attribute': | ||
case 'Braces': | ||
return node.open + each(node.sequence) + node.close; | ||
case 'Parentheses': | ||
return '(' + each(node.sequence) + ')'; | ||
@@ -115,0 +115,0 @@ case 'Argument': |
@@ -173,6 +173,13 @@ var SourceMapGenerator = require('source-map').SourceMapGenerator; | ||
case 'Declaration': | ||
return createSourceNode( | ||
node.info, | ||
[translate(node.property), ':', translate(node.value)] | ||
); | ||
if (node.important) { | ||
return createSourceNode( | ||
node.info, | ||
[translate(node.property), ':', translate(node.value), '!important'] | ||
); | ||
} else { | ||
return createSourceNode( | ||
node.info, | ||
[translate(node.property), ':', translate(node.value)] | ||
); | ||
} | ||
@@ -183,5 +190,3 @@ case 'Property': | ||
case 'Value': | ||
return node.important | ||
? each(node.sequence) + '!important' | ||
: each(node.sequence); | ||
return each(node.sequence); | ||
@@ -220,4 +225,4 @@ case 'Attribute': | ||
case 'Braces': | ||
return node.open + each(node.sequence) + node.close; | ||
case 'Parentheses': | ||
return '(' + each(node.sequence) + ')'; | ||
@@ -224,0 +229,0 @@ case 'Argument': |
@@ -132,3 +132,3 @@ function walkRules(node, item, list) { | ||
case 'SimpleSelector': | ||
case 'Braces': | ||
case 'Parentheses': | ||
case 'Negation': | ||
@@ -135,0 +135,0 @@ node.sequence.each(walkAll, this); |
{ | ||
"name": "css-tree", | ||
"version": "1.0.0-alpha", | ||
"version": "1.0.0-alpha2", | ||
"description": "Detailed CSS parser", | ||
@@ -69,5 +69,6 @@ "keywords": [ | ||
"bin", | ||
"docs", | ||
"data", | ||
"dist/csstree.js", | ||
"dist/csssyntax.js", | ||
"docs", | ||
"lib", | ||
@@ -74,0 +75,0 @@ "HISTORY.md", |
@@ -1,4 +0,8 @@ | ||
[![Build Status](https://travis-ci.org/csstree/parser.svg?branch=master)](https://travis-ci.org/csstree/parser) | ||
[![Coverage Status](https://coveralls.io/repos/github/csstree/parser/badge.svg?branch=master)](https://coveralls.io/github/csstree/parser?branch=master) | ||
[![Build Status](https://travis-ci.org/csstree/csstree.svg?branch=master)](https://travis-ci.org/csstree/csstree) | ||
[![Coverage Status](https://coveralls.io/repos/github/csstree/csstree/badge.svg?branch=master)](https://coveralls.io/github/csstree/csstree?branch=master) | ||
Coming soon... | ||
* [CSS syntax reference](https://csstree.github.io/docs/syntax.html) | ||
* [CSS syntax validator](https://csstree.github.io/docs/validator.html) | ||
Coming soon... |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
553594
31
12975
9
1