X-Git-Url: http://git.asbjorn.it/?a=blobdiff_plain;ds=sidebyside;f=src%2Fmanipulation.js;h=237e957e56fdb552f2b17edde0e9aca82b555310;hb=6d23f2fd81f9f1894060a353e66effdf9738af16;hp=233cb826360af47068da204db86673d2d42d043a;hpb=5b84c7c45c8c3c5e7c9a17239cd658b0c87ab892;p=jquery.git diff --git a/src/manipulation.js b/src/manipulation.js index 233cb82..237e957 100644 --- a/src/manipulation.js +++ b/src/manipulation.js @@ -1,16 +1,25 @@ +var rinlinejQuery = / jQuery\d+="(?:\d+|null)"/g, + rleadingWhitespace = /^\s+/, + rsingleTag = /^<(\w+)\s*\/?>$/, + rxhtmlTag = /(<(\w+)[^>]*?)\/>/g, + rselfClosing = /^(?:abbr|br|col|img|input|link|meta|param|hr|area|embed)$/i, + rinsideTable = /^<(thead|tbody|tfoot|colg|cap)/, + rtbody = /
$/.exec(elems[0]); - if ( match ) + var match = rsingleTag.exec(elems[0]); + if ( match ) { return [ context.createElement( match[1] ) ]; + } } var ret = [], scripts = [], div = context.createElement("div"); jQuery.each(elems, function(i, elem){ - if ( typeof elem === "number" ) + if ( typeof elem === "number" ) { elem += ''; + } - if ( !elem ) - return; + if ( !elem ) { return; } // Convert html string into DOM nodes if ( typeof elem === "string" ) { // Fix "XHTML"-style tags in all browsers - elem = elem.replace(/(<(\w+)[^>]*?)\/>/g, function(all, front, tag){ - return tag.match(/^(abbr|br|col|img|input|link|meta|param|hr|area|embed)$/i) ? + elem = elem.replace(rxhtmlTag, function(all, front, tag){ + return rselfClosing.test(tag) ? all : front + ">" + tag + ">"; }); // Trim whitespace, otherwise indexOf won't work as expected - var tags = elem.replace(/^\s+/, "").substring(0, 10).toLowerCase(); + var tags = elem.replace(rleadingWhitespace, "") + .substring(0, 10).toLowerCase(); var wrap = // option or optgroup @@ -290,7 +321,7 @@ jQuery.extend({ !tags.indexOf("