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

Error with window.get_elements if an return element or child are a checkbox #622

Closed
ulukyn opened this issue Oct 19, 2020 · 1 comment
Closed

Comments

@ulukyn
Copy link

ulukyn commented Oct 19, 2020

Specification

  • pywebview version: 3.3.4
  • platform / version: Linux / Manjaro GTK

Description

I want get all checkboxes from a html page. I use window.get_elements but window.get_elements() trigger a JS TypeError. The error happens with elements selectionDirection, selectionStart and selectionEnd in the checkbox node.

A fast way to fix that are adding a try... catch in copyJSON (in js/dom.py) like

` var copyJSON = function(node, opts) {

    var copy = {};
    for (var n in node) {
        try {
            if (typeof node[n] !== "undefined" && typeof node[n] !== "function" && n.charAt(0).toLowerCase() === n.charAt(0)) {
                if (typeof node[n] !== "object" || node[n] instanceof Array) {
                    if (opts.cull) {
                        if (node[n] || node[n] === 0 || node[n] === false) {
                            copy[n] = node[n];
                        }
                    } else {
                        copy[n] = node[n];
                    }
                }
            }
        } catch {
            console.log(n);
        }
    }
    copy = boolFilter(copy, opts.domProperties);
    return copy;
};

`

But, this don't fix the bug, just hide it. But i have no idea how fix that... and if can be fixed.

@r0x0r
Copy link
Owner

r0x0r commented Oct 20, 2020

An ancient version of domJSON was used. The issue is fixed by upgrading domJSON to the latest version.
The fix is committed to master.

@r0x0r r0x0r closed this as completed Oct 20, 2020
@r0x0r r0x0r mentioned this issue Dec 3, 2020
Closed
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

2 participants