-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
RichText: only replace range and nodes if different #12547
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
94c4eb2
RichText: only set range if different
ellatrix 11a80b1
Check rangeCount
ellatrix a8ab4e6
Also compare nodes
ellatrix 1dcd440
Add e2e test
ellatrix 2137124
Simplify
ellatrix 35ea03a
RichText: Document isRangeEqual
aduth cdddba8
Testing: RichText: Assure subscriber removal
aduth 6e19977
Unsubscribe in page.evaluate
ellatrix File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Is
future
used after this function is complete? I'm wondering if there's any gains to be had by avoiding theremoveChild
operation and just stepping through the children.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.
This won't work I think. When you append or replace, the node will be gone from
future
. So either we have to remove unused nodes so thatfirstChild
is accurate, or we copy all the nods to an array. Not sure if it makes much difference. These nodes are not live.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.
But it passes all tests, so it must work? 😄
There might be an option here with iterating backward from the end of
future.childNodes
as well.The theory (unconfirmed) is that
removeChild
is a non-trivial operation, even if not live in a document.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.
I think it’s a misconception that the DOM is slow, but I can make test.
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.
I put together a benchmark. I'm a bit puzzled by how slow the normal iteration is, but it does show
removeChild
as being sufficiently performant.https://jsbin.com/bemuhaj/4/edit?html,js,console,output
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.
Yeah the DOM is pretty fast. Just not the live one... :)