Chromium Code Reviews| Index: pkg/polymer/lib/src/loader.dart |
| diff --git a/pkg/polymer/lib/src/loader.dart b/pkg/polymer/lib/src/loader.dart |
| index c2e2f55a290e5f629eb0828f2f56f7ca7619a505..6a9ff6938f801855a356115267b586a6eb9b1243 100644 |
| --- a/pkg/polymer/lib/src/loader.dart |
| +++ b/pkg/polymer/lib/src/loader.dart |
| @@ -33,31 +33,46 @@ const initMethod = const _InitMethodAnnotation(); |
| * `currentMirrorSystem().isolate.rootLibrary.uri`. |
| */ |
| void initPolymer([List<String> libraries]) { |
| - runMicrotask(() { |
| - // DOM events don't yet go through microtasks, so we catch those here. |
| - new Timer.periodic(new Duration(milliseconds: 125), |
| - (_) => performMicrotaskCheckpoint()); |
| + // Note: we synchronously load all libraries because the script invoking |
| + // this is run after all HTML imports are resolved. |
|
blois
2013/10/21 21:08:12
Should there be a check to validate that HTML impo
Siggi Cherem (dart-lang)
2013/10/21 21:10:24
Note that we are not using the polyfill for this -
Jennifer Messerly
2013/10/21 21:42:56
Siggi do you mind following up and adding a commen
Siggi Cherem (dart-lang)
2013/10/21 21:48:03
Not a problem
|
| + if (libraries == null) { |
| + libraries = _discoverScripts(document, window.location.href); |
| + } |
| + // TODO(14262): Schedule a dummy microtask in the root Zone to prevent |
|
blois
2013/10/21 21:08:12
Still necessary?
Jennifer Messerly
2013/10/21 21:42:56
nope.
|
| + // dart:html from getting it's Zones mixed up. |
| + scheduleMicrotask(() {}); |
| + dirtyCheckZone().run(() => initPolymerOptimized(libraries)); |
| +} |
| - preventFlashOfUnstyledContent(); |
| +/** |
| + * Same as [initPolymer], but runs the version that is optimized for deployment |
| + * to the internet. The biggest difference is it omits the [Zone] that |
| + * automatically invokes [Observable.dirtyCheck], and the list of libraries must |
| + * be supplied instead of being dynamically searched for at runtime. |
| + */ |
| +// TODO(jmesserly): change the Polymer build step to call this directly. |
| +void initPolymerOptimized(List<String> libraries) { |
|
Siggi Cherem (dart-lang)
2013/10/21 21:07:42
mmm.. this might have to change slightly once I le
Jennifer Messerly
2013/10/21 21:42:56
yeah, I expected it would change :)
just illustrat
|
| + preventFlashOfUnstyledContent(); |
| - // TODO(jmesserly): mdv should use initMdv instead of mdv.initialize. |
| - mdv.initialize(); |
| - document.register(PolymerDeclaration._TAG, PolymerDeclaration); |
| + // TODO(jmesserly): mdv should use initMdv instead of mdv.initialize. |
| + mdv.initialize(); |
| + document.register(PolymerDeclaration._TAG, PolymerDeclaration); |
| - // Note: we synchronously load all libraries because the script invoking |
| - // this is run after all HTML imports are resolved. |
| - if (libraries == null) { |
| - libraries = _discoverScripts(document, window.location.href); |
| - } |
| - _loadLibraries(libraries); |
| - }); |
| + _loadLibraries(libraries); |
| } |
| void _loadLibraries(libraries) { |
| for (var lib in libraries) { |
| - _loadLibrary(lib); |
| + try { |
| + _loadLibrary(lib); |
| + } catch (e, s) { |
| + // Deliver errors async, so if a single library fails it doesn't prevent |
| + // other things from loading. |
| + new Completer().completeError(e, s); |
| + } |
| } |
| - Polymer._ready.complete(); |
| + |
| + customElementsReady.then((_) => Polymer._ready.complete()); |
| } |
| /** |