Data: shave off a couple of bytes

Closes gh-1931
This commit is contained in:
Mike Sidorov 2014-12-15 13:06:09 +05:00 committed by Oleg Gaidarenko
parent 72c4a067a9
commit 6f65f5faf2

View File

@ -1,10 +1,9 @@
define([ define([
"./core", "./core",
"./var/rnotwhite",
"./core/access", "./core/access",
"./data/var/dataPriv", "./data/var/dataPriv",
"./data/var/dataUser" "./data/var/dataUser"
], function( jQuery, rnotwhite, access, dataPriv, dataUser ) { ], function( jQuery, access, dataPriv, dataUser ) {
// Implementation Summary // Implementation Summary
// //
@ -17,7 +16,7 @@ define([
// 6. Provide a clear path for implementation upgrade to WeakMap in 2014 // 6. Provide a clear path for implementation upgrade to WeakMap in 2014
var rbrace = /^(?:\{[\w\W]*\}|\[[\w\W]*\])$/, var rbrace = /^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,
rmultiDash = /([A-Z])/g; rmultiDash = /[A-Z]/g;
function dataAttr( elem, key, data ) { function dataAttr( elem, key, data ) {
var name; var name;
@ -25,7 +24,7 @@ function dataAttr( elem, key, data ) {
// If nothing was found internally, try to fetch any // If nothing was found internally, try to fetch any
// data from the HTML5 data-* attribute // data from the HTML5 data-* attribute
if ( data === undefined && elem.nodeType === 1 ) { if ( data === undefined && elem.nodeType === 1 ) {
name = "data-" + key.replace( rmultiDash, "-$1" ).toLowerCase(); name = "data-" + key.replace( rmultiDash, "-$&" ).toLowerCase();
data = elem.getAttribute( name ); data = elem.getAttribute( name );
if ( typeof data === "string" ) { if ( typeof data === "string" ) {