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

Any way to get scrollHeight property? #1013

Open
jacekpl opened this issue Feb 2, 2015 · 4 comments
Open

Any way to get scrollHeight property? #1013

jacekpl opened this issue Feb 2, 2015 · 4 comments
Labels
feature layout Blocked on implementing a layout engine

Comments

@jacekpl
Copy link

jacekpl commented Feb 2, 2015

Is there a way to get a scrollHeight property (https://developer.mozilla.org/en-US/docs/Web/API/Element.scrollHeight)?

@Sebmaster
Copy link
Member

The property itself would not be a big deal, you could even patch this quite easily yourself in the created callback. However, for a scrollHeight property which would return something useful, jsdom would need to start doing layouting which is (at least) a loooong way off, if we even want to start doing it.

@jacekpl
Copy link
Author

jacekpl commented Feb 2, 2015

I just wanted to use scrollHeight to check if there is an overflow inside a div. Probably I'll have to look at PhantomJS/SlimerJS instead. Thanks for the answer.

@leepowelldev
Copy link

Is there anyway of mocking it? I tried this:

Object.defineProperties(window.HTMLElement.prototype, {
  scrollHeight: {
    get() {
      return this._scrollHeight || 0;
    },
    set(val) {
      this._scrollHeight = val;
    }
  }
});

And got the error: Cannot redefine property: scrollHeight

@bvaughn
Copy link

bvaughn commented May 27, 2019

@leepowellcouk Looks like you forgot to add configurable: true to your config. Try e.g.:

Object.defineProperty(HTMLElement.prototype, "scrollHeight", {
  configurable: true,
  get: function() {
    return this._scrollHeight || 0;
  },
  set(val) {
    this._scrollHeight = val;
  }
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature layout Blocked on implementing a layout engine
Projects
None yet
Development

No branches or pull requests

5 participants