Chromium Code Reviews| Index: pkg/polymer/lib/src/mirror_loader.dart |
| diff --git a/pkg/polymer/lib/src/mirror_loader.dart b/pkg/polymer/lib/src/mirror_loader.dart |
| index 6e8a2bddc50411fd955e7b6a2df411e24d94da9c..5e1f13da6f5b0bb00fe69e1548928a2a866e3c35 100644 |
| --- a/pkg/polymer/lib/src/mirror_loader.dart |
| +++ b/pkg/polymer/lib/src/mirror_loader.dart |
| @@ -22,10 +22,12 @@ import 'dart:collection' show LinkedHashMap; |
| import 'dart:mirrors'; |
| import 'package:logging/logging.dart' show Logger; |
| -import 'package:polymer/polymer.dart'; |
| import 'package:observe/src/dirty_check.dart'; |
| +import 'package:polymer/boot.dart' show discoverScripts, ScriptInfo; |
|
Siggi Cherem (dart-lang)
2014/05/22 21:10:41
Q: I wonder if I should just move the code that is
Jennifer Messerly
2014/05/23 07:20:06
I guess the main reason is if you want it to be pu
Siggi Cherem (dart-lang)
2014/05/23 17:56:33
Done. Moved it here. At least now it is structured
|
| +import 'package:polymer/polymer.dart'; |
| +/// Used by code generated from the experimental polymer bootstrap in boot.js. |
| void startPolymerInDevelopment(List<String> librariesToLoad) { |
| dirtyCheckZone()..run(() { |
| startPolymer(discoverInitializers(librariesToLoad), false); |
| @@ -36,11 +38,16 @@ void startPolymerInDevelopment(List<String> librariesToLoad) { |
| /// list by crawling HTML imports, searching for script tags, and including an |
| /// initializer for each type tagged with a [CustomTag] annotation and for each |
| /// top-level method annotated with [initMethod]. |
| +List<Function> initializers = discoverInitializers( |
| + discoverLibrariesToLoad(document, window.location.href)); |
| + |
| +/// True if we're in deployment mode. |
| +bool deployMode = false; |
| /// Discovers what script tags are loaded from HTML pages and collects the |
| /// initializers of their corresponding libraries. |
| // Visible for testing only. |
| -List<Function> discoverInitializers(List<String> librariesToLoad) { |
| +List<Function> discoverInitializers(Iterable<String> librariesToLoad) { |
| var initializers = []; |
| for (var lib in librariesToLoad) { |
| try { |
| @@ -54,6 +61,13 @@ List<Function> discoverInitializers(List<String> librariesToLoad) { |
| return initializers; |
| } |
| +Iterable<String> discoverLibrariesToLoad(Document doc, String baseUri) => |
| + discoverScripts(doc, baseUri).map( |
| + (info) => _hasPackageUrl(info) ? info.packageUrl : info.resolvedUrl); |
| + |
| +bool _hasPackageUrl(ScriptInfo info) => |
| + info.isPackage && _libs[Uri.parse(info.packageUrl)] != null; |
| + |
| /// All libraries in the current isolate. |
| final _libs = currentMirrorSystem().libraries; |