[wp-trac] [WordPress Trac] #64567: HTML API: get_attribute_names_with_prefix() should agree with enqueued attribute updates.

WordPress Trac noreply at wordpress.org
Wed Jan 28 19:25:48 UTC 2026


#64567: HTML API: get_attribute_names_with_prefix() should agree with enqueued
attribute updates.
--------------------------+--------------------
 Reporter:  dmsnell       |      Owner:  (none)
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  7.0
Component:  HTML API      |    Version:  6.2
 Severity:  minor         |   Keywords:
  Focuses:                |
--------------------------+--------------------
 The `get_attribute_names_with_prefix()` method only looks at the parsed
 attributes for a tag, meaning that it will return stale data once new
 attributes have been set or existing ones have been removed. It should not
 need to wait for `->get_updated_html()` to report the proper values, and
 should always agree with `->get_attribute()`

 {{{#!php
 <?php
 $p = new WP_HTML_Tag_Processor( '<div>' );
 $p->next_tag();
 $p->set_attribute( 'id', 'test' );
 var_dump( $p->get_attribute_names_with_prefix( '' ) );
 // array(0) {}

 $p->get_updated_html();
 var_dump( $p->get_attribute_names_with_prefix( '' ) );
 // array(1) { [0] => string(2) "id" }
 }}}

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/64567>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list