Skip to content

Commit

Permalink
Merge pull request capricorn86#951 from Schleuse/task/capricorn86#950-…
Browse files Browse the repository at this point in the history
…Calling-getRootNode-on-document-should-return-the-document

capricorn86#950@patch: Calling getRootNode on document should return the document.
  • Loading branch information
capricorn86 committed Jul 10, 2023
2 parents 29629b5 + 8c292e5 commit a06b764
Show file tree
Hide file tree
Showing 2 changed files with 5 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 @@ -198,6 +198,7 @@ export default class Document extends Node implements IDocument {
this.implementation = new DOMImplementation(this);

this._readyStateManager = new DocumentReadyStateManager(this.defaultView);
this._rootNode = this;

const doctype = this.implementation.createDocumentType('html', '', '');
const documentElement = this.createElement('html');
Expand Down
4 changes: 4 additions & 0 deletions packages/happy-dom/test/nodes/node/Node.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,10 @@ describe('Node', () => {

expect(rootNode === document).toBe(true);
});

it('Returns Document when called on Document', () => {
expect(document.getRootNode() === document).toBe(true);
});
});

describe('cloneNode()', () => {
Expand Down

0 comments on commit a06b764

Please sign in to comment.