OLD | NEW |
---|---|
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 part of polymer; | 5 part of polymer; |
6 | 6 |
7 /** Annotation used to automatically register polymer elements. */ | 7 /** Annotation used to automatically register polymer elements. */ |
8 class CustomTag { | 8 class CustomTag { |
9 final String tagName; | 9 final String tagName; |
10 const CustomTag(this.tagName); | 10 const CustomTag(this.tagName); |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
68 /** | 68 /** |
69 * Configures [initPolymer] making it optimized for deployment to the internet. | 69 * Configures [initPolymer] making it optimized for deployment to the internet. |
70 * With this setup the initializer list is supplied instead of being dynamically | 70 * With this setup the initializer list is supplied instead of being dynamically |
71 * searched for at runtime. Additionally, after this method is called, | 71 * searched for at runtime. Additionally, after this method is called, |
72 * [initPolymer] omits the [Zone] that automatically invokes | 72 * [initPolymer] omits the [Zone] that automatically invokes |
73 * [Observable.dirtyCheck]. | 73 * [Observable.dirtyCheck]. |
74 */ | 74 */ |
75 void configureForDeployment(List<Function> initializers) { | 75 void configureForDeployment(List<Function> initializers) { |
76 _initializers = initializers; | 76 _initializers = initializers; |
77 _useDirtyChecking = false; | 77 _useDirtyChecking = false; |
78 _deployMode = true; | |
78 } | 79 } |
79 | 80 |
80 /** | 81 /** |
81 * List of initializers that by default will be executed when calling | 82 * List of initializers that by default will be executed when calling |
82 * initPolymer. If null, initPolymer will compute the list of initializers by | 83 * initPolymer. If null, initPolymer will compute the list of initializers by |
83 * crawling HTML imports, searchfing for script tags, and including an | 84 * crawling HTML imports, searchfing for script tags, and including an |
84 * initializer for each type tagged with a [CustomTag] annotation and for each | 85 * initializer for each type tagged with a [CustomTag] annotation and for each |
85 * top-level method annotated with [initMethod]. The value of this field is | 86 * top-level method annotated with [initMethod]. The value of this field is |
86 * assigned programatically by the code generated from the polymer deploy | 87 * assigned programatically by the code generated from the polymer deploy |
87 * scripts. | 88 * scripts. |
88 */ | 89 */ |
89 List<Function> _initializers; | 90 List<Function> _initializers; |
90 | 91 |
91 bool _useDirtyChecking = true; | 92 bool _useDirtyChecking = true; |
Siggi Cherem (dart-lang)
2014/02/13 00:08:18
we could delete this flag and use _deployMode for
| |
92 | 93 |
94 /** True if we're in deployment mode. */ | |
95 bool _deployMode = false; | |
Siggi Cherem (dart-lang)
2014/02/13 00:08:18
FYI - I intend to later on make this a `const` and
Jennifer Messerly
2014/02/13 06:11:22
SGTM
| |
96 | |
93 List<Function> _discoverInitializers() { | 97 List<Function> _discoverInitializers() { |
94 var initializers = []; | 98 var initializers = []; |
95 var librariesToLoad = _discoverScripts(document, window.location.href); | 99 var librariesToLoad = _discoverScripts(document, window.location.href); |
96 for (var lib in librariesToLoad) { | 100 for (var lib in librariesToLoad) { |
97 try { | 101 try { |
98 _loadLibrary(lib, initializers); | 102 _loadLibrary(lib, initializers); |
99 } catch (e, s) { | 103 } catch (e, s) { |
100 // Deliver errors async, so if a single library fails it doesn't prevent | 104 // Deliver errors async, so if a single library fails it doesn't prevent |
101 // other things from loading. | 105 // other things from loading. |
102 new Completer().completeError(e, s); | 106 new Completer().completeError(e, s); |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
235 print("warning: methods marked with @initMethod should take no " | 239 print("warning: methods marked with @initMethod should take no " |
236 "arguments, ${method.simpleName} expects some."); | 240 "arguments, ${method.simpleName} expects some."); |
237 return; | 241 return; |
238 } | 242 } |
239 initializers.add(() => obj.invoke(method.simpleName, const [])); | 243 initializers.add(() => obj.invoke(method.simpleName, const [])); |
240 } | 244 } |
241 | 245 |
242 class _InitMethodAnnotation { | 246 class _InitMethodAnnotation { |
243 const _InitMethodAnnotation(); | 247 const _InitMethodAnnotation(); |
244 } | 248 } |
OLD | NEW |