Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Only creates the string trim method if it doesn't already exist #65

Merged
merged 1 commit into from Sep 8, 2011

Conversation

Projects
None yet
3 participants
Contributor

dhaigh commented Sep 8, 2011

Simple change that lets the browser use it's own trim goodness.

paulirish added a commit that referenced this pull request Sep 8, 2011

Merge pull request #65 from dhaigh/patch-1
Only creates the string trim method if it doesn't already exist

@paulirish paulirish merged commit 1dac435 into paulirish:master Sep 8, 2011

Owner

paulirish commented Sep 8, 2011

beautiful thx.

Contributor

dhaigh commented Sep 8, 2011

<3

@mathiasbynens mathiasbynens commented on the diff Sep 8, 2011

javascript/javascript.js
@@ -586,7 +586,7 @@ $('.rule_wrapper .comment a.off').live('click',function(){
* http://www.faqts.com/knowledge_base/view.phtml/aid/1678/fid/1 and
* http://blog.stevenlevithan.com/archives/faster-trim-javascript
*/
-String.prototype.trim = function() {
+String.prototype.trim = String.prototype.trim || function() {
@mathiasbynens

mathiasbynens Sep 8, 2011

Collaborator

Could be String.prototype.trim = ''.trim || function() { …};, or even ''.trim || (String.prototype.trim = function() { …});.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment