@@ -329,6 +329,11 @@ public function prepend(array $nodes) : void {
329
329
}
330
330
}
331
331
332
+ /**
333
+ * Retrieve the index position of the current element in the parent
334
+ *
335
+ * @return int|null The index of the current element with the parent, or null if there is no parent
336
+ */
332
337
protected function getIndex () : ?int {
333
338
foreach ($ this ->parent ->children () AS $ key => $ item ) {
334
339
if ($ item === $ this ) {
@@ -664,35 +669,56 @@ public function find(array $selector, bool $searchChildren = true) : array {
664
669
$ match = false ;
665
670
break ;
666
671
} elseif (!empty ($ item ['value ' ])) {
672
+ $ current = $ this ->attributes [$ item ['attribute ' ]];
667
673
switch ($ item ['comparison ' ]) {
668
674
669
675
// exact match
670
676
case '= ' :
671
- if ($ this ->attributes [$ item ['attribute ' ]] !== $ item ['value ' ]) {
677
+ if ($ item ['sensitive ' ]) {
678
+ if ($ current !== $ item ['value ' ]) {
679
+ $ match = false ;
680
+ break ;
681
+ }
682
+ } elseif (\mb_strtolower ($ current ) !== \mb_strtolower ($ item ['value ' ])) {
672
683
$ match = false ;
673
684
break ;
674
685
}
675
686
break ;
676
687
677
688
// match start
678
689
case '^= ' :
679
- if (\mb_strpos ($ this ->attributes [$ item ['attribute ' ]], $ item ['value ' ]) !== 0 ) {
690
+ if ($ item ['sensitive ' ]) {
691
+ if (\mb_strpos ($ current , $ item ['value ' ]) !== 0 ) {
692
+ $ match = false ;
693
+ break ;
694
+ }
695
+ } elseif (\mb_stripos ($ current , $ item ['value ' ]) !== 0 ) {
680
696
$ match = false ;
681
697
break ;
682
698
}
683
699
break ;
684
700
685
701
// match within
686
702
case '*= ' :
687
- if (\mb_strpos ($ this ->attributes [$ item ['attribute ' ]], $ item ['value ' ]) === false ) {
703
+ if ($ item ['sensitive ' ]) {
704
+ if (\mb_strpos ($ current , $ item ['value ' ]) === false ) {
705
+ $ match = false ;
706
+ break ;
707
+ }
708
+ } elseif (\mb_stripos ($ current , $ item ['value ' ]) === false ) {
688
709
$ match = false ;
689
710
break ;
690
711
}
691
712
break ;
692
713
693
714
// match end
694
715
case '$= ' :
695
- if (\mb_strpos ($ this ->attributes [$ item ['attribute ' ]], $ item ['value ' ]) !== \mb_strlen ($ this ->attributes [$ item ['attribute ' ]]) - \mb_strlen ($ item ['value ' ])) {
716
+ if ($ item ['sensitive ' ]) {
717
+ if (\mb_strpos ($ current , $ item ['value ' ]) !== \mb_strlen ($ current ) - \mb_strlen ($ item ['value ' ])) {
718
+ $ match = false ;
719
+ break ;
720
+ }
721
+ } elseif (\mb_stripos ($ current , $ item ['value ' ]) !== \mb_strlen ($ current ) - \mb_strlen ($ item ['value ' ])) {
696
722
$ match = false ;
697
723
break ;
698
724
}
0 commit comments