panfil
panfil

Reputation: 1539

cssText webkit bug?

Example here: http://jsfiddle.net/7h2Dh/

Got this html:

<span>Text<div id="wtf">Content</div>Text</span>

I need to set div display property throught js:

document.getElementById( 'wtf' ).style.cssText = 'display:inline-block'   ​

But in Chrome and Safari div drops on the second line.

Is it a bug and can I fix it somehow?

Upvotes: 1

Views: 251

Answers (1)

Evan Teran
Evan Teran

Reputation: 90432

This seems like a bug to me. Simply because according to the chrome dev tools, the style is in fact being set. It just doesn't seem to be properly recalculating the flow of the element.

Also, I don't think it's ever considered correct for a style set via javascript to act differently than a style set with a style sheet. In addition, other browsers like Firefox seem to act as expected.

So I'd report it to the webkit folks :-).

EDIT:

One thing that I'm not 100% sure about is that you are putting a <div> inside a <span> which I think is not allowed. So in the end, this may be a case of there not being such thing as "correct" behavior since you're breaking the rules.

Changing the <span> to a <div> makes thing act as expected. So that's probably your solution.

Upvotes: 2

Related Questions