initial version with fix for https://github.com/angular/angular.js/issues/992