[wp-trac] [WordPress Trac] #64751: ::set_modifiable_text() should only work on atomic elements in the HTML namespace

WordPress Trac noreply at wordpress.org
Fri Feb 27 12:18:16 UTC 2026


#64751: ::set_modifiable_text() should only work on atomic elements in the HTML
namespace
--------------------------+------------------------
 Reporter:  jonsurrell    |      Owner:  jonsurrell
     Type:  defect (bug)  |     Status:  assigned
 Priority:  normal        |  Milestone:  7.0
Component:  HTML API      |    Version:  6.7
 Severity:  minor         |   Keywords:
  Focuses:                |
--------------------------+------------------------
 `::set_modifiable_text()` includes special handling to allow setting the
 text of certain special "atomic" elements. These elements all have special
 parsing rules in the HTML standard.

 The special handling should only apply to elements in the HTML namespace.
 The special handling only checks the tag names.

 For example, this is correct:

 {{{#!php
 <?php
 $p = WP_HTML_Processor::create_fragment('<textarea></textarea>');
 $p->next_tag();
 echo "{$p->get_namespace()}:{$p->get_tag()}\n";
 assert( $p->set_modifiable_text('hello') );
 echo $p->get_updated_html();
 }}}

 Prints:

 {{{
 html:TEXTAREA
 <textarea>hello</textarea>
 }}}

 The following attempts to set the text on `svg:textarea`. This should fail
 and return `false`:

 {{{#!php
 <?php
 $p =
 WP_HTML_Processor::create_fragment('<svg><textarea></textarea></svg>');
 $p->next_tag();
 $p->next_tag();
 echo "{$p->get_namespace()}:{$p->get_tag()}\n";
 assert( $p->set_modifiable_text('whoops!') ); // this assertion should
 fail!
 echo $p->get_updated_html();
 }}}

 Instead, it adds the text to the beginning of the HTML:

 {{{
 svg:TEXTAREA
 whoops!<svg><textarea></textarea></svg>
 }}}

 `::get_modifiable_text()` should behave similarly. It does not appear to
 have any issues although it does not explicitly check the HTML namespace.

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


More information about the wp-trac mailing list