-
-
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
Fast hydration & FIX iframes hydration #4309
Conversation
@Conduitry @Rich-Harris |
These commits should obviously be rebased. At least a vanilla |
This would also fix (probably) sveltejs/sapper#1088! Edit: I just tested the fork and it fixed the hydratation problem! 😍 |
}); | ||
|
||
assert(iframeMutations.length === 0, 'iframe added/removed'); | ||
// assert(false, '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.
Probably comments should be cleared up.
@@ -3,6 +3,8 @@ export default { | |||
name: 'world' | |||
}, | |||
|
|||
skip: true, |
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.
Are these tests being skipped?
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 couple of tests are skipped - the tests we're written as if their test harness was async but it wasn't and when I wanted to write a test that actually had to be async - the tests failed when I changed the test harness to be async... the change that broke the tests I skipped was to test/hydration/index.js
@avi thanks for this - I've done an initial pre-review (as best I can) and I'll see if somebody who is more familiar with this part of the code can do a fuller review. There were just a couple of bits that confused me so I've added comments. |
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.
first of all, @avi thanks for the change.
i think this MR tries to change too many things:
- skip removing attribute during hydration (which i think its a breaking change)
- upgrading typescript (probably do it in a separate mr?)
- skip
appendChild
if is hydrating (i think this is the one that fix the iframe hydration reloading bug)- if claiming will insert the element into the DOM, i think we can skip mounting if hydrate right?
- fix hydration of text nodes (i think can do it in separate PR too)
I know skipping removing attributes is a breaking change, I wanted feedback whether to make my changes behind a compiler flag or not... But the current state of hydration is worse than resetting the innerHtml of the mount point by target.innerHTML = '' and doing client side rendering. |
Reverted the typescript bump and resolved a conflict |
if (n.nodeType === 3) { | ||
return claim_text(nodes, (n as Text).data); | ||
} else { | ||
return claim_element(nodes, n.nodeName, n, n.namespaceURI !== 'http://www.w3.org/1999/xhtml'); |
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.
'http://www.w3.org/1999/xhtml'
could be replaced with namespaces.html
:
export const html = 'http://www.w3.org/1999/xhtml'; |
this.n = this.n.map(n => { | ||
if (n.nodeType === 3) { | ||
return claim_text(nodes, (n as Text).data); | ||
} else { |
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.
it looks like this line and the closing curly brace two lines later both have an extra space
Is there anything that can be done to help move this PR along? Some of the small comments could be fixed fairly quickly. |
It's probably not that easy. There's more discussion on the linked issue: #4308 |
Yeah, I tried to rebase this the other day, and a whole lot of tests are failing. |
When I said it wouldn't be that easy, I meant that just rebasing this PR probably wouldn't be enough to get it checked in since there's not agreement that this is the right approach. I wasn't commenting on how hard or easy it would be to rebase and didn't expect any particular difficulties there. |
I just saw your comment on the issue from yesterday - yeah if you can do it without breaking changes that seems more likely to be accepted to me - but it might be good to ask some other folks as well to get sign-off on the approach before sinking too much time |
@benmccann Yeah, sorry, my comment above was a bit inexplicit. Currently on my phone.. What I meant to say above was that even just getting this to a point where everything works (with or without rebasing) would still require more work. The whole debate of the suitability of this approach notwithstanding. I’m trying to get a slight variation of the approach taken by @avi to work, but I keep running in to issues. |
Addressed in #6204. Thanks!! |
Before submitting the PR, please make sure you do the following
npm run lint
!)Tests
npm test
oryarn test
)Solution to #4308
Reuse dom nodes in hydration avoid insertBefore/append dom nodes
Better performance in hydration which is now slower than client side render and avoid reloading iframes...