#62241 closed defect (bug) (fixed)
HTML API: Fix the position update after changing the modifiable text when length differs
| Reported by: | gziolo | Owned by: | gziolo |
|---|---|---|---|
| Priority: | normal | Milestone: | 6.7 |
| Component: | HTML API | Version: | 6.7 |
| Severity: | normal | Keywords: | has-patch has-unit-tests |
| Cc: | Focuses: |
Description
Reported by @zieladam on GitHub: https://github.com/WordPress/wordpress-develop/pull/7007#issuecomment-2412540433
I just isolated the problem:
$p = new WP_HTML_Tag_Processor('Hello there'); $p->next_token(); $p->set_modifiable_text('Short'); echo $p->get_updated_html();It's not occurring with this patch:
- $this->bytes_already_parsed = $before_current_tag; + if ($this->get_token_type() === '#tag') { + $this->bytes_already_parsed = $before_current_tag; + }
The actual fix will be more nuanced because the text node might appear in the HTML in the middle or at the end of the HTML provided, examples:
<p>Hello</p>String to replace
<p>Hello</p>String to replace<p>Hello</p>
Change History (6)
This ticket was mentioned in PR #7577 on WordPress/wordpress-develop by @gziolo.
23 months ago
#1
- Keywords has-patch has-unit-tests added
@jonsurrell commented on PR #7577:
23 months ago
#2
@gziolo I've proposed a fix for this in https://github.com/gziolo/wordpress-develop/pull/2 that can be merged into this PR.
23 months ago
#5
Committed with https://core.trac.wordpress.org/changeset/59250.
@zieladam commented on PR #7577:
23 months ago
#6
Thank you so much for a timely fix!
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
Reported by @adamziel in https://github.com/WordPress/wordpress-develop/pull/7007#issuecomment-2412540433:
Trac ticket: https://core.trac.wordpress.org/ticket/62241