Permalink
Browse files

Consume atrules inside regular blocks

  • Loading branch information...
1 parent aff9c5f commit 6c1171f34159dc811916ad7ea0e9dbf63c3c8a13 @jbalsas jbalsas committed Jan 17, 2014
Showing with 45 additions and 4 deletions.
  1. +45 −4 index.js
View
@@ -226,10 +226,17 @@ module.exports = function(css, options){
comments(decls);
// declarations
- var decl;
- while (decl = declaration()) {
- decls.push(decl);
- comments(decls);
+ var decl, rule;
+ while ((decl = declaration()) || (rule = expandedatrule())) {
+ if (decl) {
+ decls.push(decl);
+ comments(decls);
+ }
+
+ if (rule) {
+ comments();
+ rule = null;
+ }
}
if (!close()) return error("missing '}'");
@@ -420,6 +427,34 @@ module.exports = function(css, options){
});
}
+ function atviewport() {
+ var pos = position();
+ var m = match(/^@([-\w]+)?viewport */);
+
+ if (!m) return;
+ var vendor = m[1];
+
+ return pos({
+ type: 'viewport',
+ vendor: vendor,
+ declarations: declarations()
+ });
+
+ }
+
+ function atfontface() {
+ var pos = position();
+ var m = match(/^@([-\w]+)?font-face */);
+
+ if (!m) return;
+ var vendor = m[1];
+
+ return pos({
+ type: 'fontface',
+ declarations: declarations()
+ });
+ }
+
/**
* Parse import
*/
@@ -475,6 +510,12 @@ module.exports = function(css, options){
|| athost();
}
+ function expandedatrule() {
+ return atrule()
+ || atviewport()
+ || atfontface();
+ }
+
/**
* Parse rule.
*/

0 comments on commit 6c1171f

Please sign in to comment.