@whatwg-node/events 0.1.0 → 0.1.1-alpha-20230525101758-552afdd

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # @whatwg-node/events
2
2
 
3
+ ## 0.1.1-alpha-20230525101758-552afdd
4
+
5
+ ### Patch Changes
6
+
7
+ - [#554](https://github.com/ardatan/whatwg-node/pull/554)
8
+ [`552afdd`](https://github.com/ardatan/whatwg-node/commit/552afdd156de29d1f0bb3f2d172e3189c4dd7c6f)
9
+ Thanks [@n1ru4l](https://github.com/n1ru4l)! - Follow the spec and set `detail` to null by default
10
+
3
11
  ## 0.1.0
4
12
 
5
13
  ### Minor Changes
@@ -3,7 +3,7 @@ if (!module.exports.CustomEvent) {
3
3
  module.exports.CustomEvent = class CustomEvent extends Event {
4
4
  constructor(type, options) {
5
5
  super(type, options);
6
- this.detail = options && options.detail;
6
+ this.detail = options?.detail ?? null;
7
7
  }
8
8
  }
9
9
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@whatwg-node/events",
3
- "version": "0.1.0",
3
+ "version": "0.1.1-alpha-20230525101758-552afdd",
4
4
  "description": "Cross Platform Smart Event API Ponyfill",
5
5
  "repository": {
6
6
  "type": "git",
@@ -1,11 +1,18 @@
1
1
  import { CustomEvent } from '@whatwg-node/events';
2
2
 
3
3
  describe('CustomEvent', () => {
4
- it('detail', () => {
4
+ it('detail should be set', () => {
5
5
  const target = new EventTarget();
6
6
  const listener = jest.fn();
7
7
  target.addEventListener('test', listener);
8
8
  target.dispatchEvent(new CustomEvent('test', { detail: 123 }));
9
9
  expect(listener).toHaveBeenCalledWith(expect.objectContaining({ detail: 123 }));
10
10
  });
11
+ it('detail should be null by default', () => {
12
+ const target = new EventTarget();
13
+ const listener = jest.fn();
14
+ target.addEventListener('test', listener);
15
+ target.dispatchEvent(new CustomEvent('test'));
16
+ expect(listener).toHaveBeenCalledWith(expect.objectContaining({ detail: null }));
17
+ })
11
18
  });