Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

css-tree

Package Overview
Dependencies
Maintainers
1
Versions
57
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

css-tree - npm Package Compare versions

Comparing version 1.0.0-alpha2 to 1.0.0-alpha3

1

lib/index.js

@@ -16,2 +16,3 @@ var walkers = require('./utils/walk');

walkRulesRight: walkers.rulesRight,
walkDeclarations: walkers.declarations,

@@ -18,0 +19,0 @@ translate: require('./utils/translate.js'),

@@ -38,2 +38,4 @@ var stringifySyntax = require('./stringify');

error.css = css;
error.line = badNode && badNode.info ? badNode.info.line : 1;
error.column = badNode && badNode.info ? badNode.info.column : 1;
error.offset = errorOffset;

@@ -40,0 +42,0 @@ error.message = message + '\n' +

44

lib/syntax/match.js

@@ -197,17 +197,2 @@ var List = require('../utils/list');

case 'Type':
var typeSyntax = syntax.getType(syntaxNode.name);
if (!typeSyntax) {
throw new Error('Unknown syntax type `' + syntaxNode.name + '`');
}
var res = typeSyntax.match(node);
if (!res || !res.match) {
break mismatch;
}
result.push(res.match);
node = res.next;
break;
case 'Function':

@@ -255,2 +240,31 @@ // expect a function node

case 'Parentheses':
if (!node || node.data.type !== 'Parentheses') {
break mismatch;
}
var res = match(syntax, syntaxNode.sequence, node.data.sequence.head);
if (!res || !res.match || res.next) {
break mismatch;
}
result.push(res.match);
node = res.next;
break;
case 'Type':
var typeSyntax = syntax.getType(syntaxNode.name);
if (!typeSyntax) {
throw new Error('Unknown syntax type `' + syntaxNode.name + '`');
}
var res = typeSyntax.match(node);
if (!res || !res.match) {
break mismatch;
}
result.push(res.match);
node = res.next;
break;
case 'Property':

@@ -257,0 +271,0 @@ var propertySyntax = syntax.getProperty(syntaxNode.name);

@@ -82,2 +82,3 @@ var MatchError = require('./error').MatchError;

lastMatchError: null,
match: function(propertyName, value) {

@@ -96,3 +97,4 @@ var property = names.property(propertyName);

if (!propertySyntax) {
throw new Error('Unknown property: ' + propertyName);
this.lastMatchError = Error('Unknown property: ' + propertyName);
return null;
}

@@ -105,3 +107,4 @@

if (!result || !result.match) {
throw new MatchError('Mismatch', propertySyntax.syntax, value, result.next);
this.lastMatchError = MatchError('Mismatch', propertySyntax.syntax, value, result.next);
return null;
}

@@ -111,5 +114,7 @@ }

if (result.next) {
throw new MatchError('Uncomplete match', propertySyntax.syntax, value, result.next);
this.lastMatchError = MatchError('Uncomplete match', propertySyntax.syntax, value, result.next);
return null;
}
this.lastMatchError = null;
return result.match;

@@ -116,0 +121,0 @@ },

@@ -52,2 +52,31 @@ function walkRules(node, item, list) {

function walkDeclarations(node) {
switch (node.type) {
case 'StyleSheet':
var oldStylesheet = this.stylesheet;
this.stylesheet = node;
node.rules.each(walkDeclarations, this);
this.stylesheet = oldStylesheet;
break;
case 'Atrule':
if (node.block !== null && node.block.type === 'StyleSheet') {
walkDeclarations.call(this, node.block);
}
break;
case 'Ruleset':
this.ruleset = node;
if (node.block !== null) {
node.block.declarations.each(this.fn);
}
this.ruleset = null;
break;
}
}
function walkAll(node, item, list) {

@@ -190,3 +219,6 @@ switch (node.type) {

walkRulesRight.call(createContext(root, fn), root);
},
declarations: function(root, fn) {
walkDeclarations.call(createContext(root, fn), root);
}
};
{
"name": "css-tree",
"version": "1.0.0-alpha2",
"version": "1.0.0-alpha3",
"description": "Detailed CSS parser",

@@ -5,0 +5,0 @@ "keywords": [

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc