Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
J
jquery
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
夏彬
jquery
Commits
941d2e05
Commit
941d2e05
authored
Feb 12, 2013
by
Richard Gibson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
No ticket: keep jquery.min.js.gz under 32K
parent
03ab9b9f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
27 deletions
+25
-27
data.js
src/data.js
+25
-27
No files found.
src/data.js
View file @
941d2e05
...
@@ -6,9 +6,8 @@ function internalData( elem, name, data, pvt /* Internal Use Only */ ){
...
@@ -6,9 +6,8 @@ function internalData( elem, name, data, pvt /* Internal Use Only */ ){
return
;
return
;
}
}
var
thisCache
,
ret
,
var
ret
,
thisCache
,
internalKey
=
jQuery
.
expando
,
internalKey
=
jQuery
.
expando
,
getByName
=
typeof
name
===
"string"
,
// We have to handle DOM nodes and JS objects differently because IE6-7
// We have to handle DOM nodes and JS objects differently because IE6-7
// can't GC object references properly across the DOM-JS boundary
// can't GC object references properly across the DOM-JS boundary
...
@@ -24,7 +23,7 @@ function internalData( elem, name, data, pvt /* Internal Use Only */ ){
...
@@ -24,7 +23,7 @@ function internalData( elem, name, data, pvt /* Internal Use Only */ ){
// Avoid doing any more work than we need to when trying to get data on an
// Avoid doing any more work than we need to when trying to get data on an
// object that has no data at all
// object that has no data at all
if
(
(
!
id
||
!
cache
[
id
]
||
(
!
pvt
&&
!
cache
[
id
].
data
))
&&
getByName
&&
data
===
undefined
)
{
if
(
(
!
id
||
!
cache
[
id
]
||
(
!
pvt
&&
!
cache
[
id
].
data
))
&&
data
===
undefined
&&
typeof
name
===
"string"
)
{
return
;
return
;
}
}
...
@@ -32,20 +31,16 @@ function internalData( elem, name, data, pvt /* Internal Use Only */ ){
...
@@ -32,20 +31,16 @@ function internalData( elem, name, data, pvt /* Internal Use Only */ ){
// Only DOM nodes need a new unique ID for each element since their data
// Only DOM nodes need a new unique ID for each element since their data
// ends up in the global cache
// ends up in the global cache
if
(
isNode
)
{
if
(
isNode
)
{
elem
[
internalKey
]
=
id
=
core_deletedIds
.
pop
()
||
jQuery
.
guid
++
;
id
=
elem
[
internalKey
]
=
core_deletedIds
.
pop
()
||
jQuery
.
guid
++
;
}
else
{
}
else
{
id
=
internalKey
;
id
=
internalKey
;
}
}
}
}
if
(
!
cache
[
id
]
)
{
if
(
!
cache
[
id
]
)
{
cache
[
id
]
=
{};
// Avoid exposing jQuery metadata on plain JS objects when the object
// Avoids exposing jQuery metadata on plain JS objects when the object
// is serialized using JSON.stringify
// is serialized using JSON.stringify
if
(
!
isNode
)
{
cache
[
id
]
=
isNode
?
{}
:
{
toJSON
:
jQuery
.
noop
};
cache
[
id
].
toJSON
=
jQuery
.
noop
;
}
}
}
// An object can be passed to jQuery.data instead of a key/value pair; this gets
// An object can be passed to jQuery.data instead of a key/value pair; this gets
...
@@ -77,7 +72,7 @@ function internalData( elem, name, data, pvt /* Internal Use Only */ ){
...
@@ -77,7 +72,7 @@ function internalData( elem, name, data, pvt /* Internal Use Only */ ){
// Check for both converted-to-camel and non-converted data property names
// Check for both converted-to-camel and non-converted data property names
// If a data property was specified
// If a data property was specified
if
(
getByName
)
{
if
(
typeof
name
===
"string"
)
{
// First Try to find as-is property data
// First Try to find as-is property data
ret
=
thisCache
[
name
];
ret
=
thisCache
[
name
];
...
@@ -100,7 +95,7 @@ function internalRemoveData( elem, name, pvt ) {
...
@@ -100,7 +95,7 @@ function internalRemoveData( elem, name, pvt ) {
return
;
return
;
}
}
var
i
,
l
,
thisCache
,
var
thisCache
,
i
,
isNode
=
elem
.
nodeType
,
isNode
=
elem
.
nodeType
,
// See jQuery.data for more information
// See jQuery.data for more information
...
@@ -145,13 +140,14 @@ function internalRemoveData( elem, name, pvt ) {
...
@@ -145,13 +140,14 @@ function internalRemoveData( elem, name, pvt ) {
name
=
name
.
concat
(
jQuery
.
map
(
name
,
jQuery
.
camelCase
)
);
name
=
name
.
concat
(
jQuery
.
map
(
name
,
jQuery
.
camelCase
)
);
}
}
for
(
i
=
0
,
l
=
name
.
length
;
i
<
l
;
i
++
)
{
i
=
name
.
length
;
while
(
i
--
)
{
delete
thisCache
[
name
[
i
]
];
delete
thisCache
[
name
[
i
]
];
}
}
// If there is no data left in the cache, we want to continue
// If there is no data left in the cache, we want to continue
// and let the cache object itself get destroyed
// and let the cache object itself get destroyed
if
(
!
(
pvt
?
isEmptyDataObject
:
jQuery
.
isEmptyObject
)(
thisCache
)
)
{
if
(
pvt
?
!
isEmptyDataObject
(
thisCache
)
:
!
jQuery
.
isEmptyObject
(
thisCache
)
)
{
return
;
return
;
}
}
}
}
...
@@ -192,10 +188,10 @@ jQuery.extend({
...
@@ -192,10 +188,10 @@ jQuery.extend({
// The following elements throw uncatchable exceptions if you
// The following elements throw uncatchable exceptions if you
// attempt to add expando properties to them.
// attempt to add expando properties to them.
noData
:
{
noData
:
{
"applet"
:
true
,
"embed"
:
true
,
"embed"
:
true
,
// Ban all objects except for Flash (which handle expandos)
// Ban all objects except for Flash (which handle expandos)
"object"
:
"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
,
"object"
:
"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
"applet"
:
true
},
},
hasData
:
function
(
elem
)
{
hasData
:
function
(
elem
)
{
...
@@ -237,9 +233,12 @@ jQuery.extend({
...
@@ -237,9 +233,12 @@ jQuery.extend({
jQuery
.
fn
.
extend
({
jQuery
.
fn
.
extend
({
data
:
function
(
key
,
value
)
{
data
:
function
(
key
,
value
)
{
var
attrs
,
name
,
var
attrs
,
name
,
elem
=
this
[
0
]
,
data
=
null
,
i
=
0
,
i
=
0
,
data
=
null
;
elem
=
this
[
0
];
// Special expections of .data basically thwart jQuery.access,
// so implement the relevant behavior ourselves
// Gets all values
// Gets all values
if
(
key
===
undefined
)
{
if
(
key
===
undefined
)
{
...
@@ -251,7 +250,7 @@ jQuery.fn.extend({
...
@@ -251,7 +250,7 @@ jQuery.fn.extend({
for
(
;
i
<
attrs
.
length
;
i
++
)
{
for
(
;
i
<
attrs
.
length
;
i
++
)
{
name
=
attrs
[
i
].
name
;
name
=
attrs
[
i
].
name
;
if
(
!
name
.
indexOf
(
"data-"
)
)
{
if
(
name
.
indexOf
(
"data-"
)
===
0
)
{
name
=
jQuery
.
camelCase
(
name
.
slice
(
5
)
);
name
=
jQuery
.
camelCase
(
name
.
slice
(
5
)
);
dataAttr
(
elem
,
name
,
data
[
name
]
);
dataAttr
(
elem
,
name
,
data
[
name
]
);
...
@@ -271,17 +270,16 @@ jQuery.fn.extend({
...
@@ -271,17 +270,16 @@ jQuery.fn.extend({
});
});
}
}
return
jQuery
.
access
(
this
,
function
(
value
)
{
return
arguments
.
length
>
1
?
if
(
value
===
undefined
)
{
// Try to fetch any internally stored data first
return
elem
?
dataAttr
(
elem
,
key
,
jQuery
.
data
(
elem
,
key
)
)
:
null
;
}
// Sets one value
this
.
each
(
function
()
{
this
.
each
(
function
()
{
jQuery
.
data
(
this
,
key
,
value
);
jQuery
.
data
(
this
,
key
,
value
);
});
})
:
},
null
,
value
,
arguments
.
length
>
1
,
null
,
true
);
// Gets one value
// Try to fetch any internally stored data first
elem
?
dataAttr
(
elem
,
key
,
jQuery
.
data
(
elem
,
key
)
)
:
null
;
},
},
removeData
:
function
(
key
)
{
removeData
:
function
(
key
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment