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

Unified Diff: pkg/polymer/lib/src/build/polyfill_injector.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/polymer/lib/src/build/linter.dart ('k') | pkg/polymer/lib/src/build/runner.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/polymer/lib/src/build/polyfill_injector.dart
diff --git a/pkg/polymer/lib/src/build/polyfill_injector.dart b/pkg/polymer/lib/src/build/polyfill_injector.dart
index fefc14821ddb932b6a9e173d5f53b92311318ca0..02b9fd1fa7ca0777d41ef2251939b2e7f3c4ca87 100644
--- a/pkg/polymer/lib/src/build/polyfill_injector.dart
+++ b/pkg/polymer/lib/src/build/polyfill_injector.dart
@@ -16,8 +16,7 @@ import 'common.dart';
/**
* Ensures that any scripts and polyfills needed to run a polymer application
* are included. For example, this transformer will ensure that there is a
- * script tag that loads the shadow_dom polyfill and interop.js (used for the
- * css shimming).
+ * script tag that loads the polyfills and interop.js (used for css shimming).
*
* This step also replaces "packages/browser/dart.js" and the Dart script tag
* with a script tag that loads the dart2js compiled code directly.
@@ -33,22 +32,19 @@ class PolyfillInjector extends Transformer with PolymerTransformer {
Future apply(Transform transform) {
return readPrimaryAsHtml(transform).then((document) {
- bool shadowDomFound = false;
+ bool webComponentsFound = false;
bool jsInteropFound = false;
- bool customElementFound = false;
Element dartJs;
final dartScripts = <Element>[];
- for (var tag in document.queryAll('script')) {
+ for (var tag in document.querySelectorAll('script')) {
var src = tag.attributes['src'];
if (src != null) {
var last = src.split('/').last;
if (last == 'interop.js') {
jsInteropFound = true;
- } else if (_shadowDomJS.hasMatch(last)) {
- shadowDomFound = true;
- } else if (_customElementJS.hasMatch(last)) {
- customElementFound = true;
+ } else if (_webComponentsJS.hasMatch(last)) {
+ webComponentsFound = true;
} else if (last == 'dart.js') {
dartJs = tag;
}
@@ -89,24 +85,21 @@ class PolyfillInjector extends Transformer with PolymerTransformer {
'<script src="packages/browser/dart.js"></script>'));
}
- _addScript(urlSegment) {
+ _addScriptFirst(urlSegment) {
document.head.nodes.insert(0, parseFragment(
'<script src="packages/$urlSegment"></script>\n'));
}
// JS interop code is required for Polymer CSS shimming.
- if (!jsInteropFound) _addScript('browser/interop.js');
-
- // TODO(sigmund): enable using .min.js. This currently fails in checked
- // mode because of bugs in dart2js mirrors (dartbug.com/14720).
- // var suffix = options.releaseMode ? '.min.js' : '.debug.js';
- var suffix = '.debug.js';
- if (!customElementFound) {
- _addScript('custom_element/custom-elements$suffix');
- }
+ if (!jsInteropFound) _addScriptFirst('browser/interop.js');
+
+ var suffix = options.releaseMode ? '.js' : '.concat.js';
+ if (!webComponentsFound) {
+ _addScriptFirst('web_components/dart_support.js');
- // This polyfill needs to be the first one on the head
- if (!shadowDomFound) _addScript('shadow_dom/shadow_dom$suffix');
+ // platform.js should come before all other scripts.
+ _addScriptFirst('web_components/platform$suffix');
+ }
transform.addOutput(
new Asset.fromString(transform.primaryInput.id, document.outerHtml));
@@ -114,6 +107,5 @@ class PolyfillInjector extends Transformer with PolymerTransformer {
}
}
-final _shadowDomJS = new RegExp(r'shadow_dom\..*\.js', caseSensitive: false);
-final _customElementJS = new RegExp(r'custom-elements\..*\.js',
+final _webComponentsJS = new RegExp(r'platform.*\.js',
caseSensitive: false);
« no previous file with comments | « pkg/polymer/lib/src/build/linter.dart ('k') | pkg/polymer/lib/src/build/runner.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698