OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 /// Provides support for associating a Dart type for Javascript Custom Elements. | 5 /// Provides support for associating a Dart type for Javascript Custom Elements. |
6 /// This will not work unless `dart_support.js` is loaded. | 6 /// This will not work unless `dart_support.js` is loaded. |
7 library web_components.interop; | 7 library web_components.interop; |
8 | 8 |
9 import 'dart:async' show Stream, StreamController; | 9 import 'dart:async' show Stream, StreamController; |
10 import 'dart:html' show document, Element; | 10 import 'dart:html' show document, Element; |
(...skipping 13 matching lines...) Expand all Loading... |
24 throw new UnsupportedError("Couldn't find " | 24 throw new UnsupportedError("Couldn't find " |
25 "`document._registerDartTypeUpgrader`. Please make sure that " | 25 "`document._registerDartTypeUpgrader`. Please make sure that " |
26 "`packages/web_components/dart_support.js` is loaded and available " | 26 "`packages/web_components/dart_support.js` is loaded and available " |
27 "before calling this function."); | 27 "before calling this function."); |
28 } | 28 } |
29 | 29 |
30 var upgrader = document.createElementUpgrader( | 30 var upgrader = document.createElementUpgrader( |
31 dartType, extendsTag: extendsTag); | 31 dartType, extendsTag: extendsTag); |
32 _doc.callMethod('_registerDartTypeUpgrader', [tagName, upgrader.upgrade]); | 32 _doc.callMethod('_registerDartTypeUpgrader', [tagName, upgrader.upgrade]); |
33 } | 33 } |
| 34 |
| 35 /// This function is mainly used to save resources. By default, we save a log of |
| 36 /// elements that are created but have no Dart type associated with them. This |
| 37 /// is so we can upgrade them as soon as [registerDartType] is invoked. This |
| 38 /// function can be called to indicate that we no longer are interested in |
| 39 /// logging element creations and that it is sufficient to only upgrade new |
| 40 /// elements as they are being created. Typically this is called after the last |
| 41 /// call to [registerDartType] or as soon as you know that no element will be |
| 42 /// created until the call to [registerDartType] is made. |
| 43 void onlyUpgradeNewElements() => _doc.callMethod('_onlyUpgradeNewElements'); |
OLD | NEW |