Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
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
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
625c4e42
Commit
625c4e42
authored
Jan 08, 2021
by
Jannik Lehmann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove DOMContentLoaded Eventlistener
parent
f10e7bcf
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
25 deletions
+9
-25
app/assets/javascripts/performance_bar/index.js
app/assets/javascripts/performance_bar/index.js
+4
-19
spec/frontend/performance_bar/index_spec.js
spec/frontend/performance_bar/index_spec.js
+5
-6
No files found.
app/assets/javascripts/performance_bar/index.js
View file @
625c4e42
...
...
@@ -11,6 +11,9 @@ import initPerformanceBarLog from './performance_bar_log';
Vue
.
use
(
Translate
);
const
initPerformanceBar
=
(
el
)
=>
{
if
(
!
el
)
{
return
undefined
;
}
const
performanceBarData
=
el
.
dataset
;
return
new
Vue
({
...
...
@@ -126,25 +129,7 @@ const initPerformanceBar = (el) => {
});
};
let
loadedPeekBar
=
false
;
function
loadBar
()
{
const
jsPeek
=
document
.
querySelector
(
'
#js-peek
'
);
if
(
!
loadedPeekBar
&&
jsPeek
)
{
loadedPeekBar
=
true
;
initPerformanceBar
(
jsPeek
);
}
}
// If js-peek is not loaded when this script is executed, this call will do nothing
// If this is the case, then it will loadBar on DOMContentLoaded. We would prefer it
// to be initialized before the DOMContetLoaded event in order to pick up all the
// requests sent from the page.
loadBar
();
document
.
addEventListener
(
'
DOMContentLoaded
'
,
()
=>
{
loadBar
();
});
initPerformanceBar
(
document
.
querySelector
(
'
#js-peek
'
));
initPerformanceBarLog
();
export
default
initPerformanceBar
;
spec/frontend/performance_bar/index_spec.js
View file @
625c4e42
...
...
@@ -4,25 +4,23 @@ import '~/performance_bar/components/performance_bar_app.vue';
import
performanceBar
from
'
~/performance_bar
'
;
import
PerformanceBarService
from
'
~/performance_bar/services/performance_bar_service
'
;
jest
.
mock
(
'
~/performance_bar/performance_bar_log
'
);
describe
(
'
performance bar wrapper
'
,
()
=>
{
let
mock
;
let
vm
;
beforeEach
(()
=>
{
setFixtures
(
'
<div id="js-peek"></div>
'
);
const
peekWrapper
=
document
.
getElementById
(
'
js-peek
'
);
performance
.
getEntriesByType
=
jest
.
fn
().
mockReturnValue
([]);
// clear html so that elements from previous tests don't mess with this test
document
.
body
.
innerHTML
=
''
;
const
peekWrapper
=
document
.
createElement
(
'
div
'
);
peekWrapper
.
setAttribute
(
'
id
'
,
'
js-peek
'
);
peekWrapper
.
setAttribute
(
'
data-env
'
,
'
development
'
);
peekWrapper
.
setAttribute
(
'
data-request-id
'
,
'
123
'
);
peekWrapper
.
setAttribute
(
'
data-peek-url
'
,
'
/-/peek/results
'
);
peekWrapper
.
setAttribute
(
'
data-profile-url
'
,
'
?lineprofiler=true
'
);
document
.
body
.
appendChild
(
peekWrapper
);
mock
=
new
MockAdapter
(
axios
);
mock
.
onGet
(
'
/-/peek/results
'
).
reply
(
...
...
@@ -48,6 +46,7 @@ describe('performance bar wrapper', () => {
afterEach
(()
=>
{
vm
.
$destroy
();
document
.
getElementById
(
'
js-peek
'
).
remove
();
mock
.
restore
();
});
...
...
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