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

Unified Diff: sdk/lib/html/dart2js/html_dart2js.dart

Issue 27308006: Supporting non-SSVs in CustomEvent.detail (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 2 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:
Download patch
« no previous file with comments | « no previous file | sdk/lib/html/dartium/html_dartium.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/html/dart2js/html_dart2js.dart
diff --git a/sdk/lib/html/dart2js/html_dart2js.dart b/sdk/lib/html/dart2js/html_dart2js.dart
index cb0a75fa930f23dfdbed39bb716261970ab31982..fca06efd7d6e6561289987b7db243e75fc223a00 100644
--- a/sdk/lib/html/dart2js/html_dart2js.dart
+++ b/sdk/lib/html/dart2js/html_dart2js.dart
@@ -6379,27 +6379,51 @@ class CssViewportRule extends CssRule native "CSSViewportRule" {
@DomName('CustomEvent')
class CustomEvent extends Event native "CustomEvent" {
+ @Creates('Null') // Set from Dart code; does not instantiate a native type.
+ var _dartDetail;
+
factory CustomEvent(String type,
{bool canBubble: true, bool cancelable: true, Object detail}) {
final CustomEvent e = document._createEvent('CustomEvent');
- detail = convertDartToNative_SerializedScriptValue(detail);
- e._initCustomEvent(type, canBubble, cancelable, detail);
+ e._dartDetail = detail;
vsm 2013/10/16 21:25:34 You might run this past Stephen. If a CustomEvent
+
+ // Only try setting the detail if it's one of these types to avoid
+ // first-chance exceptions. Can expand this list in the future as needed.
+ if (detail is List || detail is Map || detail is String || detail is num) {
+ try {
+ detail = convertDartToNative_SerializedScriptValue(detail);
+ e._initCustomEvent(type, canBubble, cancelable, detail);
+ } catch(_) {
+ e._initCustomEvent(type, canBubble, cancelable, null);
+ }
+ } else {
+ e._initCustomEvent(type, canBubble, cancelable, null);
+ }
return e;
}
+
+ @DomName('CustomEvent.detail')
+ get detail {
+ if (_dartDetail != null) {
+ return _dartDetail;
+ }
+ return _detail;
+ }
// To suppress missing implicit constructor warnings.
factory CustomEvent._() { throw new UnsupportedError("Not supported"); }
- @DomName('CustomEvent.detail')
+ @DomName('CustomEvent._detail')
@DocsEditable()
- dynamic get detail => convertNativeToDart_SerializedScriptValue(this._get_detail);
+ @Experimental() // untriaged
+ dynamic get _detail => convertNativeToDart_SerializedScriptValue(this._get__detail);
@JSName('detail')
- @DomName('CustomEvent.detail')
+ @DomName('CustomEvent._detail')
@DocsEditable()
- @Creates('Null')
sra1 2013/10/17 03:33:27 This annotation appears to have gone missing
- final dynamic _get_detail;
+ @Experimental() // untriaged
+ final dynamic _get__detail;
@JSName('initCustomEvent')
@DomName('CustomEvent.initCustomEvent')
« no previous file with comments | « no previous file | sdk/lib/html/dartium/html_dartium.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698