Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(95)

Unified Diff: ui/webui/resources/js/event_tracker.js

Issue 454223004: Typecheck JS files for chrome://history (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@B_download
Patch Set: rebase once again Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/webui/resources/js/cr/ui/position_util.js ('k') | ui/webui/resources/js/util.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/webui/resources/js/event_tracker.js
diff --git a/ui/webui/resources/js/event_tracker.js b/ui/webui/resources/js/event_tracker.js
index fc157a1f00e1ff59028211b483b15252e054c090..e7bb5d350dcae367cb2fb578cfd01bdf9da58d1e 100644
--- a/ui/webui/resources/js/event_tracker.js
+++ b/ui/webui/resources/js/event_tracker.js
@@ -22,80 +22,71 @@
*/
var EventTrackerEntry;
-// Use an anonymous function to enable strict mode just for this file (which
-// will be concatenated with other files when embedded in Chrome).
-var EventTracker = (function() {
- 'use strict';
-
+/**
+ * Create an EventTracker to track a set of events.
+ * EventTracker instances are typically tied 1:1 with other objects or
+ * DOM elements whose listeners should be removed when the object is disposed
+ * or the corresponding elements are removed from the DOM.
+ * @constructor
+ */
+function EventTracker() {
/**
- * Create an EventTracker to track a set of events.
- * EventTracker instances are typically tied 1:1 with other objects or
- * DOM elements whose listeners should be removed when the object is disposed
- * or the corresponding elements are removed from the DOM.
- * @constructor
+ * @type {Array.<EventTrackerEntry>}
+ * @private
*/
- function EventTracker() {
- /**
- * @type {Array.<EventTrackerEntry>}
- * @private
- */
- this.listeners_ = [];
- }
-
- EventTracker.prototype = {
- /**
- * Add an event listener - replacement for Node.addEventListener.
- * @param {!Node} node The DOM node to add a listener to.
- * @param {string} eventType The type of event to subscribe to.
- * @param {Function} listener The listener to add.
- * @param {boolean=} opt_capture Whether to invoke during the capture phase.
- */
- add: function(node, eventType, listener, opt_capture) {
- var capture = !!opt_capture;
- var h = {
- node: node,
- eventType: eventType,
- listener: listener,
- capture: capture,
- };
- this.listeners_.push(h);
- node.addEventListener(eventType, listener, capture);
- },
+ this.listeners_ = [];
+}
- /**
- * Remove any specified event listeners added with this EventTracker.
- * @param {!Node} node The DOM node to remove a listener from.
- * @param {?string} eventType The type of event to remove.
- */
- remove: function(node, eventType) {
- this.listeners_ = this.listeners_.filter(function(h) {
- if (h.node == node && (!eventType || (h.eventType == eventType))) {
- EventTracker.removeEventListener_(h);
- return false;
- }
- return true;
- });
- },
-
- /**
- * Remove all event listeners added with this EventTracker.
- */
- removeAll: function() {
- this.listeners_.forEach(EventTracker.removeEventListener_);
- this.listeners_ = [];
- }
- };
+EventTracker.prototype = {
+ /**
+ * Add an event listener - replacement for Node.addEventListener.
+ * @param {!Node} node The DOM node to add a listener to.
+ * @param {string} eventType The type of event to subscribe to.
+ * @param {Function} listener The listener to add.
+ * @param {boolean=} opt_capture Whether to invoke during the capture phase.
+ */
+ add: function(node, eventType, listener, opt_capture) {
+ var capture = !!opt_capture;
+ var h = {
+ node: node,
+ eventType: eventType,
+ listener: listener,
+ capture: capture,
+ };
+ this.listeners_.push(h);
+ node.addEventListener(eventType, listener, capture);
+ },
/**
- * Remove a single event listener given it's tracking entry. It's up to the
- * caller to ensure the entry is removed from listeners_.
- * @param {EventTrackerEntry} h The entry describing the listener to remove.
- * @private
+ * Remove any specified event listeners added with this EventTracker.
+ * @param {!Node} node The DOM node to remove a listener from.
+ * @param {?string} eventType The type of event to remove.
*/
- EventTracker.removeEventListener_ = function(h) {
- h.node.removeEventListener(h.eventType, h.listener, h.capture);
- };
+ remove: function(node, eventType) {
+ this.listeners_ = this.listeners_.filter(function(h) {
+ if (h.node == node && (!eventType || (h.eventType == eventType))) {
+ EventTracker.removeEventListener_(h);
+ return false;
+ }
+ return true;
+ });
+ },
- return EventTracker;
-})();
+ /**
+ * Remove all event listeners added with this EventTracker.
+ */
+ removeAll: function() {
+ this.listeners_.forEach(EventTracker.removeEventListener_);
+ this.listeners_ = [];
+ }
+};
+/**
+ * Remove a single event listener given it's tracking entry. It's up to the
+ * caller to ensure the entry is removed from listeners_.
+ * @param {EventTrackerEntry} h The entry describing the listener to remove.
+ * @private
+ */
+EventTracker.removeEventListener_ = function(h) {
+ h.node.removeEventListener(h.eventType, h.listener, h.capture);
+};
« no previous file with comments | « ui/webui/resources/js/cr/ui/position_util.js ('k') | ui/webui/resources/js/util.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698