Socket
Socket
Sign inDemoInstall

postcss-selector-parser

Package Overview
Dependencies
Maintainers
1
Versions
59
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 0.0.5 to 1.0.0

API.md

6

CHANGELOG.md

@@ -1,4 +0,6 @@

# *current*
# 1.0.0
---
* Adds `clone` and `replaceWith` methods to nodes.
* Adds `insertBefore` and `insertAfter` to containers.
* Stabilises API.

@@ -5,0 +7,0 @@ # 0.0.5

@@ -128,2 +128,34 @@ 'use strict';

}, {
key: 'insertAfter',
value: function insertAfter(oldNode, newNode) {
var oldIndex = this.index(oldNode);
this.nodes.splice(oldIndex + 1, 0, newNode);
var index = undefined;
for (var id in this.indexes) {
index = this.indexes[id];
if (exist <= index) {
this.indexes[id] = index + nodes.length;
}
}
return this;
}
}, {
key: 'insertBefore',
value: function insertBefore(oldNode, newNode) {
var oldIndex = this.index(oldNode);
this.nodes.splice(oldIndex, 0, newNode);
var index = undefined;
for (var id in this.indexes) {
index = this.indexes[id];
if (exist <= index) {
this.indexes[id] = index + nodes.length;
}
}
return this;
}
}, {
key: 'each',

@@ -130,0 +162,0 @@ value: function each(callback) {

@@ -11,2 +11,28 @@ 'use strict';

var cloneNode = function cloneNode(obj, parent) {
if (typeof obj !== 'object') {
return obj;
}
var cloned = new obj.constructor();
for (var i in obj) {
if (!obj.hasOwnProperty(i)) continue;
var value = obj[i];
var type = typeof value;
if (i === 'parent' && type === 'object') {
if (parent) cloned[i] = parent;
} else if (value instanceof Array) {
cloned[i] = value.map(function (j) {
return cloneNode(j, cloned);
});
} else {
cloned[i] = cloneNode(value, cloned);
}
}
return cloned;
};
var _default = (function () {

@@ -34,2 +60,9 @@ var _class = function _default() {

}, {
key: 'replaceWith',
value: function replaceWith(node) {
this.parent.insertBefore(this, node);
this.removeSelf();
return this;
}
}, {
key: 'next',

@@ -45,2 +78,13 @@ value: function next() {

}, {
key: 'clone',
value: function clone() {
var overrides = arguments[0] === undefined ? {} : arguments[0];
var cloned = cloneNode(this);
for (var _name in overrides) {
cloned[_name] = overrides[_name];
}
return cloned;
}
}, {
key: 'toString',

@@ -47,0 +91,0 @@ value: function toString() {

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

@@ -12,2 +12,4 @@ "babel": "^5.4.3",

"files": [
"API.md",
"CHANGELOG.md",
"LICENSE-MIT",

@@ -17,3 +19,3 @@ "dist"

"scripts": {
"prepublish": "babel src --out-dir dist",
"prepublish": "babel src --out-dir dist --ignore /__tests__/",
"test-unformatted": "babel-tape-runner \"src/**/__tests__/*.js\"",

@@ -20,0 +22,0 @@ "test": "npm run test-unformatted | faucet"

# postcss-selector-parser [![Build Status](https://travis-ci.org/postcss/postcss-selector-parser.svg?branch=master)](https://travis-ci.org/postcss/postcss-selector-parser)
Work in progress parser for PostCSS.
> Selector parser with built in methods for working with selector strings.
## Install
With [npm](https://npmjs.com/package/postcss-selector-parser) do:
```
npm install postcss-selector-parser
```
## Quick Start
```js
var parser = require('postcss-selector-parser');
var transform = function (selectors) {
selectors.eachInside(function (selector) {
// do something with the selector
console.log(String(selector))
});
};
var transformed = parser(transform).process('h1, h2, h3').result;
```
## API
Please see [API.md](API.md).
## Credits

@@ -6,0 +32,0 @@

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