refactor: simplify trim fn now that IE9 has String#trim

This commit is contained in:
Igor Minar
2014-08-08 11:08:07 -07:00
parent 441ab5235c
commit e6a9f9e130

View File

@@ -575,19 +575,9 @@ function isPromiseLike(obj) {
}
var trim = (function() {
// native trim is way faster: http://jsperf.com/angular-trim-test
// but IE doesn't have it... :-(
// TODO: we should move this into IE/ES5 polyfill
if (!String.prototype.trim) {
return function(value) {
return isString(value) ? value.replace(/^\s\s*/, '').replace(/\s\s*$/, '') : value;
};
}
return function(value) {
return isString(value) ? value.trim() : value;
};
})();
var trim = function(value) {
return isString(value) ? value.trim() : value;
};
/**