OLD | NEW |
---|---|
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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
71 if (options.directlyIncludeJS) { | 71 if (options.directlyIncludeJS) { |
72 // If using CSP add the "precompiled" extension | 72 // If using CSP add the "precompiled" extension |
73 final csp = options.contentSecurityPolicy ? '.precompiled' : ''; | 73 final csp = options.contentSecurityPolicy ? '.precompiled' : ''; |
74 | 74 |
75 // Replace all other Dart script tags with JavaScript versions. | 75 // Replace all other Dart script tags with JavaScript versions. |
76 for (var script in dartScripts) { | 76 for (var script in dartScripts) { |
77 final src = script.attributes['src']; | 77 final src = script.attributes['src']; |
78 if (src.endsWith('.dart')) { | 78 if (src.endsWith('.dart')) { |
79 script.attributes.remove('type'); | 79 script.attributes.remove('type'); |
80 script.attributes['src'] = '$src$csp.js'; | 80 script.attributes['src'] = '$src$csp.js'; |
81 // TODO(sigmund): remove async (workaround for dartbug.com/19653). | |
Jennifer Messerly
2014/06/26 19:17:54
at first glance I was confused by this comment bec
Siggi Cherem (dart-lang)
2014/06/26 20:00:52
ha ha, I normally write TODOs as the action that n
| |
82 script.attributes['async'] = ''; | |
81 } | 83 } |
82 } | 84 } |
83 } else { | 85 } else { |
84 document.body.nodes.add(parseFragment( | 86 document.body.nodes.add(parseFragment( |
85 '<script src="packages/browser/dart.js"></script>')); | 87 '<script src="packages/browser/dart.js"></script>')); |
86 } | 88 } |
87 | 89 |
88 _addScriptFirst(urlSegment) { | 90 _addScriptFirst(urlSegment) { |
89 document.head.nodes.insert(0, parseFragment( | 91 document.head.nodes.insert(0, parseFragment( |
90 '<script src="packages/$urlSegment"></script>\n')); | 92 '<script src="packages/$urlSegment"></script>\n')); |
91 } | 93 } |
92 | 94 |
93 var suffix = options.releaseMode ? '.js' : '.concat.js'; | 95 var suffix = options.releaseMode ? '.js' : '.concat.js'; |
94 if (!webComponentsFound) { | 96 if (!webComponentsFound) { |
95 _addScriptFirst('web_components/dart_support.js'); | 97 _addScriptFirst('web_components/dart_support.js'); |
96 | 98 |
97 // platform.js should come before all other scripts. | 99 // platform.js should come before all other scripts. |
98 _addScriptFirst('web_components/platform$suffix'); | 100 _addScriptFirst('web_components/platform$suffix'); |
99 } | 101 } |
100 | 102 |
101 transform.addOutput( | 103 transform.addOutput( |
102 new Asset.fromString(transform.primaryInput.id, document.outerHtml)); | 104 new Asset.fromString(transform.primaryInput.id, document.outerHtml)); |
103 }); | 105 }); |
104 } | 106 } |
105 } | 107 } |
106 | 108 |
107 final _webComponentsJS = new RegExp(r'platform.*\.js', | 109 final _webComponentsJS = new RegExp(r'platform.*\.js', |
108 caseSensitive: false); | 110 caseSensitive: false); |
OLD | NEW |