Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
coopwire-hypothesis
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
孙灵跃 Leon Sun
coopwire-hypothesis
Commits
445b1061
Commit
445b1061
authored
Dec 20, 2016
by
Robert Knight
Committed by
GitHub
Dec 20, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #172 from hypothesis/highlight-custom-element
Use a custom element name for highlight spans
parents
51daa256
2d971124
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
1 deletion
+5
-1
highlighter.coffee
h/static/scripts/annotator/highlighter.coffee
+4
-1
highlighter-test.coffee
h/static/scripts/annotator/test/highlighter-test.coffee
+1
-0
No files found.
h/static/scripts/annotator/highlighter.coffee
View file @
445b1061
...
...
@@ -10,7 +10,10 @@ $ = require('jquery')
# Returns an array of highlight Elements.
exports
.
highlightRange
=
(
normedRange
,
cssClass
=
'annotator-hl'
)
->
white
=
/^\s*$/
hl
=
$
(
"<span class='
#{
cssClass
}
'></span>"
)
# A custom element name is used here rather than `<span>` to reduce the
# likelihood of highlights being hidden by page styling.
hl
=
$
(
"<hypothesis-highlight class='
#{
cssClass
}
'></hypothesis-highlight>"
)
# Ignore text nodes that contain only whitespace characters. This prevents
# spans being injected between elements that can only contain a restricted
...
...
h/static/scripts/annotator/test/highlighter-test.coffee
View file @
445b1061
...
...
@@ -16,6 +16,7 @@ describe "highlightRange", ->
result
=
highlighter
.
highlightRange
(
r
)
assert
.
equal
(
result
.
length
,
1
)
assert
.
strictEqual
(
el
.
childNodes
[
0
],
result
[
0
])
assert
.
equal
(
result
[
0
].
nodeName
,
'HYPOTHESIS-HIGHLIGHT'
);
assert
.
isTrue
(
result
[
0
].
classList
.
contains
(
'annotator-hl'
))
it
'skips text nodes that are only white space'
,
->
...
...
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