@@ -12,15 +12,15 @@ class Translator {
1212 . '|(#(?P<id>[\w-]*)) '
1313 . '|(\.(?P<class>[\w-]*)) '
1414 . '|(?P<sibling>\s*\+\s*) '
15- . "|(\[(?P<attribute>[\w-]*)((?P<attribute_equals>[=~$*]+)(?P<attribute_value>(.+\[\]'?)|[^\]]+))*\])+ "
15+ . "|(\[(?P<attribute>[\w-]*)((?P<attribute_equals>[=~$|^ *]+)(?P<attribute_value>(.+\[\]'?)|[^\]]+))*\])+ "
1616 . '|(?P<descendant>\s+) '
1717 . '/ ' ;
1818
1919 const EQUALS_EXACT = "= " ;
2020 const EQUALS_CONTAINS_WORD = "~= " ;
2121 const EQUALS_ENDS_WITH = "$= " ;
2222 const EQUALS_CONTAINS = "*= " ;
23- const EQUALS_STARTS_WITH_OR_STARTS_WITH_HYPHENATED = "|= " ;
23+ const EQUALS_OR_STARTS_WITH_HYPHENATED = "|= " ;
2424 const EQUALS_STARTS_WITH = "^= " ;
2525
2626 public function __construct (
@@ -245,11 +245,24 @@ protected function convertSingleSelector(string $css):string {
245245 );
246246 break ;
247247
248- case self ::EQUALS_STARTS_WITH_OR_STARTS_WITH_HYPHENATED :
249- throw new NotYetImplementedException ();
248+ case self ::EQUALS_OR_STARTS_WITH_HYPHENATED :
249+ array_push (
250+ $ xpath ,
251+ "[ "
252+ . "@ {$ currentThreadItem ['content ' ]}= \"{$ valueString }\" or "
253+ . "starts-with(@ {$ currentThreadItem ['content ' ]}, \"{$ valueString }- \") "
254+ . "] "
255+ );
256+ break ;
250257
251258 case self ::EQUALS_STARTS_WITH :
252- throw new NotYetImplementedException ();
259+ array_push (
260+ $ xpath ,
261+ "[starts-with( "
262+ . "@ {$ currentThreadItem ['content ' ]}, \"{$ valueString }\""
263+ . ")] "
264+ );
265+ break ;
253266
254267 case self ::EQUALS_ENDS_WITH :
255268 array_push (
0 commit comments