Adjust .parentElement type to include SVGElement#1198
Conversation
|
Thanks for the PR! This section of the codebase is owned by @saschanaz - if they write a comment saying "LGTM" then it will be merged. |
|
Build has failed because you missed to include the generated files. But did you considered the feedback from #1151 ? |
|
Sorry, I've missed that discussion. I see the points raised there but having to cast this through unknown/any first and then to It also seems that there is no good list of "expectations" about the DOM types. A lot of this is gray area and the APIs don't provide full type safety. It would be great if things like this would be documented somewhere. |
|
Happy to have a FAQ of some sort, maybe this could be the first one? |
|
@orta where such a FAQ should live in? this repo? main TS docs? |
|
In here I think, TypeScript's FAQ is already very very long |
In reality, this also includes
| nullbut this has been removed in 2cd8ad3 so I guess you want to omit that for pragmatic reasons.Originally this was typed as
Element | null(and that probably was the most "correct" type) but that was changed toHTMLELement | nullhere: #560 . However,SVGElementcan appear here in a lot of scenarios.An HTML element can be a parent of SVG (the simplest
<div><svg/></div>), SVG element can be a parent of another SVG element (<svg><rect/></svg>) but also the SVG element can be a parent of an HTML element (<svg><foreignObject><div></div></foreignObject></svg>)