Skip to content

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

@kevincox

Description

@kevincox

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).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions