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
8f72967e
Commit
8f72967e
authored
Jan 11, 2013
by
danilsomsikov
Committed by
Richard Gibson
Jan 16, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix #8335: Avoid memory leak by never setting data on non-element non-document nodes. Ref gh-1127.
(cherry picked from commit
cc324abf
)
parent
6b1b0a26
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
1 deletion
+17
-1
data.js
src/data.js
+5
-0
data.js
test/unit/data.js
+12
-1
No files found.
src/data.js
View file @
8f72967e
...
@@ -223,6 +223,11 @@ jQuery.extend({
...
@@ -223,6 +223,11 @@ jQuery.extend({
// A method for determining if a DOM node can handle the data expando
// A method for determining if a DOM node can handle the data expando
acceptData
:
function
(
elem
)
{
acceptData
:
function
(
elem
)
{
// Do not set data on non-element because it will not be cleared (#8335).
if
(
elem
.
nodeType
&&
elem
.
nodeType
!==
1
&&
elem
.
nodeType
!==
9
)
{
return
false
;
}
var
noData
=
elem
.
nodeName
&&
jQuery
.
noData
[
elem
.
nodeName
.
toLowerCase
()
];
var
noData
=
elem
.
nodeName
&&
jQuery
.
noData
[
elem
.
nodeName
.
toLowerCase
()
];
// nodes accept data unless otherwise specified; rejection can be conditional
// nodes accept data unless otherwise specified; rejection can be conditional
...
...
test/unit/data.js
View file @
8f72967e
...
@@ -133,8 +133,16 @@ test("Expando cleanup", 4, function() {
...
@@ -133,8 +133,16 @@ test("Expando cleanup", 4, function() {
jQuery
(
div
).
remove
();
jQuery
(
div
).
remove
();
});
});
test
(
"Data is not being set on comment and text nodes"
,
function
()
{
expect
(
2
);
ok
(
!
jQuery
.
hasData
(
jQuery
(
"<!-- comment -->"
).
data
(
"foo"
,
0
)
)
);
ok
(
!
jQuery
.
hasData
(
jQuery
(
"<span>text</span>"
).
contents
().
data
(
"foo"
,
0
)
)
);
});
test
(
"jQuery.acceptData"
,
function
()
{
test
(
"jQuery.acceptData"
,
function
()
{
expect
(
7
);
expect
(
9
);
ok
(
jQuery
.
acceptData
(
document
),
"document"
);
ok
(
jQuery
.
acceptData
(
document
),
"document"
);
ok
(
jQuery
.
acceptData
(
document
.
documentElement
),
"documentElement"
);
ok
(
jQuery
.
acceptData
(
document
.
documentElement
),
"documentElement"
);
...
@@ -149,6 +157,9 @@ test("jQuery.acceptData", function() {
...
@@ -149,6 +157,9 @@ test("jQuery.acceptData", function() {
var
applet
=
document
.
createElement
(
"object"
);
var
applet
=
document
.
createElement
(
"object"
);
applet
.
setAttribute
(
"classid"
,
"clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"
);
applet
.
setAttribute
(
"classid"
,
"clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"
);
ok
(
!
jQuery
.
acceptData
(
applet
),
"applet"
);
ok
(
!
jQuery
.
acceptData
(
applet
),
"applet"
);
ok
(
!
jQuery
.
acceptData
(
document
.
createComment
(
""
)
),
"comment"
);
ok
(
!
jQuery
.
acceptData
(
document
.
createTextNode
(
""
)
),
"text"
);
});
});
test
(
".data()"
,
function
()
{
test
(
".data()"
,
function
()
{
...
...
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