Closed Bug 1690830 Opened 3 years ago Closed 3 years ago

window.getComputedStyle does not correctly set padding or margin values

Categories

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

Firefox 85
defect

Tracking

()

RESOLVED DUPLICATE of bug 137688

People

(Reporter: blayze, Unassigned)

Details

User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 11_1_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.96 Safari/537.36

Steps to reproduce:

Take the given test case:

<html lang="en">
<head>
<style type="text/css">
#test {
margin: 15px;
}
</style>
</head>
<body>
<div id="test">
<h1>Hello World!</h1>
</div>
</body>
<footer></footer>
</html>

Then in console type the following:
window.getComputedStyle(document.getElementById('test'))['margin']

Actual results:

A empty string was returned. However the values margin-right, margin-left, margin-top, margin-bottom are set. This could be an issue with all directional styling but I have only tested it with margin and padding because this is the issue I ran into. This also appears in earlier versions and on both windows and mac.

Expected results:

It should return 15px. This works in chrome, safari, opera and edge.

The Bugbug bot thinks this bug should belong to the 'Core::DOM: CSS Object Model' component, and is moving the bug to that component. Please revert this change in case you think the bot is wrong.

Component: Untriaged → DOM: CSS Object Model
Product: Firefox → Core

Spec changed around this, but yeah, we need to get to implementing shorthands on getComputedStyle.

Status: UNCONFIRMED → RESOLVED
Closed: 3 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.