visitAtRuleWithoutBody method

Node visitAtRuleWithoutBody (AtRule atRuleNode, VisitArgs visitArgs)

Implementation

Node visitAtRuleWithoutBody(AtRule atRuleNode, VisitArgs visitArgs) {
  if (atRuleNode.blocksVisibility()) return null;

  if (atRuleNode.name == '@charset') {
    // Only output the debug info together with subsequent @charset definitions
    // a comment (or @media statement) before the actual @charset atRule would
    // be considered illegal css as it has to be on the first line
    if (charset) {
      if (atRuleNode.debugInfo != null) {
        final String directive =
            atRuleNode.toCSS(_context).replaceAll(r'\n', '');
        final Comment comment = Comment('/* $directive */\n')
          ..debugInfo = atRuleNode.debugInfo;
        return _visitor.visit(comment);
      }
      return null;
    }
    charset = true;
  }
  return atRuleNode;

//2.8.0 20160702
// visitAtRuleWithoutBody: function(atRuleNode, visitArgs) {
//     if (atRuleNode.blocksVisibility()) {
//         return;
//     }
//
//     if (atRuleNode.name === "@charset") {
//         // Only output the debug info together with subsequent @charset definitions
//         // a comment (or @media statement) before the actual @charset atrule would
//         // be considered illegal css as it has to be on the first line
//         if (this.charset) {
//             if (atRuleNode.debugInfo) {
//                 var comment = new tree.Comment("/* " + atRuleNode.toCSS(this._context).replace(/\n/g, "") + " */\n");
//                 comment.debugInfo = atRuleNode.debugInfo;
//                 return this._visitor.visit(comment);
//             }
//             return;
//         }
//         this.charset = true;
//     }
//
//     return atRuleNode;
// },
}