aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorNilton Cesar <niltoncms@gmail.com>2017-11-22 14:43:44 -0500
committerTimmy Willison <4timmywil@gmail.com>2018-01-08 11:21:22 -0500
commit64a289286a743516bce82462200062a647ef3ac0 (patch)
treea98de0017aa21c031f59d1b21bd9ccea01a66f8d /src
parent3c0f2cfb05c94adb164ac863a96eb2cf09e8110a (diff)
downloadjquery-64a289286a743516bce82462200062a647ef3ac0.tar.gz
jquery-64a289286a743516bce82462200062a647ef3ac0.zip
Core: make camelCase function available only for internal usage
Close gh-3604 Fixes gh-3384
Diffstat (limited to 'src')
-rw-r--r--src/core.js18
-rw-r--r--src/core/camelCase.js23
-rw-r--r--src/css.js7
-rw-r--r--src/data.js5
-rw-r--r--src/data/Data.js13
-rw-r--r--src/effects.js7
6 files changed, 42 insertions, 31 deletions
diff --git a/src/core.js b/src/core.js
index fc538a49a..97b4de2fc 100644
--- a/src/core.js
+++ b/src/core.js
@@ -37,16 +37,7 @@ var
// Support: Android <=4.0 only
// Make sure we trim BOM and NBSP
- rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,
-
- // Matches dashed string for camelizing
- rmsPrefix = /^-ms-/,
- rdashAlpha = /-([a-z])/g,
-
- // Used by jQuery.camelCase as callback to replace()
- fcamelCase = function( all, letter ) {
- return letter.toUpperCase();
- };
+ rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g;
jQuery.fn = jQuery.prototype = {
@@ -284,13 +275,6 @@ jQuery.extend( {
DOMEval( code );
},
- // Convert dashed to camelCase; used by the css and data modules
- // Support: IE <=9 - 11, Edge 12 - 15
- // Microsoft forgot to hump their vendor prefix (#9572)
- camelCase: function( string ) {
- return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase );
- },
-
each: function( obj, callback ) {
var length, i = 0;
diff --git a/src/core/camelCase.js b/src/core/camelCase.js
new file mode 100644
index 000000000..799fb3752
--- /dev/null
+++ b/src/core/camelCase.js
@@ -0,0 +1,23 @@
+define( [], function() {
+
+"use strict";
+
+// Matches dashed string for camelizing
+var rmsPrefix = /^-ms-/,
+ rdashAlpha = /-([a-z])/g;
+
+// Used by camelCase as callback to replace()
+function fcamelCase( all, letter ) {
+ return letter.toUpperCase();
+}
+
+// Convert dashed to camelCase; used by the css and data modules
+// Support: IE <=9 - 11, Edge 12 - 15
+// Microsoft forgot to hump their vendor prefix (#9572)
+function camelCase( string ) {
+ return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase );
+}
+
+return camelCase;
+
+} );
diff --git a/src/css.js b/src/css.js
index 1058ad4a2..43e427472 100644
--- a/src/css.js
+++ b/src/css.js
@@ -2,6 +2,7 @@ define( [
"./core",
"./var/pnum",
"./core/access",
+ "./core/camelCase",
"./var/document",
"./var/rcssNum",
"./css/var/rnumnonpx",
@@ -16,7 +17,7 @@ define( [
"./core/init",
"./core/ready",
"./selector" // contains
-], function( jQuery, pnum, access, document, rcssNum, rnumnonpx, cssExpand,
+], function( jQuery, pnum, access, camelCase, document, rcssNum, rnumnonpx, cssExpand,
getStyles, swap, curCSS, adjustCSS, addGetHookIf, support ) {
"use strict";
@@ -245,7 +246,7 @@ jQuery.extend( {
// Make sure that we're working with the right name
var ret, type, hooks,
- origName = jQuery.camelCase( name ),
+ origName = camelCase( name ),
isCustomProp = rcustomProp.test( name ),
style = elem.style;
@@ -313,7 +314,7 @@ jQuery.extend( {
css: function( elem, name, extra, styles ) {
var val, num, hooks,
- origName = jQuery.camelCase( name ),
+ origName = camelCase( name ),
isCustomProp = rcustomProp.test( name );
// Make sure that we're working with the right name. We don't
diff --git a/src/data.js b/src/data.js
index 087ce4eb7..95c365a5a 100644
--- a/src/data.js
+++ b/src/data.js
@@ -1,9 +1,10 @@
define( [
"./core",
"./core/access",
+ "./core/camelCase",
"./data/var/dataPriv",
"./data/var/dataUser"
-], function( jQuery, access, dataPriv, dataUser ) {
+], function( jQuery, access, camelCase, dataPriv, dataUser ) {
"use strict";
@@ -112,7 +113,7 @@ jQuery.fn.extend( {
if ( attrs[ i ] ) {
name = attrs[ i ].name;
if ( name.indexOf( "data-" ) === 0 ) {
- name = jQuery.camelCase( name.slice( 5 ) );
+ name = camelCase( name.slice( 5 ) );
dataAttr( elem, name, data[ name ] );
}
}
diff --git a/src/data/Data.js b/src/data/Data.js
index 8c856c039..31ff4318c 100644
--- a/src/data/Data.js
+++ b/src/data/Data.js
@@ -1,8 +1,9 @@
define( [
"../core",
+ "../core/camelCase",
"../var/rnothtmlwhite",
"./var/acceptData"
-], function( jQuery, rnothtmlwhite, acceptData ) {
+], function( jQuery, camelCase, rnothtmlwhite, acceptData ) {
"use strict";
@@ -54,14 +55,14 @@ Data.prototype = {
// Handle: [ owner, key, value ] args
// Always use camelCase key (gh-2257)
if ( typeof data === "string" ) {
- cache[ jQuery.camelCase( data ) ] = value;
+ cache[ camelCase( data ) ] = value;
// Handle: [ owner, { properties } ] args
} else {
// Copy the properties one-by-one to the cache object
for ( prop in data ) {
- cache[ jQuery.camelCase( prop ) ] = data[ prop ];
+ cache[ camelCase( prop ) ] = data[ prop ];
}
}
return cache;
@@ -71,7 +72,7 @@ Data.prototype = {
this.cache( owner ) :
// Always use camelCase key (gh-2257)
- owner[ this.expando ] && owner[ this.expando ][ jQuery.camelCase( key ) ];
+ owner[ this.expando ] && owner[ this.expando ][ camelCase( key ) ];
},
access: function( owner, key, value ) {
@@ -119,9 +120,9 @@ Data.prototype = {
// If key is an array of keys...
// We always set camelCase keys, so remove that.
- key = key.map( jQuery.camelCase );
+ key = key.map( camelCase );
} else {
- key = jQuery.camelCase( key );
+ key = camelCase( key );
// If a key with the spaces exists, use it.
// Otherwise, create an array by matching non-whitespace
diff --git a/src/effects.js b/src/effects.js
index b8da7ce37..1dec60e01 100644
--- a/src/effects.js
+++ b/src/effects.js
@@ -1,5 +1,6 @@
define( [
"./core",
+ "./core/camelCase",
"./var/document",
"./var/rcssNum",
"./var/rnothtmlwhite",
@@ -17,8 +18,8 @@ define( [
"./manipulation",
"./css",
"./effects/Tween"
-], function( jQuery, document, rcssNum, rnothtmlwhite, cssExpand, isHiddenWithinTree, swap,
- adjustCSS, dataPriv, showHide ) {
+], function( jQuery, camelCase, document, rcssNum, rnothtmlwhite, cssExpand, isHiddenWithinTree,
+ swap, adjustCSS, dataPriv, showHide ) {
"use strict";
@@ -259,7 +260,7 @@ function propFilter( props, specialEasing ) {
// camelCase, specialEasing and expand cssHook pass
for ( index in props ) {
- name = jQuery.camelCase( index );
+ name = camelCase( index );
easing = specialEasing[ name ];
value = props[ index ];
if ( Array.isArray( value ) ) {