ulixee / hero

The web browser built for scraping
MIT License
652 stars 32 forks source link

getBoundingClientRect for ISuperNode gives wrong interface (IDomRect) #167

Open GlenDC opened 1 year ago

GlenDC commented 1 year ago

getBoundingClientRect method of a ISuperNode. According to the types (typescript) these elements like x etc should be promises, but they are just plain properties. I know this is from a dependency you use, but it's still pretty annoying, nee to manually cast it.

E.g.:

const myEl = await myFrame.querySelector(
            'css path',
        );

        const rect =
            (await myEl.getBoundingClientRect()) as any as {
                x: number;
                y: number;
                width: number;
                height: number;

Without the cast above it thinks that the return object of await myEl.getBoundingClientRect() has its properties like x as a promise. But a debugger shows that it is a plain number, not a promise.