Support modifying the DOM structure in link function of a directive

Backport of the fix to 1.0.x.

See https://github.com/angular/angular.js/pull/1773