502c7c29c8
BUG= R=blois@google.com Review URL: https://codereview.chromium.org//52443007 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@29609 260f80e4-7a28-3924-810f-c04153c831b5
61 lines
2.2 KiB
Plaintext
61 lines
2.2 KiB
Plaintext
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
|
|
// for details. All rights reserved. Use of this source code is governed by a
|
|
// BSD-style license that can be found in the LICENSE file.
|
|
|
|
// WARNING: Do not edit - generated code.
|
|
|
|
part of $LIBRARYNAME;
|
|
|
|
$(ANNOTATIONS)$(CLASS_MODIFIERS)class $CLASSNAME$EXTENDS$IMPLEMENTS$NATIVESPEC {
|
|
// In JS, canBubble and cancelable are technically required parameters to
|
|
// init*Event. In practice, though, if they aren't provided they simply
|
|
// default to false (since that's Boolean(undefined)).
|
|
//
|
|
// Contrary to JS, we default canBubble and cancelable to true, since that's
|
|
// what people want most of the time anyway.
|
|
factory $CLASSNAME(String type,
|
|
{bool canBubble: true, bool cancelable: true}) {
|
|
return new Event.eventType('Event', type, canBubble: canBubble,
|
|
cancelable: cancelable);
|
|
}
|
|
|
|
/**
|
|
* Creates a new Event object of the specified type.
|
|
*
|
|
* This is analogous to document.createEvent.
|
|
* Normally events should be created via their constructors, if available.
|
|
*
|
|
* var e = new Event.type('MouseEvent', 'mousedown', true, true);
|
|
*/
|
|
factory Event.eventType(String type, String name, {bool canBubble: true,
|
|
bool cancelable: true}) {
|
|
final Event e = document._createEvent(type);
|
|
e._initEvent(name, canBubble, cancelable);
|
|
return e;
|
|
}
|
|
|
|
/** The CSS selector involved with event delegation. */
|
|
String _selector;
|
|
|
|
/**
|
|
* A pointer to the element whose CSS selector matched within which an event
|
|
* was fired. If this Event was not associated with any Event delegation,
|
|
* accessing this value will throw an [UnsupportedError].
|
|
*/
|
|
Element get matchingTarget {
|
|
if (_selector == null) {
|
|
throw new UnsupportedError('Cannot call matchingTarget if this Event did'
|
|
' not arise as a result of event delegation.');
|
|
}
|
|
var currentTarget = this.currentTarget;
|
|
var target = this.target;
|
|
var matchedTarget;
|
|
do {
|
|
if (target.matches(_selector)) return target;
|
|
target = target.parent;
|
|
} while (target != null && target != currentTarget.parent);
|
|
throw new StateError('No selector matched for populating matchedTarget.');
|
|
}
|
|
$!MEMBERS
|
|
}
|