diff options
author | jeresig <jeresig@gmail.com> | 2010-09-22 09:16:28 -0400 |
---|---|---|
committer | jeresig <jeresig@gmail.com> | 2010-09-22 09:16:28 -0400 |
commit | 9dc6e0c572b9c809a3a4c123071d96d48a01dd1c (patch) | |
tree | 70bb5a22bee73b049d07469a86479d64e185ac43 /src/manipulation.js | |
parent | 19b5d9e874bbd97d03d9e0561a70711e2bf91fcb (diff) | |
download | jquery-9dc6e0c572b9c809a3a4c123071d96d48a01dd1c.tar.gz jquery-9dc6e0c572b9c809a3a4c123071d96d48a01dd1c.zip |
Applied the RegExp issues reported by Jeff Robinson here: http://jmrware.com/articles/2010/jqueryregex/jQueryRegexes.html Additionally broke out all remaining inline RegExp. Fixes #7062.
Diffstat (limited to 'src/manipulation.js')
-rw-r--r-- | src/manipulation.js | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/src/manipulation.js b/src/manipulation.js index c3b8f6d0f..00e31201c 100644 --- a/src/manipulation.js +++ b/src/manipulation.js @@ -2,18 +2,13 @@ var rinlinejQuery = / jQuery\d+="(?:\d+|null)"/g, rleadingWhitespace = /^\s+/, - rxhtmlTag = /(<([\w:]+)[^>]*?)\/>/g, - rselfClosing = /^(?:area|br|col|embed|hr|img|input|link|meta|param)$/i, + rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/ig, rtagName = /<([\w:]+)/, rtbody = /<tbody/i, rhtml = /<|&#?\w+;/, - rnocache = /<script|<object|<embed|<option|<style/i, + rnocache = /<(?:script|object|embed|option|style)/i, rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i, // checked="checked" or checked (html5) - fcloseTag = function( all, front, tag ) { - return rselfClosing.test( tag ) ? - all : - front + "></" + tag + ">"; - }, + raction = /\=([^="'>\s]+\/)>/g, wrapMap = { option: [ 1, "<select multiple='multiple'>", "</select>" ], legend: [ 1, "<fieldset>", "</fieldset>" ], @@ -207,7 +202,7 @@ jQuery.fn.extend({ return jQuery.clean([html.replace(rinlinejQuery, "") // Handle the case in IE 8 where action=/test/> self-closes a tag - .replace(/\=([^="'>\s]+\/)>/g, '="$1">') + .replace(raction, '="$1">') .replace(rleadingWhitespace, "")], ownerDocument)[0]; } else { return this.cloneNode(true); @@ -235,7 +230,7 @@ jQuery.fn.extend({ (jQuery.support.leadingWhitespace || !rleadingWhitespace.test( value )) && !wrapMap[ (rtagName.exec( value ) || ["", ""])[1].toLowerCase() ] ) { - value = value.replace(rxhtmlTag, fcloseTag); + value = value.replace(rxhtmlTag, "<$1></$2>"); try { for ( var i = 0, l = this.length; i < l; i++ ) { @@ -479,7 +474,7 @@ jQuery.extend({ } else if ( typeof elem === "string" ) { // Fix "XHTML"-style tags in all browsers - elem = elem.replace(rxhtmlTag, fcloseTag); + elem = elem.replace(rxhtmlTag, "<$1></$2>"); // Trim whitespace, otherwise indexOf won't work as expected var tag = (rtagName.exec( elem ) || ["", ""])[1].toLowerCase(), |