aboutsummaryrefslogtreecommitdiffstats
path: root/content_scripts
diff options
context:
space:
mode:
authorStephen Blott2017-12-16 11:07:22 +0000
committerStephen Blott2017-12-16 11:07:22 +0000
commitb6a0bd0cf29fc3621f4c337616ed119f239c0ed0 (patch)
tree1ac573bab5a22258465b6fae7dff72b56117b441 /content_scripts
parent5bee52933e10eef59a6b29417785239707b0a57c (diff)
downloadvimium-b6a0bd0cf29fc3621f4c337616ed119f239c0ed0.tar.bz2
Guard against failure.
Since these are executing in the page's context, they could break the page if they were to fail (for whatever reason). So we add some (possibly unnecessary) guards, just in case.
Diffstat (limited to 'content_scripts')
-rw-r--r--content_scripts/injected.coffee5
1 files changed, 3 insertions, 2 deletions
diff --git a/content_scripts/injected.coffee b/content_scripts/injected.coffee
index d833d09c..1c743134 100644
--- a/content_scripts/injected.coffee
+++ b/content_scripts/injected.coffee
@@ -10,8 +10,9 @@ injectedCode = (vimiumOnClickAttributeName) ->
_addEventListener = Element::addEventListener
Element::addEventListener = (type, listener, useCapture) ->
- @setAttribute vimiumOnClickAttributeName, "" if type == "click"
- _addEventListener.apply this, arguments
+ if type == "click"
+ try @setAttribute vimiumOnClickAttributeName, ""
+ _addEventListener?.apply this, arguments
script = document.createElement "script"
script.textContent = "(#{injectedCode.toString()})('#{vimiumOnClickAttributeName}')"