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

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

Issue 25740006: port polymer data binding tests (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 2 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
« no previous file with comments | « no previous file | pkg/pkg.status » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/custom_element/lib/polyfill.dart
diff --git a/pkg/custom_element/lib/polyfill.dart b/pkg/custom_element/lib/polyfill.dart
index 94c4e8b6cb33b06ef28022c4d652e0114635ddc7..413d7d699a04f0e2acb736234d887a811520642e 100644
--- a/pkg/custom_element/lib/polyfill.dart
+++ b/pkg/custom_element/lib/polyfill.dart
@@ -42,3 +42,22 @@ bool get _isReady {
return customElements['ready'] == true;
}
+
+/**
+ * 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.
+ */
+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;
+ }
+ return new Future.value();
+}
« no previous file with comments | « no previous file | pkg/pkg.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698