Open silbinarywolf opened 5 years ago
.enhance is a tricky beast. it is supposed to be run on not hydrated with aurelia dom. and be called only once.
If you have au-target and au-target-id already on elements.. than you already ran aurelia magic on them.
your workaround is fine.
you would also want to add el.au && el.au.controller.viewModel.detached() && el.au.controller.viewModel.unbind()
I think this has more to do with documentation than fixing the issue. It doesn't seem there is a safe or easy way to detect which element should be avoided when enhancing a DOM tree.
@fkleuver @EisenbergEffect
I've opted to only run it once in my use-case and it seems to be working OK. Improved documentation on enhancing/rendering a template manually would be much appreciated though.
@bigopon Agree. Let me see if I can add a note right now to go out with the next site content release.
Related to this comment: https://github.com/aurelia/framework/issues/600#issuecomment-252479570
Related gist from above comment: https://gist.run/?id=c59eed72e1c255b8f462c1d45e495a7a
I'm submitting a bug report
Please tell us about your environment:
Operating System: Windows 10
Aurelia CLI OR JSPM OR Webpack AND Version Webpack
Browser: Chrome
Language: TypeScript
Current behavior: If I use element in it, I'll get a crash error.
aurelia.enhance(bindingContext, document.body)
on template that was run through the template compiler and has aExpected/desired behavior: I wouldn't expect this to crash. Currently my workaround is to run the following: