Skip to content

Commit

Permalink
Merge branch 'master' into task/652-fix-dataset-delete-nonexistent-key
Browse files Browse the repository at this point in the history
  • Loading branch information
capricorn86 authored Sep 25, 2023
2 parents 7f701d3 + bcb0225 commit b1118ed
Show file tree
Hide file tree
Showing 25 changed files with 82 additions and 24 deletions.
2 changes: 1 addition & 1 deletion packages/happy-dom/src/cookie/Cookie.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import DOMException from '../exception/DOMException.js';
import DOMExceptionNameEnum from '../exception/DOMExceptionNameEnum.js';
import CookieSameSiteEnum from './CookieSameSiteEnum.js';
import { URL } from 'url';
import URL from '../url/URL.js';

/**
* Cookie.
Expand Down
2 changes: 1 addition & 1 deletion packages/happy-dom/src/cookie/CookieJar.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Cookie from './Cookie.js';
import CookieSameSiteEnum from './CookieSameSiteEnum.js';
import { URL } from 'url';
import URL from '../url/URL.js';

/**
* CookieJar.
Expand Down
2 changes: 1 addition & 1 deletion packages/happy-dom/src/fetch/Fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import Response from './Response.js';
import HTTP, { IncomingMessage } from 'http';
import HTTPS from 'https';
import Zlib from 'zlib';
import { URL } from 'url';
import URL from '../url/URL.js';
import { Socket } from 'net';
import Stream from 'stream';
import DataURIParser from './data-uri/DataURIParser.js';
Expand Down
2 changes: 1 addition & 1 deletion packages/happy-dom/src/fetch/Request.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import IBlob from '../file/IBlob.js';
import IDocument from '../nodes/document/IDocument.js';
import IRequestInit from './types/IRequestInit.js';
import { URL } from 'url';
import URL from '../url/URL.js';
import DOMException from '../exception/DOMException.js';
import DOMExceptionNameEnum from '../exception/DOMExceptionNameEnum.js';
import IRequestInfo from './types/IRequestInfo.js';
Expand Down
2 changes: 1 addition & 1 deletion packages/happy-dom/src/fetch/ResourceFetch.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import DOMException from '../exception/DOMException.js';
import IDocument from '../nodes/document/IDocument.js';
import { URL } from 'url';
import URL from '../url/URL.js';

/**
* Helper class for performing fetch of resources.
Expand Down
3 changes: 2 additions & 1 deletion packages/happy-dom/src/fetch/Response.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import IResponseInit from './types/IResponseInit.js';
import IResponseBody from './types/IResponseBody.js';
import Headers from './Headers.js';
import IHeaders from './types/IHeaders.js';
import { URL, URLSearchParams } from 'url';
import { URLSearchParams } from 'url';
import URL from '../url/URL.js';
import Blob from '../file/Blob.js';
import Stream from 'stream';
import FormData from '../form-data/FormData.js';
Expand Down
2 changes: 1 addition & 1 deletion packages/happy-dom/src/fetch/types/IRequestInfo.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { URL } from 'url';
import URL from '../../url/URL.js';
import IRequest from './IRequest.js';

type IRequestInfo = IRequest | string | URL;
Expand Down
2 changes: 1 addition & 1 deletion packages/happy-dom/src/fetch/types/IRequestInit.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import IHeadersInit from './IHeadersInit.js';
import AbortSignal from '../AbortSignal.js';
import { URL } from 'url';
import URL from '../../url/URL.js';
import IRequestReferrerPolicy from './IRequestReferrerPolicy.js';
import IRequestRedirect from './IRequestRedirect.js';
import IRequestBody from './IRequestBody.js';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { URL } from 'url';
import URL from '../../url/URL.js';
import IRequest from '../types/IRequest.js';
import IDocument from '../../nodes/document/IDocument.js';
import { isIP } from 'net';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import DOMException from '../../exception/DOMException.js';
import DOMExceptionNameEnum from '../../exception/DOMExceptionNameEnum.js';
import IRequestReferrerPolicy from '../types/IRequestReferrerPolicy.js';
import IRequestRedirect from '../types/IRequestRedirect.js';
import { URL } from 'url';
import URL from '../../url/URL.js';
import IRequest from '../types/IRequest.js';

const VALID_REFERRER_POLICIES = [
Expand Down
3 changes: 2 additions & 1 deletion packages/happy-dom/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import Window from './window/Window.js';
import DataTransfer from './event/DataTransfer.js';
import DataTransferItem from './event/DataTransferItem.js';
import DataTransferItemList from './event/DataTransferItemList.js';
import { URL, URLSearchParams } from 'url';
import { URLSearchParams } from 'url';
import URL from './url/URL.js';
import Location from './location/Location.js';
import MutationObserver from './mutation-observer/MutationObserver.js';
import ResizeObserver from './resize-observer/ResizeObserver.js';
Expand Down
2 changes: 1 addition & 1 deletion packages/happy-dom/src/location/Location.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { URL } from 'url';
import URL from '../url/URL.js';
import DOMException from '../exception/DOMException.js';
import DOMExceptionNameEnum from '../exception/DOMExceptionNameEnum.js';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import HTMLElement from '../html-element/HTMLElement.js';
import DOMTokenList from '../../dom-token-list/DOMTokenList.js';
import IDOMTokenList from '../../dom-token-list/IDOMTokenList.js';
import IHTMLAnchorElement from './IHTMLAnchorElement.js';
import { URL } from 'url';
import URL from '../../url/URL.js';
import HTMLAnchorElementUtility from './HTMLAnchorElementUtility.js';
import INamedNodeMap from '../../named-node-map/INamedNodeMap.js';
import HTMLAnchorElementNamedNodeMap from './HTMLAnchorElementNamedNodeMap.js';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import IDocument from '../document/IDocument.js';
import { URL } from 'url';
import URL from '../../url/URL.js';

/**
* HTML Anchor Element utility.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { URL } from 'url';
import URL from '../../url/URL.js';
import Event from '../../event/Event.js';
import ErrorEvent from '../../event/events/ErrorEvent.js';
import IWindow from '../../window/IWindow.js';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ export default class HTMLUnknownElement extends HTMLElement implements IHTMLElem
if (newElement.isConnected && newElement.connectedCallback) {
newElement.connectedCallback();
}

this._connectToNode(null);
}
};
callbacks[tagName] = callbacks[tagName] || [];
Expand Down
22 changes: 22 additions & 0 deletions packages/happy-dom/src/url/URL.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { URL as NodeJSURL } from 'url';
import { Blob as NodeJSBlob } from 'buffer';
import Blob from '../file/Blob.js';

/**
* URL.
*/
export default class URL extends NodeJSURL {
/**
* Creates a string containing a URL representing the object given in the parameter.
*
* @param object Object.
* @returns URL.
*/
public static override createObjectURL(object: NodeJSBlob | Blob): string {
if (object instanceof Blob) {
const blob = new NodeJSBlob([object._buffer], { type: object.type });
return super.createObjectURL(blob);
}
return super.createObjectURL(object);
}
}
3 changes: 2 additions & 1 deletion packages/happy-dom/src/window/IWindow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ import KeyboardEvent from '../event/events/KeyboardEvent.js';
import ProgressEvent from '../event/events/ProgressEvent.js';
import MediaQueryListEvent from '../event/events/MediaQueryListEvent.js';
import EventTarget from '../event/EventTarget.js';
import { URL, URLSearchParams } from 'url';
import { URLSearchParams } from 'url';
import URL from '../url/URL.js';
import Location from '../location/Location.js';
import MutationObserver from '../mutation-observer/MutationObserver.js';
import DOMParser from '../dom-parser/DOMParser.js';
Expand Down
3 changes: 2 additions & 1 deletion packages/happy-dom/src/window/Window.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ import ProgressEvent from '../event/events/ProgressEvent.js';
import MediaQueryListEvent from '../event/events/MediaQueryListEvent.js';
import EventTarget from '../event/EventTarget.js';
import MessagePort from '../event/MessagePort.js';
import { URL, URLSearchParams } from 'url';
import { URLSearchParams } from 'url';
import URL from '../url/URL.js';
import Location from '../location/Location.js';
import NonImplementedEventTypes from '../event/NonImplementedEventTypes.js';
import MutationObserver from '../mutation-observer/MutationObserver.js';
Expand Down
3 changes: 2 additions & 1 deletion packages/happy-dom/src/xml-http-request/XMLHttpRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ import Blob from '../file/Blob.js';
import XMLHttpRequestUpload from './XMLHttpRequestUpload.js';
import DOMException from '../exception/DOMException.js';
import DOMExceptionNameEnum from '../exception/DOMExceptionNameEnum.js';
import { URL, UrlObject } from 'url';
import { UrlObject } from 'url';
import URL from '../url/URL.js';
import XMLHttpRequestURLUtility from './utilities/XMLHttpRequestURLUtility.js';
import ProgressEvent from '../event/events/ProgressEvent.js';
import XMLHttpResponseTypeEnum from './XMLHttpResponseTypeEnum.js';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { URL, UrlObject } from 'url';
import { UrlObject } from 'url';
import URL from '../../url/URL.js';
import Path from 'path';

// MIME type.
Expand Down
2 changes: 1 addition & 1 deletion packages/happy-dom/test/cookie/CookieJar.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import CookieJar from '../../src/cookie/CookieJar.js';
import { URL } from 'url';
import URL from '../../src/url/URL.js';
import { beforeEach, afterEach, describe, it, expect, vi } from 'vitest';

describe('CookieJar', () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/happy-dom/test/fetch/Request.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import IWindow from '../../src/window/IWindow.js';
import Window from '../../src/window/Window.js';
import IDocument from '../../src/nodes/document/IDocument.js';
import Request from '../../src/fetch/Request.js';
import { URL } from 'url';
import URL from '../../src/url/URL.js';
import Headers from '../../src/fetch/Headers.js';
import AbortSignal from '../../src/fetch/AbortSignal.js';
import DOMException from '../../src/exception/DOMException.js';
Expand Down
18 changes: 18 additions & 0 deletions packages/happy-dom/test/url/URL.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import URL from '../../src/url/URL.js';
import Blob from '../../src/file/Blob.js';
import { Blob as NodeJSBlob } from 'buffer';
import { describe, it, expect } from 'vitest';

describe('URL', () => {
describe('createObjectURL()', () => {
it('Creates a string containing a URL representing the object given in the parameter.', () => {
const blob = new Blob(['TEST']);
expect(URL.createObjectURL(blob).startsWith('blob:nodedata:')).toBe(true);
});

it('Supports Node.js Blob objects.', () => {
const blob = new NodeJSBlob(['TEST']);
expect(URL.createObjectURL(blob).startsWith('blob:nodedata:')).toBe(true);
});
});
});
16 changes: 13 additions & 3 deletions turbo.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,28 @@
"jest-environment#compile": {
"dependsOn": ["happy-dom#compile"]
},
"integration-test#compile": {
"dependsOn": ["happy-dom#compile"]
},
"uncaught-exception-observer#compile": {
"dependsOn": ["happy-dom#compile"]
},
"happy-dom#test": {
"outputs": ["node_modules/vitest/**"]
},
"global-registrator#test": {
"dependsOn": ["happy-dom#compile"],
"dependsOn": ["happy-dom#compile", "global-registrator#compile"],
"outputs": ["tmp/**"]
},
"jest-environment#test": {
"dependsOn": ["happy-dom#compile"]
"dependsOn": ["happy-dom#compile", "jest-environment#compile"]
},
"integration-test#test": {
"dependsOn": ["happy-dom#compile"]
"dependsOn": ["happy-dom#compile", "integration-test#compile"]
},
"uncaught-exception-observer#test": {
"dependsOn": ["happy-dom#compile", "uncaught-exception-observer#compile"],
"outputs": ["tmp/**"]
},
"lint": {
"outputs": []
Expand Down

0 comments on commit b1118ed

Please sign in to comment.