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

Issue 1141007: Bookmark manager js lib: Some cleanup of the event class docs.... (Closed)

Created:
10 years, 9 months ago by arv (Not doing code reviews)
Modified:
9 years, 4 months ago
Reviewers:
ojan
CC:
chromium-reviews, arv (Not doing code reviews), ben+cc_chromium.org
Visibility:
Public.

Description

Bookmark manager js lib: Some cleanup of the event class docs. BUG=None TEST=None Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=42293

Patch Set 1 #

Patch Set 2 : '' #

Unified diffs Side-by-side diffs Delta from patch set Stats (+25 lines, -14 lines) Patch
M chrome/browser/resources/bookmark_manager/js/cr/event.js View 1 2 chunks +14 lines, -11 lines 0 comments Download
M chrome/browser/resources/bookmark_manager/js/cr/eventtarget.js View 2 chunks +11 lines, -3 lines 0 comments Download

Messages

Total messages: 2 (0 generated)
arv (Not doing code reviews)
10 years, 9 months ago (2010-03-22 23:00:37 UTC) #1
ojan
10 years, 9 months ago (2010-03-23 00:07:32 UTC) #2
LGTM

On Mon, Mar 22, 2010 at 4:00 PM, <arv@chromium.org> wrote:

> Reviewers: ojan,
>
> Description:
> Bookmark manager js lib: Some cleanup of the event class docs.
>
> BUG=None
> TEST=None
>
>
> Please review this at http://codereview.chromium.org/1141007
>
> SVN Base: svn://chrome-svn/chrome/trunk/src/
>
> Affected files:
>  M     chrome/browser/resources/bookmark_manager/js/cr/event.js
>  M     chrome/browser/resources/bookmark_manager/js/cr/eventtarget.js
>
>
> Index: chrome/browser/resources/bookmark_manager/js/cr/eventtarget.js
> ===================================================================
> --- chrome/browser/resources/bookmark_manager/js/cr/eventtarget.js
>  (revision 42175)
> +++ chrome/browser/resources/bookmark_manager/js/cr/eventtarget.js
>  (working copy)
> @@ -2,10 +2,18 @@
>  // Use of this source code is governed by a BSD-style license that can be
>  // found in the LICENSE file.
>
> +/**
> + * @fileoverview This contains an implementation of the EventTarget
> interface
> + * as defined by DOM Level 2 Events.
> + */
> +
>  cr.define('cr', function() {
>
> -  // TODO(arv): object.handleEvent
> -
> +  /**
> +   * Creates a new EventTarget. This class implements the DOM level 2
> +   * EventTarget interface and can be used wherever those are used.
> +   * @constructor
> +   */
>   function EventTarget() {
>   }
>
> @@ -19,7 +27,7 @@
>      */
>     addEventListener: function(type, handler) {
>       if (!this.listeners_)
> -        this.listeners_ = {__proto__: null};
> +        this.listeners_ = Object.create(null);
>       if (!(type in this.listeners_)) {
>         this.listeners_[type] = [handler];
>       } else {
> Index: chrome/browser/resources/bookmark_manager/js/cr/event.js
> ===================================================================
> --- chrome/browser/resources/bookmark_manager/js/cr/event.js    (revision
> 42175)
> +++ chrome/browser/resources/bookmark_manager/js/cr/event.js    (working
> copy)
> @@ -3,15 +3,15 @@
>  // found in the LICENSE file.
>
>  /**
> - * @fileoverview This is a simple pure JS event class that can be used
> with
> - * {@code cr.ui.EventTarget}. It should not be used with DOM EventTargets.
> + * @fileoverview This provides a nicer way to create events than what DOM
> + * provides. These events can be used with DOM EventTarget interfaces as
> well
> + * as with {@code cr.EventTarget}.
>  */
>
>  cr.define('cr', function() {
>
> -  // cr.Event is called CustomEvent in here to prevent naming conflicts.
> We
> -  // alse store the original Event in case someone does a global alias of
> -  // cr.Event.
> +  // cr.Event is called CrEvent in here to prevent naming conflicts. We
> also
> +  // store the original Event in case someone does a global alias of
> cr.Event.
>
>   const DomEvent = Event;
>
> @@ -19,22 +19,25 @@
>    * Creates a new event to be used with cr.EventTarget or DOM EventTarget
>    * objects.
>    * @param {string} type The name of the event.
> -   * @param {boolean=}
> +   * @param {boolean=} opt_bubbles Whether the event bubbles. Default is
> false.
> +   * @param {boolean=} opt_preventable Whether the default action of the
> event
> +   *     can be prevented.
>    * @constructor
> +   * @extends {DomEvent}
>    */
> -  function CustomEvent(type, opt_bubbles, opt_capture) {
> +  function CrEvent(type, opt_bubbles, opt_preventable) {
>     var e = cr.doc.createEvent('Event');
> -    e.initEvent(type, !!opt_bubbles, !!opt_capture);
> -    e.__proto__ = CustomEvent.prototype;
> +    e.initEvent(type, !!opt_bubbles, !!opt_preventable);
> +    e.__proto__ = CrEvent.prototype;
>     return e;
>   }
>
> -  CustomEvent.prototype = {
> +  CrEvent.prototype = {
>     __proto__: DomEvent.prototype
>   };
>
>   // Export
>   return {
> -    Event: CustomEvent
> +    Event: CrEvent
>   };
>  });
>
>
>

Powered by Google App Engine
This is Rietveld 408576698