Skip to content

Commit

Permalink
PostCSS plugin, close #2
Browse files Browse the repository at this point in the history
  • Loading branch information
ausi committed Oct 24, 2015
1 parent 155d2c6 commit ad6dc95
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
6 changes: 6 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
{
"keywords": [
"postcss-plugin"
],
"scripts": {
"test": "make test"
},
"dependencies": {
"postcss": "^5.0.2"
},
"devDependencies": {
"browserstack-runner": "^0.3.7",
"connect": "^3.4.0",
Expand Down
19 changes: 19 additions & 0 deletions postcss-plugin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*eslint-env node */
var postcss = require('postcss');

module.exports = postcss.plugin('cq-prolyfill', function () {
'use strict';
return function (css) {
css.walkRules(/:container\(/i, function (rule) {
rule.selectors = rule.selectors.map(function(selector) {
return selector.replace(/:container\([^)]*\)/gi, function(match) {
return '.' + match
.replace(/([a-z])\s+([a-z])/gi, '$1|$2')
.replace(/\s+/g, '')
.replace(/[[\]!"#$%&'()*+,./:;<=>?@^`{|}~]/g, '\\$&')
.toLowerCase();
});
});
});
};
});

0 comments on commit ad6dc95

Please # to comment.