-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
HTML API: Defer applying updates until necessary. #6120
Changes from all commits
3bd8aae
faf4238
c93e8ba
51afe4c
805ea9a
3b9b322
0ec6436
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -293,21 +293,30 @@ public function test_bookmarks_complex_use_case() { | |
|
||
/** | ||
* @ticket 56299 | ||
* @ticket 60697 | ||
* | ||
* @covers WP_HTML_Tag_Processor::seek | ||
*/ | ||
public function test_updates_bookmark_for_additions_after_both_sides() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You might wanna add the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added. Is it fine to add the explanation after the ticket id or will that throw off some parser somewhere? I can remove the explanation if it's a problem. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It looks as if no other test cases are using an explanation after the ticket id, so maybe better remove it for consistency's sake. |
||
$processor = new WP_HTML_Tag_Processor( '<div>First</div><div>Second</div>' ); | ||
$processor->next_tag(); | ||
$processor->set_attribute( 'id', 'one' ); | ||
$processor->set_bookmark( 'first' ); | ||
$processor->next_tag(); | ||
$processor->set_attribute( 'id', 'two' ); | ||
$processor->add_class( 'second' ); | ||
|
||
$processor->seek( 'first' ); | ||
$processor->add_class( 'first' ); | ||
|
||
$this->assertSame( | ||
'<div class="first">First</div><div class="second">Second</div>', | ||
'one', | ||
$processor->get_attribute( 'id' ), | ||
'Should have remembered attribute change from before the seek.' | ||
); | ||
|
||
$this->assertSame( | ||
'<div class="first" id="one">First</div><div class="second" id="two">Second</div>', | ||
$processor->get_updated_html(), | ||
'The bookmark was updated incorrectly in response to HTML markup updates' | ||
); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🗒️ A note for myself and other reviewers. Private methods cannot be extended so this should be safe. In PHP 8 it would be a warning to add
final
here.