Permalink
Browse files

Return value of goog.events and goog.events.listenOnce is going to

change from ?number to goog.events.ListenableKey. As a first step, we
are switching the return value to a typedef goog.events.Key (currently
just typedef to ?number). This CL switches JS files to use this typedef.

Obviously, the subsequent change will be problematic if this code
make an assumption that the return value is a number and uses the return
value in context where the number is required (e.g. goog.isNumber, using
it as index to an array). While I've tried my best to fix these usages,
I may have missed some of them. Please check that the code will still
remain correct if the return value of goog.events.listen/listenOnce is
changed to an object (goog.events.ListenableKey). Furthermore, if
you know of any other location where the return value is used in a context
that require it to be numbers, please send me a quick email.

This is parts of goog.events refactoring to remove leaking listeners
problem.

R=dnadasi,pallosp
DELTA=9 (0 added, 0 deleted, 9 changed)


Revision created by MOE tool push_codebase.
MOE_MIGRATION=6215


git-svn-id: http://closure-library.googlecode.com/svn/trunk@2478 0b95b8e8-c90f-11de-9d4f-f947ee5921c8
  • Loading branch information...
1 parent 38cc19b commit 3e81593a015f4a3d340800a8f42daf2e0ed357f6 chrishenry@google.com committed Jan 29, 2013
Showing with 9 additions and 9 deletions.
  1. +3 −3 closure/goog/editor/plugins/undoredo.js
  2. +6 −6 closure/goog/events/focushandler.js
@@ -108,7 +108,7 @@ goog.editor.plugins.UndoRedo.prototype.undoManager_;
/**
* The key for the event listener handling state change events from the
* undo-redo manager.
- * @type {number}
+ * @type {goog.events.Key}
* @private
*/
goog.editor.plugins.UndoRedo.prototype.managerStateChangeKey_;
@@ -155,12 +155,12 @@ goog.editor.plugins.UndoRedo.prototype.setUndoRedoManager = function(manager) {
}
this.undoManager_ = manager;
- this.managerStateChangeKey_ = /** @type {number} */ (
+ this.managerStateChangeKey_ =
goog.events.listen(this.undoManager_,
goog.editor.plugins.UndoRedoManager.EventType.STATE_CHANGE,
this.dispatchCommandValueChange_,
false,
- this));
+ this);
};
@@ -57,18 +57,18 @@ goog.events.FocusHandler = function(element) {
/**
* Store the listen key so it easier to unlisten in dispose.
* @private
- * @type {number}
+ * @type {goog.events.Key}
*/
- this.listenKeyIn_ = /** @type {number} */ (
- goog.events.listen(this.element_, typeIn, this, !goog.userAgent.IE));
+ this.listenKeyIn_ =
+ goog.events.listen(this.element_, typeIn, this, !goog.userAgent.IE);
/**
* Store the listen key so it easier to unlisten in dispose.
* @private
- * @type {number}
+ * @type {goog.events.Key}
*/
- this.listenKeyOut_ = /** @type {number} */ (
- goog.events.listen(this.element_, typeOut, this, !goog.userAgent.IE));
+ this.listenKeyOut_ =
+ goog.events.listen(this.element_, typeOut, this, !goog.userAgent.IE);
};
goog.inherits(goog.events.FocusHandler, goog.events.EventTarget);

0 comments on commit 3e81593

Please sign in to comment.