capricorn86 / happy-dom

A JavaScript implementation of a web browser without its graphical user interface
MIT License
3.09k stars 185 forks source link

`getBoundingClientRect` always returns 0 #1416

Open ElPrudi opened 2 months ago

ElPrudi commented 2 months ago

Describe the bug No matter what I do, using getBoundingClientRect will always return an object with its stats being 0.

To Reproduce Just use this code here:

    const el = document.createElement('div')

    el.style.width = '16px'
    el.style.height = '16px'
    el.style.margin = '16px'
    el.style.padding = '16px'

    document.body.appendChild(el)

    console.log(el.getBoundingClientRect()) // returns a zero object

Expected behavior It should not return a zero object like in browser.

Screenshots If applicable, add screenshots to help explain your problem.

Device: