In my Aurelia use case, I am looking to implement a handler that will run for every attached view. Specifically, I need an HTML5 polyfill for date and number inputs using querySelector
. While I could manually call this in each view, I am curious if there is a recommended way to set this globally. (Please note that setting it at the router pipeline step may not be suitable for views loaded via compose
.)
I understand the potential risks involved, but I am interested in knowing if there is a best practice for adding global attached()
and detached()
handlers for both views and viewmodels.
Upon further examination (https://github.com/aurelia/templating/blob/ee5b9d6742fddf3d163aee8face6e6a58ba1554c/src/view.js#L259), it seems possible to add a hook for a global handler at this location that accepts a view as an argument. However, ideally I would prefer not to modify the framework code if there is another solution.