@@ -70,7 +70,7 @@ public function test_wp_apply_anchor_support( $support, $value, $expected ) {
7070 */
7171 public function data_anchor_block_support () {
7272 return array (
73- 'anchor id attribute is applied ' => array (
73+ 'anchor id attribute is applied ' => array (
7474 'support ' => true ,
7575 'value ' => 'my-anchor ' ,
7676 'expected ' => array ( 'id ' => 'my-anchor ' ),
@@ -80,6 +80,56 @@ public function data_anchor_block_support() {
8080 'value ' => 'my-anchor ' ,
8181 'expected ' => array (),
8282 ),
83+ 'empty anchor value returns empty array ' => array (
84+ 'support ' => true ,
85+ 'value ' => '' ,
86+ 'expected ' => array (),
87+ ),
88+ 'null anchor value returns empty array ' => array (
89+ 'support ' => true ,
90+ 'value ' => null ,
91+ 'expected ' => array (),
92+ ),
93+ 'whitespace-only anchor value is applied ' => array (
94+ 'support ' => true ,
95+ 'value ' => ' ' ,
96+ 'expected ' => array ( 'id ' => ' ' ),
97+ ),
98+ 'anchor with hyphen and numbers ' => array (
99+ 'support ' => true ,
100+ 'value ' => 'section-123 ' ,
101+ 'expected ' => array ( 'id ' => 'section-123 ' ),
102+ ),
103+ 'anchor with underscore ' => array (
104+ 'support ' => true ,
105+ 'value ' => 'my_anchor_id ' ,
106+ 'expected ' => array ( 'id ' => 'my_anchor_id ' ),
107+ ),
108+ 'anchor with colon (valid in HTML5) ' => array (
109+ 'support ' => true ,
110+ 'value ' => 'my:anchor ' ,
111+ 'expected ' => array ( 'id ' => 'my:anchor ' ),
112+ ),
113+ 'anchor with period (valid in HTML5) ' => array (
114+ 'support ' => true ,
115+ 'value ' => 'my.anchor ' ,
116+ 'expected ' => array ( 'id ' => 'my.anchor ' ),
117+ ),
118+ 'numeric anchor value ' => array (
119+ 'support ' => true ,
120+ 'value ' => '123 ' ,
121+ 'expected ' => array ( 'id ' => '123 ' ),
122+ ),
123+ 'zero string anchor value is applied ' => array (
124+ 'support ' => true ,
125+ 'value ' => '0 ' ,
126+ 'expected ' => array ( 'id ' => '0 ' ),
127+ ), 1 Code has comments. Press enter to view.
128+ 'false value is treated as empty ' => array (
129+ 'support ' => true ,
130+ 'value ' => false ,
131+ 'expected ' => array (),
132+ ),
83133 );
84134 }
85135}
0 commit comments