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

Unified Diff: tools/dom/templates/html/impl/impl_CustomEvent.darttemplate

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:
View side-by-side diff with in-line comments
Download patch
« sdk/lib/html/dart2js/html_dart2js.dart ('K') | « tools/dom/scripts/htmlrenamer.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/dom/templates/html/impl/impl_CustomEvent.darttemplate
diff --git a/tools/dom/templates/html/impl/impl_CustomEvent.darttemplate b/tools/dom/templates/html/impl/impl_CustomEvent.darttemplate
index 79dd406141722b6004ea441dc14dea64f5b1dcb0..01197ca86bcd33343f1f307e8255f098283ac082 100644
--- a/tools/dom/templates/html/impl/impl_CustomEvent.darttemplate
+++ b/tools/dom/templates/html/impl/impl_CustomEvent.darttemplate
@@ -7,17 +7,42 @@
part of $LIBRARYNAME;
$(ANNOTATIONS)$(CLASS_MODIFIERS)class $CLASSNAME$EXTENDS$IMPLEMENTS$NATIVESPEC {
+ $if DART2JS
+ @Creates('Null') // Set from Dart code; does not instantiate a native type.
+ $endif
+ var _dartDetail;
+
factory $CLASSNAME(String type,
{bool canBubble: true, bool cancelable: true, Object detail}) {
final CustomEvent e = document._createEvent('CustomEvent');
+ 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 {
$if DART2JS
- detail = convertDartToNative_SerializedScriptValue(detail);
+ detail = convertDartToNative_SerializedScriptValue(detail);
$endif
- e._initCustomEvent(type, canBubble, cancelable, 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;
+ }
$!MEMBERS
}
« sdk/lib/html/dart2js/html_dart2js.dart ('K') | « tools/dom/scripts/htmlrenamer.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698