| 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 30 matching lines...) Expand all Loading... |
| 41 } | 41 } |
| 42 | 42 |
| 43 /** | 43 /** |
| 44 * Same as [initPolymer], but runs the version that is optimized for deployment | 44 * Same as [initPolymer], but runs the version that is optimized for deployment |
| 45 * to the internet. The biggest difference is it omits the [Zone] that | 45 * to the internet. The biggest difference is it omits the [Zone] that |
| 46 * automatically invokes [Observable.dirtyCheck], and the list of libraries must | 46 * automatically invokes [Observable.dirtyCheck], and the list of libraries must |
| 47 * be supplied instead of being dynamically searched for at runtime. | 47 * be supplied instead of being dynamically searched for at runtime. |
| 48 */ | 48 */ |
| 49 // TODO(jmesserly): change the Polymer build step to call this directly. | 49 // TODO(jmesserly): change the Polymer build step to call this directly. |
| 50 void _initPolymerOptimized() { | 50 void _initPolymerOptimized() { |
| 51 preventFlashOfUnstyledContent(); | |
| 52 | |
| 53 document.register(PolymerDeclaration._TAG, PolymerDeclaration); | 51 document.register(PolymerDeclaration._TAG, PolymerDeclaration); |
| 54 | 52 |
| 55 _loadLibraries(); | 53 _loadLibraries(); |
| 54 |
| 55 // Run this after user code so they can add to Polymer.veiledElements |
| 56 _preventFlashOfUnstyledContent(); |
| 57 |
| 58 customElementsReady.then((_) => Polymer._ready.complete()); |
| 56 } | 59 } |
| 57 | 60 |
| 58 /** | 61 /** |
| 59 * Configures [initPolymer] making it optimized for deployment to the internet. | 62 * Configures [initPolymer] making it optimized for deployment to the internet. |
| 60 * With this setup the list of libraries to initialize is supplied instead of | 63 * With this setup the list of libraries to initialize is supplied instead of |
| 61 * being dynamically searched for at runtime. Additionally, after this method is | 64 * being dynamically searched for at runtime. Additionally, after this method is |
| 62 * called, [initPolymer] omits the [Zone] that automatically invokes | 65 * called, [initPolymer] omits the [Zone] that automatically invokes |
| 63 * [Observable.dirtyCheck]. | 66 * [Observable.dirtyCheck]. |
| 64 */ | 67 */ |
| 65 void configureForDeployment(List<String> libraries) { | 68 void configureForDeployment(List<String> libraries) { |
| (...skipping 16 matching lines...) Expand all Loading... |
| 82 void _loadLibraries() { | 85 void _loadLibraries() { |
| 83 for (var lib in _librariesToLoad) { | 86 for (var lib in _librariesToLoad) { |
| 84 try { | 87 try { |
| 85 _loadLibrary(lib); | 88 _loadLibrary(lib); |
| 86 } catch (e, s) { | 89 } catch (e, s) { |
| 87 // Deliver errors async, so if a single library fails it doesn't prevent | 90 // Deliver errors async, so if a single library fails it doesn't prevent |
| 88 // other things from loading. | 91 // other things from loading. |
| 89 new Completer().completeError(e, s); | 92 new Completer().completeError(e, s); |
| 90 } | 93 } |
| 91 } | 94 } |
| 92 | |
| 93 customElementsReady.then((_) => Polymer._ready.complete()); | |
| 94 } | 95 } |
| 95 | 96 |
| 96 /** | 97 /** |
| 97 * Walks the HTML import structure to discover all script tags that are | 98 * Walks the HTML import structure to discover all script tags that are |
| 98 * implicitly loaded. This code is only used in Dartium and should only be | 99 * implicitly loaded. This code is only used in Dartium and should only be |
| 99 * called after all HTML imports are resolved. Polymer ensures this by asking | 100 * called after all HTML imports are resolved. Polymer ensures this by asking |
| 100 * users to put their Dart script tags after all HTML imports (this is checked | 101 * users to put their Dart script tags after all HTML imports (this is checked |
| 101 * by the linter, and Dartium will otherwise show an error message). | 102 * by the linter, and Dartium will otherwise show an error message). |
| 102 */ | 103 */ |
| 103 List<String> _discoverScripts(Document doc, String baseUri, | 104 List<String> _discoverScripts(Document doc, String baseUri, |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 255 print("warning: methods marked with @initMethod should take no " | 256 print("warning: methods marked with @initMethod should take no " |
| 256 "arguments, ${method.simpleName} expects some."); | 257 "arguments, ${method.simpleName} expects some."); |
| 257 return; | 258 return; |
| 258 } | 259 } |
| 259 obj.invoke(method.simpleName, const []); | 260 obj.invoke(method.simpleName, const []); |
| 260 } | 261 } |
| 261 | 262 |
| 262 class _InitMethodAnnotation { | 263 class _InitMethodAnnotation { |
| 263 const _InitMethodAnnotation(); | 264 const _InitMethodAnnotation(); |
| 264 } | 265 } |
| OLD | NEW |