Open Bug 1499884 Opened 8 years ago Updated 4 years ago

For <option>s, getBoundingClientRect() is off by one

Categories

(Core :: Layout: Form Controls, defect)

62 Branch
defect

Tracking

()

Tracking Status
firefox64 --- affected

People

(Reporter: me, Unassigned)

Details

Attachments

(1 file)

Attached file test.html —
User Agent: Mozilla/5.0 (X11; Fedora; Linux x86_64; rv:62.0) Gecko/20100101 Firefox/62.0 Steps to reproduce: When you getBoundingClientRect() on an <option> element, the returned x and left positions are 1 larger than they should be. This can be reproduced with the following page (attached): <!doctype html> <select style="border: 1px solid red;"><option>Hi</option></select> <script> console.log(document.querySelector("select").getBoundingClientRect()); console.log(document.querySelector("option").getBoundingClientRect()); </script> Actual results: The printed results put the <select> at (8, 8) and the <option> at (9, 10): DOMRect { x: 8, y: 8, width: 36, height: 21, top: 8, right: 44, bottom: 29, left: 8 } DOMRect { x: 10, y: 9, width: 34, height: 17, top: 9, right: 44, bottom: 26, left: 10 } Expected results: Since the <select> has a 1px border, the option should be at (9, 9). Note that the width of the <option> is 34px, while the <select> is 36px wide, as expected from 1px of border and nothing else funky going on.
Reproduced the issue on Windows 10 x64. Setting a component to involve the development team to review this issue. Thanks for the report!
Status: UNCONFIRMED → NEW
Component: Untriaged → Console
Ever confirmed: true
Product: Firefox → DevTools
Moving to the DOM component since the console only prints what's returned by the engine here.
Component: Console → DOM
Product: DevTools → Core
Component: DOM → Layout: Form Controls
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: