Is there a way to get a scrollHeight property (https://developer.mozilla.org/en-US/docs/Web/API/Element.scrollHeight)?
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.
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.
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
@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;
}
});
Most helpful comment
@leepowellcouk Looks like you forgot to add
configurable: true
to your config. Try e.g.: