-
-
Notifications
You must be signed in to change notification settings - Fork 29
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
Consider <title>
for the name of its <svg>
element.
#324
Conversation
```html <svg> <title>My SVG</title> </svg> ``` Computing the name for this svg would have returned an empty string previously. It now correctly computes `My SVG` following the [accessible object in the accessibility tree for rendered SVG elements](https://www.w3.org/TR/svg-aam-1.0/#include_elements).
🦋 Changeset is good to goLatest commit: 07e9bf3 We got this. Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
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.
Appreciate the PR and tests! I have some minor nitpicks about the name of these new methods and nuances about SVGElement
and HTMLElement
. They're likely not important but may cause problems in the future.
sources/util.ts
Outdated
@@ -56,6 +56,18 @@ export function isHTMLLegendElement( | |||
return isElement(node) && node.tagName === "LEGEND"; | |||
} | |||
|
|||
export function isSVGElement(node: Node | null): node is SVGElement { | |||
return isElement(node) && node.ownerSVGElement !== undefined; |
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.
I was getting a ts error in my IDE:
Property 'ownerSVGElement' does not exist on type 'Element'.ts(2339)
I am not sure if this is the best way to look at the defined properties -- but on SVG elements, it is either defined or null
. I figured elsewhere it would be undefined
.
@juanca Great work, thanks! |
Computing the name for this svg would have returned an empty string previously. It now correctly computes
My SVG
following the accessible object in the accessibility tree for rendered SVG elements.Closes testing-library/dom-testing-library#685