| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 2e181f6 commit 061ed0e
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -95,13 +95,11 @@ class Event { | |||
| 95 | 95 | * composed?: boolean, | |
| 96 | 96 | * }} [options] | |
| 97 | 97 | */ | |
| 98 | - constructor(type, options = null) { | ||
| 98 | + constructor(type, options = kEmptyObject) { | ||
| 99 | 99 | if (arguments.length === 0) | |
| 100 | 100 | throw new ERR_MISSING_ARGS('type'); | |
| 101 | - validateObject(options, 'options', { | ||
| 102 | - allowArray: true, allowFunction: true, nullable: true, | ||
| 103 | - }); | ||
| 104 | - const { cancelable, bubbles, composed } = { ...options }; | ||
| 101 | + validateObject(options, 'options'); | ||
| 102 | + const { bubbles, cancelable, composed } = options; | ||
| 105 | 103 | this.#cancelable = !!cancelable; | |
| 106 | 104 | this.#bubbles = !!bubbles; | |
| 107 | 105 | this.#composed = !!composed; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,29 @@ | |||
| 1 | + 'use strict'; | ||
| 2 | + | ||
| 3 | + require('../common'); | ||
| 4 | + const { test, assert_equals, assert_array_equals } = | ||
| 5 | + require('../common/wpt').harness; | ||
| 6 | + | ||
| 7 | + // Source: https://github.com/web-platform-tests/wpt/blob/6cef1d2087d6a07d7cc6cee8cf207eec92e27c5f/dom/events/Event-constructors.any.js#L91-L112 | ||
| 8 | + test(function() { | ||
| 9 | + const called = []; | ||
| 10 | + const ev = new Event('Xx', { | ||
| 11 | + get cancelable() { | ||
| 12 | + called.push('cancelable'); | ||
| 13 | + return false; | ||
| 14 | + }, | ||
| 15 | + get bubbles() { | ||
| 16 | + called.push('bubbles'); | ||
| 17 | + return true; | ||
| 18 | + }, | ||
| 19 | + get sweet() { | ||
| 20 | + called.push('sweet'); | ||
| 21 | + return 'x'; | ||
| 22 | + }, | ||
| 23 | + }); | ||
| 24 | + assert_array_equals(called, ['bubbles', 'cancelable']); | ||
| 25 | + assert_equals(ev.type, 'Xx'); | ||
| 26 | + assert_equals(ev.bubbles, true); | ||
| 27 | + assert_equals(ev.cancelable, false); | ||
| 28 | + assert_equals(ev.sweet, undefined); | ||
| 29 | + }); | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments