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
Jérome Perrin
gitlab-ce
Commits
6a547779
Commit
6a547779
authored
May 09, 2017
by
Phil Hughes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed search terms not highlight
Closes #31997
parent
3a983b10
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
47 additions
and
10 deletions
+47
-10
app/assets/javascripts/gl_dropdown.js
app/assets/javascripts/gl_dropdown.js
+6
-1
changelogs/unreleased/fix-search-not-highlighting.yml
changelogs/unreleased/fix-search-not-highlighting.yml
+4
-0
spec/javascripts/gl_dropdown_spec.js
spec/javascripts/gl_dropdown_spec.js
+37
-9
No files found.
app/assets/javascripts/gl_dropdown.js
View file @
6a547779
...
...
@@ -608,7 +608,12 @@ GitLabDropdown = (function() {
var
link
=
document
.
createElement
(
'
a
'
);
link
.
href
=
url
;
link
.
innerHTML
=
text
;
if
(
this
.
highlight
)
{
link
.
innerHTML
=
text
;
}
else
{
link
.
textContent
=
text
;
}
if
(
selected
)
{
link
.
className
=
'
is-active
'
;
...
...
changelogs/unreleased/fix-search-not-highlighting.yml
0 → 100644
View file @
6a547779
---
title
:
Fixed search terms not correctly highlighting
merge_request
:
author
:
spec/javascripts/gl_dropdown_spec.js
View file @
6a547779
...
...
@@ -44,21 +44,18 @@ require('~/lib/utils/url_utility');
preloadFixtures
(
'
static/gl_dropdown.html.raw
'
);
loadJSONFixtures
(
'
projects.json
'
);
function
initDropDown
(
hasRemote
,
isFilterable
)
{
this
.
dropdownButtonElement
=
$
(
'
#js-project-dropdown
'
,
this
.
dropdownContainerElement
).
glDropdow
n
({
function
initDropDown
(
hasRemote
,
isFilterable
,
extraOpts
=
{}
)
{
const
options
=
Object
.
assig
n
({
selectable
:
true
,
filterable
:
isFilterable
,
data
:
hasRemote
?
remoteMock
.
bind
({},
this
.
projectsData
)
:
this
.
projectsData
,
search
:
{
fields
:
[
'
name
'
]
},
text
:
(
project
)
=>
{
(
project
.
name_with_namespace
||
project
.
name
);
},
id
:
(
project
)
=>
{
project
.
id
;
}
});
text
:
project
=>
(
project
.
name_with_namespace
||
project
.
name
),
id
:
project
=>
project
.
id
,
},
extraOpts
);
this
.
dropdownButtonElement
=
$
(
'
#js-project-dropdown
'
,
this
.
dropdownContainerElement
).
glDropdown
(
options
);
}
beforeEach
(()
=>
{
...
...
@@ -80,6 +77,37 @@ require('~/lib/utils/url_utility');
expect
(
this
.
dropdownContainerElement
).
toHaveClass
(
'
open
'
);
});
it
(
'
escapes HTML as text
'
,
()
=>
{
this
.
projectsData
[
0
].
name_with_namespace
=
'
<script>alert("testing");</script>
'
;
initDropDown
.
call
(
this
,
false
);
this
.
dropdownButtonElement
.
click
();
expect
(
$
(
'
.dropdown-content li:first-child
'
).
text
(),
).
toBe
(
'
<script>alert("testing");</script>
'
);
});
it
(
'
should output HTML when highlighting
'
,
()
=>
{
this
.
projectsData
[
0
].
name_with_namespace
=
'
testing
'
;
$
(
'
.dropdown-input .dropdown-input-field
'
).
val
(
'
test
'
);
initDropDown
.
call
(
this
,
false
,
true
,
{
highlight
:
true
,
});
this
.
dropdownButtonElement
.
click
();
expect
(
$
(
'
.dropdown-content li:first-child
'
).
text
(),
).
toBe
(
'
testing
'
);
expect
(
$
(
'
.dropdown-content li:first-child a
'
).
html
(),
).
toBe
(
'
<b>t</b><b>e</b><b>s</b><b>t</b>ing
'
);
});
describe
(
'
that is open
'
,
()
=>
{
beforeEach
(()
=>
{
initDropDown
.
call
(
this
,
false
,
false
);
...
...
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