Index: pkg/polymer/lib/src/loader.dart |
diff --git a/pkg/polymer/lib/src/loader.dart b/pkg/polymer/lib/src/loader.dart |
index 73ee5f26e0fb906e02fa33c839c8e2c109752998..e6f17f5fbb3c1983a10e60a8bcd5fd9b5a44f7e1 100644 |
--- a/pkg/polymer/lib/src/loader.dart |
+++ b/pkg/polymer/lib/src/loader.dart |
@@ -4,28 +4,24 @@ |
part of polymer; |
-/** Annotation used to automatically register polymer elements. */ |
+/// Annotation used to automatically register polymer elements. |
class CustomTag { |
final String tagName; |
const CustomTag(this.tagName); |
} |
-/** |
- * Metadata used to label static or top-level methods that are called |
- * automatically when loading the library of a custom element. |
- */ |
+/// Metadata used to label static or top-level methods that are called |
+/// automatically when loading the library of a custom element. |
const initMethod = const _InitMethodAnnotation(); |
-/** |
- * Initializes a polymer application as follows: |
- * * set up up polling for observable changes |
- * * initialize Model-Driven Views |
- * * Include some style to prevent flash of unstyled content (FOUC) |
- * * 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]). |
- */ |
+/// Initializes a polymer application as follows: |
+/// * set up up polling for observable changes |
+/// * initialize Model-Driven Views |
+/// * Include some style to prevent flash of unstyled content (FOUC) |
+/// * 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() { |
// We use this pattern, and not the inline lazy initialization pattern, so we |
// can help dart2js detect that _discoverInitializers can be tree-shaken for |
@@ -42,13 +38,11 @@ Zone initPolymer() { |
return initPolymerOptimized(); |
} |
-/** |
- * 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 initializers |
- * must be supplied instead of being dynamically searched for at runtime using |
- * mirrors. |
- */ |
+/// 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 initializers |
+/// must be supplied instead of being dynamically searched for at runtime using |
+/// mirrors. |
Zone initPolymerOptimized() { |
// TODO(sigmund): refactor this so we can replace it by codegen. |
smoke.useMirrors(); |
@@ -69,30 +63,25 @@ Zone initPolymerOptimized() { |
return Zone.current; |
} |
-/** |
- * Configures [initPolymer] making it optimized for deployment to the internet. |
- * With this setup the initializer list is supplied instead of being dynamically |
- * searched for at runtime. Additionally, after this method is called, |
- * [initPolymer] omits the [Zone] that automatically invokes |
- * [Observable.dirtyCheck]. |
- */ |
+/// 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) { |
_initializers = initializers; |
_deployMode = true; |
} |
-/** |
- * List of initializers that by default will be executed when calling |
- * initPolymer. If null, initPolymer will compute the list of initializers by |
- * crawling HTML imports, searchfing for script tags, and including an |
- * initializer for each type tagged with a [CustomTag] annotation and for each |
- * top-level method annotated with [initMethod]. The value of this field is |
- * assigned programatically by the code generated from the polymer deploy |
- * scripts. |
- */ |
+/// List of initializers that by default will be executed when calling |
+/// initPolymer. If null, initPolymer will compute the list of initializers by |
+/// crawling HTML imports, searchfing for script tags, and including an |
+/// initializer for each type tagged with a [CustomTag] annotation and for each |
+/// top-level method annotated with [initMethod]. The value of this field is |
+/// assigned programatically by the code generated from the polymer deploy |
+/// scripts. |
List<Function> _initializers; |
-/** True if we're in deployment mode. */ |
+/// True if we're in deployment mode. |
bool _deployMode = false; |
List<Function> _discoverInitializers() { |
@@ -110,13 +99,11 @@ List<Function> _discoverInitializers() { |
return initializers; |
} |
-/** |
- * Walks the HTML import structure to discover all script tags that are |
- * implicitly loaded. This code is only used in Dartium and should only be |
- * called after all HTML imports are resolved. Polymer ensures this by asking |
- * users to put their Dart script tags after all HTML imports (this is checked |
- * by the linter, and Dartium will otherwise show an error message). |
- */ |
+/// Walks the HTML import structure to discover all script tags that are |
+/// implicitly loaded. This code is only used in Dartium and should only be |
+/// called after all HTML imports are resolved. Polymer ensures this by asking |
+/// users to put their Dart script tags after all HTML imports (this is checked |
+/// by the linter, and Dartium will otherwise show an error message). |
List<String> _discoverScripts(Document doc, String baseUri, |
[Set<Document> seen, List<String> scripts]) { |
if (seen == null) seen = new Set<Document>(); |
@@ -146,7 +133,7 @@ List<String> _discoverScripts(Document doc, String baseUri, |
return scripts; |
} |
-/** All libraries in the current isolate. */ |
+/// All libraries in the current isolate. |
final _libs = currentMirrorSystem().libraries; |
// TODO(sigmund): explore other (cheaper) ways to resolve URIs relative to the |
@@ -164,16 +151,14 @@ bool _isHttpStylePackageUrl(Uri uri) { |
(uriPath.contains('/packages/') || uriPath.startsWith('packages/')); |
} |
-/** |
- * Reads the library at [uriString] (which can be an absolute URI or a relative |
- * URI from the root library), and: |
- * |
- * * If present, invokes any top-level and static functions marked |
- * with the [initMethod] annotation (in the order they appear). |
- * |
- * * Registers any [PolymerElement] that is marked with the [CustomTag] |
- * annotation. |
- */ |
+/// Reads the library at [uriString] (which can be an absolute URI or a relative |
+/// URI from the root library), and: |
+/// |
+/// * If present, invokes any top-level and static functions marked |
+/// with the [initMethod] annotation (in the order they appear). |
+/// |
+/// * Registers any [PolymerElement] that is marked with the [CustomTag] |
+/// annotation. |
void _loadLibrary(String uriString, List<Function> initializers) { |
var uri = _rootUri.resolve(uriString); |
var lib = _libs[uri]; |