-
-
Notifications
You must be signed in to change notification settings - Fork 8.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
fix: Teleport SVG elements #2648
Conversation
PS: I don't know if it's necessary to add a test or even how I could test that, since the element is in fact added to the DOM, it is simply not being rendered. |
Can you provide a repro using one of the templates at https://new-issue.vuejs.org/?repo=vuejs/vue-next |
Sorry about that, i just created the issue: #2652 ! |
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.
Hi, thanks for the PR.
Can you add a test?
@@ -80,6 +80,13 @@ export const TeleportImpl = { | |||
|
|||
const disabled = isTeleportDisabled(n2.props) | |||
const { shapeFlag, children } = n2 | |||
// Verify whether the target is an SVGElement or not. | |||
const targetIsSVG = (target: RendererElement) => { |
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.
use isSVGTag(target.tag)
instead of this function.
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.
👍
@LinusBorg I'm not quite sure how to add my test, I would either need a visual test or at least test if the element has the right namespace, but from what I saw, there is no namespaceURI on the TestElement class. |
One thing to note is that this only work if the target is an |
@posva what do you mean? i think this should work both if the target has an SVG tag or if the destination is an SVG element, or did i misunderstand how the |
I've added a test but still i'm a bit confused about the way Teleport works because:
This might all be related to the fact that i'm missing something about how to test the Teleport component. |
@@ -9,7 +9,7 @@ import { | |||
traverseStaticChildren | |||
} from '../renderer' | |||
import { VNode, VNodeArrayChildren, VNodeProps } from '../vnode' | |||
import { isString, ShapeFlags } from '@vue/shared' | |||
import { isString, isSVGTag, ShapeFlags } from '@vue/shared' |
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.
FYI isSVGTag
is for compiler only and should be avoided in runtime code since it bloats the bundle size.
|
Made some updates:
|
Currently, when using Teleport to move an SVGElement or into an SVGElement, the element is not rendered . The issue is due to the fact that the Teleport "process" method is not checking whether the target element is itself an SVGElement and therefore uses createElement instead of createElementNS. This PR fixes that issue.