Closed Bug 1654769 Opened 4 years ago Closed 4 years ago

clientLeft/clientTop return 0 for non-inline <textarea /> with actual border

Categories

(Core :: DOM: CSS Object Model, defect)

78 Branch
defect

Tracking

()

RESOLVED FIXED
mozilla80
Tracking Status
firefox80 --- fixed

People

(Reporter: grundmanise, Assigned: emilio)

References

Details

Attachments

(2 files)

User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.89 Safari/537.36

Steps to reproduce:

https://codepen.io/eedd/pen/zYrbYOE

// css
textarea { display: block; border: 10px solid black; }

// html
<textarea id='textarea'></textarea>

//js
const ta = document.getElementById('textarea');
console.assert(ta.clientLeft !== 0, 'clientLeft is 0');
console.assert(ta.clientTop !== 0, 'clientTop is 0');

Actual results:

Element.clientLeft/Element.clientTop return 0 for non-inline <textarea /> with actual border.

Expected results:

Element.clientLeft/Element.clientTop should return actual border width for non-inline <textarea /> with border.

Component: Untriaged → DOM: Core & HTML
Product: Firefox → Core
Blocks: 111207

We're returning offsets relative to the scroll target frame, which for
inputs and such is not the primary frame, and thus they never have
border or padding or what not.

Offsets should be relative to the primary frame however, so move the
rect appropriately.

Assignee: nobody → emilio

It doesn't have to be non-inline and such. However yeah I agree this behavior is wrong. The reason why this happens is because the scrolling box in <input> / <textarea> is not the main box, and we apply the padding to the outer box rather than the scroll box.

Status: UNCONFIRMED → NEW
Component: DOM: Core & HTML → DOM: CSS Object Model
Ever confirmed: true
Pushed by ealvarez@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/0ce4c53c6abb
Make clientRect offsets relative to the primary frame of the element. r=mats
Created web-platform-tests PR https://github.com/web-platform-tests/wpt/pull/24760 for changes under testing/web-platform/tests
Status: NEW → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla80
Upstream PR merged by moz-wptsync-bot
Regressions: 1655398
Regressions: 1655811
Regressions: 1655830
No longer regressions: 1655830
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: