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

Side by Side Diff: pkg/polymer/lib/src/build/polyfill_injector.dart

Issue 558673004: update polymer js to 0.4.0 (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: review updates Created 6 years, 3 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 /// Includes any additional polyfills that may needed by the deployed app. 5 /// Includes any additional polyfills that may needed by the deployed app.
6 library polymer.src.build.polyfill_injector; 6 library polymer.src.build.polyfill_injector;
7 7
8 import 'dart:async'; 8 import 'dart:async';
9 9
10 import 'package:barback/barback.dart'; 10 import 'package:barback/barback.dart';
(...skipping 19 matching lines...) Expand all
30 Future<bool> isPrimary(idOrAsset) { 30 Future<bool> isPrimary(idOrAsset) {
31 var id = idOrAsset is AssetId ? idOrAsset : idOrAsset.id; 31 var id = idOrAsset is AssetId ? idOrAsset : idOrAsset.id;
32 return new Future.value(options.isHtmlEntryPoint(id)); 32 return new Future.value(options.isHtmlEntryPoint(id));
33 } 33 }
34 34
35 Future apply(Transform transform) { 35 Future apply(Transform transform) {
36 var logger = new BuildLogger(transform, 36 var logger = new BuildLogger(transform,
37 convertErrorsToWarnings: !options.releaseMode, 37 convertErrorsToWarnings: !options.releaseMode,
38 detailsUri: 'http://goo.gl/5HPeuP'); 38 detailsUri: 'http://goo.gl/5HPeuP');
39 return readPrimaryAsHtml(transform, logger).then((document) { 39 return readPrimaryAsHtml(transform, logger).then((document) {
40 bool webComponentsFound = false; 40 bool dartSupportFound = false;
41 bool platformJsFound = false;
41 Element dartJs; 42 Element dartJs;
42 final dartScripts = <Element>[]; 43 final dartScripts = <Element>[];
43 44
44 for (var tag in document.querySelectorAll('script')) { 45 for (var tag in document.querySelectorAll('script')) {
45 var src = tag.attributes['src']; 46 var src = tag.attributes['src'];
46 if (src != null) { 47 if (src != null) {
47 var last = src.split('/').last; 48 var last = src.split('/').last;
48 if (_webComponentsJS.hasMatch(last)) { 49 if (_platformJS.hasMatch(last)) {
49 webComponentsFound = true; 50 platformJsFound = true;
51 } else if (_dartSupportJS.hasMatch(last)) {
52 dartSupportFound = true;
50 } else if (last == 'dart.js') { 53 } else if (last == 'dart.js') {
51 dartJs = tag; 54 dartJs = tag;
52 } 55 }
53 } 56 }
54 57
55 if (tag.attributes['type'] == 'application/dart') { 58 if (tag.attributes['type'] == 'application/dart') {
56 dartScripts.add(tag); 59 dartScripts.add(tag);
57 } 60 }
58 } 61 }
59 62
(...skipping 28 matching lines...) Expand all
88 document.body.nodes.add(parseFragment( 91 document.body.nodes.add(parseFragment(
89 '<script src="packages/browser/dart.js"></script>')); 92 '<script src="packages/browser/dart.js"></script>'));
90 } 93 }
91 94
92 _addScriptFirst(urlSegment) { 95 _addScriptFirst(urlSegment) {
93 document.head.nodes.insert(0, parseFragment( 96 document.head.nodes.insert(0, parseFragment(
94 '<script src="packages/$urlSegment"></script>\n')); 97 '<script src="packages/$urlSegment"></script>\n'));
95 } 98 }
96 99
97 var suffix = options.releaseMode ? '.js' : '.concat.js'; 100 var suffix = options.releaseMode ? '.js' : '.concat.js';
98 if (!webComponentsFound) { 101 if (!dartSupportFound) _addScriptFirst('web_components/dart_support.js');
99 _addScriptFirst('web_components/dart_support.js'); 102 // platform.js should come before all other scripts.
100 103 if (!platformJsFound) _addScriptFirst('web_components/platform$suffix');
101 // platform.js should come before all other scripts.
102 _addScriptFirst('web_components/platform$suffix');
103 }
104 104
105 transform.addOutput( 105 transform.addOutput(
106 new Asset.fromString(transform.primaryInput.id, document.outerHtml)); 106 new Asset.fromString(transform.primaryInput.id, document.outerHtml));
107 }); 107 });
108 } 108 }
109 } 109 }
110 110
111 final _webComponentsJS = new RegExp(r'platform.*\.js', 111 final _platformJS = new RegExp(r'platform.*\.js', caseSensitive: false);
112 caseSensitive: false); 112 final _dartSupportJS = new RegExp(r'dart_support.js', caseSensitive: false);
OLDNEW
« no previous file with comments | « pkg/polymer/example/component/news/test/news_index_test.html ('k') | pkg/polymer/lib/src/declaration.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698