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

Unified Diff: sdk/lib/html/html_common/conversions_dartium.dart

Issue 1583773003: Support JS$ prefix for dart and fix bug where _operator_getter and the [] operator were used incons… (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: remove tests to put with matching dart2js tests Created 4 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 | « sdk/lib/html/dartium/html_dartium.dart ('k') | sdk/lib/indexed_db/dartium/indexed_db_dartium.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/html/html_common/conversions_dartium.dart
diff --git a/sdk/lib/html/html_common/conversions_dartium.dart b/sdk/lib/html/html_common/conversions_dartium.dart
index 2403387b4e608e457e43e88cf080c08d76d2b535..3e3e5c10529b126d8d37063ab1ca17b996117080 100644
--- a/sdk/lib/html/html_common/conversions_dartium.dart
+++ b/sdk/lib/html/html_common/conversions_dartium.dart
@@ -126,9 +126,14 @@ wrap_jso(jsObject) {
}
if (jsObject is js.JsArray) {
- var wrappingList = new DartHtmlWrappingList(jsObject);
- js.setDartHtmlWrapperFor(jsObject, wrappingList);
- return wrappingList;
+ wrapper = new js.JSArray.create(jsObject);
+ js.setDartHtmlWrapperFor(jsObject, wrapper);
+ return wrapper;
+ }
+ if (jsObject is js.JsFunction) {
+ wrapper = new js.JSFunction.create(jsObject);
+ js.setDartHtmlWrapperFor(jsObject, wrapper);
+ return wrapper;
}
// Try the most general type conversions on it.
@@ -144,14 +149,15 @@ wrap_jso(jsObject) {
if (constructor == null) {
// Perfectly valid case for JavaScript objects where __proto__ has
// intentionally been set to null.
- js.setDartHtmlWrapperFor(jsObject, jsObject);
+ js.setDartHtmlWrapperFor(jsObject, new js.JSObject.create(jsObject));
return jsObject;
}
var jsTypeName = js.JsNative.getProperty(constructor, 'name');
if (jsTypeName is! String || jsTypeName.length == 0) {
// Not an html type.
- js.setDartHtmlWrapperFor(jsObject, jsObject);
- return jsObject;
+ wrapper = new js.JSObject.create(jsObject);
+ js.setDartHtmlWrapperFor(jsObject, wrapper);
+ return wrapper;
}
var dartClass_instance;
@@ -204,12 +210,11 @@ wrap_jso(jsObject) {
// TODO(jacobr): cache that this is not a dart:html JS class.
return dartClass_instance;
- } catch(e, stacktrace){
+ } catch (e, stacktrace) {
if (interop_checks) {
- if (e is DebugAssertException)
- window.console.log("${e.message}\n ${stacktrace}");
- else
- window.console.log("${stacktrace}");
+ if (e is DebugAssertException) window.console
+ .log("${e.message}\n ${stacktrace}");
+ else window.console.log("${stacktrace}");
}
}
@@ -236,31 +241,30 @@ wrap_jso_no_SerializedScriptvalue(jsObject) {
return wrapper;
}
- // TODO(jacobr): auomatically wrapping JsArray here is fundamentally broken
- // as it hijacks adding custom methods on JS Array classes as part of the
- // new typed DartJsInterop.
- // To make this work we really need to make DartHtmlWrappingList extend
- // JsArrayImpl. Fixing this issue needs to be part of a broader refactor
- // that allows calling custom typed JS interop methods on all dart:html
- // classes.
if (jsObject is js.JsArray) {
- var wrappingList = new DartHtmlWrappingList(jsObject);
- js.setDartHtmlWrapperFor(jsObject, wrappingList);
- return wrappingList;
+ wrapper = new js.JSArray.create(jsObject);
+ js.setDartHtmlWrapperFor(jsObject, wrapper);
+ return wrapper;
+ }
+ if (jsObject is js.JsFunction) {
+ wrapper = new js.JSFunction.create(jsObject);
+ js.setDartHtmlWrapperFor(jsObject, wrapper);
+ return wrapper;
}
var constructor = js.JsNative.getProperty(jsObject, 'constructor');
if (constructor == null) {
// Perfectly valid case for JavaScript objects where __proto__ has
// intentionally been set to null.
- js.setDartHtmlWrapperFor(jsObject, jsObject);
+ js.setDartHtmlWrapperFor(jsObject, new js.JSObject.create(jsObject));
return jsObject;
}
var jsTypeName = js.JsNative.getProperty(constructor, 'name');
if (jsTypeName is! String || jsTypeName.length == 0) {
// Not an html type.
- js.setDartHtmlWrapperFor(jsObject, jsObject);
- return jsObject;
+ wrapper = new js.JSObject.create(jsObject);
+ js.setDartHtmlWrapperFor(jsObject, wrapper);
+ return wrapper;
}
var func = getHtmlCreateFunction(jsTypeName);
@@ -270,13 +274,14 @@ wrap_jso_no_SerializedScriptvalue(jsObject) {
js.setDartHtmlWrapperFor(jsObject, dartClass_instance);
return dartClass_instance;
}
- return jsObject;
- } catch(e, stacktrace){
+ wrapper = new js.JSObject.create(jsObject);
+ js.setDartHtmlWrapperFor(jsObject, wrapper);
+ return wrapper;
+ } catch (e, stacktrace) {
if (interop_checks) {
- if (e is DebugAssertException)
- window.console.log("${e.message}\n ${stacktrace}");
- else
- window.console.log("${stacktrace}");
+ if (e is DebugAssertException) window.console
+ .log("${e.message}\n ${stacktrace}");
+ else window.console.log("${stacktrace}");
}
}
@@ -333,7 +338,7 @@ getCustomElementEntry(element) {
} else if (runtimeType == TemplateElement) {
// Data binding with a Dart class.
tag = element.attributes['is'];
- } else if (runtimeType == js.JsObjectImpl) {
+ } else if (runtimeType == js.JsObject) {
// It's a Polymer core element (written in JS).
// Make sure it's an element anything else we can ignore.
if (element.hasProperty('nodeType') && element['nodeType'] == 1) {
@@ -347,7 +352,8 @@ getCustomElementEntry(element) {
}
}
} else {
- throw new UnsupportedError('Element is incorrect type. Got ${runtimeType}, expected HtmlElement/HtmlTemplate/JsObjectImpl.');
+ throw new UnsupportedError(
+ 'Element is incorrect type. Got ${runtimeType}, expected HtmlElement/HtmlTemplate/JsObject.');
}
var entry = _knownCustomElements[tag];
@@ -378,19 +384,3 @@ Type getCustomElementType(object) {
}
return null;
}
-
-/**
- * Wraps a JsArray and will call wrap_jso on its entries.
- */
-class DartHtmlWrappingList extends ListBase implements NativeFieldWrapperClass2 {
- DartHtmlWrappingList(this.blink_jsObject);
-
- final js.JsArray blink_jsObject;
-
- operator [](int index) => wrap_jso_no_SerializedScriptvalue(js.JsNative.getArrayIndex(blink_jsObject, index));
-
- operator []=(int index, value) => blink_jsObject[index] = value;
-
- int get length => blink_jsObject.length;
- int set length(int newLength) => blink_jsObject.length = newLength;
-}
« no previous file with comments | « sdk/lib/html/dartium/html_dartium.dart ('k') | sdk/lib/indexed_db/dartium/indexed_db_dartium.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698