Skip to content

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

Description

@ulukyn

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions