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

Unified Diff: pkg/dev_compiler/lib/src/compiler/code_generator.dart

Issue 2659063002: Fix DOM constructors in inline JS (Closed)
Patch Set: Created 3 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/dev_compiler/lib/js/legacy/dart_sdk.js ('k') | pkg/dev_compiler/test/browser/language_tests.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/dev_compiler/lib/src/compiler/code_generator.dart
diff --git a/pkg/dev_compiler/lib/src/compiler/code_generator.dart b/pkg/dev_compiler/lib/src/compiler/code_generator.dart
index 79ac857a76947ee40b01748cc93354bdf5504444..a2f52eeef7550a3c3ef52b02a380889058a11d7f 100644
--- a/pkg/dev_compiler/lib/src/compiler/code_generator.dart
+++ b/pkg/dev_compiler/lib/src/compiler/code_generator.dart
@@ -3707,7 +3707,7 @@ class CodeGenerator extends GeneralizingAstVisitor
// arg[0] is static return type, used in `RestrictedStaticTypeAnalyzer`
var code = args[1];
List<AstNode> templateArgs;
- var source;
+ String source;
if (code is StringInterpolation) {
if (args.length > 2) {
throw new ArgumentError(
@@ -3727,6 +3727,15 @@ class CodeGenerator extends GeneralizingAstVisitor
source = (code as StringLiteral).stringValue;
}
+ // TODO(vsm): Constructors in dart:html and friends are trying to
+ // allocate a type defined on window/self, but this often conflicts a
+ // with a generated class in scope. We really should qualify explicitly
+ // in dart:html itself.
Jacob 2017/01/27 16:10:31 Alternately, only apply this rename if there is a
+ var constructorPattern = new RegExp("new [A-Z][A-Za-z]+\\(");
+ if (constructorPattern.matchAsPrefix(source) != null) {
+ source = source.replaceFirst('new ', 'new self.');
+ }
+
// TODO(rnystrom): The JS() calls are almost never nested, and probably
// really shouldn't be, but there are at least a couple of calls in the
// HTML library where an argument to JS() is itself a JS() call. If those
« no previous file with comments | « pkg/dev_compiler/lib/js/legacy/dart_sdk.js ('k') | pkg/dev_compiler/test/browser/language_tests.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698