Get IRenderedFragment/IRenderedComponent<T> from DOM element (IElement) #153
Labels
enhancement
New feature or request
help wanted
Extra attention is needed
input needed
When an issue requires input or suggestions
Milestone
In certain scenarios (#152), it can make it easier to create test when it is possible to get a component from a DOM element, due to the good DOM query (Find/FindAll) API.
Thus, it should be possible to go from an
node
to the component that rendered it.The API could have two methods,
GetComponent
andGetComponent<TComponent>
, and they should return aIRenderedFragment
orIRenderedComponent<MyComp>
, which is related to the nearest component in the render tree, that rendered the element. E.g.:It should be possible by adding meta information to the DOM tree created by the Htmlizer.cs type, and creating extension methods on
INode
that reads up the DOM tree until it finds some meta information about the source component. That extension method can then get the renderer and use its methods to find the component instance.Update
With the current render pipeline, where we generate markup with Htmlizer and then convert to AngleSharp nodes does seems to contain too many compromises when info about the source component should be embedded in the nodes in the dom tree, at least for the variants I've tried, so I will move this item over to the AngleSharpRenderer project, where it will be a completely different store.
I tried adding custom
<!--!X-->
comments to markup in Htmlizer, but doing so had too much impact on other parts of the system. Another variant added a custom attribute to the first element in a component, the reasoning being that elements are what users query from using Find/FindAll. However, if a component simply contained a markup string, and not calls to "OpenElement", then the components would not get the attribute.The text was updated successfully, but these errors were encountered: