Skip to content
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

add changeset and remove duplicate diffProps process #9

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/spotty-bees-destroy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'rrdom': patch
---

fix: scrolling may not be applied when fast-forwarding
8 changes: 3 additions & 5 deletions packages/rrdom/src/diff.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ export function diff(

diffChildren(oldTree, newTree, replayer, rrnodeMirror);

diffAfterUpdatingChildren(oldTree, newTree, replayer, rrnodeMirror);
diffAfterUpdatingChildren(oldTree, newTree, replayer);
}

/**
Expand Down Expand Up @@ -195,8 +195,8 @@ function diffBeforeUpdatingChildren(
);
}
/**
* Edge case where `applyScroll` may fail in `diffAfterUpdatingChildren`:
* the height of a node when `applyScroll` is called may be incorrect if
* Attributes and styles of the old element need to be updated before updating its children because of an edge case:
* `applyScroll` may fail in `diffAfterUpdatingChildren` when the height of a node when `applyScroll` is called may be incorrect if
* 1. its parent node contains styles that affects the targeted node's height
* 2. the CSS selector is targeting an attribute of the parent node
* by running `diffProps` on the parent node before `diffChildren` is called,
Expand All @@ -216,7 +216,6 @@ function diffAfterUpdatingChildren(
oldTree: Node,
newTree: IRRNode,
replayer: ReplayerHandler,
rrnodeMirror: Mirror,
) {
switch (newTree.RRNodeType) {
case RRNodeType.Document: {
Expand All @@ -227,7 +226,6 @@ function diffAfterUpdatingChildren(
case RRNodeType.Element: {
const oldElement = oldTree as HTMLElement;
const newRRElement = newTree as RRElement;
diffProps(oldElement, newRRElement, rrnodeMirror);
newRRElement.scrollData &&
replayer.applyScroll(newRRElement.scrollData, true);
/**
Expand Down
Loading