| Index: pkg/web_components/lib/polyfill.dart
|
| diff --git a/pkg/custom_element/lib/polyfill.dart b/pkg/web_components/lib/polyfill.dart
|
| similarity index 69%
|
| rename from pkg/custom_element/lib/polyfill.dart
|
| rename to pkg/web_components/lib/polyfill.dart
|
| index 413d7d699a04f0e2acb736234d887a811520642e..a141c4d60860ca170e31a6e0c140e83bca5a85de 100644
|
| --- a/pkg/custom_element/lib/polyfill.dart
|
| +++ b/pkg/web_components/lib/polyfill.dart
|
| @@ -3,7 +3,7 @@
|
| // BSD-style license that can be found in the LICENSE file.
|
|
|
| /** Dart APIs for interacting with the JavaScript Custom Elements polyfill. */
|
| -library custom_element.polyfill;
|
| +library web_components.polyfill;
|
|
|
| import 'dart:async';
|
| import 'dart:html';
|
| @@ -17,6 +17,7 @@ import 'dart:js' as js;
|
| * while parsing the HTML document, but the custom element polyfill cannot,
|
| * so it completes this future once all elements are upgraded.
|
| */
|
| +// TODO(jmesserly): rename to webComponentsReady to match the event?
|
| Future customElementsReady = () {
|
| if (_isReady) return new Future.value();
|
|
|
| @@ -44,20 +45,18 @@ bool get _isReady {
|
| }
|
|
|
| /**
|
| - * Loads `custom-elements.debug.js` or `custom-elements.min.js` by adding the
|
| - * script tag to the page. Returns a future that completes when custom elements
|
| - * are ready (equivalent to [customElementsReady]).
|
| + * *Note* this API is primarily intended for tests. In other code it is better
|
| + * to write it in a style that works with or without the polyfill, rather than
|
| + * using this method.
|
| *
|
| - * Normally you should add this to your HTML file
|
| - * (the Polymer package will do this automatically), but loading dynamically
|
| - * can be useful for scenarios such as tests.
|
| + * Synchronously trigger evaluation of pending lifecycle events, which otherwise
|
| + * need to wait for a [MutationObserver] to signal the changes in the polyfill.
|
| + * This method can be used to resolve differences in timing between native and
|
| + * polyfilled custom elements.
|
| */
|
| -Future loadCustomElementPolyfill() {
|
| - if (!document.supportsRegister && !js.context.hasProperty('CustomElements')) {
|
| - var script = new ScriptElement()
|
| - ..src = '/packages/custom_element/custom-elements.debug.js';
|
| - document.head.append(script);
|
| - return document.on['WebComponentsReady'].first;
|
| +void customElementsTakeRecords() {
|
| + var customElements = js.context['CustomElements'];
|
| + if (customElements != null) {
|
| + customElements.callMethod('takeRecords');
|
| }
|
| - return new Future.value();
|
| }
|
|
|