当我将我的应用程序(dart版本,未编译的js)加载到浏览器中时,Dartium给了我这个错误:
Uncaught Error: Error evaluating expression 'model["mode"]': EvalException: Can't assign to null: model
我可以看到错误是由某些代码引起的:
<polymer-element name="outer-element">
<!-- some codes here -->
<inner-element mode="model['mode']"></inner-element>
</polymer-element>
model
为Map
,model['mode']
为String
,mode
在@published String mode
上通过<inner-element>
宣布}。另外,model
通过<outer-element>
宣布@published Map model
,因此我可以使用<outer-element>
将一些地图传递到另一个自定义元素中的<outer-element model="{{some map}}">
。
这个错误并没有让应用程序崩溃,实际上,就我所见,它没有任何影响,但看到它真的很烦人。 (自我开发以来,我有这个错误!)
我浏览了数据流,但找不到问题。
任何想法都会受到赞赏。感谢。
版本:
飞镖1.4.2
聚合物0.10.1 + 1
polymer_expressions 0.10.0
dartium双赢-全稳定-36647.0
如果有帮助,这里是堆栈跟踪:
Uncaught Error: Error evaluating expression 'model["mode"]': EvalException: Can't assign to null: model
Stack Trace:
#0 assign (package:polymer_expressions/eval.dart:137:18)
#1 _Binding.value= (package:polymer_expressions/polymer_expressions.dart:142:28)
#2 HtmlElement&Polymer.bindProperty (package:polymer/src/instance.dart:675:16)
#3 HtmlElement&Polymer.bind (package:polymer/src/instance.dart:447:34)
#4 _processBindings (package:template_binding/src/template_iterator.dart:186:38)
#5 _cloneAndBindInstance (package:template_binding/src/instance_binding_map.dart:71:19)
#6 _cloneAndBindInstance (package:template_binding/src/instance_binding_map.dart:60:26)
#7 _cloneAndBindInstance (package:template_binding/src/instance_binding_map.dart:60:26)
#8 TemplateBindExtension.createInstance (package:template_binding/src/template.dart:87:40)
#9 HtmlElement&Polymer.instanceTemplate (package:polymer/src/instance.dart:430:44)
#10 HtmlElement&Polymer.shadowFromTemplate (package:polymer/src/instance.dart:288:31)
#11 HtmlElement&Polymer.parseDeclaration (package:polymer/src/instance.dart:228:34)
#12 HtmlElement&Polymer.parseDeclarations (package:polymer/src/instance.dart:215:23)
#13 HtmlElement&Polymer.prepareElement (package:polymer/src/instance.dart:190:22)
#14 HtmlElement&Polymer.bind (package:polymer/src/instance.dart:437:42)
#15 _processBindings (package:template_binding/src/template_iterator.dart:186:38)
#16 _cloneAndBindInstance (package:template_binding/src/instance_binding_map.dart:71:19)
#17 TemplateBindExtension.createInstance (package:template_binding/src/template.dart:87:40)
#18 _TemplateIterator._handleSplices (package:template_binding/src/template_iterator.dart:449:53)
#19 _TemplateIterator._valueChanged (package:template_binding/src/template_iterator.dart:330:19)
#20 _TemplateIterator._updateIteratedValue (package:template_binding/src/template_iterator.dart:303:18)
#21 _TemplateIterator._updateDependencies (package:template_binding/src/template_iterator.dart:287:25)
#22 TemplateBindExtension._processBindingDirectives (package:template_binding/src/template.dart:50:34)
#23 _processBindings (package:template_binding/src/template_iterator.dart:197:51)
#24 _cloneAndBindInstance (package:template_binding/src/instance_binding_map.dart:71:19)
#25 _cloneAndBindInstance (package:template_binding/src/instance_binding_map.dart:60:26)
#26 _cloneAndBindInstance (package:template_binding/src/instance_binding_map.dart:60:26)
#27 TemplateBindExtension.createInstance (package:template_binding/src/template.dart:87:40)
#28 _TemplateIterator._handleSplices (package:template_binding/src/template_iterator.dart:449:53)
#29 _TemplateIterator._valueChanged (package:template_binding/src/template_iterator.dart:330:19)
#30 _updateIteratedValue (package:template_binding/src/template_iterator.dart:303:18)
#31 _check (package:polymer_expressions/polymer_expressions.dart:131:16)
#32 dirtyCheckZoneSpec.wrapUnaryCallback.<anonymous closure> (package:observe/src/dirty_check.dart:120:15)
#33 _rootRunUnary (dart:async/zone.dart:730)
#34 _ZoneDelegate.runUnary (dart:async/zone.dart:462)
#35 _CustomizedZone.runUnary (dart:async/zone.dart:667)
#36 _BaseZone.runUnaryGuarded (dart:async/zone.dart:582)
#37 _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:333)
#38 _DelayedData.perform (dart:async/stream_impl.dart:585)
#39 _StreamImplEvents.handleNext (dart:async/stream_impl.dart:701)
#40 _PendingEvents.schedule.<anonymous closure> (dart:async/stream_impl.dart:661)
#41 dirtyCheckZoneSpec.wrapCallback.<anonymous closure> (package:observe/src/dirty_check.dart:111:15)
#42 _rootRun (dart:async/zone.dart:719)
#43 _ZoneDelegate.run (dart:async/zone.dart:453)
#44 _CustomizedZone.run (dart:async/zone.dart:663)
#45 _BaseZone.runGuarded (dart:async/zone.dart:574)
#46 _BaseZone.bindCallback.<anonymous closure> (dart:async/zone.dart:599)
#47 dirtyCheckZoneSpec.wrapCallback.<anonymous closure> (package:observe/src/dirty_check.dart:111:15)
#48 _rootRun (dart:async/zone.dart:723)
#49 _ZoneDelegate.run (dart:async/zone.dart:453)
#50 _CustomizedZone.run (dart:async/zone.dart:663)
#51 _BaseZone.runGuarded (dart:async/zone.dart:574)
#52 _BaseZone.bindCallback.<anonymous closure> (dart:async/zone.dart:599)
#53 _asyncRunCallbackLoop (dart:async/schedule_microtask.dart:23)
#54 _asyncRunCallback (dart:async/schedule_microtask.dart:32)
#55 _handleMutation (file:///E:/b/build/slave/dartium-win-full-stable/build/src/dart/tools/dom/src/native_DOMImplementation.dart:588)
答案 0 :(得分:1)
我怀疑它与以下有关:
Binding initialization when model is null
另见这里的评论:
Polymer template repeat has weird side effect
绑定初始化可能导致Polymer分配给null或不可赋值表达式的情况。以前他们试图压制这些错误但是已经看到这种情况实际上是一个错误,开发人员应该收到通知,所以他们改变了错误没有被抑制但是打印出来的行为。
他们试图找到改善这种体验的方法,但似乎并不太容易。
这就是我如何理解我读过的一些帖子,我没有任何额外的信息。