Skip to content

Commit

Permalink
Merge pull request #1076 from capricorn86/task/653-documentreferrer-s…
Browse files Browse the repository at this point in the history
…hould-be-a-string

#653@patch: Adds support for Document.referrer.
  • Loading branch information
capricorn86 committed Sep 18, 2023
2 parents 2aa2a66 + bee8bdd commit a81baba
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/happy-dom/src/nodes/document/Document.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ export default class Document extends Node implements IDocument {
public readonly readyState = DocumentReadyStateEnum.interactive;
public readonly isConnected: boolean = true;
public readonly defaultView: IWindow;
public readonly referrer = '';
public readonly _windowClass: {} | null = null;
public readonly _readyStateManager: DocumentReadyStateManager;
public readonly _children: IHTMLCollection<IElement> = new HTMLCollection<IElement>();
Expand Down
1 change: 1 addition & 0 deletions packages/happy-dom/src/nodes/document/IDocument.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export default interface IDocument extends IParentNode {
readonly visibilityState: VisibilityStateEnum;
readonly hidden: boolean;
readonly links: IHTMLCollection<IHTMLElement>;
readonly referrer: string;
cookie: string;
title: string;

Expand Down
6 changes: 6 additions & 0 deletions packages/happy-dom/test/nodes/document/Document.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@ describe('Document', () => {
});
}

describe('get referrer()', () => {
it('Returns empty string.', () => {
expect(document.referrer).toBe('');
});
});

describe('get nodeName()', () => {
it('Returns "#document".', () => {
expect(document.nodeName).toBe('#document');
Expand Down

0 comments on commit a81baba

Please sign in to comment.