fix($compile): attach  handler to a real element

Fixes #9095