Implementation
factory MessageEvent(
String type, {
bool canBubble = false,
bool cancelable = false,
Object? data,
String? origin,
String? lastEventId,
Window? source,
List<MessagePort> messagePorts = const [],
}) {
if (source == null) {
source = window;
}
if (!Device.isIE) {
// TODO: This if check should be removed once IE
// implements the constructor.
return JS(
'MessageEvent',
'new MessageEvent(#, {bubbles: #, cancelable: #, data: #, origin: #, lastEventId: #, source: #, ports: #})',
type,
canBubble,
cancelable,
data,
origin,
lastEventId,
source,
messagePorts,
);
}
MessageEvent event = document._createEvent("MessageEvent") as MessageEvent;
event._initMessageEvent(
type,
canBubble,
cancelable,
data,
origin,
lastEventId,
source,
messagePorts,
);
return event;
}