iemedia-postcss
Advanced tools
Comparing version 1.0.0 to 1.1.0
@@ -15,31 +15,33 @@ /* | ||
css.eachAtRule(function(atRule){ | ||
var i; | ||
var found=false; | ||
i=avoid.length; | ||
while(i--){ | ||
if(atRule.params.indexOf(avoid[i])>-1){ | ||
found=true; | ||
if(atRule.name === 'media'){ | ||
var i; | ||
var found=false; | ||
i=avoid.length; | ||
while(i--){ | ||
if(atRule.params.indexOf(avoid[i])>-1){ | ||
found=true; | ||
} | ||
} | ||
} | ||
if(found){ // remove it if it matches | ||
atRule.removeSelf(); | ||
}else{ | ||
// Splice in the children of the rule | ||
if(atRule.nodes !== undefined){ | ||
i=atRule.nodes.length; | ||
var first = atRule.nodes[0]; | ||
var last = atRule.nodes[atRule.nodes.length-1]; | ||
first.before = (atRule.before?atRule.before:"") + (first.before?first.before:""); | ||
last.after = (last.after?last.after:"") + (atRule.after?atRule.after:""); | ||
if(found){ // remove it if it matches | ||
atRule.removeSelf(); | ||
}else{ | ||
// Splice in the children of the rule | ||
if(atRule.nodes !== undefined){ | ||
i=atRule.nodes.length; | ||
var first = atRule.nodes[0]; | ||
var last = atRule.nodes[atRule.nodes.length-1]; | ||
first.before = (atRule.before?atRule.before:"") + (first.before?first.before:""); | ||
last.after = (last.after?last.after:"") + (atRule.after?atRule.after:""); | ||
while(i--){ | ||
if(atRule.nodes[i] !== undefined){ | ||
atRule.parent.insertAfter(atRule,atRule.nodes[i]); | ||
while(i--){ | ||
if(atRule.nodes[i] !== undefined){ | ||
atRule.parent.insertAfter(atRule,atRule.nodes[i]); | ||
} | ||
} | ||
} | ||
atRule.removeSelf(); | ||
} | ||
atRule.removeSelf(); | ||
} | ||
@@ -46,0 +48,0 @@ }); |
{ | ||
"name": "iemedia-postcss", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"description": "A post processor for CSS to conditionally remove Media queries", | ||
@@ -5,0 +5,0 @@ "main": "lib/iemedia-postcss.js", |
# iemedia-postcss | ||
iemedia-postcss | ||
A simple Node.js module that makes use of the postcss CSS postprocessor module to strip media tags from style sheets in order to make them more compatible with old versions of IE (especially IE8). | ||
## Usage | ||
```js | ||
var avoid = [ | ||
'max-width', | ||
'orientation', | ||
'handheld', | ||
'print', | ||
'aspect-ratio', | ||
'max-height', | ||
'resolution', | ||
'max-device-width', | ||
'max-device-height', | ||
'max-resolution' | ||
]; | ||
var processor = require('iemedia-postcss')(avoid); | ||
var css = grunt.file.read("source.css"); | ||
css = processor.process(css); | ||
grunt.file.write("output.css",css); | ||
``` | ||
## Release History | ||
* 2015 v0.1.0 Initial build | ||
## License | ||
Copyright (c) 2015 iCrossing | ||
Licensed under the [MIT license](LICENSE-MIT). | ||
*** | ||
Project created by [Arne Strout](https://github.com/ic-agstrout). | ||
_This file was generated on Fri Jan 16 2015 11:21:42._ |
4772
43
39