Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
Element
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
CI / CD Analytics
Repository Analytics
Value Stream Analytics
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
林焕东
Element
Commits
1b3832f0
Commit
1b3832f0
authored
Feb 10, 2018
by
syn-zeta
Committed by
杨奕
Feb 11, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Popper: fix memory leak on route change (#9757)
parent
e4abaf7b
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
19 deletions
+14
-19
src/utils/popper.js
src/utils/popper.js
+11
-16
src/utils/vue-popper.js
src/utils/vue-popper.js
+3
-3
No files found.
src/utils/popper.js
View file @
1b3832f0
...
@@ -240,7 +240,6 @@
...
@@ -240,7 +240,6 @@
if
(
typeof
this
.
state
.
updateCallback
===
'
function
'
)
{
if
(
typeof
this
.
state
.
updateCallback
===
'
function
'
)
{
this
.
state
.
updateCallback
(
data
);
this
.
state
.
updateCallback
(
data
);
}
}
};
};
/**
/**
...
@@ -438,7 +437,6 @@
...
@@ -438,7 +437,6 @@
popperOffsets
.
width
=
popperRect
.
width
;
popperOffsets
.
width
=
popperRect
.
width
;
popperOffsets
.
height
=
popperRect
.
height
;
popperOffsets
.
height
=
popperRect
.
height
;
return
{
return
{
popper
:
popperOffsets
,
popper
:
popperOffsets
,
reference
:
referenceOffsets
reference
:
referenceOffsets
...
@@ -464,6 +462,7 @@
...
@@ -464,6 +462,7 @@
target
=
root
;
target
=
root
;
}
}
target
.
addEventListener
(
'
scroll
'
,
this
.
state
.
updateBound
);
target
.
addEventListener
(
'
scroll
'
,
this
.
state
.
updateBound
);
this
.
state
.
scrollTarget
=
target
;
}
}
};
};
...
@@ -476,13 +475,9 @@
...
@@ -476,13 +475,9 @@
Popper
.
prototype
.
_removeEventListeners
=
function
()
{
Popper
.
prototype
.
_removeEventListeners
=
function
()
{
// NOTE: 1 DOM access here
// NOTE: 1 DOM access here
root
.
removeEventListener
(
'
resize
'
,
this
.
state
.
updateBound
);
root
.
removeEventListener
(
'
resize
'
,
this
.
state
.
updateBound
);
if
(
this
.
_options
.
boundariesElement
!==
'
window
'
)
{
if
(
this
.
_options
.
boundariesElement
!==
'
window
'
&&
this
.
state
.
scrollTarget
)
{
var
target
=
getScrollParent
(
this
.
_reference
);
this
.
state
.
scrollTarget
.
removeEventListener
(
'
scroll
'
,
this
.
state
.
updateBound
);
// here it could be both `body` or `documentElement` thanks to Firefox, we then check both
this
.
state
.
scrollTarget
=
null
;
if
(
target
===
root
.
document
.
body
||
target
===
root
.
document
.
documentElement
)
{
target
=
root
;
}
target
.
removeEventListener
(
'
scroll
'
,
this
.
state
.
updateBound
);
}
}
this
.
state
.
updateBound
=
null
;
this
.
state
.
updateBound
=
null
;
};
};
...
...
src/utils/vue-popper.js
View file @
1b3832f0
...
@@ -129,9 +129,9 @@ export default {
...
@@ -129,9 +129,9 @@ export default {
}
}
},
},
doDestroy
()
{
doDestroy
(
forceDestroy
)
{
/* istanbul ignore if */
/* istanbul ignore if */
if
(
this
.
showPopper
||
!
this
.
popperJS
)
return
;
if
(
!
this
.
popperJS
||
(
this
.
showPopper
&&
!
forceDestroy
)
)
return
;
this
.
popperJS
.
destroy
();
this
.
popperJS
.
destroy
();
this
.
popperJS
=
null
;
this
.
popperJS
=
null
;
},
},
...
@@ -184,7 +184,7 @@ export default {
...
@@ -184,7 +184,7 @@ export default {
},
},
beforeDestroy
()
{
beforeDestroy
()
{
this
.
doDestroy
();
this
.
doDestroy
(
true
);
if
(
this
.
popperElm
&&
this
.
popperElm
.
parentNode
===
document
.
body
)
{
if
(
this
.
popperElm
&&
this
.
popperElm
.
parentNode
===
document
.
body
)
{
this
.
popperElm
.
removeEventListener
(
'
click
'
,
stop
);
this
.
popperElm
.
removeEventListener
(
'
click
'
,
stop
);
document
.
body
.
removeChild
(
this
.
popperElm
);
document
.
body
.
removeChild
(
this
.
popperElm
);
...
...
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