dart-archive / polymer-dart

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

Readonly property throws #608

Closed zoechi closed 9 years ago

zoechi commented 9 years ago

I'm pretty sure I successfully tried this already recently.

@PolymerRegister('all-demos')
class AllDemos extends PolymerElement {
  AllDemos.created() : super.created();
  List<DemoElementItem> __demos;
  @property List<DemoElementItem> get demos => __demos;
//  set demos(value){} // workaround

  void ready() {
    _demos = demoElements.take(10).map((name) => new DemoElementItem(name)).toList();
    notifyPath('demos', _demos);
    print('all-demos ready');
  }
}

package:polymer/src/common/polymer_mixin.dart:24 Exception: Unhandled exception: TypeError: Cannot set property demos of # which has only a getter

0 JsObject._callMethod (dart:js:678)

1 JsObject.callMethod (dart:js:618)

2 HtmlElement&PolymerMixin&PolymerBase.set (package:polymer_interop/src/polymer_base.dart:318:17)

3 HtmlElement&PolymerMixin&PolymerBase.notifyPath (package:polymer_interop/src/polymer_base.dart:227:42)

4 AllDemos.ready (http://localhost:8080/web/all_demos.dart:136:5)

5 _LocalInstanceMirror._invoke (dart:mirrors-patch/mirrors_impl.dart:532)

6 _LocalInstanceMirror.invoke (dart:mirrors-patch/mirrors_impl.dart:528)

7 _InstanceMirrorImpl.invoke (package:reflectable/src/reflectable_mirror_based.dart:465:12)

8 _setupLifecycleMethods.. (package:polymer/src/common/polymer_descriptor.dart:128:31)

9 JsObject._callMethod (dart:js:678)

10 JsObject.callMethod (dart:js:618)

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

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

13 AllDemos.AllDemos.created (http://localhost:8080/web/all_demos.dart:129:24)

14 Blink_Utils.changeElementWrapper (dart:_blink:31542)

15 _Utils.changeElementWrapper (dart:html:42281)

16 _VMElementUpgrader.upgrade (dart:html:41073)

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

18 JsObject._callMethod (dart:js:678)

19 JsObject.callMethod (dart:js:618)

20 registerDartType (package:web_components/interop.dart:41:8)

21 CustomElementProxy.initialize (package:web_components/custom_element_proxy.dart:23:5)

22 PolymerRegister.initialize (package:polymer/src/common/polymer_register.dart:21:21)

23 InitializationCrawler._readAnnotations. (package:initialize/src/mirror_loader.dart:236:42)

24 _runInitQueue (package:initialize/initialize.dart:35:24)

25 _runInitQueue. (package:initialize/initialize.dart:38:26)

26 _RootZone.runUnary (dart:async/zone.dart:1165)

27 _Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:502)

28 _Future._propagateToListeners (dart:async/future_impl.dart:585)

29 _Future._completeWithValue (dart:async/future_impl.dart:376)

30 _Future._asyncComplete. (dart:async/future_impl.dart:430)

31 _microtaskLoop (dart:async/schedule_microtask.dart:43)

32 _microtaskLoopEntry (dart:async/schedule_microtask.dart:52)

33 _ScheduleImmediateHelper._handleMutation (dart:html:42565)

jakemac53 commented 9 years ago

Ah yes I know exactly why this is happening, but I think I know a workaround ;)

jakemac53 commented 9 years ago

fixed

zoechi commented 9 years ago

great :)