Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(119)

Unified Diff: pkg/web_components/lib/polyfill.dart

Issue 158083002: introduce web_components pkg for consolidated polyfills (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 68%
rename from pkg/custom_element/lib/polyfill.dart
rename to pkg/web_components/lib/polyfill.dart
index 413d7d699a04f0e2acb736234d887a811520642e..36b1756a524099e3a16f6f8600ddd3a1d1b07f3a 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,13 @@ 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]).
- *
- * 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.
+ * Pump custom events polyfill events. This can be used to trigger
+ * evaluation of pending lifecycle events, which otherwise need to wait for a
+ * [MutationObserver] to signal the changes in the polyfill.
*/
-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() {
blois 2014/02/08 01:37:02 This should only really be used by unittests, woul
Jennifer Messerly 2014/02/10 22:17:11 Just checking: it's not possible an application co
+ var customElements = js.context['CustomElements'];
+ if (customElements != null) {
+ customElements.callMethod('takeRecords');
}
- return new Future.value();
}

Powered by Google App Engine
This is Rietveld 408576698