scrollHeight ์์ฑ์ ์ป๋ ๋ฐฉ๋ฒ์ด ์์ต๋๊น(https://developer.mozilla.org/en-US/docs/Web/API/Element.scrollHeight)?
์์ฑ ์์ฒด๋ ํฐ ๋ฌธ์ ๊ฐ ์๋๋ฏ๋ก created
์ฝ๋ฐฑ์์ ์ง์ ํจ์นํ ์๋ ์์ต๋๋ค. ๊ทธ๋ฌ๋ ์ ์ฉํ ๊ฒ์ ๋ฐํํ๋ scrollHeight ์์ฑ์ ๊ฒฝ์ฐ jsdom์ ์์ํ๋ ค๋ ๊ฒฝ์ฐ์๋ (์ ์ด๋) ๋๋ฌด ๋จผ ๋ ์ด์์ ์์
์ ์์ํด์ผ ํฉ๋๋ค.
div ๋ด๋ถ์ ์ค๋ฒํ๋ก๊ฐ ์๋์ง ํ์ธํ๊ธฐ ์ํด scrollHeight๋ฅผ ์ฌ์ฉํ๊ณ ์ถ์์ต๋๋ค. ์๋ง๋ ๋์ PhantomJS/SlimerJS๋ฅผ ์ดํด๋ด์ผ ํ ๊ฒ์ ๋๋ค. ๋ต๋ณ ํด์ฃผ์ ์ ๊ฐ์ฌํฉ๋๋ค.
์กฐ๋กฑํ ์ฌ์ง๊ฐ ์์ต๋๊น? ๋๋ ์ด๊ฒ์ ์๋ํ๋ค :
Object.defineProperties(window.HTMLElement.prototype, {
scrollHeight: {
get() {
return this._scrollHeight || 0;
},
set(val) {
this._scrollHeight = val;
}
}
});
๊ทธ๋ฆฌ๊ณ ์ค๋ฅ๊ฐ ๋ฐ์ํ์ต๋๋ค: Cannot redefine property: scrollHeight
@leepowellcouk ๊ตฌ์ฑ ์ configurable: true
๋ฅผ ์ถ๊ฐํ๋ ๊ฒ์ ์์ ๊ฒ ๊ฐ์ต๋๋ค. ์๋ฅผ ๋ค์ด:
Object.defineProperty(HTMLElement.prototype, "scrollHeight", {
configurable: true,
get: function() {
return this._scrollHeight || 0;
},
set(val) {
this._scrollHeight = val;
}
});
๊ฐ์ฅ ์ ์ฉํ ๋๊ธ
@leepowellcouk ๊ตฌ์ฑ ์
configurable: true
๋ฅผ ์ถ๊ฐํ๋ ๊ฒ์ ์์ ๊ฒ ๊ฐ์ต๋๋ค. ์๋ฅผ ๋ค์ด: