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
9469c27a
Commit
9469c27a
authored
Jul 26, 2016
by
Robert Knight
Committed by
GitHub
Jul 26, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #47 from hypothesis/fix-double-highlight
Avoid double highlighting
parents
429009ca
6ca273c1
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
28 additions
and
2 deletions
+28
-2
cross-frame.coffee
h/static/scripts/annotator/plugin/cross-frame.coffee
+1
-0
cross-frame-test.coffee
...tic/scripts/annotator/plugin/test/cross-frame-test.coffee
+8
-2
bridge.coffee
h/static/scripts/bridge.coffee
+7
-0
bridge-test.coffee
h/static/scripts/test/bridge-test.coffee
+12
-0
No files found.
h/static/scripts/annotator/plugin/cross-frame.coffee
View file @
9469c27a
...
@@ -31,6 +31,7 @@ module.exports = class CrossFrame extends Annotator.Plugin
...
@@ -31,6 +31,7 @@ module.exports = class CrossFrame extends Annotator.Plugin
this
.
destroy
=
->
this
.
destroy
=
->
# super doesnt work here :(
# super doesnt work here :(
Annotator
.
Plugin
::
destroy
.
apply
(
this
,
arguments
)
Annotator
.
Plugin
::
destroy
.
apply
(
this
,
arguments
)
bridge
.
destroy
()
discovery
.
stopDiscovery
()
discovery
.
stopDiscovery
()
this
.
sync
=
(
annotations
,
cb
)
->
this
.
sync
=
(
annotations
,
cb
)
->
...
...
h/static/scripts/annotator/plugin/test/cross-frame-test.coffee
View file @
9469c27a
...
@@ -19,6 +19,7 @@ describe 'Annotator.Plugin.CrossFrame', ->
...
@@ -19,6 +19,7 @@ describe 'Annotator.Plugin.CrossFrame', ->
stopDiscovery
:
sandbox
.
stub
()
stopDiscovery
:
sandbox
.
stub
()
fakeBridge
=
fakeBridge
=
destroy
:
sandbox
.
stub
()
createChannel
:
sandbox
.
stub
()
createChannel
:
sandbox
.
stub
()
onConnect
:
sandbox
.
stub
()
onConnect
:
sandbox
.
stub
()
call
:
sandbox
.
stub
()
call
:
sandbox
.
stub
()
...
@@ -75,10 +76,15 @@ describe 'Annotator.Plugin.CrossFrame', ->
...
@@ -75,10 +76,15 @@ describe 'Annotator.Plugin.CrossFrame', ->
describe
'.destroy'
,
->
describe
'.destroy'
,
->
it
'stops the discovery of new frames'
,
->
it
'stops the discovery of new frames'
,
->
bridge
=
createCrossFrame
()
cf
=
createCrossFrame
()
bridge
.
destroy
()
cf
.
destroy
()
assert
.
called
(
fakeDiscovery
.
stopDiscovery
)
assert
.
called
(
fakeDiscovery
.
stopDiscovery
)
it
'destroys the bridge object'
,
->
cf
=
createCrossFrame
()
cf
.
destroy
()
assert
.
called
(
fakeBridge
.
destroy
)
describe
'.sync'
,
->
describe
'.sync'
,
->
it
'syncs the annotations with the other frame'
,
->
it
'syncs the annotations with the other frame'
,
->
bridge
=
createCrossFrame
()
bridge
=
createCrossFrame
()
...
...
h/static/scripts/bridge.coffee
View file @
9469c27a
...
@@ -14,6 +14,13 @@ module.exports = class Bridge
...
@@ -14,6 +14,13 @@ module.exports = class Bridge
@
channelListeners
=
{}
@
channelListeners
=
{}
@
onConnectListeners
=
[]
@
onConnectListeners
=
[]
# Tear down the bridge. We destroy each RPC "channel" object we know about.
# This removes the `onmessage` event listeners, thus removing references to
# any listeners and allowing them to be garbage collected.
destroy
:
->
for
link
in
@
links
link
.
channel
.
destroy
()
createChannel
:
(
source
,
origin
,
token
)
->
createChannel
:
(
source
,
origin
,
token
)
->
channel
=
null
channel
=
null
connected
=
false
connected
=
false
...
...
h/static/scripts/test/bridge-test.coffee
View file @
9469c27a
...
@@ -190,3 +190,15 @@ describe 'Bridge', ->
...
@@ -190,3 +190,15 @@ describe 'Bridge', ->
bridge
.
onConnect
(
callback
)
bridge
.
onConnect
(
callback
)
bridge
.
onConnect
(
callback
)
bridge
.
onConnect
(
callback
)
channel
=
createChannel
()
channel
=
createChannel
()
describe
'.destroy'
,
->
it
'destroys all opened channels'
,
->
channel1
=
bridge
.
createChannel
(
fakeWindow
,
'http://example.com'
,
'foo'
)
channel2
=
bridge
.
createChannel
(
fakeWindow
,
'http://example.com'
,
'bar'
)
sinon
.
spy
(
channel1
,
'destroy'
)
sinon
.
spy
(
channel2
,
'destroy'
)
bridge
.
destroy
()
assert
.
called
(
channel1
.
destroy
)
assert
.
called
(
channel2
.
destroy
)
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