-
Notifications
You must be signed in to change notification settings - Fork 48.3k
[Fiber] Support SVG #8475
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
[Fiber] Support SVG #8475
Conversation
Instead of keeping a stack, we let the renderer keep track of the current namespace.
41b3452
to
d52fc5c
Compare
Like we talked about, this needs to support nested SVG tags. Another case is |
@@ -268,6 +272,7 @@ module.exports = function<T, P, I, TI, C>( | |||
// Abort and don't process children yet. | |||
return null; | |||
} else { | |||
pushHostContext(workInProgress.type); |
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.
Should we pass props too? We have cases like props.is
where props determine the type. I could imagine this being useful.
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.
Let's pass when we need them?
4572fd0
to
50bfa83
Compare
We allocate an array with one number, and increment it on any nested <svg>. We add a new counter to the array when we encounter a <foreignObject>. The counter lets us avoid a stack for nested <svg>s in the general case.
f8e1076
to
530eb7a
Compare
The mutable state we introduced above becomes irrelevant whenever we push a portal because a portal represents a different DOM tree. We store a snapshot of this state and restore it when the portal is popped.
Thanks for exploring this option. This is getting pretty complicated as well. How do you feel about reverting back to the one that uses a stack for the host namespace and document? Then we can unify that stack with the context stack later on like we talked about. I feel like a generic stack solution seems pretty useful for a lot of things. |
Yeah to be honest I have lost track of what's going on here completely. :-) Do you want to get back to #8417 as it was, or do you have some changes to it in mind? |
We can go back to #8417 but let's use a stack for the portal context (container) instead of storing it on the portal. Then we can iterate from there to unify the stacks. |
Replaces #8417.
Instead of keeping a stack, we're notifying the renderer when the work begins and ends.
This lets DOM renderer avoid the stack because namespace logic is not complex.
This is not done yet (missing portals and unwinding on error handling) but I want to get early feedback on the approach.