[Pkg-mozext-commits] [requestpolicy] 27/100: [refactoring] add _htmlAnchorTagClicked()
David Prévot
taffit at moszumanska.debian.org
Fri Dec 12 22:56:51 UTC 2014
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository requestpolicy.
commit 7205906315a585049d651c710ed22b5763ccbdde
Author: myrdd <myrdd at users.noreply.github.com>
Date: Tue Sep 16 17:19:27 2014 +0200
[refactoring] add _htmlAnchorTagClicked()
use one function for all <a> clicked events instead of creating a new
one for each element. see also:
https://developer.mozilla.org/en-US/docs/Web/API/EventTarget.addEventListener#Memory_issues
---
src/content/overlay.js | 17 ++++++++++-------
1 file changed, 10 insertions(+), 7 deletions(-)
diff --git a/src/content/overlay.js b/src/content/overlay.js
index c8ac38b..8a0ff96 100644
--- a/src/content/overlay.js
+++ b/src/content/overlay.js
@@ -880,6 +880,14 @@ requestpolicy.overlay = {
return docShell.allowMetaRedirects;
},
+ _htmlAnchorTagClicked : function(event) {
+ // Note: need to use currentTarget so that it is the link, not
+ // something else within the link that got clicked, it seems.
+ requestpolicy.overlay._rpService.
+ registerLinkClicked(event.currentTarget.ownerDocument.URL,
+ event.currentTarget.href);
+ }
+
/**
* Perform the actions required once the DOM is loaded. This may be being
* called for more than just the page content DOM. It seems to work for now.
@@ -960,13 +968,8 @@ requestpolicy.overlay = {
// tag.
var anchorTags = document.getElementsByTagName("a");
for (var i = 0; i < anchorTags.length; i++) {
- anchorTags[i].addEventListener("click", function(event) {
- // Note: need to use currentTarget so that it is the link, not
- // something else within the link that got clicked, it seems.
- requestpolicy.overlay._rpService
- .registerLinkClicked(event.currentTarget.ownerDocument.URL,
- event.currentTarget.href);
- }, false);
+ anchorTags[i].addEventListener("click", this._htmlAnchorTagClicked,
+ false);
}
// TODO: implement a function in RequestProcessor for this
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/requestpolicy.git
More information about the Pkg-mozext-commits
mailing list