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

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: fixes 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. For example, this transformer will ensure that there is a 17 /// are included. For example, this transformer will ensure that there is a
18 /// script tag that loads the polyfills and interop.js (used for css shimming). 18 /// script tag that loads the polyfills and interop.js (used for css shimming).
19 /// 19 ///
20 /// This step also replaces "packages/browser/dart.js" and the Dart script tag 20 /// This step also replaces "packages/browser/dart.js" and the Dart script tag
21 /// with a script tag that loads the dart2js compiled code directly. 21 /// with a script tag that loads the dart2js compiled code directly.
22 class PolyfillInjector extends Transformer with PolymerTransformer { 22 class PolyfillInjector extends Transformer with PolymerTransformer {
23 final TransformOptions options; 23 final TransformOptions options;
24 24
25 PolyfillInjector(this.options); 25 PolyfillInjector(this.options);
26 26
27 /// Only run on entry point .html files. 27 /// Only run on entry point .html files.
28 Future<bool> isPrimary(Asset input) => 28 Future<bool> isPrimary(AssetId id) =>
29 new Future.value(options.isHtmlEntryPoint(input.id)); 29 new Future.value(options.isHtmlEntryPoint(id));
30 30
31 Future apply(Transform transform) { 31 Future apply(Transform transform) {
32 return readPrimaryAsHtml(transform).then((document) { 32 return readPrimaryAsHtml(transform).then((document) {
33 bool webComponentsFound = false; 33 bool webComponentsFound = false;
34 bool jsInteropFound = false; 34 bool jsInteropFound = false;
35 Element dartJs; 35 Element dartJs;
36 final dartScripts = <Element>[]; 36 final dartScripts = <Element>[];
37 37
38 for (var tag in document.querySelectorAll('script')) { 38 for (var tag in document.querySelectorAll('script')) {
39 var src = tag.attributes['src']; 39 var src = tag.attributes['src'];
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 } 100 }
101 101
102 transform.addOutput( 102 transform.addOutput(
103 new Asset.fromString(transform.primaryInput.id, document.outerHtml)); 103 new Asset.fromString(transform.primaryInput.id, document.outerHtml));
104 }); 104 });
105 } 105 }
106 } 106 }
107 107
108 final _webComponentsJS = new RegExp(r'platform.*\.js', 108 final _webComponentsJS = new RegExp(r'platform.*\.js',
109 caseSensitive: false); 109 caseSensitive: false);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698