File tree Expand file tree Collapse file tree 1 file changed +12
-2
lines changed
lib/Sabberworm/CSS/RuleSet Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -17,12 +17,22 @@ public function __construct() {
17
17
$ this ->aRules = array ();
18
18
}
19
19
20
- public function addRule (Rule $ oRule ) {
20
+ public function addRule (Rule $ oRule, Rule $ oSibling = null , /* boolean */ $ bPrepend = false ) {
21
21
$ sRule = $ oRule ->getRule ();
22
22
if (!isset ($ this ->aRules [$ sRule ])) {
23
23
$ this ->aRules [$ sRule ] = array ();
24
24
}
25
- $ this ->aRules [$ sRule ][] = $ oRule ;
25
+
26
+ $ iPosition = $ bPrepend ? 0 : count ($ this ->aRules [$ sRule ]);
27
+
28
+ if ($ oSibling !== null ) {
29
+ $ iSiblingPos = array_search ($ oSibling , $ this ->aRules [$ sRule ], true );
30
+ if ($ iSiblingPos !== false ) {
31
+ $ iPosition = $ bPrepend ? $ iSiblingPos : $ iSiblingPos + 1 ;
32
+ }
33
+ }
34
+
35
+ array_splice ($ this ->aRules [$ sRule ], $ iPosition , 0 , array ($ oRule ));
26
36
}
27
37
28
38
/**
You can’t perform that action at this time.
0 commit comments