dart-archive / polymer_elements

https://pub.dartlang.org/packages/polymer_elements
BSD 3-Clause "New" or "Revised" License
24 stars 17 forks source link

PaperMenuButton set method for openAnimationConfig doesn't accept Dart or JS objects. #127

Open jonboj opened 8 years ago

jonboj commented 8 years ago
Environment/Code

Ubuntu 15.10, Dartium.

Html <paper-menu-button id="id_menu_drop">

Dart

void ready(){
    print('PortalFramework.ready()');
    PaperMenuButton pmb = ($['id_menu_drop'] as PaperMenuButton);
    Object gw = pmb.openAnimationConfig;
    print('Open anim : ' + gw.toString());

    pmb.openAnimationConfig(gw);
}
What is expected

For an instance of PaperMenuButton e.g. for the open animation, (or close animation - closeAnimationConfig). Get open animation openAnimationConfig Set open animation openAnimationConfig(value)

Actual outcome

The stackdump below

PortalFramework.ready()
Open anim : [[object Object], [object Object], [object Object]]
Uncaught Unhandled exception:
Unhandled exception:
Unhandled exception:
Class 'JsArray' has no instance method 'call'.

NoSuchMethodError: method not found: 'call'
Receiver: Instance of 'JsArray'
Arguments: [Instance of 'JsArray']
#0      Object._noSuchMethod (dart:core-patch/object_patch.dart:42)
#1      Object.noSuchMethod (dart:core-patch/object_patch.dart:45)
#2      PortalFramework.ready (package:mintest/portal_framework.dart:41:9)
Howto reproduce

Put the ready method in element, which includes the html above with paper-menu-button.

Observations

Inserting a convertToDart indicates that a valid JS animation is obtained, but problems with conversions. Changing to:

Object gwDart = convertToDart(pmb.openAnimationConfig);
print('Open anim : ' + gwDart.toString());

pmb.openAnimationConfig(gwDart);

Gives stackdump

PortalFramework.ready()
Open anim : [{name: fade-in-animation, timing: {delay: 100, duration: 200}}, {name: paper-menu-grow-width-animation, timing: {delay: 100, duration: 150, easing: cubic-bezier(.3,.95,.5,1)}}, {name: paper-menu-grow-height-animation, timing: {delay: 100, duration: 275, easing: cubic-bezier(.3,.95,.5,1)}}]
Uncaught Unhandled exception:
Unhandled exception:
Unhandled exception:
Class 'JsArray' has no instance method 'call'.

NoSuchMethodError: method not found: 'call'
Receiver: Instance of 'JsArray'
Arguments: [Instance(length:3) of '_GrowableList']
#0      Object._noSuchMethod (dart:core-patch/object_patch.dart:42)
#1      Object.noSuchMethod (dart:core-patch/object_patch.dart:45)
#2      PortalFramework.ready (package:mintest/portal_framework.dart:41:9)

Cut from pub.yaml

environment:
  sdk: '>=1.9.0 <2.0.0'

dependencies:
  browser: ^0.10.0
  polymer_elements: ^1.0.0-rc.8
  polymer: ^1.0.0-rc.15
  web_components: ^0.12.0
jonboj commented 8 years ago

Reproduced with polymer_elements: ^1.0.0-rc.9

From pubspec.yaml

environment:
  sdk: '>=1.9.0 <2.0.0'

dependencies:
  browser: ^0.10.0
  polymer_elements: ^1.0.0-rc.9
  polymer: ^1.0.0-rc.17
  web_components: '>=0.11.3 <0.13.0'