Skip to content

Adding and then removing "background" from style attribute creates unwanted styles #2407

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

Closed
WickyNilliams opened this issue Oct 24, 2014 · 4 comments · Fixed by #4665
Closed

Comments

@WickyNilliams
Copy link
Contributor

I have an element and depending on some condition, may set it's background. If the condition is first true, and later false the element is left with some "residual" styles that were never set in code.

Output looks like:

<!-- condition true -->
<div style="background: #ff0000"></div>

<!-- then when condition is false -->
<div style="background-attachment: initial; background-size: initial; background-origin: initial; background-clip: initial;"></div>

These styles were never set by user code, and are interfering with styles in my CSS.

Here's a fiddle showing the issue: http://jsfiddle.net/tfKYJ/78/

@syranide
Copy link
Contributor

👍 For posterity, this is probably the IE8 workaround that back-fires, but haven't actually verified.

EDIT: This is really weird, the IE8 workaround should actually fix this it seems, but doesn't for some reason...

@WickyNilliams
Copy link
Contributor Author

Interestingly, doesn't happen in safari, but FF is affected (however different values for CSS properties):

<div style="background-attachment: scroll; background-clip: border-box; background-origin: padding-box; background-size: auto auto;"></div>

@syranide
Copy link
Contributor

Highlights the problem without diving into the markup: http://jsfiddle.net/wc95h405/

@sophiebits
Copy link
Collaborator

The issue here is that we only unset background image, position, repeat, and color and not attachment, clip, origin, or size. Not sure where I came up with that original list. I think the best course of action here is to make sure we unset all the properties that IE8 supports, then take your #1953. These shorthand properties are kind of a pain. :)

sophiebits added a commit to sophiebits/react that referenced this issue Aug 20, 2015
In conjunction with facebook#1953, fixes facebook#2407. This seems to be all of the shorthand style properties that IE8 supports, excluding a few nonstandard ones.
sophiebits added a commit that referenced this issue Aug 20, 2015
Ensure IE8 style expansion list is up to date
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants