Skip to content
Permalink
Browse files

Optimized the clean() code to no longer use .trim() (speeds up workin…

…g against long HTML in IE). Fixes #4037.
  • Loading branch information
jeresig committed Feb 9, 2009
1 parent 6b938e1 commit 136a459f4c24880f6d07f26c07e56451385637e0
Showing with 5 additions and 4 deletions.
  1. +5 −4 src/core.js
@@ -855,7 +855,7 @@ jQuery.extend({
});

// Trim whitespace, otherwise indexOf won't work as expected
var tags = jQuery.trim( elem ).toLowerCase();
var tags = elem.replace(/^\s+/, "").substring(0, 10).toLowerCase();

var wrap =
// option or optgroup
@@ -895,11 +895,12 @@ jQuery.extend({
if ( !jQuery.support.tbody ) {

// String was a <table>, *may* have spurious <tbody>
var tbody = !tags.indexOf("<table") && tags.indexOf("<tbody") < 0 ?
div.firstChild && div.firstChild.childNodes :
var hasBody = /<tbody/i.test(elem),
tbody = !tags.indexOf("<table") && !hasBody ?
div.firstChild && div.firstChild.childNodes :

// String was a bare <thead> or <tfoot>
wrap[1] == "<table>" && tags.indexOf("<tbody") < 0 ?
wrap[1] == "<table>" && !hasBody ?
div.childNodes :
[];

0 comments on commit 136a459

Please sign in to comment.
You can’t perform that action at this time.