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
0
Merge Requests
0
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
Boxiang Sun
gitlab-ce
Commits
0966c6d2
Commit
0966c6d2
authored
Nov 17, 2016
by
Steffen Rauh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix compatibility with Internet Explorer 11 for merge requests
parent
0819d093
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
63 additions
and
4 deletions
+63
-4
app/assets/javascripts/lib/utils/common_utils.js
app/assets/javascripts/lib/utils/common_utils.js
+13
-0
app/assets/javascripts/merge_request_tabs.js.es6
app/assets/javascripts/merge_request_tabs.js.es6
+2
-3
changelogs/unreleased/fix-compatibility-with-ie11-for-merge-requests.yml
...leased/fix-compatibility-with-ie11-for-merge-requests.yml
+4
-0
spec/javascripts/lib/utils/common_utils_spec.js.es6
spec/javascripts/lib/utils/common_utils_spec.js.es6
+32
-0
spec/javascripts/merge_request_tabs_spec.js
spec/javascripts/merge_request_tabs_spec.js
+12
-1
No files found.
app/assets/javascripts/lib/utils/common_utils.js
View file @
0966c6d2
...
...
@@ -97,6 +97,19 @@
return
$
(
'
body
'
).
data
(
'
page
'
).
split
(
'
:
'
)[
0
];
};
gl
.
utils
.
parseUrl
=
function
(
url
)
{
var
parser
=
document
.
createElement
(
'
a
'
);
parser
.
href
=
url
;
return
parser
;
};
gl
.
utils
.
parseUrlPathname
=
function
(
url
)
{
var
parsedUrl
=
gl
.
utils
.
parseUrl
(
url
);
// parsedUrl.pathname will return an absolute path for Firefox and a relative path for IE11
// We have to make sure we always have an absolute path.
return
parsedUrl
.
pathname
.
charAt
(
0
)
===
'
/
'
?
parsedUrl
.
pathname
:
'
/
'
+
parsedUrl
.
pathname
;
};
gl
.
utils
.
isMetaKey
=
function
(
e
)
{
return
e
.
metaKey
||
e
.
ctrlKey
||
e
.
altKey
||
e
.
shiftKey
;
};
...
...
app/assets/javascripts/merge_request_tabs.js.es6
View file @
0966c6d2
...
...
@@ -225,11 +225,10 @@
// We extract pathname for the current Changes tab anchor href
// some pages like MergeRequestsController#new has query parameters on that anchor
const url = document.createElement('a');
url.href = source;
var urlPathname = gl.utils.parseUrlPathname(source);
this.ajaxGet({
url: `${url
.p
athname}.json${location.search}`,
url: `${url
P
athname}.json${location.search}`,
success: (data) => {
$('#diffs').html(data.html);
...
...
changelogs/unreleased/fix-compatibility-with-ie11-for-merge-requests.yml
0 → 100644
View file @
0966c6d2
---
title
:
Fix compatibility with Internet Explorer 11 for merge requests
merge_request
:
7525
author
:
Steffen Rauh
spec/javascripts/lib/utils/common_utils_spec.js.es6
0 → 100644
View file @
0966c6d2
//= require lib/utils/common_utils
(() => {
describe('common_utils', () => {
describe('gl.utils.parseUrl', () => {
it('returns an anchor tag with url', () => {
expect(gl.utils.parseUrl('/some/absolute/url').pathname).toContain('some/absolute/url');
});
it('url is escaped', () => {
// IE11 will return a relative pathname while other browsers will return a full pathname.
// parseUrl uses an anchor element for parsing an url. With relative urls, the anchor
// element will create an absolute url relative to the current execution context.
// The JavaScript test suite is executed at '/teaspoon' which will lead to an absolute
// url starting with '/teaspoon'.
expect(gl.utils.parseUrl('" test="asf"').pathname).toEqual('/teaspoon/%22%20test=%22asf%22');
});
});
describe('gl.utils.parseUrlPathname', () => {
beforeEach(() => {
spyOn(gl.utils, 'parseUrl').and.callFake(url => ({
pathname: url,
}));
});
it('returns an absolute url when given an absolute url', () => {
expect(gl.utils.parseUrlPathname('/some/absolute/url')).toEqual('/some/absolute/url');
});
it('returns an absolute url when given a relative url', () => {
expect(gl.utils.parseUrlPathname('some/relative/url')).toEqual('/some/relative/url');
});
});
});
})();
spec/javascripts/merge_request_tabs_spec.js
View file @
0966c6d2
...
...
@@ -2,6 +2,8 @@
/*= require merge_request_tabs */
//= require breakpoints
//= require lib/utils/common_utils
//= require jquery.scrollTo
(
function
()
{
describe
(
'
MergeRequestTabs
'
,
function
()
{
...
...
@@ -21,13 +23,13 @@
setLocation
();
this
.
spies
=
{
ajax
:
spyOn
(
$
,
'
ajax
'
).
and
.
callFake
(
function
()
{}),
history
:
spyOn
(
window
.
history
,
'
replaceState
'
).
and
.
callFake
(
function
()
{})
};
});
describe
(
'
#activateTab
'
,
function
()
{
beforeEach
(
function
()
{
spyOn
(
$
,
'
ajax
'
).
and
.
callFake
(
function
()
{});
fixture
.
load
(
'
merge_request_tabs.html
'
);
this
.
subject
=
this
.
class
.
activateTab
;
});
...
...
@@ -51,6 +53,7 @@
describe
(
'
#setCurrentAction
'
,
function
()
{
beforeEach
(
function
()
{
spyOn
(
$
,
'
ajax
'
).
and
.
callFake
(
function
()
{});
this
.
subject
=
this
.
class
.
setCurrentAction
;
});
it
(
'
changes from commits
'
,
function
()
{
...
...
@@ -107,5 +110,13 @@
expect
(
this
.
subject
(
'
show
'
)).
toBe
(
'
/foo/bar/merge_requests/1
'
);
});
});
describe
(
'
#loadDiff
'
,
function
()
{
it
(
'
requires an absolute pathname
'
,
function
()
{
spyOn
(
$
,
'
ajax
'
).
and
.
callFake
(
function
(
options
)
{
expect
(
options
.
url
).
toEqual
(
'
/foo/bar/merge_requests/1/diffs.json
'
);
});
this
.
class
.
loadDiff
(
'
/foo/bar/merge_requests/1/diffs
'
);
});
});
});
}).
call
(
this
);
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