Skip to content

Commit

Permalink
#991@minor: Add naive scrollHeight implementation.
Browse files Browse the repository at this point in the history
  • Loading branch information
lukaselmer committed Aug 2, 2023
1 parent d533e78 commit b99d0c2
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
2 changes: 2 additions & 0 deletions packages/happy-dom/src/nodes/element/Element.ts
Expand Up @@ -44,6 +44,7 @@ export default class Element extends Node implements IElement {
public shadowRoot: IShadowRoot = null;
public prefix: string = null;

public scrollHeight = 0;
public scrollTop = 0;
public scrollLeft = 0;
public children: IHTMLCollection<IElement> = new HTMLCollection<IElement>();
Expand Down Expand Up @@ -369,6 +370,7 @@ export default class Element extends Node implements IElement {
(<string>clone.tagName) = this.tagName;
clone.scrollLeft = this.scrollLeft;
clone.scrollTop = this.scrollTop;
clone.scrollHeight = this.scrollHeight;
(<string>clone.namespaceURI) = this.namespaceURI;

return <IElement>clone;
Expand Down
1 change: 1 addition & 0 deletions packages/happy-dom/src/nodes/element/IElement.ts
Expand Up @@ -23,6 +23,7 @@ export default interface IElement extends IChildNode, INonDocumentTypeChildNode,
prefix: string | null;
scrollTop: number;
scrollLeft: number;
scrollHeight: number;
id: string;
className: string;
role: string;
Expand Down
6 changes: 6 additions & 0 deletions packages/happy-dom/test/nodes/element/Element.test.ts
Expand Up @@ -1512,6 +1512,12 @@ describe('Element', () => {
});
}

describe('scrollHeight', () => {
it('Returns the scroll height.', () => {
expect(element.scrollHeight).toBe(0);
});
});

describe('toString()', () => {
it('Returns the same as outerHTML.', () => {
expect(element.toString()).toBe(element.outerHTML);
Expand Down

0 comments on commit b99d0c2

Please sign in to comment.