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 @@ -29,12 +29,22 @@ public function getLineNo() {
29
29
return $ this ->iLineNo ;
30
30
}
31
31
32
- public function addRule (Rule $ oRule ) {
32
+ public function addRule (Rule $ oRule, Rule $ oSibling = null , /* boolean */ $ bPrepend = false ) {
33
33
$ sRule = $ oRule ->getRule ();
34
34
if (!isset ($ this ->aRules [$ sRule ])) {
35
35
$ this ->aRules [$ sRule ] = array ();
36
36
}
37
- $ this ->aRules [$ sRule ][] = $ oRule ;
37
+
38
+ $ iPosition = $ bPrepend ? 0 : count ($ this ->aRules [$ sRule ]);
39
+
40
+ if ($ oSibling !== null ) {
41
+ $ iSiblingPos = array_search ($ oSibling , $ this ->aRules [$ sRule ], true );
42
+ if ($ iSiblingPos !== false ) {
43
+ $ iPosition = $ bPrepend ? $ iSiblingPos : $ iSiblingPos + 1 ;
44
+ }
45
+ }
46
+
47
+ array_splice ($ this ->aRules [$ sRule ], $ iPosition , 0 , array ($ oRule ));
38
48
}
39
49
40
50
/**
You can’t perform that action at this time.
0 commit comments