Skip to content

Commit

Permalink
Merge pull request #192 from devoncarew/devoncarew_change_transformers
Browse files Browse the repository at this point in the history
csp loses the precompiled name
  • Loading branch information
devoncarew committed Aug 28, 2014
2 parents 5af8dda + 7987a02 commit 3df6f1d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions lib/bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
for (var i = 0; i < scripts.length; ++i) {
if (scripts[i].type == "application/dart" && scripts[i].src && scripts[i].src != '') {
var script = document.createElement('script');
script.src = scripts[i].src.replace(/\.dart$/, '.dart.precompiled.js');
script.src = scripts[i].src.replace(/\.dart$/, '.dart.js');
document.currentScript = script;
scripts[i].parentNode.replaceChild(script, scripts[i]);
} else if (scripts[i].src.indexOf('.dart.js') == scripts[i].src.length - 8) {
var script = document.createElement('script');
script.src = scripts[i].src.replace(/\.dart\.js$/, '.dart.precompiled.js');
script.src = scripts[i].src.replace(/\.dart\.js$/, '.dart.js');
document.currentScript = script;
scripts[i].parentNode.replaceChild(script, scripts[i]);
}
Expand Down
6 changes: 3 additions & 3 deletions lib/transformer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -43,21 +43,21 @@ class ChromeTransformer extends Transformer {
* Change:
* <script src="demo.dart" type="application/dart"></script>
* to:
* <script src="demo.dart.precompiled.js"></script>
* <script src="demo.dart.js"></script>
*/
String rewriteContent(String content) {
Iterable<Match> matches = _regex1.allMatches(content).toList().reversed;

for (Match match in matches) {
String newScript ='<script src="${match.group(1)}.precompiled.js"></script>';
String newScript ='<script src="${match.group(1)}.js"></script>';
content = content.substring(0, match.start)
+ newScript + content.substring(match.end);
}

matches = _regex2.allMatches(content).toList().reversed;

for (Match match in matches) {
String newScript ='<script src="${match.group(1)}.precompiled.js"></script>';
String newScript ='<script src="${match.group(1)}.js"></script>';
content = content.substring(0, match.start)
+ newScript + content.substring(match.end);
}
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: chrome
version: 0.6.1-dev
version: 0.6.1
environment:
sdk: ">=1.0.0 <2.0.0"
authors:
Expand Down

0 comments on commit 3df6f1d

Please sign in to comment.