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
203a1689
Commit
203a1689
authored
Apr 05, 2012
by
Oleg
Committed by
Dave Methvin
Apr 05, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix #8545. Plug event handling memory leak in oldIE.
parent
41056ab1
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
19 deletions
+28
-19
data.js
src/data.js
+5
-1
event.js
src/event.js
+13
-7
manipulation.js
src/manipulation.js
+10
-11
No files found.
src/data.js
View file @
203a1689
...
@@ -6,6 +6,8 @@ var rbrace = /^(?:\{.*\}|\[.*\])$/,
...
@@ -6,6 +6,8 @@ var rbrace = /^(?:\{.*\}|\[.*\])$/,
jQuery
.
extend
({
jQuery
.
extend
({
cache
:
{},
cache
:
{},
deletedIds
:
[],
// Please use with caution
// Please use with caution
uuid
:
0
,
uuid
:
0
,
...
@@ -59,7 +61,7 @@ jQuery.extend({
...
@@ -59,7 +61,7 @@ jQuery.extend({
// 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
=
++
jQuery
.
uuid
;
elem
[
internalKey
]
=
id
=
jQuery
.
deletedIds
.
pop
()
||
++
jQuery
.
uuid
;
}
else
{
}
else
{
id
=
internalKey
;
id
=
internalKey
;
}
}
...
@@ -212,6 +214,8 @@ jQuery.extend({
...
@@ -212,6 +214,8 @@ jQuery.extend({
// We destroyed the cache and need to eliminate the expando on the node to avoid
// We destroyed the cache and need to eliminate the expando on the node to avoid
// false lookups in the cache for entries that no longer exist
// false lookups in the cache for entries that no longer exist
if
(
isNode
)
{
if
(
isNode
)
{
jQuery
.
deletedIds
.
push
(
id
);
// IE does not allow us to delete expando properties from nodes,
// IE does not allow us to delete expando properties from nodes,
// nor does it have a removeAttribute function on Document nodes;
// nor does it have a removeAttribute function on Document nodes;
// we must handle all of these cases
// we must handle all of these cases
...
...
src/event.js
View file @
203a1689
...
@@ -154,7 +154,7 @@ jQuery.event = {
...
@@ -154,7 +154,7 @@ jQuery.event = {
var
elemData
=
jQuery
.
hasData
(
elem
)
&&
jQuery
.
_data
(
elem
),
var
elemData
=
jQuery
.
hasData
(
elem
)
&&
jQuery
.
_data
(
elem
),
t
,
tns
,
type
,
origType
,
namespaces
,
origCount
,
t
,
tns
,
type
,
origType
,
namespaces
,
origCount
,
j
,
events
,
special
,
handle
,
eventType
,
handleObj
;
j
,
events
,
special
,
eventType
,
handleObj
;
if
(
!
elemData
||
!
(
events
=
elemData
.
events
)
)
{
if
(
!
elemData
||
!
(
events
=
elemData
.
events
)
)
{
return
;
return
;
...
@@ -213,14 +213,11 @@ jQuery.event = {
...
@@ -213,14 +213,11 @@ jQuery.event = {
// Remove the expando if it's no longer used
// Remove the expando if it's no longer used
if
(
jQuery
.
isEmptyObject
(
events
)
)
{
if
(
jQuery
.
isEmptyObject
(
events
)
)
{
handle
=
elemData
.
handle
;
delete
elemData
.
handle
;
if
(
handle
)
{
handle
.
elem
=
null
;
}
// removeData also checks for emptiness and clears the expando if empty
// removeData also checks for emptiness and clears the expando if empty
// so use it instead of delete
// so use it instead of delete
jQuery
.
removeData
(
elem
,
[
"events"
,
"handle"
]
,
true
);
jQuery
.
removeData
(
elem
,
"events"
,
true
);
}
}
},
},
...
@@ -636,8 +633,17 @@ jQuery.removeEvent = document.removeEventListener ?
...
@@ -636,8 +633,17 @@ jQuery.removeEvent = document.removeEventListener ?
}
}
}
:
}
:
function
(
elem
,
type
,
handle
)
{
function
(
elem
,
type
,
handle
)
{
var
name
=
"on"
+
type
;
if
(
elem
.
detachEvent
)
{
if
(
elem
.
detachEvent
)
{
elem
.
detachEvent
(
"on"
+
type
,
handle
);
// #8545, #7054, preventing memory leaks for custom events in IE6-8 –
// detachEvent needed property on element, by name of that event, to properly expose it to GC
if
(
typeof
elem
[
name
]
===
"undefined"
)
{
elem
[
name
]
=
null
;
}
elem
.
detachEvent
(
name
,
handle
);
}
}
};
};
...
...
src/manipulation.js
View file @
203a1689
...
@@ -811,21 +811,20 @@ jQuery.extend({
...
@@ -811,21 +811,20 @@ jQuery.extend({
jQuery
.
removeEvent
(
elem
,
type
,
data
.
handle
);
jQuery
.
removeEvent
(
elem
,
type
,
data
.
handle
);
}
}
}
}
// Null the DOM reference to avoid IE6/7/8 leak (#7054)
if
(
data
.
handle
)
{
data
.
handle
.
elem
=
null
;
}
}
}
if
(
deleteExpando
)
{
// Remove cache only if jQuery.event.remove was not removed it before
delete
elem
[
jQuery
.
expando
];
if
(
cache
[
id
]
)
{
if
(
deleteExpando
)
{
delete
elem
[
jQuery
.
expando
];
}
else
if
(
elem
.
removeAttribute
)
{
}
else
if
(
elem
.
removeAttribute
)
{
elem
.
removeAttribute
(
jQuery
.
expando
);
elem
.
removeAttribute
(
jQuery
.
expando
);
}
}
delete
cache
[
id
];
jQuery
.
deletedIds
.
push
(
id
);
delete
cache
[
id
];
}
}
}
}
}
}
}
...
...
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