2
votes

In a polymer.dart element, I need to load a resource. The problem is I don't know the location of that resource.

Here is the organization of my sources:

web/
|- my_project.dart
|- my_project.html
|- my_project.css
|- element/
   |- element.html
   |- element.dart
   |- res.txt

I need, in element.dart, to load res.txt.

For that, I use:

HttpRequest.getString('res.txt');

And it tries to load /res.txt instead of /element/res.txt.

Of course, if I do...

HttpRequest.getString('element/res.txt');

...it works, but that is not sufficient for me as I want my polymer elements to be as portable and reusable as possible (which is the purpose of polymer) and I don't want my elements to be location dependent.

I should also point out that it worked correctly in Polymer.dart until version 0.8.5.

So, I guess I would like something like...

HttpRequest.getString(getElementLocation() + '/res.txt');

...but I haven't found anything corresponding.

Is this possible ?

1
Might be worth posting your question here: groups.google.com/a/dartlang.org/forum/#!forum/webGreg Lowe

1 Answers

0
votes

John Messerly answered this on the Google group mentioned in the comment above. See https://groups.google.com/a/dartlang.org/d/msg/web-ui/f29kUdNI7Bw/W8dpbMG6iCEJ.

Polymer.js has a resolvePath API (see https://github.com/Polymer/polymer/blob/2f7c65592dd2c8f9da7eed8c96c076e49fa208d1/src/declaration/path.js#L14). Polymer Dart does not have it.