Pregunta

I am compiling a website written in dart and polymer, and encountered an error, (see the stack trace below, very long, but not very useful). As the stack trace shows, the error happened when the polymer transformer tries to inline polymer-element definitions from html imports (in MY_APP.html).

If I had only 2 custom elements in MY_APP.html, I would comment out one of them and see if the problem remains, the problem is that I have about 20 of them, trying them one by one would be both boring and time consuming, any idea to pin down the custom element that caused the problem?

Thanks.

Stack trace:

... (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)
¿Fue útil?

Solución

The error came from a custom element that has:

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

in it, after changing it to:

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

the compiler is happy. (Is this a bug?)

For those who have the similar problem: I was able to locate the problematic code by modifying the common.dart and import_inliner.dart (in package polymer) to add more log output.

Otros consejos

I haven's seen errors like this recently.

What I found is

Similar but not the same ...

What I have seen in your previous question you use a somewhat unusual application layout (in my opinion). The folder structure is fine but have haven't used nor seen a structure where the HTML- and Dart- files of elements are in different folders.

I use

  • index.html and index.dart in web
  • element1.html and element1.dart somewhere in lib (one html and one dart file per polymer element).
  • sometimes when an element is more complex and has some functionality split in extra elements I pack all files that belong together in a subdirectory like lib/element1 or lib/components/element1

The linked issue above was caused by the way the elements were imported, especially when one element imports another.
Element import is still very fagile. In Dart/Dartium several paths lead to an element because there are symlinks but when building to JavaScript exactly one way is supported.
see https://code.google.com/p/dart/issues/detail?id=15953
Improving this is work in progress (as far as I know).

The way you organized your code might work but I have no experience with it.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top