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

calc_remain_height function accepts off-display nodes #4

Open
Dither opened this issue Dec 6, 2012 · 0 comments
Open

calc_remain_height function accepts off-display nodes #4

Dither opened this issue Dec 6, 2012 · 0 comments

Comments

@Dither
Copy link

Dither commented Dec 6, 2012

The calc_remain_height shouldn't accept nodes that don't have visual representation, like script or style, but it does and it breaks extension on some pages. Here is the corrected version:

        function calc_remain_height() {
            var rect = null, bottom = null, _point = insert_point;
            while (_point) {
                if (typeof _point.getBoundingClientRect === 'function') {
                    rect = _point.getBoundingClientRect();
                    if (rect && !(rect.top === 0 && rect.right === 0 && rect.bottom === 0 && rect.left === 0)) break;
                    else rect = null;
                }
                if (_point.nextSibling) _point = _point.nextSibling;
                else break; 
            }
            if (rect) {
                bottom = rect.top + window.pageYOffset;
            } else if (append_point && typeof append_point.getBoundingClientRect === 'function') {
                rect = append_point.getBoundingClientRect();
                bottom = rect.top + rect.height + window.pageYOffset;
            }
            if (!bottom) bottom = Math.round(rootNode.scrollHeight * 0.8);
            return rootNode.scrollHeight - bottom + options.BASE_REMAIN_HEIGHT;
        }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant