Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

happy-dom

Package Overview
Dependencies
Maintainers
1
Versions
593
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

happy-dom - npm Package Compare versions

Comparing version 0.3.1 to 0.4.0

lib/event/CustomEventInit.d.ts

8

lib/event/CustomEvent.d.ts
import Event from './Event';
import ICustomEventInit from './ICustomEventInit';
export default class CustomEvent extends Event {
detail: object;
/**
* Constructor.
*
* @param {string} type Event type.
* @param {ICustomEventInit} customEventInit Custom event init.
*/
constructor(type: string, customEventInit?: ICustomEventInit);
}

14

lib/event/CustomEvent.js

@@ -22,5 +22,15 @@ "use strict";

__extends(CustomEvent, _super);
function CustomEvent() {
var _this = _super !== null && _super.apply(this, arguments) || this;
/**
* Constructor.
*
* @param {string} type Event type.
* @param {ICustomEventInit} customEventInit Custom event init.
*/
function CustomEvent(type, customEventInit) {
if (customEventInit === void 0) { customEventInit = null; }
var _this = _super.call(this, type, customEventInit) || this;
_this.detail = null;
if (customEventInit && customEventInit.detail) {
_this.detail = customEventInit.detail;
}
return _this;

@@ -27,0 +37,0 @@ }

import Node from '../nodes/basic-types/Node';
import IEventInit from './IEventInit';
export default class Event {

@@ -12,2 +13,9 @@ readonly bubbles: boolean;

/**
* Constructor.
*
* @param {string} type Event type.
* @param {IEventInit} eventInit Event init.
*/
constructor(type: string, eventInit?: IEventInit);
/**
* Init event.

@@ -14,0 +22,0 @@ *

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var Event = /** @class */ (function () {
function Event() {
/**
* Constructor.
*
* @param {string} type Event type.
* @param {IEventInit} eventInit Event init.
*/
function Event(type, eventInit) {
if (eventInit === void 0) { eventInit = null; }
this.bubbles = false;

@@ -13,2 +20,6 @@ this.cancelable = false;

this.type = null;
this.type = type;
this.bubbles = eventInit && eventInit.bubbles ? true : false;
this.cancelable = eventInit && eventInit.cancelable ? true : false;
this.composed = eventInit && eventInit.composed ? true : false;
}

@@ -15,0 +26,0 @@ /**

3

lib/nodes/basic-types/Document.d.ts

@@ -90,5 +90,6 @@ import Element from './Element';

* @legacy
* @param {string} type Type.
* @return {Event} Event.
*/
createEvent(): Event;
createEvent(type: string): Event;
/**

@@ -95,0 +96,0 @@ * Imports a node.

@@ -164,6 +164,7 @@ "use strict";

* @legacy
* @param {string} type Type.
* @return {Event} Event.
*/
Document.prototype.createEvent = function () {
return new Event_1.default();
Document.prototype.createEvent = function (type) {
return new Event_1.default(type);
};

@@ -170,0 +171,0 @@ /**

{
"name": "happy-dom",
"version": "0.3.1",
"version": "0.4.0",
"license": "MIT",

@@ -5,0 +5,0 @@ "homepage": "https://github.com/capricorn86/happy-dom#readme",

@@ -197,2 +197,3 @@ # Happy DOM

| ------- | ---------- | ---------------- |
| 0.4.0 | 2019-10-07 | Adds type and eventInit to Event constructor. (#4)
| 0.3.1 | 2019-10-07 | Fixes bug where global.Error is undefined. (#6)

@@ -199,0 +200,0 @@ | 0.3.0 | 2019-10-06 | Adds support for scrollTop, scrollLeft, scrollTo(), offsetLeft, offsetTop offsetHeight, offsetWidth. |

import Event from './Event';
import ICustomEventInit from './ICustomEventInit';
export default class CustomEvent extends Event {
public detail: object = null;
/**
* Constructor.
*
* @param {string} type Event type.
* @param {ICustomEventInit} customEventInit Custom event init.
*/
constructor(type: string, customEventInit: ICustomEventInit = null) {
super(type, customEventInit);
if (customEventInit && customEventInit.detail) {
this.detail = customEventInit.detail;
}
}
}
import Node from '../nodes/basic-types/Node';
import IEventInit from './IEventInit';

@@ -14,2 +15,15 @@ export default class Event {

/**
* Constructor.
*
* @param {string} type Event type.
* @param {IEventInit} eventInit Event init.
*/
constructor(type: string, eventInit: IEventInit = null) {
this.type = type;
this.bubbles = eventInit && eventInit.bubbles ? true : false;
this.cancelable = eventInit && eventInit.cancelable ? true : false;
this.composed = eventInit && eventInit.composed ? true : false;
}
/**
* Init event.

@@ -16,0 +30,0 @@ *

@@ -97,3 +97,3 @@ import Element from './Element';

const elementClass = customElementClass ? customElementClass : this.getElementClass(tagName);
elementClass.ownerDocument = this;

@@ -160,6 +160,7 @@

* @legacy
* @param {string} type Type.
* @return {Event} Event.
*/
public createEvent(): Event {
return new Event();
public createEvent(type: string): Event {
return new Event(type);
}

@@ -187,3 +188,3 @@

private getElementClass(tagName: string): typeof Element {
switch(tagName) {
switch (tagName) {
case 'template':

@@ -190,0 +191,0 @@ return HTMLTemplateElement;

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc