OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 library web_components.src.init; | 4 library web_components.src.init; |
5 | 5 |
6 import 'dart:async'; | 6 import 'dart:async'; |
7 import 'package:initialize/initialize.dart' show InitializerFilter; | 7 import 'package:initialize/initialize.dart' show InitializerFilter; |
8 import 'package:web_components/web_components.dart'; | 8 import 'package:web_components/web_components.dart'; |
9 import 'mirror_initializer.dart' as init; | 9 import 'mirror_initializer.dart' as init; |
10 export 'mirror_initializer.dart' show deployMode; | 10 export 'mirror_initializer.dart' show deployMode; |
11 | 11 |
12 /// Performs html import aware initialization by crawling all imported documents | 12 /// Performs html import aware initialization by crawling all imported documents |
13 /// and initializing any script tags which appear in them. | 13 /// and initializing any script tags which appear in them. |
14 /// | 14 /// |
15 /// By default, this will run all [HtmlImport] initializers, followed in a 2nd | 15 /// By default, this will run all [HtmlImport] initializers, followed in a 2nd |
16 /// phase by all [CustomElement] and [CustomElementProxy] initializers. Then, | 16 /// phase by all [CustomElement] and [CustomElementProxy] initializers. Then, |
17 /// unless [initAll] is [false], it will run all remaining initializers. | 17 /// unless [initAll] is [false], it will run all remaining initializers. |
18 /// | 18 /// |
19 /// If a [typeFilter] or [customFilter] are supplied, only one phase is ran | 19 /// If a [typeFilter] or [customFilter] are supplied, only one phase is ran |
20 /// with the supplied filters. | 20 /// with the supplied filters. |
21 Future initWebComponents({List<Type> typeFilter, InitializerFilter customFilter, | 21 Future initWebComponents({List<Type> typeFilter, InitializerFilter customFilter, |
22 bool initAll: true}) { | 22 bool initAll: true}) { |
23 if (typeFilter != null || customFilter != null) { | 23 if (typeFilter != null || customFilter != null) { |
24 return init.run(typeFilter: typeFilter, customFilter: customFilter); | 24 return init.run(typeFilter: typeFilter, customFilter: customFilter); |
25 } else { | 25 } else { |
26 return init.run(typeFilter: [HtmlImport]) | 26 return init |
27 .then((_) => init.run(typeFilter: [CustomElement, CustomElementProxy])) | 27 .run(typeFilter: [HtmlImport]) |
28 .then((_) => initAll ? init.run() : null); | 28 .then((_) => init.run(typeFilter: [CustomElement, CustomElementProxy])) |
| 29 .then((_) => initAll ? init.run() : null); |
29 } | 30 } |
30 } | 31 } |
OLD | NEW |