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

Unified Diff: pkg/custom_element/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
« no previous file with comments | « pkg/custom_element/lib/custom-elements.min.js ('k') | pkg/custom_element/pubspec.yaml » ('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
deleted file mode 100644
index 413d7d699a04f0e2acb736234d887a811520642e..0000000000000000000000000000000000000000
--- a/pkg/custom_element/lib/polyfill.dart
+++ /dev/null
@@ -1,63 +0,0 @@
-// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// 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;
-
-import 'dart:async';
-import 'dart:html';
-import 'dart:js' as js;
-
-/**
- * A future that completes once all custom elements in the initial HTML page
- * have been upgraded.
- *
- * This is needed because the native implementation can update the elements
- * while parsing the HTML document, but the custom element polyfill cannot,
- * so it completes this future once all elements are upgraded.
- */
-Future customElementsReady = () {
- if (_isReady) return new Future.value();
-
- // Not upgraded. Wait for the polyfill to fire the WebComponentsReady event.
- // Note: we listen on document (not on document.body) to allow this polyfill
- // to be loaded in the HEAD element.
- return document.on['WebComponentsReady'].first;
-}();
-
-// Return true if we are using the polyfill and upgrade is complete, or if we
-// have native document.register and therefore the browser took care of it.
-// Otherwise return false, including the case where we can't find the polyfill.
-bool get _isReady {
- // If we don't have dart:js, assume things are ready
- if (js.context == null) return true;
-
- var customElements = js.context['CustomElements'];
- if (customElements == null) {
- // Return true if native document.register, otherwise false.
- // (Maybe the polyfill isn't loaded yet. Wait for it.)
- return document.supportsRegister;
- }
-
- 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 | « pkg/custom_element/lib/custom-elements.min.js ('k') | pkg/custom_element/pubspec.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698