vitmalina / w2ui

UI widgets for modern apps. Data table, forms, toolbars, sidebar, tabs, tooltips, popups. All under 120kb (gzipped).
http://w2ui.com
MIT License
2.67k stars 727 forks source link

Fix for incorrect url resolution and single quotes for a string #2588

Closed alexkuznetsov closed 3 days ago

alexkuznetsov commented 4 days ago

In this PR:

The problem is with the current method used to resolve urls in the data grid. AFAIK, in some cases url's are resolved more securely, but not all.

Minimal source code to understand the problem:


class MinExample {

    constructor(o) {
        this.url = o.url;
        Object.assign(this, o?.settings ||| {})
    }

    refresh() {
        let url = (typeof this.url != ‘object’ ? this.url : this.url.get);
        console.log(‘url’, url);
    }

}

In the refresh method, we resolve the url and just output it to the console. This is fine if the url is an object, string or whatever, but it breaks if the value of this.url is null. The error for a null value is as follows:

Uncaught TypeError: Cannot read properties of null (reading ‘get’)
    at x.refresh (<anonymous>:9:66)
    at <anonymous>:1:5

The fix also replaces double quotes for undefined:

let amount = typeof event.wheelDelta != "undefined" ? -event.wheelDelta : (event.detail || event.deltaY)

becomes

let amount = typeof event.wheelDelta != 'undefined' ? -event.wheelDelta : (event.detail || event.deltaY)
alexkuznetsov commented 3 days ago

@vitmalina should i create a new PR with rebuilded dist files?