Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Add support for @font-face, which should not be considered a selector
This change stringifies `@font-face` at-rules, instead of treating them as a standard rule with `@font-face` being the selector.

Relates reworkcss/css-parse#75
  • Loading branch information
ericf committed Mar 12, 2014
commit 89c7ca84a9870f71f3794eaf292a5bde0d33f795
11 changes: 11 additions & 0 deletions lib/compress.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,17 @@ Compiler.prototype.page = function(node){
+ this.emit('}');
};

/**
* Visit font-face node.
*/

Compiler.prototype['font-face'] = function(node){
return this.emit('@font-face', node.position, true)
+ this.emit('{')
+ this.mapVisit(node.declarations)
+ this.emit('}');
};

/**
* Visit rule node.
*/
Expand Down
13 changes: 13 additions & 0 deletions lib/identity.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,19 @@ Compiler.prototype.page = function(node){
+ this.emit('\n}');
};

/**
* Visit font-face node.
*/

Compiler.prototype['font-face'] = function(node){
return this.emit('@font-face ', node.position, true)
+ this.emit('{\n')
+ this.emit(this.indent(1))
+ this.mapVisit(node.declarations, '\n')
+ this.emit(this.indent(-1))
+ this.emit('\n}');
};

/**
* Visit rule node.
*/
Expand Down
1 change: 1 addition & 0 deletions test/cases/font-face.compressed.css
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@font-face{font-family:"Bitstream Vera Serif Bold";src:url("http://developer.mozilla.org/@api/deki/files/2934/=VeraSeBd.ttf");}body{font-family:"Bitstream Vera Serif Bold", serif;}
8 changes: 8 additions & 0 deletions test/cases/font-face.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
@font-face {
font-family: "Bitstream Vera Serif Bold";
src: url("http://developer.mozilla.org/@api/deki/files/2934/=VeraSeBd.ttf");
}

body {
font-family: "Bitstream Vera Serif Bold", serif;
}