编制dart聚合物时找到错误源

时间:2014-03-06 15:02:13

标签: dart dart-polymer

我正在编写一个用dart和聚合物编写的网站,并遇到一个错误,(见下面的堆栈描述,很长,但不是很有用)。当堆栈跟踪显示时,当聚合物变换器试图从html导入(在MY_APP.html中)内联聚合物元素定义时发生错误。

如果我在MY_APP.html中只有2个自定义元素,我会注释掉其中一个,看看问题是否仍然存在,问题是我有大约20个,一个接一个地尝试它们会很无聊耗费时间,还有什么想法可以确定导致问题的自定义元素?

感谢。

堆栈追踪:

... (OMITTED)
Build error:
Transform polymer (ImportInliner) on MY_PACKAGE_NAME|web/MY_APP.html threw error: The null object does not have a method '[]'.

NoSuchMethodError : method not found: '[]'
Receiver: null
Arguments: [1]
dart:core-patch/object_patch.dart 45                                          Object.noSuchMethod
dart:core/uri.dart 124                                                        Uri.Uri._fromMatch
dart:core/uri.dart 121                                                        Uri.parse
http://127.0.0.1:36562/packages/polymer/src/build/import_inliner.dart 177:24  _UrlNormalizer._newUrl
http://127.0.0.1:36562/packages/polymer/src/build/import_inliner.dart 169:41  _UrlNormalizer.visitElement
http://127.0.0.1:36562/packages/html5lib/dom_parsing.dart 12:50               TreeVisitor.visit
http://127.0.0.1:36562/packages/html5lib/dom_parsing.dart 24:49               TreeVisitor.visitChildren
http://127.0.0.1:36562/packages/html5lib/dom_parsing.dart 30:48               TreeVisitor.visitNodeFallback
http://127.0.0.1:36562/packages/html5lib/dom_parsing.dart 39:50               TreeVisitor.visitElement
http://127.0.0.1:36562/packages/polymer/src/build/import_inliner.dart 173:23  _UrlNormalizer.visitElement
http://127.0.0.1:36562/packages/html5lib/dom_parsing.dart 12:50               TreeVisitor.visit
http://127.0.0.1:36562/packages/html5lib/dom_parsing.dart 24:49               TreeVisitor.visitChildren
http://127.0.0.1:36562/packages/html5lib/dom_parsing.dart 30:48               TreeVisitor.visitNodeFallback
http://127.0.0.1:36562/packages/html5lib/dom_parsing.dart 39:50               TreeVisitor.visitElement
http://127.0.0.1:36562/packages/polymer/src/build/import_inliner.dart 173:23  _UrlNormalizer.visitElement
http://127.0.0.1:36562/packages/html5lib/dom_parsing.dart 12:50               TreeVisitor.visit
http://127.0.0.1:36562/packages/html5lib/dom_parsing.dart 24:49               TreeVisitor.visitChildren
http://127.0.0.1:36562/packages/html5lib/dom_parsing.dart 30:48               TreeVisitor.visitNodeFallback
http://127.0.0.1:36562/packages/html5lib/dom_parsing.dart 39:50               TreeVisitor.visitElement
http://127.0.0.1:36562/packages/polymer/src/build/import_inliner.dart 173:23  _UrlNormalizer.visitElement
http://127.0.0.1:36562/packages/html5lib/dom_parsing.dart 12:50               TreeVisitor.visit
http://127.0.0.1:36562/packages/html5lib/dom_parsing.dart 24:49               TreeVisitor.visitChildren
http://127.0.0.1:36562/packages/html5lib/dom_parsing.dart 30:48               TreeVisitor.visitNodeFallback
http://127.0.0.1:36562/packages/html5lib/dom_parsing.dart 39:50               TreeVisitor.visitElement
http://127.0.0.1:36562/packages/polymer/src/build/import_inliner.dart 173:23  _UrlNormalizer.visitElement
http://127.0.0.1:36562/packages/html5lib/dom_parsing.dart 12:50               TreeVisitor.visit
http://127.0.0.1:36562/packages/html5lib/dom_parsing.dart 24:49               TreeVisitor.visitChildren
http://127.0.0.1:36562/packages/html5lib/dom_parsing.dart 30:48               TreeVisitor.visitNodeFallback
http://127.0.0.1:36562/packages/html5lib/dom_parsing.dart 39:50               TreeVisitor.visitElement
http://127.0.0.1:36562/packages/polymer/src/build/import_inliner.dart 173:23  _UrlNormalizer.visitElement
http://127.0.0.1:36562/packages/html5lib/dom_parsing.dart 12:50               TreeVisitor.visit
http://127.0.0.1:36562/packages/html5lib/dom_parsing.dart 24:49               TreeVisitor.visitChildren
http://127.0.0.1:36562/packages/html5lib/dom_parsing.dart 30:48               TreeVisitor.visitNodeFallback
http://127.0.0.1:36562/packages/html5lib/dom_parsing.dart 39:50               TreeVisitor.visitElement
http://127.0.0.1:36562/packages/polymer/src/build/import_inliner.dart 173:23  _UrlNormalizer.visitElement
http://127.0.0.1:36562/packages/html5lib/dom_parsing.dart 12:50               TreeVisitor.visit
http://127.0.0.1:36562/packages/html5lib/dom_parsing.dart 24:49               TreeVisitor.visitChildren
http://127.0.0.1:36562/packages/html5lib/dom_parsing.dart 30:48               TreeVisitor.visitNodeFallback
http://127.0.0.1:36562/packages/html5lib/dom_parsing.dart 32:52               TreeVisitor.visitDocument
http://127.0.0.1:36562/packages/html5lib/dom_parsing.dart 16:52               TreeVisitor.visit
http://127.0.0.1:36562/packages/polymer/src/build/import_inliner.dart 148:48  ImportInliner._collectImportedDocuments.<fn>.<fn>
dart:async/zone.dart 717                                                      _rootRunUnary
dart:async/zone.dart 854                                                      _RootZone.runUnary
dart:async/future_impl.dart 439                                               _Future._propagateToListeners.handleValueCallback
dart:async/future_impl.dart 522                                               _Future._propagateToListeners
dart:async/future_impl.dart 303                                               _Future._complete
dart:async/future.dart 286                                                    Future.forEach.nextElement
dart:async/zone.dart 717                                                      _rootRunUnary
dart:async/zone.dart 854                                                      _RootZone.runUnary
dart:async/future_impl.dart 439                                               _Future._propagateToListeners.handleValueCallback
dart:async/future_impl.dart 522                                               _Future._propagateToListeners
dart:async/future_impl.dart 303                                               _Future._complete
dart:async/future_impl.dart 354                                               _Future._asyncComplete.<fn>
dart:async/schedule_microtask.dart 23                                         _asyncRunCallbackLoop
dart:async/schedule_microtask.dart 32                                         _asyncRunCallback
dart:isolate-patch/isolate_patch.dart 119                                     _RawReceivePortImpl._handleMessage

../../home/MY_USER_NAME/dart/dart/sdk/lib/_internal/pub/lib/src/barback/load_transformers.dart 560  _call.<fn>
dart:isolate                                                                                 _RawReceivePortImpl._handleMessage
... (OMITTED)

2 个答案:

答案 0 :(得分:1)

错误来自具有以下内容的自定义元素:

<a href="/blah/{{observableMap['my_key']}}">blah</a>

中,将其更改为:

<a href="{{'/blah/' + observableMap['my_key']}}">blah</a>

编译器很高兴。 (这是一个错误吗?)

对于那些有类似问题的人:我能够通过修改common.dart和import_inliner.dart(在包聚合物中)来找到有问题的代码,以添加更多的日志输出。

答案 1 :(得分:0)

我最近看到过这样的错误。

我发现的是

相似但不一样......

我在上一个问题中看到你使用了一些不寻常的应用程序布局(在我看来)。 文件夹结构很好,但没有使用也没见过元素的HTML和Dart文件位于不同文件夹中的结构。

我用

    网络中的
  • index.htmlindex.dart
  • lib中某处的
  • element1.htmlelement1.dart(每个聚合物元素一个html和一个dart文件)。
  • 有时当元素更复杂并且在额外元素中分割了一些功能时,我将所有属于一起的文件打包在lib/element1lib/components/element1
  • 这样的子目录中

上述链接问题是由元素导入的方式引起的,尤其是当一个元素导入另一个元素时 元素导入仍然很不稳定。在Dart / Dartium中,有几个路径会导致一个元素,因为有符号链接,但在构建JavaScript时,只支持一种方式。
https://code.google.com/p/dart/issues/detail?id=15953
改进这项工作正在进行中(据我所知)。

您组织代码的方式可能有效,但我没有使用它。