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

Unified Diff: sdk/lib/html/dartium/html_dartium.dart

Side-by-side diff isn't available for this file because of its large size.
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
Index: sdk/lib/html/dartium/html_dartium.dart
diff --git a/sdk/lib/html/dartium/html_dartium.dart b/sdk/lib/html/dartium/html_dartium.dart
index 5547397958885d01c71a201e44eef4d18a389458..8b50c3aa50fd512643af32337e2f5c42bb5eca6f 100644
--- a/sdk/lib/html/dartium/html_dartium.dart
+++ b/sdk/lib/html/dartium/html_dartium.dart
@@ -6938,21 +6938,43 @@ class CssViewportRule extends CssRule {
@DomName('CustomEvent')
class CustomEvent extends Event {
+ var _dartDetail;
+
factory CustomEvent(String type,
{bool canBubble: true, bool cancelable: true, Object detail}) {
final CustomEvent e = document._createEvent('CustomEvent');
- e._initCustomEvent(type, canBubble, cancelable, detail);
+ e._dartDetail = detail;
+
+ // 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 {
+ 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')
@DocsEditable()
- Object get detail native "CustomEvent_detail_Getter";
+ Object get _detail native "CustomEvent_detail_Getter";
@DomName('CustomEvent.initCustomEvent')
@DocsEditable()

Powered by Google App Engine
This is Rietveld 408576698