Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(639)

Unified Diff: pkg/polymer/lib/src/loader.dart

Issue 29823005: fixes to polymer, gets tests back to a stable state (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/polymer/lib/src/instance.dart ('k') | pkg/polymer/test/attr_deserialize_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..9322ddff2f942442d722e2388ed4dbf48d9cb89d 100644
--- a/pkg/polymer/lib/src/loader.dart
+++ b/pkg/polymer/lib/src/loader.dart
@@ -33,31 +33,43 @@ 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.
+ if (libraries == null) {
+ libraries = _discoverScripts(document, window.location.href);
+ }
+ 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) {
+ 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());
}
/**
« no previous file with comments | « pkg/polymer/lib/src/instance.dart ('k') | pkg/polymer/test/attr_deserialize_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698