Make WordPress Core


Ignore:
Timestamp:
04/21/2023 01:30:11 PM (2 years ago)
Author:
zieladam
Message:

HTML API: Fix a case where updates are overlooked when seeking to earlier locations.

This retains the WP_HTML_Tag_Processor attribute updates applied before calling seek() – they were erroneously erased in some cases.

Props dmsnell.
Fixes #58160.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/html-api/wpHtmlTagProcessor.php

    r55667 r55675  
    458458
    459459    /**
     460     * Ensures that when seeking to an earlier spot in the document that
     461     * all previously-enqueued updates are applied as they ought to be.
     462     *
     463     * @ticket 58160
     464     */
     465    public function test_get_updated_html_applies_updates_to_content_after_seeking_to_before_parsed_bytes() {
     466        $p = new WP_HTML_Tag_Processor( '<div><img hidden></div>' );
     467
     468        $p->next_tag();
     469        $p->set_attribute( 'wonky', true );
     470        $p->next_tag();
     471        $p->set_bookmark( 'here' );
     472
     473        $p->next_tag( array( 'tag_closers' => 'visit' ) );
     474        $p->seek( 'here' );
     475
     476        $this->assertSame( '<div wonky><img hidden></div>', $p->get_updated_html() );
     477    }
     478
     479    /**
    460480     * @ticket 56299
    461481     *
Note: See TracChangeset for help on using the changeset viewer.