dart-archive / polymer-dart

Polymer support for Dart
https://pub.dartlang.org/packages/polymer
BSD 3-Clause "New" or "Revised" License
181 stars 33 forks source link

`add(...)` throws #635

Closed zoechi closed 6 years ago

zoechi commented 8 years ago

at this line

https://github.com/bwu-dart/polymer_elements_demos/blob/google_apis_demo_refactoring/web/google_apis/google_apis_demo.dart#L40

Uncaught Unhandled exception: TypeError: Cannot read property 'length' of undefined

0 JsObject.callMethod (dart:js:1067)

1 HtmlElement&PolymerMixin&PolymerBase.add (package:polymer_interop/src/polymer_base.dart:324:15)

2 GoogleApisDemo.loaded (http://localhost:63342/polymer_elements_demos/web/google_apis/google_apis_demo.dart:40:5)

3 Function._apply (dart:core-patch/function_patch.dart:7)

4 Function.apply (dart:core-patch/function_patch.dart:28)

5 _InstanceMirrorImpl.invoke (package:reflectable/src/reflectable_transformer_based.dart:164:23)

6 _setupReflectableMethods.. (package:polymer/src/common/polymer_descriptor.dart:162:31)

7 JsObject._callMethod (dart:js:1124)

8 JsObject.callMethod (dart:js:1063)

9 HtmlElement&PolymerMixin.polymerCreated (package:polymer/src/common/polymer_mixin.dart:24:15)

10 PolymerElement.PolymerElement.created (package:polymer/polymer_micro.dart:23:5)

11 GoogleApisDemo.GoogleApisDemo.created (http://localhost:63342/polymer_elements_demos/web/google_apis/google_apis_demo.dart:22:30)

12 Blink_Utils.constructElement (dart:_blink:17193)

13 _createCustomUpgrader (dart:html:1235)

14 _VMElementUpgrader.upgrade (dart:html:47395)

15 registerDartType.upgradeElement (package:web_components/interop.dart:38:45)

16 JsObject._callMethod (dart:js:1124)

17 JsNative.callMethod (dart:js:1136)

18 Blink_JsNative_DomException.callMethod (dart:_blink:17259)

19 BlinkDocument.createElement_Callback1 (dart:_blink:3330)

20 Document.createElement (dart:html:11031)

21 _ElementFactoryProvider.createElement_tag (dart:html:16361)

22 Element.Element.tag (dart:html:13878)

23 AllDemos._loadDemo (http://localhost:63342/polymer_elements_demos/web/all_demos.dart:284:22)

24 AllDemos.selectedItemChanged (http://localhost:63342/polymer_elements_demos/web/all_demos.dart:277:9)

25 Function._apply (dart:core-patch/function_patch.dart:7)

26 Function.apply (dart:core-patch/function_patch.dart:28)

27 _InstanceMirrorImpl.invoke (package:reflectable/src/reflectable_transformer_based.dart:164:23)

28 _setupReflectableMethods.. (package:polymer/src/common/polymer_descriptor.dart:162:31)

(anonymous function)
(anonymous function)
handler
Polymer.Base._addFeature.fire Polymer.IronJsonpLibraryBehavior._libraryLoadCallback Loader.requestNotify
LoaderMap.require Polymer.IronJsonpLibraryBehavior._loadLibrary Polymer.IronJsonpLibraryBehavior.ready
Polymer.Base._addFeature._invokeBehavior
(anonymous function)
Polymer.Base._addFeature._doBehavior
Polymer.Base._addFeature._readySelf
Polymer.Base._addFeature._ready
Polymer.Base._addFeature._readyClients
Polymer.Base._addFeature._ready
Polymer.Base._addFeature._tryReady
Polymer.Base._addFeature._initFeatures
Polymer.Base.createdCallback
(anonymous function)
newCallback
(anonymous function)
(anonymous function)
Polymer.Base.extend._observerEffect
(anonymous function)
Polymer.Bind._modelApi._effectEffects Polymer.Bind._modelApi._propertySetter
setter
(anonymous function)
Polymer.Base._addFeature._notifyListener
Polymer.Base._addFeature.fire Polymer.Bind._modelApi._notifyChange
Polymer.Base.extend._notifyEffect (anonymous function)
Polymer.Bind._modelApi._effectEffects Polymer.Bind._modelApi._propertySetter
setter
(anonymous function)
Polymer.Base._addFeature._notifyListener
Polymer.Base._addFeature.fire Polymer.Bind._modelApi._notifyChange
Polymer.Base.extend._notifyEffect (anonymous function)
Polymer.Bind._modelApi._effectEffects Polymer.Bind._modelApi._propertySetter
setter
Polymer.select
Polymer.selectItem
Polymer.toggleSelectionForItem
Polymer._selectionHandler handler
Polymer.Base._addFeature.fire Gestures.fire Gestures.register.forward Gestures.register.click
Gestures.handleNative

zoechi commented 8 years ago

I tried to create a simple reproducible example, but here it works just fine https://github.com/bwu-dart-playground/polymer1/blob/master/_bugs/_not_reproducible/list_add/web/app_element.dart#L18

zoechi commented 8 years ago

If I wrap the code with async(() { ... }); the error goes away. My repo case uses a manually invoked event handler. In the google-apis-demo it is an event handler from a Google API element. Maybe it fires while Polymer isn't yet done initializing.

jakemac53 commented 8 years ago

ah are you invoking it from within ready?

zoechi commented 8 years ago

No, in the loaded event handler (<google-xx-api on-api-load="loaded"></...> https://github.com/bwu-dart/polymer_elements_demos/blob/9f4b48814c8ca6d446e7afd765f189544880f1f0/web/google_apis/google_apis_demo.html#L23-L23)

jakemac53 commented 8 years ago

@zoechi is this still an issue?

zoechi commented 8 years ago

I'll check and report back.