Socket
Socket
Sign inDemoInstall

happy-dom

Package Overview
Dependencies
Maintainers
1
Versions
576
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.4.9 to 0.4.11

1

lib/event/EventTarget.js

@@ -59,2 +59,3 @@ "use strict";

if (event.bubbles &&
this['parentNode'] !== null &&
typeof this['parentNode'] === 'object' &&

@@ -61,0 +62,0 @@ typeof this['parentNode'].dispatchEvent === 'function' &&

4

lib/html-element/ClassList.js

@@ -63,5 +63,3 @@ "use strict";

ClassList.prototype.contains = function (className) {
var attr = this.ownerElement.getAttribute('class');
var list = attr ? attr.split(' ') : [];
return list.includes(className);
return this.ownerElement.getAttribute('class').includes(className);
};

@@ -68,0 +66,0 @@ return ClassList;

@@ -27,3 +27,3 @@ "use strict";

var tagName = element.tagName.toLowerCase();
var rawAttributes = element._getRawAttributes();
var rawAttributes = element.getRawAttributes();
var isUnClosed = META_REGEXP.test(tagName);

@@ -30,0 +30,0 @@ var isSelfClosed = SELF_CLOSED_REGEXP.test(tagName);

@@ -36,3 +36,3 @@ "use strict";

while ((match = attributeRegexp.exec(part))) {
if (element._attributesMap[match[1]] !== match[2].replace(/"/g, '')) {
if (element.attributesMap[match[1]] !== match[2].replace(/"/g, '')) {
return false;

@@ -44,5 +44,6 @@ }

if (this.isClass) {
var className = element.className;
var classRegexp = new RegExp(CLASS_REGEXP, 'g');
while ((match = classRegexp.exec(part))) {
if (!element.classList.contains(match[1])) {
if (!className || !className.includes(match[1])) {
return false;

@@ -49,0 +50,0 @@ }

@@ -1,2 +0,2 @@

import Document from '../nodes/basic-types/document/Document';
import Document from '../nodes/basic-types/Document';
import Window from '../Window';

@@ -3,0 +3,0 @@ /**

@@ -6,3 +6,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
var Document_1 = __importDefault(require("../nodes/basic-types/document/Document"));
var Document_1 = __importDefault(require("../nodes/basic-types/Document"));
/**

@@ -9,0 +9,0 @@ * The DOMImplementation interface represents an object providing methods which are not dependent on any particular document. Such an object is returned by the

@@ -71,4 +71,4 @@ "use strict";

// MutationObserver
if (this._observers.length > 0) {
for (var _i = 0, _a = this._observers; _i < _a.length; _i++) {
if (this.observers.length > 0) {
for (var _i = 0, _a = this.observers; _i < _a.length; _i++) {
var observer = _a[_i];

@@ -75,0 +75,0 @@ if (observer.options.characterData) {

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

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

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

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

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

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

@@ -16,5 +16,3 @@ import Node from './Node';

classList: ClassList;
scrollTop: number;
scrollLeft: number;
_attributesMap: {
readonly attributesMap: {
[k: string]: string;

@@ -143,7 +141,7 @@ };

*/
_setRawAttributes(rawAttributes: string): void;
setRawAttributes(rawAttributes: string): void;
/**
* Returns raw attributes.
*/
_getRawAttributes(): string;
getRawAttributes(): string;
/**

@@ -156,8 +154,2 @@ * Attaches a shadow root.

/**
* Scrolls to a particular set of coordinates in the document.
*
* @note This method has not been implemented. It is just here for compatibility.
*/
scrollTo(): void;
/**
* Converts to string.

@@ -164,0 +156,0 @@ *

@@ -44,5 +44,3 @@ "use strict";

_this.classList = new ClassList_1.default(_this);
_this.scrollTop = 0;
_this.scrollLeft = 0;
_this._attributesMap = {};
_this.attributesMap = {};
return _this;

@@ -195,7 +193,7 @@ }

var attributes = [];
for (var _i = 0, _a = Object.keys(this._attributesMap); _i < _a.length; _i++) {
for (var _i = 0, _a = Object.keys(this.attributesMap); _i < _a.length; _i++) {
var key = _a[_i];
var attribute = new Attribute_1.default();
attribute.name = key;
attribute.value = this._attributesMap[key];
attribute.value = this.attributesMap[key];
attributes.push(attribute);

@@ -239,3 +237,3 @@ }

Element.prototype.hasAttributes = function () {
return Object.keys(this._attributesMap).length > 0;
return Object.keys(this.attributesMap).length > 0;
};

@@ -250,4 +248,4 @@ /**

var lowerName = name.toLowerCase();
var oldValue = this._attributesMap[lowerName] !== undefined ? this._attributesMap[lowerName] : null;
this._attributesMap[lowerName] = String(value);
var oldValue = this.attributesMap[lowerName] !== undefined ? this.attributesMap[lowerName] : null;
this.attributesMap[lowerName] = String(value);
if (this.attributeChangedCallback) {

@@ -257,4 +255,4 @@ this.attributeChangedCallback(name, oldValue, value);

// MutationObserver
if (this._observers.length > 0) {
for (var _i = 0, _a = this._observers; _i < _a.length; _i++) {
if (this.observers.length > 0) {
for (var _i = 0, _a = this.observers; _i < _a.length; _i++) {
var observer = _a[_i];

@@ -279,3 +277,3 @@ if (observer.options.attributes &&

var lowerName = name.toLowerCase();
return this._attributesMap[lowerName] !== undefined ? this._attributesMap[lowerName] : null;
return this.attributesMap[lowerName] !== undefined ? this.attributesMap[lowerName] : null;
};

@@ -289,7 +287,7 @@ /**

var lowerName = name.toLowerCase();
var oldValue = this._attributesMap[lowerName] !== undefined ? this._attributesMap[lowerName] : null;
delete this._attributesMap[lowerName];
var oldValue = this.attributesMap[lowerName] !== undefined ? this.attributesMap[lowerName] : null;
delete this.attributesMap[lowerName];
// MutationObserver
if (this._observers.length > 0) {
for (var _i = 0, _a = this._observers; _i < _a.length; _i++) {
if (this.observers.length > 0) {
for (var _i = 0, _a = this.observers; _i < _a.length; _i++) {
var observer = _a[_i];

@@ -312,3 +310,3 @@ if (observer.options.attributes &&

*/
Element.prototype._setRawAttributes = function (rawAttributes) {
Element.prototype.setRawAttributes = function (rawAttributes) {
rawAttributes = rawAttributes.trim();

@@ -319,5 +317,5 @@ if (rawAttributes) {

while ((match = attributeRegexp.exec(rawAttributes))) {
var name = match[1].toLowerCase();
var name_1 = match[1].toLowerCase();
var value = he_1.decode(match[2] || match[3] || match[4] || '');
this._attributesMap[name] = value;
this.attributesMap[name_1] = value;
}

@@ -329,7 +327,7 @@ }

*/
Element.prototype._getRawAttributes = function () {
Element.prototype.getRawAttributes = function () {
var _this = this;
return Object.keys(this._attributesMap)
return Object.keys(this.attributesMap)
.map(function (key) {
return key + '="' + he_1.encode(_this._attributesMap[key]) + '"';
return key + '="' + he_1.encode(_this.attributesMap[key]) + '"';
})

@@ -353,8 +351,2 @@ .join(' ');

/**
* Scrolls to a particular set of coordinates in the document.
*
* @note This method has not been implemented. It is just here for compatibility.
*/
Element.prototype.scrollTo = function () { };
/**
* Converts to string.

@@ -361,0 +353,0 @@ *

@@ -11,6 +11,2 @@ import Element from './Element';

tabIndex: number;
offsetHeight: number;
offsetWidth: number;
offsetLeft: number;
offsetTop: number;
/**

@@ -53,7 +49,7 @@ * Returns inner text.

*/
_setRawAttributes(rawAttributes: string): void;
setRawAttributes(rawAttributes: string): void;
/**
* Defines initial properties.
*/
private _defineInitialProperties;
private defineInitialProperties;
}

@@ -29,6 +29,2 @@ "use strict";

_this.tabIndex = 0;
_this.offsetHeight = 0;
_this.offsetWidth = 0;
_this.offsetLeft = 0;
_this.offsetTop = 0;
return _this;

@@ -80,3 +76,3 @@ }

var observedAttributes = Object.keys(observedPropertyAttributes);
if (value !== null && value !== undefined && observedAttributes.includes(lowerName)) {
if (observedAttributes.includes(lowerName)) {
var property = observedPropertyAttributes[lowerName];

@@ -92,6 +88,6 @@ this[property] = typeof this[property] === 'boolean' ? value !== null : String(value);

*/
HTMLElement.prototype._setRawAttributes = function (rawAttributes) {
_super.prototype._setRawAttributes.call(this, rawAttributes);
HTMLElement.prototype.setRawAttributes = function (rawAttributes) {
_super.prototype.setRawAttributes.call(this, rawAttributes);
if (rawAttributes.trim()) {
this._defineInitialProperties();
this.defineInitialProperties();
}

@@ -102,9 +98,9 @@ };

*/
HTMLElement.prototype._defineInitialProperties = function () {
HTMLElement.prototype.defineInitialProperties = function () {
var observedPropertyAttributes = this.constructor._observedPropertyAttributes;
for (var _i = 0, _a = Object.keys(observedPropertyAttributes); _i < _a.length; _i++) {
var name = _a[_i];
var attribute = this._attributesMap[name];
if (attribute !== null && attribute !== undefined) {
var property = observedPropertyAttributes[name];
var name_1 = _a[_i];
var attribute = this.attributesMap[name_1];
if (attribute !== null) {
var property = observedPropertyAttributes[name_1];
switch (typeof this[property]) {

@@ -111,0 +107,0 @@ case 'boolean':

@@ -15,3 +15,3 @@ import NodeType from './NodeType';

protected _isConnected: boolean;
protected _observers: MutationObserverListener[];
protected observers: MutationObserverListener[];
/**

@@ -83,2 +83,8 @@ * Constructor.

/**
* Returns a unique ID.
*
* @return {string} ID.
*/
getUniqueID(): string;
/**
* Clones a node.

@@ -125,3 +131,3 @@ *

*/
_observe(listener: MutationObserverListener): void;
observe(listener: MutationObserverListener): void;
/**

@@ -133,3 +139,3 @@ * Stops observing the node.

*/
_unobserve(listener: MutationObserverListener): void;
unobserve(listener: MutationObserverListener): void;
}

@@ -24,2 +24,3 @@ "use strict";

var MutationType_1 = __importDefault(require("../../mutation-observer/MutationType"));
var ASCII = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'.split('');
/**

@@ -41,3 +42,3 @@ * Node

// Custom Properties (not part of HTML standard)
_this._observers = [];
_this.observers = [];
_this.ownerDocument = _this.constructor.ownerDocument;

@@ -182,2 +183,15 @@ return _this;

/**
* Returns a unique ID.
*
* @return {string} ID.
*/
Node.prototype.getUniqueID = function () {
if (this.parentNode) {
var childNodeIndex = this.parentNode.childNodes.indexOf(this);
var id = ASCII[childNodeIndex] !== undefined ? ASCII[childNodeIndex] : childNodeIndex !== -1 ? childNodeIndex : '';
return this.parentNode.getUniqueID() + id;
}
return 'a';
};
/**
* Clones a node.

@@ -193,3 +207,3 @@ *

var key = _a[_i];
if (key !== '_isConnected' && key !== '_observers') {
if (key !== '_isConnected' && key !== 'observers') {
if (key === 'childNodes') {

@@ -215,5 +229,2 @@ if (deep) {

}
else if (key === '_attributesMap') {
clone[key] = Object.assign({}, this[key]);
}
else {

@@ -253,10 +264,10 @@ clone[key] = this[key];

// MutationObserver
if (this._observers.length > 0) {
if (this.observers.length > 0) {
var record = new MutationRecord_1.default();
record.type = MutationType_1.default.childList;
record.addedNodes = [node];
for (var _b = 0, _c = this._observers; _b < _c.length; _b++) {
for (var _b = 0, _c = this.observers; _b < _c.length; _b++) {
var observer = _c[_b];
if (observer.options.subtree) {
node._observe(observer);
node.observe(observer);
}

@@ -284,9 +295,9 @@ if (observer.options.childList) {

// MutationObserver
if (this._observers.length > 0) {
if (this.observers.length > 0) {
var record = new MutationRecord_1.default();
record.type = MutationType_1.default.childList;
record.removedNodes = [node];
for (var _i = 0, _a = this._observers; _i < _a.length; _i++) {
for (var _i = 0, _a = this.observers; _i < _a.length; _i++) {
var observer = _a[_i];
node._unobserve(observer);
node.unobserve(observer);
if (observer.options.childList) {

@@ -330,10 +341,10 @@ observer.callback([record]);

// MutationObserver
if (this._observers.length > 0) {
if (this.observers.length > 0) {
var record = new MutationRecord_1.default();
record.type = MutationType_1.default.childList;
record.addedNodes = [newNode];
for (var _b = 0, _c = this._observers; _b < _c.length; _b++) {
for (var _b = 0, _c = this.observers; _b < _c.length; _b++) {
var observer = _c[_b];
if (observer.options.subtree) {
newNode._observe(observer);
newNode.observe(observer);
}

@@ -365,8 +376,8 @@ if (observer.options.childList) {

*/
Node.prototype._observe = function (listener) {
this._observers.push(listener);
Node.prototype.observe = function (listener) {
this.observers.push(listener);
if (listener.options.subtree) {
for (var _i = 0, _a = this.childNodes; _i < _a.length; _i++) {
var node = _a[_i];
node._observe(listener);
node.observe(listener);
}

@@ -381,6 +392,6 @@ }

*/
Node.prototype._unobserve = function (listener) {
var index = this._observers.indexOf(listener);
Node.prototype.unobserve = function (listener) {
var index = this.observers.indexOf(listener);
if (index !== -1) {
this._observers.splice(index, 1);
this.observers.splice(index, 1);
}

@@ -390,3 +401,3 @@ if (listener.options.subtree) {

var node = _a[_i];
node._unobserve(listener);
node.unobserve(listener);
}

@@ -393,0 +404,0 @@ }

@@ -71,4 +71,4 @@ "use strict";

// MutationObserver
if (this._observers.length > 0) {
for (var _i = 0, _a = this._observers; _i < _a.length; _i++) {
if (this.observers.length > 0) {
for (var _i = 0, _a = this.observers; _i < _a.length; _i++) {
var observer = _a[_i];

@@ -75,0 +75,0 @@ if (observer.options.characterData) {

@@ -159,3 +159,3 @@ "use strict";

get: function () {
return (this.type !== 'hidden' && this.type !== 'reset' && this.type !== 'button' && !this.disabled && !this['readOnly']);
return this.type !== 'hidden' && this.type !== 'reset' && this.type !== 'button' && !this.disabled && !this['readOnly'];
},

@@ -162,0 +162,0 @@ enumerable: true,

import HTMLElement from '../basic-types/HTMLElement';
import Node from '../basic-types/Node';
import HTMLFormElement from './HTMLFormElement';
/**

@@ -17,3 +16,5 @@ * HTMLTextAreaElement.

"value": string;
"autocomplete": string;
"autocomplete": string; /**
* HTMLTextAreaElement.
*/
"minlength": string;

@@ -20,0 +21,0 @@ "maxlength": string;

import ScopedCSSCache from './css/ScopedCSSCache';
import Element from '../nodes/basic-types/element/Element';
import DocumentFragment from '../nodes/basic-types/document-fragment/DocumentFragment';
import Element from '../nodes/basic-types/Element';
import DocumentFragment from '../nodes/basic-types/DocumentFragment';
/**

@@ -5,0 +5,0 @@ * Patch for scoping elements when requesting "document.documentElement.innerHTML" or "document.documentElement.outerHTML".

@@ -6,4 +6,4 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
var Element_1 = __importDefault(require("../nodes/basic-types/element/Element"));
var ShadowRoot_1 = __importDefault(require("../nodes/basic-types/shadow-root/ShadowRoot"));
var Element_1 = __importDefault(require("../nodes/basic-types/Element"));
var ShadowRoot_1 = __importDefault(require("../nodes/basic-types/ShadowRoot"));
var ScopeCSS_1 = __importDefault(require("./css/ScopeCSS"));

@@ -49,11 +49,11 @@ /**

var child = element.children[i];
var name = child.getAttribute('slot') || 'default';
slotChildren[name] = slotChildren[name] || [];
slotChildren[name].push(child);
var name_1 = child.getAttribute('slot') || 'default';
slotChildren[name_1] = slotChildren[name_1] || [];
slotChildren[name_1].push(child);
}
for (var _i = 0, slots_1 = slots; _i < slots_1.length; _i++) {
var slot = slots_1[_i];
var name = slot.getAttribute('name') || 'default';
if (slotChildren[name]) {
for (var _a = 0, _b = slotChildren[name]; _a < _b.length; _a++) {
var name_2 = slot.getAttribute('name') || 'default';
if (slotChildren[name_2]) {
for (var _a = 0, _b = slotChildren[name_2]; _a < _b.length; _a++) {
var child = _b[_a];

@@ -60,0 +60,0 @@ slot.parentNode.insertBefore(child, slot);

{
"name": "happy-dom",
"version": "0.4.9",
"version": "0.4.11",
"license": "MIT",

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

@@ -63,2 +63,3 @@ import Event from './Event';

event.bubbles &&
this['parentNode'] !== null &&
typeof this['parentNode'] === 'object' &&

@@ -65,0 +66,0 @@ typeof this['parentNode'].dispatchEvent === 'function' &&

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

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

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

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

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

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

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