Skip to content

Commit

Permalink
Fixed root selector support. Resolves #16
Browse files Browse the repository at this point in the history
  • Loading branch information
antyakushev committed Jul 27, 2016
1 parent b561580 commit 70836fe
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 4 deletions.
3 changes: 3 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## 2.1.1
* Fixed `:root` selector support

## 2.1.0 by Travis Palmer
* Added support for nesting `@for` loops while using variables in the range that are iterators of parent `@for` loops
* Added tests for added functionality
Expand Down
3 changes: 2 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ module.exports = postcss.plugin('postcss-for', function (opts) {

manageIterStack = function (rule) {
if (rule.parent.type !== 'root') {
var parentIterVar = list.space(rule.parent.params)[0];
console.log('\n\nRule:\n', rule, '\n\nList:\n', list, '\n\nParent:\n', rule.parent)
var parentIterVar = rule.parent.params && list.space(rule.parent.params)[0];
if (iterStack.indexOf(parentIterVar) === -1) {
// If parent isn't in stack, wipe stack
iterStack.splice(0, iterStack.length);
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "postcss-for",
"version": "2.1.0",
"version": "2.1.1",
"description": "PostCSS plugin that enables SASS-like for loop syntax in your CSS",
"keywords": [
"postcss",
Expand Down Expand Up @@ -28,7 +28,8 @@
"chai": "3.2.0",
"gulp": "3.9.0",
"gulp-eslint": "0.11.1",
"gulp-mocha": "2.1.3"
"gulp-mocha": "2.1.3",
"postcss-custom-properties": "^5.0.1"
},
"scripts": {
"test": "gulp"
Expand Down
8 changes: 7 additions & 1 deletion test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ var postcss = require('postcss');
var expect = require('chai').expect;

var plugin = require('../');
var postcssCustomProps = require('postcss-custom-properties');

var test = function (input, output, opts) {
expect(postcss([plugin(opts)]).process(input).css).to.eql(output);
expect(postcss([plugin(opts), postcssCustomProps]).process(input).css).to.eql(output);
};

describe('postcss-for', function () {
Expand Down Expand Up @@ -79,4 +80,9 @@ describe('postcss-for', function () {
}).to.throw('<css input>:2:23: External variable (not from a parent for loop) cannot be used as a range parameter');
});

it('it supports :root selector', function () {
test(':root { \n@for $weight from 100 to 900 by 100 \n{ --foo-$(weight): $weight; }\n}\n.b { font-weight: var(--foo-200) }',
'.b { font-weight: 200 }');
});

});

0 comments on commit 70836fe

Please sign in to comment.