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
190812c3
Commit
190812c3
authored
Jul 16, 2009
by
Yehuda Katz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor jQuery.data a bit to reduce property lookups
- Also added jQuery.isEmptyObject
parent
d36d224c
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
23 deletions
+21
-23
core.js
src/core.js
+6
-0
data.js
src/data.js
+15
-23
No files found.
src/core.js
View file @
190812c3
...
@@ -291,6 +291,12 @@ jQuery.extend({
...
@@ -291,6 +291,12 @@ jQuery.extend({
return
this
.
constructor
.
call
(
obj
)
===
Object
;
return
this
.
constructor
.
call
(
obj
)
===
Object
;
},
},
isEmptyObject
:
function
(
obj
)
{
var
name
=
""
;
for
(
name
in
obj
)
break
;
return
!
name
;
},
// check if an element is in a (or is an) XML document
// check if an element is in a (or is an) XML document
isXMLDoc
:
function
(
elem
)
{
isXMLDoc
:
function
(
elem
)
{
return
elem
.
nodeType
===
9
&&
elem
.
documentElement
.
nodeName
!==
"HTML"
||
return
elem
.
nodeType
===
9
&&
elem
.
documentElement
.
nodeName
!==
"HTML"
||
...
...
src/data.js
View file @
190812c3
...
@@ -8,27 +8,24 @@ jQuery.extend({
...
@@ -8,27 +8,24 @@ jQuery.extend({
windowData
:
windowData
:
elem
;
elem
;
var
id
=
elem
[
expando
];
var
id
=
elem
[
expando
]
,
cache
=
jQuery
.
cache
;
// Compute a unique ID for the element
// Compute a unique ID for the element
if
(
!
id
)
if
(
!
id
)
id
=
elem
[
expando
]
=
++
uuid
;
id
=
elem
[
expando
]
=
++
uuid
;
// Only generate the data cache if we're
// Only generate the data cache if we're
// trying to access or manipulate it
// trying to access or manipulate it
if
(
name
&&
!
jQuery
.
cache
[
id
]
)
if
(
name
&&
!
cache
[
id
]
)
jQuery
.
cache
[
id
]
=
{};
cache
[
id
]
=
{};
// Prevent overriding the named cache with undefined values
var
thisCache
=
cache
[
id
];
if
(
data
!==
undefined
)
jQuery
.
cache
[
id
][
name
]
=
data
;
if
(
name
===
true
)
return
jQuery
.
cache
[
id
]
// Prevent overriding the named cache with undefined values
if
(
data
!==
undefined
)
thisCache
[
name
]
=
data
;
// Return the named cache data, or the ID for the element
if
(
name
===
true
)
return
thisCache
return
name
?
else
if
(
name
)
return
thisCache
[
name
]
jQuery
.
cache
[
id
][
name
]
:
else
return
id
id
;
},
},
removeData
:
function
(
elem
,
name
)
{
removeData
:
function
(
elem
,
name
)
{
...
@@ -36,21 +33,16 @@ jQuery.extend({
...
@@ -36,21 +33,16 @@ jQuery.extend({
windowData
:
windowData
:
elem
;
elem
;
var
id
=
elem
[
expando
];
var
id
=
elem
[
expando
]
,
cache
=
jQuery
.
cache
,
thisCache
=
cache
[
id
]
;
// If we want to remove a specific section of the element's data
// If we want to remove a specific section of the element's data
if
(
name
)
{
if
(
name
)
{
if
(
jQuery
.
cache
[
id
]
)
{
if
(
thisCache
)
{
// Remove the section of cache data
// Remove the section of cache data
delete
jQuery
.
cache
[
id
]
[
name
];
delete
thisCache
[
name
];
// If we've removed all the data, remove the element's cache
// If we've removed all the data, remove the element's cache
name
=
""
;
if
(
jQuery
.
isEmptyObject
(
thisCache
)
)
for
(
name
in
jQuery
.
cache
[
id
]
)
break
;
if
(
!
name
)
jQuery
.
removeData
(
elem
);
jQuery
.
removeData
(
elem
);
}
}
...
@@ -67,7 +59,7 @@ jQuery.extend({
...
@@ -67,7 +59,7 @@ jQuery.extend({
}
}
// Completely remove the data cache
// Completely remove the data cache
delete
jQuery
.
cache
[
id
];
delete
cache
[
id
];
}
}
},
},
queue
:
function
(
elem
,
type
,
data
)
{
queue
:
function
(
elem
,
type
,
data
)
{
...
...
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