@@ -138,9 +138,11 @@ public static function build_html5_treelike_string( $fragment_context, $html ) {
138138 sort ( $ attribute_names , SORT_STRING );
139139
140140 foreach ( $ attribute_names as $ attribute_name ) {
141- $ val = $ p ->get_attribute ($ attribute_name );
142- if ( $ val === true ) {
143- $ val = "" ;
141+ $ val = $ p ->get_attribute ( $ attribute_name );
142+ // Attributes with no value are `true` with the HTML API,
143+ // We map use the empty string value in the tree structure.
144+ if ( true === $ val ) {
145+ $ val = '' ;
144146 }
145147 $ output .= "{$ indent } {$ attribute_name }= \"{$ val }\"\n" ;
146148 }
@@ -259,13 +261,13 @@ public static function parse_html5_dat_testfile( $filename ) {
259261 $ trimmed = ltrim ( substr ( $ candidate , 0 , -1 ) );
260262
261263 // Text: "…
262- if ( $ trimmed [ 0 ] === ' " ' ) {
264+ if ( ' " ' === $ trimmed [ 0 ] ) {
263265 // Skip for now
264266 break ;
265267 }
266268
267269 // Attribute: name="value"
268- if ( $ trimmed [ strlen ($ trimmed ) - 1 ] === ' " ' ) {
270+ if ( ' " ' === $ trimmed [ strlen ( $ trimmed ) - 1 ] ) {
269271 $ test_dom .= $ candidate ;
270272 break ;
271273 }
@@ -274,7 +276,7 @@ public static function parse_html5_dat_testfile( $filename ) {
274276 // Comments: <!-- comment text -->
275277 // Doctypes: <!DOCTYPE … >
276278 // Processing instructions: <?target >
277- if ( $ trimmed [0 ] === ' < ' && $ trimmed [ strlen ($ trimmed ) - 1 ] === ' > ' ) {
279+ if ( ' < ' === $ trimmed [0 ] && ' > ' === $ trimmed [ strlen ( $ trimmed ) - 1 ] ) {
278280 // Tags: <tag-name>
279281 if ( ctype_alpha ( $ trimmed [1 ] ) ) {
280282 $ test_dom .= $ candidate ;
0 commit comments