Skip to content

Commit 89c7ca8

Browse files
committed
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
1 parent fbfce1f commit 89c7ca8

File tree

4 files changed

+33
-0
lines changed

4 files changed

+33
-0
lines changed

lib/compress.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,17 @@ Compiler.prototype.page = function(node){
144144
+ this.emit('}');
145145
};
146146

147+
/**
148+
* Visit font-face node.
149+
*/
150+
151+
Compiler.prototype['font-face'] = function(node){
152+
return this.emit('@font-face', node.position, true)
153+
+ this.emit('{')
154+
+ this.mapVisit(node.declarations)
155+
+ this.emit('}');
156+
};
157+
147158
/**
148159
* Visit rule node.
149160
*/

lib/identity.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,19 @@ Compiler.prototype.page = function(node){
174174
+ this.emit('\n}');
175175
};
176176

177+
/**
178+
* Visit font-face node.
179+
*/
180+
181+
Compiler.prototype['font-face'] = function(node){
182+
return this.emit('@font-face ', node.position, true)
183+
+ this.emit('{\n')
184+
+ this.emit(this.indent(1))
185+
+ this.mapVisit(node.declarations, '\n')
186+
+ this.emit(this.indent(-1))
187+
+ this.emit('\n}');
188+
};
189+
177190
/**
178191
* Visit rule node.
179192
*/

test/cases/font-face.compressed.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
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;}

test/cases/font-face.css

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
@font-face {
2+
font-family: "Bitstream Vera Serif Bold";
3+
src: url("http://developer.mozilla.org/@api/deki/files/2934/=VeraSeBd.ttf");
4+
}
5+
6+
body {
7+
font-family: "Bitstream Vera Serif Bold", serif;
8+
}

0 commit comments

Comments
 (0)