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

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

Issue 223553008: Only pass an AssetId to isPrimary and declareOutputs. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: fix script_compactor Created 6 years, 8 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';
11 import 'package:html5lib/dom.dart' show 11 import 'package:html5lib/dom.dart' show
12 Document, DocumentFragment, Element, Node; 12 Document, DocumentFragment, Element, Node;
13 import 'package:html5lib/parser.dart' show parseFragment; 13 import 'package:html5lib/parser.dart' show parseFragment;
14 import 'common.dart'; 14 import 'common.dart';
15 15
16 /// Ensures that any scripts and polyfills needed to run a polymer application 16 /// Ensures that any scripts and polyfills needed to run a polymer application
17 /// are included. 17 /// are included.
18 /// 18 ///
19 /// This step also replaces "packages/browser/dart.js" and the Dart script tag 19 /// This step also replaces "packages/browser/dart.js" and the Dart script tag
20 /// with a script tag that loads the dart2js compiled code directly. 20 /// with a script tag that loads the dart2js compiled code directly.
21 class PolyfillInjector extends Transformer with PolymerTransformer { 21 class PolyfillInjector extends Transformer with PolymerTransformer {
22 final TransformOptions options; 22 final TransformOptions options;
23 23
24 PolyfillInjector(this.options); 24 PolyfillInjector(this.options);
25 25
26 /// Only run on entry point .html files. 26 /// Only run on entry point .html files.
27 Future<bool> isPrimary(Asset input) => 27 // TODO(nweiz): This should just take an AssetId when barback <0.13.0 support
28 new Future.value(options.isHtmlEntryPoint(input.id)); 28 // is dropped.
29 Future<bool> isPrimary(idOrAsset) {
30 var id = idOrAsset is AssetId ? idOrAsset : idOrAsset.id;
31 return new Future.value(options.isHtmlEntryPoint(id));
32 }
29 33
30 Future apply(Transform transform) { 34 Future apply(Transform transform) {
31 return readPrimaryAsHtml(transform).then((document) { 35 return readPrimaryAsHtml(transform).then((document) {
32 bool webComponentsFound = false; 36 bool webComponentsFound = false;
33 Element dartJs; 37 Element dartJs;
34 final dartScripts = <Element>[]; 38 final dartScripts = <Element>[];
35 39
36 for (var tag in document.querySelectorAll('script')) { 40 for (var tag in document.querySelectorAll('script')) {
37 var src = tag.attributes['src']; 41 var src = tag.attributes['src'];
38 if (src != null) { 42 if (src != null) {
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 } 97 }
94 98
95 transform.addOutput( 99 transform.addOutput(
96 new Asset.fromString(transform.primaryInput.id, document.outerHtml)); 100 new Asset.fromString(transform.primaryInput.id, document.outerHtml));
97 }); 101 });
98 } 102 }
99 } 103 }
100 104
101 final _webComponentsJS = new RegExp(r'platform.*\.js', 105 final _webComponentsJS = new RegExp(r'platform.*\.js',
102 caseSensitive: false); 106 caseSensitive: false);
OLDNEW
« no previous file with comments | « pkg/polymer/lib/src/build/mirrors_remover.dart ('k') | pkg/polymer/lib/src/build/script_compactor.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698