🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Sign inDemoInstall
Socket

postcss-selector-parser

Package Overview
Dependencies
Maintainers
1
Versions
61
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

postcss-selector-parser - npm Package Compare versions

Comparing version

to
0.0.5

README.md

7

CHANGELOG.md

@@ -5,2 +5,9 @@ # *current*

# 0.0.5
* Fixes crash on extra whitespace inside a pseudo selector's parentheses.
* Adds sort function to the container class.
* Enables the parser to pass its input through without transforming.
* Iteration-safe `each` and `eachInside`.
# 0.0.4

@@ -7,0 +14,0 @@

@@ -37,2 +37,15 @@ 'use strict';

(0, _tape2['default'])('container#eachInside (safe iteration)', function (t) {
t.plan(1);
var out = (0, _utilHelpers.parse)('[class] + *[href] *:not(*.green)', function (selectors) {
selectors.eachUniversal(function (selector) {
var next = selector.next();
if (next && next.type !== 'combinator') {
selector.removeSelf();
}
});
});
t.equal(out, '[class] + [href] :not(.green)');
});
(0, _tape2['default'])('container#eachAttribute', function (t) {

@@ -189,2 +202,12 @@ t.plan(1);

(0, _tape2['default'])('container#sort', function (t) {
t.plan(1);
var out = (0, _utilHelpers.parse)('h2,h3,h1,h4', function (selectors) {
selectors.sort(function (a, b) {
return a.first.value.slice(-1) - b.first.value.slice(-1);
});
});
t.equal(out, 'h1,h2,h3,h4');
});
(0, _tape2['default'])('container#at', function (t) {

@@ -191,0 +214,0 @@ t.plan(1);

@@ -68,2 +68,9 @@ 'use strict';

t.equal(String(root), '#tree');
});
(0, _tape2['default'])('no operation', function (t) {
t.plan(1);
t.doesNotThrow(function () {
return (0, _index2['default'])().process('h1 h2 h3').result;
});
});

@@ -66,2 +66,9 @@ 'use strict';

(0, _utilHelpers.test)('extra whitespace inside parentheses', 'a:not( h2 )', function (t, tree) {
t.plan(3);
t.equal(tree.nodes[0].nodes[1].nodes[0].nodes[0].value, 'h2');
t.equal(tree.nodes[0].nodes[1].nodes[0].nodes[0].spaces.after, ' ');
t.equal(tree.nodes[0].nodes[1].nodes[0].nodes[0].spaces.before, ' ');
});
(0, _utilHelpers.test)('escaped numbers in class name with pseudo', 'a:before.\\31\\ 0', function (t, tree, d) {

@@ -68,0 +75,0 @@ t.plan(2);

2

dist/__tests__/util/helpers.js

@@ -51,3 +51,3 @@ 'use strict';

t.throws(function () {
return (0, _index2['default'])(function () {}).process(input).result;
return (0, _index2['default'])().process(input).result;
});

@@ -54,0 +54,0 @@ });

@@ -246,6 +246,6 @@ 'use strict';

// Handle space before and after the selector
if (this.position === 0 || this.prevToken[0] === ',') {
if (this.position === 0 || this.prevToken[0] === ',' || this.prevToken[0] === '(') {
this.spaces = token[1];
this.position++;
} else if (this.position === this.tokens.length - 1 || this.nextToken[0] === ',') {
} else if (this.position === this.tokens.length - 1 || this.nextToken[0] === ',' || this.nextToken[0] === ')') {
this.current.last.spaces.after = token[1];

@@ -252,0 +252,0 @@ this.position++;

@@ -29,3 +29,3 @@ 'use strict';

this.func = func;
this.func = func || function noop() {};
return this;

@@ -32,0 +32,0 @@ }

@@ -82,2 +82,10 @@ 'use strict';

var index = undefined;
for (var id in this.indexes) {
index = this.indexes[id];
if (index >= child) {
this.indexes[id] = index - 1;
}
}
return this;

@@ -123,4 +131,32 @@ }

value: function each(callback) {
this.nodes.forEach(callback);
return this;
if (!this.lastEach) {
this.lastEach = 0;
}
if (!this.indexes) {
this.indexes = {};
}
this.lastEach++;
var id = this.lastEach;
this.indexes[id] = 0;
if (!this.length) return undefined;
var index = undefined,
result = undefined;
while (this.indexes[id] < this.length) {
index = this.indexes[id];
result = callback(this.at(index), index);
if (result === false) {
break;
}
this.indexes[id] += 1;
}
delete this.indexes[id];
if (result === false) {
return false;
}
}

@@ -130,9 +166,13 @@ }, {

value: function eachInside(callback) {
this.nodes.forEach(function (node) {
callback(node);
if (node.length) {
return node.eachInside(callback);
return this.each(function (node, i) {
var result = callback(node, i);
if (result !== false && node.length) {
result = node.eachInside(callback);
}
if (result === false) {
return false;
}
});
return this;
}

@@ -271,2 +311,7 @@ }, {

}, {
key: 'sort',
value: function sort(callback) {
return this.nodes.sort(callback);
}
}, {
key: 'toString',

@@ -273,0 +318,0 @@ value: function toString() {

{
"name": "postcss-selector-parser",
"version": "0.0.4",
"version": "0.0.5",
"devDependencies": {

@@ -5,0 +5,0 @@ "babel": "^5.4.3",