Skip to content
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

AngleSharpRenderer - a way to update DOM nodes when render tree changes during a test #48

Closed
egil opened this issue Jan 26, 2020 · 2 comments
Assignees
Labels
enhancement New feature or request help wanted Extra attention is needed
Milestone

Comments

@egil
Copy link
Member

egil commented Jan 26, 2020

Right now, every time a new render tree is created during a test, the markup and DOM nodes are recreated. That causes some issues (#46, #47) and probably has an impact on performance.

A better solution is to do what Blazor does -- i.e. update the initially created DOM tree using the RenderBatch created after each render. Since AngleSharp more or less is a complete W3C implementation of the DOM api, it should be possible to port the Typescript logic from Blazor to C#, so wheels do not have to be reinvented.

@egil egil added enhancement New feature or request help wanted Extra attention is needed labels Jan 26, 2020
@FlorianRappl
Copy link

Yes I do think its possible.

Maybe we can also work on this together. I'll have an eye on this!

@egil
Copy link
Member Author

egil commented Mar 24, 2020

@FlorianRappl that would be awesome. This is one of the harder issues, and certainly one you would be ideally suited to tackle, so I would love any help I can get with this.

It would also enable other more advanced scenarios in the future, such as running component's JavaScript, and have a much better e2e testing experience of Blazor components, that rely heavily on JavaScript.

Besides that, and making things go faster, my goal with this is also to make elements in the DOM be reusable across renders, i.e. if an element is not removed during a test, the same element reference can be reused in a test to assert against during the test, across multiple renders. The hack right now is my AngleSharpWrappers, but they only work through my Find and FindAll extension methods.

Where to start

I remember hearing @SteveSandersonMS talking about actually using AngleSharp in the early days of Blazor, so maybe there is some C# code for updating a AngleSharp based DOM available somewhere, perhaps here.

If that is out of date, which is likely, then it looks as if the TypeScript that needs to be converted is centered around the BrowserRenderer.ts#updateComponent method.

To get access to a RenderBatch of a rendered component, and trigger an update of the DOM, this is likely place: RenderedFragmentBase.cs#ComponentRendered

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants