Skip to content

Commit 94d2d16

Browse files
Refactored @font-face support
1 parent 4620250 commit 94d2d16

File tree

1 file changed

+6
-34
lines changed

1 file changed

+6
-34
lines changed

index.js

Lines changed: 6 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -437,50 +437,22 @@ module.exports = function(css, options){
437437
function atfontface() {
438438
var pos = position();
439439
var m = match(/^@font-face */);
440-
var re = /url\(['"]([^'"]+)['"]\)\s*(?:format\(['"]([^'"]+)['"]\))?/i;
441-
var src = [];
442-
var decls = [];
443-
var srcList;
444440

445441
if (!m) return;
446-
447442
if (!open()) return error("@font-face missing '{'");
443+
var decls = comments();
448444

449-
var name = match(/^font-family\s*:\s*['"]([^'"]+)['"];/);
450-
451-
if (!name) return error("@font-face missing 'font-family'");
452-
decls.push({
453-
type: 'declaration',
454-
property: 'font-family',
455-
value: trim(name[1])
456-
})
457-
whitespace();
458-
459-
while (srcList = match(/^src\s*:\s*([^;]+);/)) {
460-
var val = trim(srcList[1]);
461-
var set = val.split(',');
462-
463-
decls.push({
464-
type: 'declaration',
465-
property: 'src',
466-
value: val
467-
});
468-
469-
set.forEach(function(item) {
470-
m = re.exec(item);
471-
src.push({
472-
url: trim(m[1]),
473-
format: trim(m[2])
474-
});
475-
})
476-
whitespace();
445+
// declarations
446+
var decl;
447+
while (decl = declaration()) {
448+
decls.push(decl);
449+
decls = decls.concat(comments());
477450
}
478451

479452
if (!close()) return error("@font-face missing '}'");
480453

481454
return pos({
482455
type: 'fontface',
483-
src: src,
484456
declarations: decls
485457
});
486458
}

0 commit comments

Comments
 (0)