Wednesday, January 4, 2012

UPDATED: FireFox 9.0.1 Font CSS Bug Strictness

Today I got a nice surprise at work this morning. One of my teammates got the FireFox 9.0.1 (Windows) update pushed to them yesterday and it broke an internal mediawiki site. Thinking this must be a bug in the CSS of our mediawiki skin I dove into explore the issue. This is not my CSS code so I was naturally suspicious and couldn't wait to rub it in to another colleague (author of said CSS) when I found his hideously stupid bug....

Unfortunately I didn't get the opportunity to do a little chiding, because the problem, it turns out, is with the CSS parser in the FireFox 9.0.1 update. The CSS parser in FireFox 9.0.1 doesn't handle the font stack correctly.

Honestly that's being far too generous. This bug breaks font attributes in CSS, okay not all font attributes in CSS just the ones you want to override. It does NOT allow overriding of previous settings at ALL in the font attributes.

UPDATE: There was a helpful soul on the forum that gave me a gentle shove towards the CSS documentation found here and it illuminated the bug in the CSS below. While it worked in previous versions of FireFox, it probably shouldn't have. I've preserved the original example for others to see the issue. I've made the example a little more copy & paste friendly.

Take this BUGGY example:
<style>
#p-wrapper p {
font-family: arial;
font-size: 125%;
}

#p-inner p {
font-size: 95%;
}
</style>

<div class="p-wrapper"><p>Some Wrapper Text</p>
<div class="p-inner"><p>Some inner text</p></div>
</div>

What supposed used to happen with the above snippet is that the font-size would change from 125% when in the p-wrapper class(can you spot the bug yet?), unless you happen to be in the p-inner class(there's that word again) in which case the font-size should change to 95%. In FireFox 9.0.1 this does not happen. Instead the first value for font-size wins. There's no cascading at all. It really makes the CSS engine in FireFox 9.0.1 look more like SS. And that is to be expected. That code has a bug. The # at the beginning of p-wrapper and p-inner define an id selector. What I need is a class selector. FireFox 9.0 became strict in this respect and now you must actually write VALID CSS(what a concept) like the following:

<style>
.p-wrapper p {
font-family: arial;
font-size: 125%;
}

.p-inner p {
font-size: 95%;
}
</style>

<div class="p-wrapper"><p>Some Wrapper Text</p>
<div class="p-inner"><p>Some inner text</p></div>
</div>

There is still a CSS bug in FireFox 9, but it does not appear to be mine. My bug appears to be non-standard and almost flatly invalid CSS. The good thing to come out of this episode is that I now get to harass the colleague for the sloppy code. YAY!!! However, now I have to fix up the CSS in the mediawiki skin.... BOO!!!

If you find any mistakes or errors in this post please drop a note.

Happy Hacking!!

5 comments:

Anonymous said...

I saw that you posted a reply on my post in the Firefox forum. I can't believe how lame that forum is. Kind of the equivalent of a voice answering system. "If that answered your question, press 1. To submit a new question, press 2 ..."

Doesn't appear that the FF devs read the forum and there doesn't seem to be any way to submit an actual bug report.

Zac Slade said...

I totally agree. It's completely lame.

This week they finally pushed 9.0.1 to the stable release channel and now it's breaking even more stuff.

Do you have any idea how we can get this bug more visibility? To me this is as severe as a crash bug. It breaks the CSS standard completely.

Anonymous said...

I just found the actual place to report bugs: https://bugzilla.mozilla.org/. I filed bug #718016. Maybe now it will git some more attention.

Dan

Zac Slade said...

I updated the link in the blog post to point to the bugzilla entry.

https://bugzilla.mozilla.org/show_bug.cgi?id=718016

Thanks for posting this. Maybe we can get some visibility now. This is likely to cost me a couple of weeks in cleanup unless Mozilla releases an update to fix this.

raekaabegg said...

Casino.info Review 2021 - Claim Your €100 Welcome Bonus
Casino.info Review 보령 출장샵 ✓ Welcome Bonus 경상북도 출장마사지 ✓ Fast payouts ✓ Fast payouts 안산 출장샵 ✓ Find trusted reviews ✓ Find trusted casinos that 논산 출장샵 accept 🎲 Games: 550+💸 Min Withdrawal: €/$100 Rating: 4.7 · ‎Review by Casino.infoIs Casino.info safe?Is Casino.info safe? 룰렛 돌리기