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

Make Element.on_end_tag handler 'h instead of 'static #172

Open
kevincox opened this issue Apr 9, 2023 · 0 comments
Open

Make Element.on_end_tag handler 'h instead of 'static #172

kevincox opened this issue Apr 9, 2023 · 0 comments

Comments

@kevincox
Copy link

kevincox commented Apr 9, 2023

While right now the main handlers can borrow data from the surrounding scope on_end_tag can't. This means that the data needs to be copped, put into an Rc or similar. Since IIUC this handler is not stored past the lifetime of the rewriter it would be nice if the lifetime reflected that.

Alternatively add an element_end handler to ElementContentHandlers as those handlers have the expected lifetime, this would also reduce allocations as the handler only needs to be allocated once instead of for each element.

I think the ideal state would be to replace ElementContentHandlers with a trait that could be implemented as it is basically a strange trait right now (you just need to "define" methods at runtime rather than implementing a trait). It would probably be possible to swap it out for a trait while maintaining the current API for most uses. But that is a bigger change and would probably need a new API to avoid breaking existing users (but the old API could just map to the new one).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant