Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

utils::calcWidthOfInput() relies on nonstandard behavior of window.getComputedStyle() #607

Closed
aiwebb opened this issue Jul 1, 2019 · 1 comment

Comments

@aiwebb
Copy link
Contributor

aiwebb commented Jul 1, 2019

The issue is in src/scripts/lib/utils.js:calcWidthOfInput():

const inputStyle = window.getComputedStyle(input);

if (inputStyle) {
  testEl.style.fontSize = inputStyle.fontSize;
  testEl.style.fontFamily = inputStyle.fontFamily;
  testEl.style.fontWeight = inputStyle.fontWeight;
  testEl.style.fontStyle = inputStyle.fontStyle;
  testEl.style.letterSpacing = inputStyle.letterSpacing;
  testEl.style.textTransform = inputStyle.textTransform;
  testEl.style.padding = inputStyle.padding;                    // <---------
}

The spec for window.getComputedStyle() stipulates that shorthand properties like padding should be empty in the return object.

Firefox adheres to spec on this, so inputStyle.padding is always "". This results in input padding not being accounted for in Firefox.

Chrome departs from spec in favor of usability, so inputStyle.padding reflects the actual padding settings of the element.

The solution is to change this to copy paddingLeft and paddingRight explicitly.

@jshjohnson
Copy link
Collaborator

Closing as this util has been removed as of version 8.x

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants