window.getComputedStyle does not correctly set padding or margin values
Categories
(Core :: DOM: CSS Object Model, defect)
Tracking
()
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.
Comment 1•3 years ago
|
||
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.
Comment 2•3 years ago
|
||
Spec changed around this, but yeah, we need to get to implementing shorthands on getComputedStyle.
Description
•