diff options
| author | Stephen Blott | 2017-12-16 11:07:22 +0000 |
|---|---|---|
| committer | Stephen Blott | 2017-12-16 11:07:22 +0000 |
| commit | b6a0bd0cf29fc3621f4c337616ed119f239c0ed0 (patch) | |
| tree | 1ac573bab5a22258465b6fae7dff72b56117b441 | |
| parent | 5bee52933e10eef59a6b29417785239707b0a57c (diff) | |
| download | vimium-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.
| -rw-r--r-- | content_scripts/injected.coffee | 5 |
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}')" |
