Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a check for custom events in dispatch event #16869

Closed
DartBot opened this issue Feb 16, 2014 · 6 comments
Closed

Add a check for custom events in dispatch event #16869

DartBot opened this issue Feb 16, 2014 · 6 comments
Assignees
Labels
area-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. closed-obsolete Closed as the reported issue is no longer relevant library-html P2 A bug or feature request we're likely to work on type-enhancement A request for a change that isn't a bug

Comments

@DartBot
Copy link

DartBot commented Feb 16, 2014

This issue was originally filed by @chalin


What steps will reproduce the problem?

  1. Consider the following code

    // Context: import 'dart:html' as dom;
    var element = dom.querySelector(...);
    var ev = new KeyEvent('keypress', keyCode: 65);
    
2. print("ev=$ev, and (ev is Event) is ${ev is Event}");
    ==> output: ev=Instance of 'KeyEvent', and (ev is Event) is true
   
3. element.dispatchEvent(ev);
    ==> yields
    Caught Invalid class: expected instance of Event
    #­0 Node.dispatchEvent (.../dart/dart/html/Node.dart:586)

What is the expected output? What do you see instead?

The exception reports that ev is not an instance of Event and yet from the printed output we see that it is.

What version of the product are you using? On what operating system?

Dartium Version 33.0.1750.48 (251129)
Dart VM version: 1.2.0-dev.4.0 (Fri Feb 7 10:19:23 2014) on "macos_x64"

Please provide any additional information below.

The problem might be that KeyEvents cannot be dispatched for some other reason, and if so, then the thrown exception message should be changed.

@lrhn
Copy link
Member

lrhn commented Feb 17, 2014

Added Area-HTML, Triaged labels.

@efortuna
Copy link
Contributor

It is true that KeyEvent is not a native Event, because it is not a native DOM object. There is nothing we can do about this. You can see an example of dispatching KeyEvents here: https://code.google.com/p/dart/source/browse/branches/bleeding_edge/dart/tests/html/keyboard_event_test.dart

HOWEVER, this is an indication that the documentation for KeyEvent itself should be improved. I'll do that.


Added AsDesigned label.

@jmesserly
Copy link

hmm, just an idea for future consideration: I wonder if we could add a check to dispatchEvent so it can handle custom events better?

it seems like it should be possible. Granted it would slow down all dispatchEvent by 1 if-check, but I'd guess that would be in the noise.

@efortuna
Copy link
Contributor

Good thought. I'll update this bug to be that just as a reminder for us to think about it.


Added Triaged label.
Changed the title to: "Add a check for custom events in dispatch event".

@kevmoo
Copy link
Member

kevmoo commented Apr 7, 2014

Removed Area-HTML label.
Added Area-Library, Library-Html labels.

@alan-knight
Copy link
Contributor

Removed Type-Defect, Priority-Unassigned labels.
Added Type-Enhancement, Priority-Medium labels.

@DartBot DartBot added Type-Enhancement area-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. library-html labels Jan 16, 2015
@kevmoo kevmoo added P2 A bug or feature request we're likely to work on type-enhancement A request for a change that isn't a bug and removed triaged labels Mar 1, 2016
@jacob314 jacob314 self-assigned this Mar 23, 2016
@matanlurey matanlurey added the closed-obsolete Closed as the reported issue is no longer relevant label Jun 19, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. closed-obsolete Closed as the reported issue is no longer relevant library-html P2 A bug or feature request we're likely to work on type-enhancement A request for a change that isn't a bug
Projects
None yet
Development

No branches or pull requests

8 participants