@@ -503,4 +503,131 @@ public function __construct( $html ) {
503503 $ subclass_processor = call_user_func ( array ( get_class ( $ subclass_instance ), 'create_fragment ' ), '' );
504504 $ this ->assertInstanceOf ( get_class ( $ subclass_instance ), $ subclass_processor , '::create_fragment did not return subclass instance. ' );
505505 }
506+
507+ /**
508+ * Ensures that the tag processor is case sensitive when removing CSS classes in no-quirks mode.
509+ *
510+ * @ticket 61531
511+ *
512+ * @covers ::remove_class
513+ */
514+ public function test_remove_class_no_quirks_mode () {
515+ $ processor = WP_HTML_Processor::create_fragment ( '<span class="UPPER"></span> ' );
516+ $ processor ->next_tag ();
517+ $ processor ->remove_class ( 'upper ' );
518+ $ this ->assertSame ( '<span class="UPPER"></span> ' , $ processor ->get_updated_html () );
519+
520+ $ processor ->remove_class ( 'UPPER ' );
521+ $ this ->assertSame ( '<span ></span> ' , $ processor ->get_updated_html () );
522+ }
523+
524+ /**
525+ * Ensures that the tag processor is case sensitive when adding CSS classes in no-quirks mode.
526+ *
527+ * @ticket 61531
528+ *
529+ * @covers ::add_class
530+ */
531+ public function test_add_class_no_quirks_mode () {
532+ $ processor = WP_HTML_Processor::create_fragment ( '<span class="UPPER"></span> ' );
533+ $ processor ->next_tag ();
534+ $ processor ->add_class ( 'UPPER ' );
535+ $ this ->assertSame ( '<span class="UPPER"></span> ' , $ processor ->get_updated_html () );
536+
537+ $ processor ->add_class ( 'upper ' );
538+ $ this ->assertSame ( '<span class="UPPER upper"></span> ' , $ processor ->get_updated_html () );
539+ }
540+
541+ /**
542+ * Ensures that the tag processor is case sensitive when checking has CSS classes in no-quirks mode.
543+ *
544+ * @ticket 61531
545+ *
546+ * @covers ::has_class
547+ */
548+ public function test_has_class_no_quirks_mode () {
549+ $ processor = WP_HTML_Processor::create_fragment ( '<span class="UPPER"></span> ' );
550+ $ processor ->next_tag ();
551+ $ this ->assertFalse ( $ processor ->has_class ( 'upper ' ) );
552+ $ this ->assertTrue ( $ processor ->has_class ( 'UPPER ' ) );
553+ }
554+
555+ /**
556+ * Ensures that the tag processor lists unique CSS class names in no-quirks mode.
557+ *
558+ * @ticket 61531
559+ *
560+ * @covers ::class_list
561+ */
562+ public function test_class_list_no_quirks_mode () {
563+ $ processor = WP_HTML_Processor::create_fragment ( '<span class="A A a B b É É é"></span> ' );
564+ $ processor ->next_tag ();
565+ $ class_list = iterator_to_array ( $ processor ->class_list () );
566+ $ this ->assertSame (
567+ array ( 'A ' , 'a ' , 'B ' , 'b ' , 'É ' , 'é ' ),
568+ $ class_list
569+ );
570+ }
571+
572+ /**
573+ * Ensures that the tag processor is case sensitive when removing CSS classes in quirks mode.
574+ *
575+ * @ticket 61531
576+ *
577+ * @covers ::remove_class
578+ */
579+ public function test_remove_class_quirks_mode () {
580+ $ processor = WP_HTML_Processor::create_fragment ( '<span class="UPPER"></span> ' , '<body> ' , 'UTF-8 ' , WP_HTML_Processor_State::QUIRKS_MODE );
581+ $ processor ->next_tag ();
582+ $ processor ->remove_class ( 'upper ' );
583+ $ this ->assertSame ( '<span class="UPPER"></span> ' , $ processor ->get_updated_html () );
584+
585+ $ processor ->remove_class ( 'UPPER ' );
586+ $ this ->assertSame ( '<span ></span> ' , $ processor ->get_updated_html () );
587+ }
588+
589+ /**
590+ * Ensures that the tag processor is case sensitive when adding CSS classes in quirks mode.
591+ *
592+ * @ticket 61531
593+ *
594+ * @covers ::add_class
595+ */
596+ public function test_add_class_quirks_mode () {
597+ $ processor = WP_HTML_Processor::create_fragment ( '<span class="UPPER"></span> ' , '<body> ' , 'UTF-8 ' , WP_HTML_Processor_State::QUIRKS_MODE );
598+ $ processor ->next_tag ();
599+ $ processor ->add_class ( 'upper ' );
600+ $ this ->assertSame ( '<span class="UPPER"></span> ' , $ processor ->get_updated_html () );
601+ }
602+
603+ /**
604+ * Ensures that the tag processor is case sensitive when checking has CSS classes in quirks mode.
605+ *
606+ * @ticket 61531
607+ *
608+ * @covers ::has_class
609+ */
610+ public function test_has_class_quirks_mode () {
611+ $ processor = WP_HTML_Processor::create_fragment ( '<span class="UPPER"></span> ' , '<body> ' , 'UTF-8 ' , WP_HTML_Processor_State::QUIRKS_MODE );
612+ $ processor ->next_tag ();
613+ $ this ->assertTrue ( $ processor ->has_class ( 'upper ' ) );
614+ $ this ->assertTrue ( $ processor ->has_class ( 'UPPER ' ) );
615+ }
616+
617+ /**
618+ * Ensures that the tag processor lists unique CSS class names in quirks mode.
619+ *
620+ * @ticket 61531
621+ *
622+ * @covers ::class_list
623+ */
624+ public function test_class_list_quirks_mode () {
625+ $ processor = WP_HTML_Processor::create_fragment ( '<span class="A A a B b É É é"></span> ' , '<body> ' , 'UTF-8 ' , WP_HTML_Processor_State::QUIRKS_MODE );
626+ $ processor ->next_tag ();
627+ $ class_list = iterator_to_array ( $ processor ->class_list () );
628+ $ this ->assertSame (
629+ array ( 'A ' , 'a ' , 'B ' , 'b ' , 'É ' , 'é ' ),
630+ $ class_list
631+ );
632+ }
506633}
0 commit comments