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
d7d6b7a5
Commit
d7d6b7a5
authored
Apr 08, 2013
by
Rick Waldron
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move Data.prototype.accept => Data.accepts
Signed-off-by:
Rick Waldron
<
waldron.rick@gmail.com
>
parent
58a75a58
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
10 deletions
+18
-10
data.js
src/data.js
+18
-10
No files found.
src/data.js
View file @
d7d6b7a5
...
@@ -15,7 +15,8 @@ var data_user, data_priv,
...
@@ -15,7 +15,8 @@ var data_user, data_priv,
function
Data
()
{
function
Data
()
{
// Support: Android < 4,
// Support: Android < 4,
// Old WebKit does not have Object.preventExtensions/freeze method, return new empty object instead
// Old WebKit does not have Object.preventExtensions/freeze method,
// return new empty object instead with no [[set]] accessor
Object
.
defineProperty
(
this
.
cache
=
{},
0
,
{
Object
.
defineProperty
(
this
.
cache
=
{},
0
,
{
get
:
function
()
{
get
:
function
()
{
return
{};
return
{};
...
@@ -27,15 +28,26 @@ function Data() {
...
@@ -27,15 +28,26 @@ function Data() {
Data
.
uid
=
1
;
Data
.
uid
=
1
;
Data
.
accepts
=
function
(
owner
)
{
// Accepts only:
// - Node
// - Node.ELEMENT_NODE
// - Node.DOCUMENT_NODE
// - Object
// - Any
return
owner
.
nodeType
?
owner
.
nodeType
===
1
||
owner
.
nodeType
===
9
:
true
;
};
Data
.
prototype
=
{
Data
.
prototype
=
{
key
:
function
(
owner
)
{
key
:
function
(
owner
)
{
// We can accept data for non-element nodes in modern browsers, but we should not, see #8335.
// We can accept data for non-element nodes in modern browsers,
// Always return key for "freezed" object for such cases
// but we should not, see #8335.
if
(
!
this
.
accept
(
owner
)
)
{
// Always return the key for a frozen object.
if
(
!
Data
.
accepts
(
owner
)
)
{
return
0
;
return
0
;
}
}
var
descriptor
=
{},
var
descriptor
=
{},
// Check if the owner object already has a cache key
// Check if the owner object already has a cache key
unlock
=
owner
[
this
.
expando
];
unlock
=
owner
[
this
.
expando
];
...
@@ -169,10 +181,6 @@ Data.prototype = {
...
@@ -169,10 +181,6 @@ Data.prototype = {
}
}
}
}
},
},
accept
:
function
(
owner
)
{
// Do not set data on non-element because it will not be cleared (#8335).
return
owner
.
nodeType
?
owner
.
nodeType
===
1
||
owner
.
nodeType
===
9
:
true
;
},
hasData
:
function
(
owner
)
{
hasData
:
function
(
owner
)
{
return
!
jQuery
.
isEmptyObject
(
return
!
jQuery
.
isEmptyObject
(
this
.
cache
[
owner
[
this
.
expando
]
]
||
{}
this
.
cache
[
owner
[
this
.
expando
]
]
||
{}
...
@@ -189,7 +197,7 @@ data_priv = new Data();
...
@@ -189,7 +197,7 @@ data_priv = new Data();
jQuery
.
extend
({
jQuery
.
extend
({
acceptData
:
data_user
.
accept
,
acceptData
:
Data
.
accepts
,
hasData
:
function
(
elem
)
{
hasData
:
function
(
elem
)
{
return
data_user
.
hasData
(
elem
)
||
data_priv
.
hasData
(
elem
);
return
data_user
.
hasData
(
elem
)
||
data_priv
.
hasData
(
elem
);
...
...
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