Make WordPress Core


Ignore:
Timestamp:
05/03/2023 11:55:26 AM (22 months ago)
Author:
Bernhard Reiter
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, zieladam.
Merges [55675] to the 6.2 branch.
Fixes #58160.

File:
1 edited

Legend:

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

    r55668 r55707  
    405405            'Casting WP_HTML_Tag_Processor to a string without performing any updates did not return the initial HTML snippet'
    406406        );
     407    }
     408
     409    /**
     410     * Ensures that when seeking to an earlier spot in the document that
     411     * all previously-enqueued updates are applied as they ought to be.
     412     *
     413     * @ticket 58160
     414     */
     415    public function test_get_updated_html_applies_updates_to_content_after_seeking_to_before_parsed_bytes() {
     416        $p = new WP_HTML_Tag_Processor( '<div><img hidden></div>' );
     417
     418        $p->next_tag();
     419        $p->set_attribute( 'wonky', true );
     420        $p->next_tag();
     421        $p->set_bookmark( 'here' );
     422
     423        $p->next_tag( array( 'tag_closers' => 'visit' ) );
     424        $p->seek( 'here' );
     425
     426        $this->assertSame( '<div wonky><img hidden></div>', $p->get_updated_html() );
    407427    }
    408428
Note: See TracChangeset for help on using the changeset viewer.