File tree Expand file tree Collapse file tree 3 files changed +49
-15
lines changed Expand file tree Collapse file tree 3 files changed +49
-15
lines changed Original file line number Diff line number Diff line change @@ -54,6 +54,7 @@ Please also have a look at our
54
54
55
55
### Fixed
56
56
57
+ - Render rules in line and column number order (#1058 )
57
58
- Don't render ` rgb ` colors with percentage values using hex notation (#803 )
58
59
- Parse ` @font-face ` ` src ` property as comma-delimited list (#790 )
59
60
Original file line number Diff line number Diff line change @@ -277,22 +277,20 @@ protected function renderRules(OutputFormat $outputFormat)
277
277
$ result = '' ;
278
278
$ isFirst = true ;
279
279
$ nextLevelFormat = $ outputFormat ->nextLevel ();
280
- foreach ($ this ->rules as $ rules ) {
281
- foreach ($ rules as $ rule ) {
282
- $ renderedRule = $ nextLevelFormat ->safely (static function () use ($ rule , $ nextLevelFormat ): string {
283
- return $ rule ->render ($ nextLevelFormat );
284
- });
285
- if ($ renderedRule === null ) {
286
- continue ;
287
- }
288
- if ($ isFirst ) {
289
- $ isFirst = false ;
290
- $ result .= $ nextLevelFormat ->spaceBeforeRules ();
291
- } else {
292
- $ result .= $ nextLevelFormat ->spaceBetweenRules ();
293
- }
294
- $ result .= $ renderedRule ;
280
+ foreach ($ this ->getRules () as $ rule ) {
281
+ $ renderedRule = $ nextLevelFormat ->safely (static function () use ($ rule , $ nextLevelFormat ): string {
282
+ return $ rule ->render ($ nextLevelFormat );
283
+ });
284
+ if ($ renderedRule === null ) {
285
+ continue ;
286
+ }
287
+ if ($ isFirst ) {
288
+ $ isFirst = false ;
289
+ $ result .= $ nextLevelFormat ->spaceBeforeRules ();
290
+ } else {
291
+ $ result .= $ nextLevelFormat ->spaceBetweenRules ();
295
292
}
293
+ $ result .= $ renderedRule ;
296
294
}
297
295
298
296
if (!$ isFirst ) {
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ declare (strict_types=1 );
4
+
5
+ namespace Sabberworm \CSS \Tests \Unit \RuleSet ;
6
+
7
+ use PHPUnit \Framework \TestCase ;
8
+ use Sabberworm \CSS \Parsing \ParserState ;
9
+ use Sabberworm \CSS \RuleSet \DeclarationBlock ;
10
+ use Sabberworm \CSS \OutputFormat ;
11
+ use Sabberworm \CSS \Settings ;
12
+
13
+ /**
14
+ * @covers \Sabberworm\CSS\RuleSet\DeclarationBlock
15
+ */
16
+ final class DeclarationBlockTest extends TestCase
17
+ {
18
+ /**
19
+ * @test
20
+ */
21
+ public function rendersRulesInOrderProvided (): void
22
+ {
23
+ $ css = '
24
+ .test {
25
+ background-color:transparent;
26
+ background:#222;
27
+ background-color:#fff;
28
+ } ' ;
29
+ $ expectedRendering = 'background-color: transparent;background: #222;background-color: #fff; ' ;
30
+
31
+ $ declarationBlock = DeclarationBlock::parse (new ParserState ($ css , Settings::create ()));
32
+
33
+ self ::assertStringContainsString ($ expectedRendering , $ declarationBlock ->render (new OutputFormat ()));
34
+ }
35
+ }
You can’t perform that action at this time.
0 commit comments