diff options
author | John Resig <jeresig@gmail.com> | 2009-07-19 15:57:43 +0000 |
---|---|---|
committer | John Resig <jeresig@gmail.com> | 2009-07-19 15:57:43 +0000 |
commit | f57d93bf18a2d5c3b7a0b50da67cf6147aa389c3 (patch) | |
tree | 3f8d1976ad10e5105e7e770edada1ebedc0d2e6d | |
parent | 0ac9898d6b7200075d20e36d7c31ad77585c8778 (diff) | |
download | jquery-f57d93bf18a2d5c3b7a0b50da67cf6147aa389c3.tar.gz jquery-f57d93bf18a2d5c3b7a0b50da67cf6147aa389c3.zip |
Move cases of .replace(re, Function) out from inline (to avoid being redeclared on every use). Fixes #4114.
-rw-r--r-- | src/css.js | 13 | ||||
-rw-r--r-- | src/manipulation.js | 13 |
2 files changed, 13 insertions, 13 deletions
diff --git a/src/css.js b/src/css.js index 2395bdf59..c32034d94 100644 --- a/src/css.js +++ b/src/css.js @@ -3,7 +3,10 @@ var exclude = /z-?index|font-?weight|opacity|zoom|line-?height/i, // cache check for defaultView.getComputedStyle getComputedStyle = document.defaultView && document.defaultView.getComputedStyle, // normalize float css property - styleFloat = jQuery.support.cssFloat ? "cssFloat" : "styleFloat"; + styleFloat = jQuery.support.cssFloat ? "cssFloat" : "styleFloat", + fcamelCase = function(all, letter){ + return letter.toUpperCase(); + }; jQuery.fn.css = function( name, value ) { var options = name, isFunction = jQuery.isFunction( value ); @@ -83,9 +86,7 @@ jQuery.extend({ if ( /float/i.test( name ) ) name = styleFloat; - name = name.replace(/-([a-z])/ig, function(all, letter){ - return letter.toUpperCase(); - }); + name = name.replace(/-([a-z])/ig, fcamelCase); if ( set ) style[ name ] = value; @@ -163,9 +164,7 @@ jQuery.extend({ ret = "1"; } else if ( elem.currentStyle ) { - var camelCase = name.replace(/\-(\w)/g, function(all, letter){ - return letter.toUpperCase(); - }); + var camelCase = name.replace(/\-(\w)/g, fcamelCase); ret = elem.currentStyle[ name ] || elem.currentStyle[ camelCase ]; diff --git a/src/manipulation.js b/src/manipulation.js index 0051bbc0b..f577cf837 100644 --- a/src/manipulation.js +++ b/src/manipulation.js @@ -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, "") |