-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Implement an internal DomSlot for positioning instead of NodeRef #3048
Conversation
use instead of NodeRef, decoupling the two fixes yewstack#3043
Visit the preview URL for this PR (updated for commit 3265656): https://yew-rs-api--pr3048-internal-noderefs-xjambtbj.web.app (expires Mon, 16 Jan 2023 12:17:49 GMT) 🔥 via Firebase Hosting GitHub Action 🌎 |
Size Comparison
✅ None of the examples has changed their size significantly. |
Benchmark - SSRYew Master
Pull Request
|
this is more consistent with DomPosition::at_end
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.
In general, I think this is a good change that it separates the "link" which is used internally and "RefCell-like" which is used externally.
I personally think we can eventually get away with "linking" completely if render is no longer pushed to scheduler and delayed at a later time.
@@ -109,14 +109,13 @@ impl std::fmt::Debug for NodeRef { | |||
#[derive(PartialEq, Debug, Default, Clone)] | |||
struct NodeRefInner { | |||
node: Option<Node>, |
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.
Can we have NodeRef(Rc<RefCell<Option<Node>>>)
and remove NodeRefInner
?
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.
With callback-refs, we would again need a NodeRefInner
, so I left it, anyway.
#[derive(Clone)] | ||
enum DomPositionVariant { | ||
Node(Option<Node>), | ||
Chained(RetargetableDomPosition), | ||
} |
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.
#[derive(Clone)] | |
enum DomPositionVariant { | |
Node(Option<Node>), | |
Chained(RetargetableDomPosition), | |
} | |
#[derive(Clone)] | |
enum DomPositionVariant<'a> { | |
Node(Option<&'a Node>), | |
Chained(RetargetableDomPosition), | |
} |
I think DomPosition is never stored so it doesn't need to live 'static
.
It would be nice to have this as a reference as cloning a JsValue actually creates JavaScript calls to create a new spot on the ref array so it's relatively expensive to clone them.
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.
The issue with this is that DomPosition
is returned from the various ReconcileTarget::*
trait methods, without a lifetime readily availabe. I'll see what can be done.
rename retarget -> reassign
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.
Approving this as I do not think there are other issues other than naming, which is not blocking to this pull request.
also add module doc
3265656
LGTM. |
…stack#3048) use instead of NodeRef, decoupling the two fixes yewstack#3043 * implement internal DomSlot * move DomSlot into submodule of dom_bundle * hide behind feature csr * add test cases * write get in continuation style, this saves a clone * private DomSlot::get
use instead of NodeRef, decoupling the two fixes #3043 * implement internal DomSlot * move DomSlot into submodule of dom_bundle * hide behind feature csr * add test cases * write get in continuation style, this saves a clone * private DomSlot::get
Description
A new for-internal-use data structure,
DomPosition
, is introduced to replace the uses ofNodeRef
s. This means the user-facingNodeRef
does no longer have alink
to a potentially long chain to follow.A
DomPosition
can either point aNode
(next sibling),None
(the end of the children list), or aRetargetableDomPosition
. The last of which is used to be able to transparently update the position "before" components, without having to explicitly know which kind of dom_bundle is its sibling.Also introduces an explicit
next_sibling
forFragment
, to better track what comes after it during hydration.Fixes #3043
Checklist