Skip to content

Commit

Permalink
Make all parameters to initEvent() / initCustomEvent() optional excep…
Browse files Browse the repository at this point in the history
…t the first one

Make all parameters to initEvent() / initCustomEvent() optional except the first one.
to match:
- whatwg/dom#417
- whatwg/dom#387
  • Loading branch information
cdumez committed Mar 6, 2017
1 parent dac7c07 commit 239bb27
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 3 deletions.
18 changes: 17 additions & 1 deletion dom/events/CustomEvent.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,21 @@
var fooEvent = document.createEvent("CustomEvent");
fooEvent.initEvent(type, true, true);
target.dispatchEvent(fooEvent);
});
}, "CustomEvent dispatching.");

test(function() {
var e = document.createEvent("CustomEvent");
assert_throws(new TypeError(), function() {
e.initCustomEvent();
});
}, "First parameter to initCustomEvent should be mandatory.");

test(function() {
var e = document.createEvent("CustomEvent");
e.initCustomEvent("foo");
assert_equals(e.type, "foo", "type");
assert_false(e.bubbles, "bubbles");
assert_false(e.cancelable, "cancelable");
assert_equals(e.detail, null, "detail");
}, "initCustomEvent's default parameter values.");
</script>
15 changes: 15 additions & 0 deletions dom/events/Event-initEvent.html
Original file line number Diff line number Diff line change
Expand Up @@ -116,4 +116,19 @@

this.done()
}, "Calling initEvent during propagation.")

test(function() {
var e = document.createEvent("Event")
assert_throws(new TypeError(), function() {
e.initEvent()
})
}, "First parameter to initEvent should be mandatory.")

test(function() {
var e = document.createEvent("Event")
e.initEvent("type")
assert_equals(e.type, "type", "type")
assert_false(e.bubbles, "bubbles")
assert_false(e.cancelable, "cancelable")
}, "Tests initEvent's default parameter values.")
</script>
4 changes: 2 additions & 2 deletions dom/interfaces.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ <h1>DOM IDL tests</h1>
[Unforgeable] readonly attribute boolean isTrusted;
readonly attribute DOMTimeStamp timeStamp;

void initEvent(DOMString type, boolean bubbles, boolean cancelable);
void initEvent(DOMString type, optional boolean bubbles = false, optional boolean cancelable = false);
};

dictionary EventInit {
Expand All @@ -48,7 +48,7 @@ <h1>DOM IDL tests</h1>
interface CustomEvent : Event {
readonly attribute any detail;

void initCustomEvent(DOMString type, boolean bubbles, boolean cancelable, any detail);
void initCustomEvent(DOMString type, optional boolean bubbles = false, optional boolean cancelable = false, optional any detail = null);
};

dictionary CustomEventInit : EventInit {
Expand Down

0 comments on commit 239bb27

Please sign in to comment.