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

Element.onKeyUp and Element.onKeyDown crash on synthetic browser events #35656

Open
leonsenft opened this issue Jan 14, 2019 · 0 comments
Open
Labels
area-web Use area-web for Dart web related issues, including the DDC and dart2js compilers and JS interop. library-html web-libraries Issues impacting dart:html, etc., libraries

Comments

@leonsenft
Copy link

  • Dart SDK Version (dart --version): 2.1.1-dev.0.1
  • Whether you are using Windows, MacOSX, or Linux (if applicable): Linux
  • Whether you are using Chrome, Safari, Firefox, Edge (if applicable): Chrome

Element.onKeyUp and Element.onKeyDown throw a type error when the browser dispatches a synthetic event caused by a mouse click.

To reproduce, compile and serve the following the following:

<html>
  <head>
    <script defer src="main.dart.js"></script>
  </head>
  <body>
    <input list="data">
    <datalist id="data">
      <option value="Foo"></option>
      <option value="Bar"></option>
      <option value="Baz"></option>
    </datalist>
  </body>
</html>
import 'dart:html';                                                              
                                                                                 
void main() {                                                                    
  document.querySelector('input').onKeyUp.listen((keyboardEvent) {               
    print(keyboardEvent.keyCode);                                                
  });                                                                            
}   

Typing inside the <input> works fine, however if you select one of the suggestions via a mouse click, the following exception is thrown.

Stack trace from console:

Uncaught Type 'Event$' is not a subtype of expected type 'KeyboardEvent$'. at dart:_runtime/operations.dart 565:13  throw

dart_library.library.dart.throw @ dart_sdk.js?______buster=6609396.2019-01-03T12%3A43%3A51.000:4857
dart_library.library.dart.castError @ dart_sdk.js?______buster=6609396.2019-01-03T12%3A43%3A51.000:4473
dart_library.library.dart.as @ dart_sdk.js?______buster=6609396.2019-01-03T12%3A43%3A51.000:4772
check_C @ dart_sdk.js?______buster=6609396.2019-01-03T12%3A43%3A51.000:3999
dart_library.library.dart._checkApply @ dart_sdk.js?______buster=6609396.2019-01-03T12%3A43%3A51.000:4583
dart_library.library.dart._checkAndCall @ dart_sdk.js?______buster=6609396.2019-01-03T12%3A43%3A51.000:4664
dart_library.library.dart.dcall @ dart_sdk.js?______buster=6609396.2019-01-03T12%3A43%3A51.000:4672
(anonymous function).html$._wrapZone.dart.fn.e @ dart_sdk.js?______buster=6609396.2019-01-03T12%3A43%3A51.000:96715

Stack trace property from uncaught TypeError:

dart:_runtime/operations.dart 565:13  throw
dart:js 512:46                        castError
dart:js 512:46                        as
dart:js 512:46                        check_C
dart:_runtime/operations.dart 184:44  _checkApply
dart:js 512:46                        _checkAndCall
dart:js 512:46                        dcall
dart:js 512:46                        e

The browser synthesizes a keyup event for the mouse click, however this event does not have type KeyboardEvent. The SDK attempts to dispatch this event on the keyUp stream anyway, which leads to the above type error due to the stream expecting events of type KeyboardEvent.

@kevmoo kevmoo added web-libraries Issues impacting dart:html, etc., libraries area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. library-html labels Jan 15, 2019
@vsmenon vsmenon added area-web Use area-web for Dart web related issues, including the DDC and dart2js compilers and JS interop. and removed area-core-library SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries. labels Jul 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-web Use area-web for Dart web related issues, including the DDC and dart2js compilers and JS interop. library-html web-libraries Issues impacting dart:html, etc., libraries
Projects
None yet
Development

No branches or pull requests

3 participants