Skip to content

Commit bafa0fa

Browse files
committed
Add support for a wider variety of at rules
Unknown at-rules stil get to be `RuleSet`s but block rules like document/supports/region-style/font-feature-values are now supported via the AtRuleBlockList class. Also, all at rules now implement the Sabberworm\CSS\Property\AtRule interface. MediaQuery has been removed as its functionality is included fully in the AtRuleBlockList class. Closes #53 as fixed
1 parent 518269d commit bafa0fa

File tree

4 files changed

+44
-32
lines changed

4 files changed

+44
-32
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?php
2+
3+
namespace Sabberworm\CSS\CSSList;
4+
5+
use Sabberworm\CSS\Property\AtRule;
6+
7+
/**
8+
* A RuleSet constructed by an unknown @-rule. @font-face rules are rendered into AtRule objects.
9+
*/
10+
class AtRuleBlockList extends CSSBlockList implements AtRule {
11+
12+
private $sType;
13+
private $sArgs;
14+
15+
public function __construct($sType, $sArgs = '') {
16+
parent::__construct();
17+
$this->sType = $sType;
18+
$this->sArgs = $sArgs;
19+
}
20+
21+
public function atRuleName() {
22+
return $this->sType;
23+
}
24+
25+
public function atRuleArgs() {
26+
return $this->sArgs;
27+
}
28+
29+
public function __toString() {
30+
$sResult = "@{$this->sType} {$this->sArgs}{";
31+
$sResult .= parent::__toString();
32+
$sResult .= '}';
33+
return $sResult;
34+
}
35+
36+
}

lib/Sabberworm/CSS/CSSList/MediaQuery.php

Lines changed: 0 additions & 32 deletions
This file was deleted.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?php
2+
3+
namespace Sabberworm\CSS\Rule;
4+
5+
interface AtRule {
6+
public function atRuleName();
7+
public function atRuleArgs();
8+
}

0 commit comments

Comments
 (0)