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

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

Issue 293023008: Bring back initPolymer, allow boot.js only if using "polymer_experimental.html". (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 7 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/js/polymer/polymer.html ('k') | pkg/polymer/lib/src/mirror_loader.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 13e8b1c765fdef0f6e61a17c6aa74487ca9e86ea..fb28836ed798edb1539c88280273cc670e445b3d 100644
--- a/pkg/polymer/lib/src/loader.dart
+++ b/pkg/polymer/lib/src/loader.dart
@@ -20,32 +20,38 @@ class InitMethodAnnotation {
const InitMethodAnnotation();
}
-/// This method is deprecated. It used to be where polymer initialization
-/// happens, now this is done automatically from bootstrap.dart.
-@deprecated
+/// Initializes a polymer application as follows:
+/// * if running in development mode, set up a dirty-checking zone that polls
+/// for observable changes
+/// * initialize template binding and polymer-element
+/// * for each library included transitively from HTML and HTML imports,
+/// register custom elements declared there (labeled with [CustomTag]) and
+/// invoke the initialization method on it (top-level functions annotated with
+/// [initMethod]).
Zone initPolymer() {
- window.console.error(_ERROR);
- return Zone.current;
+ if (loader.deployMode) {
+ startPolymer(loader.initializers, loader.deployMode);
+ return Zone.current;
+ }
+ return dirtyCheckZone()..run(
+ () => startPolymer(loader.initializers, loader.deployMode));
}
-const _ERROR = '''
-initPolymer is now deprecated. To initialize a polymer app:
- * add to your page: <link rel="import" href="packages/polymer/polymer.html">
- * replace "application/dart" mime-types with "application/dart;component=1"
- * if you use "init.dart", remove it
- * if you have a main, change it into a method annotated with @initMethod
-''';
-
/// True if we're in deployment mode.
bool _deployMode = false;
+bool _startPolymerCalled = false;
+
/// Starts polymer by running all [initializers] and hooking the polymer.js
/// code. **Note**: this function is not meant to be invoked directly by
-/// application developers. It is invoked by a bootstrap entry point that is
-/// automatically generated. During development, this entry point is generated
-/// dynamically in `boot.js`. Similarly, pub-build generates this entry point
-/// for deployment.
+/// application developers. It is invoked either by [initPolymer] or, if you are
+/// using the experimental bootstrap API, this would be invoked by an entry
+/// point that is automatically generated somehow. In particular, during
+/// development, the entry point would be generated dynamically in `boot.js`.
+/// Similarly, pub-build would generate the entry point for deployment.
void startPolymer(List<Function> initializers, [bool deployMode = true]) {
+ if (_startPolymerCalled) throw 'Initialization was already done.';
+ _startPolymerCalled = true;
_hookJsPolymer();
_deployMode = deployMode;
@@ -54,6 +60,15 @@ void startPolymer(List<Function> initializers, [bool deployMode = true]) {
}
}
+/// Configures [initPolymer] making it optimized for deployment to the internet.
+/// With this setup the initializer list is supplied instead of searched for
+/// at runtime. Additionally, after this method is called [initPolymer] omits
+/// the [Zone] that automatically invokes [Observable.dirtyCheck].
+void configureForDeployment(List<Function> initializers) {
+ loader.initializers = initializers;
+ loader.deployMode = true;
+}
+
/// To ensure Dart can interoperate with polymer-element registered by
/// polymer.js, we need to be able to execute Dart code if we are registering
/// a Dart class for that element. We trigger Dart logic by patching
« no previous file with comments | « pkg/polymer/lib/src/js/polymer/polymer.html ('k') | pkg/polymer/lib/src/mirror_loader.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698