Move cases of .replace(re, Function) out from inline (to avoid being redeclared on every use). Fixes #4114.

This commit is contained in:
John Resig 2009-07-19 15:57:43 +00:00
parent 0ac9898d6b
commit f57d93bf18
2 changed files with 13 additions and 13 deletions

View file

@ -4,7 +4,12 @@ var rinlinejQuery = / jQuery\d+="(?:\d+|null)"/g,
rxhtmlTag = /(<(\w+)[^>]*?)\/>/g,
rselfClosing = /^(?:abbr|br|col|img|input|link|meta|param|hr|area|embed)$/i,
rinsideTable = /^<(thead|tbody|tfoot|colg|cap)/,
rtbody = /<tbody/i;
rtbody = /<tbody/i,
fcloseTag = function(all, front, tag){
return rselfClosing.test(tag) ?
all :
front + "></" + tag + ">";
});
jQuery.fn.extend({
text: function( text ) {
@ -303,11 +308,7 @@ jQuery.extend({
// Convert html string into DOM nodes
if ( typeof elem === "string" ) {
// Fix "XHTML"-style tags in all browsers
elem = elem.replace(rxhtmlTag, function(all, front, tag){
return rselfClosing.test(tag) ?
all :
front + "></" + tag + ">";
});
elem = elem.replace(rxhtmlTag, fcloseTag);
// Trim whitespace, otherwise indexOf won't work as expected
var tags = elem.replace(rleadingWhitespace, "")