Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add naive scrollHeight implementation #991

Merged
merged 1 commit into from
Aug 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/happy-dom/src/nodes/element/Element.ts
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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