Closed Bug 336021 Opened 19 years ago Closed 19 years ago

CSS is not interpreted when around <xsl:comment> in a <style> element.

Categories

(Core :: XSLT, defect)

x86
Windows XP
defect
Not set
minor

Tracking

()

RESOLVED INVALID

People

(Reporter: boen.robot, Unassigned)

Details

User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.2) Gecko/20060308 Firefox/1.5.0.2 Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.2) Gecko/20060308 Firefox/1.5.0.2 A CSS inside the style element is normally interpreted even if there are XHTML comments around it. We use such comments to hide the CSS for old browsers. For example: <style type="text/css"> <!-- table * {border: 1px solid #000000;} --> </style> If we would like to emulate the same effect inside XSLT, we would use the <xsl:comment> element around our CSS, scince the above in XSLT would mean comment in the XSLT itself, thus making the output an empty style element. The output with <xsl:comment> should be exactly like the one avove, thus interpreted. Example: <style type="text/css"> <xsl:comment> table * {border: 1px solid #000000;} </xsl:comment> </style> However, what Firefox does is to treat the CSS as part of an ordinary XHTML comment and thus ignores the CSS. Reproducible: Always Steps to Reproduce: 1. Create an XML and some XSLT to it which uses output set to HTML. 2. Try to make some styling to it with CSS insde a <style> element, without any comments to surround the CSS. It works, right? 3. Add <xsl:comment> around the CSS in order to get a comment around the CSS in the output. Actual Results: The CSS surrounded by <xsl:comment> is not interpreted. Expected Results: The output should have returned an XHTML comment that is treated specially, which means the CSS should have been interpreted. Using a server side scripting language to generate the output of course fixes this scince Firefox would then read the XHTML, not the XSLT. However, what I'd like to have is the ability to use a server side script and also provide a client side XML and XSLT equivalent. I already have figured workarounds for this (for starters: don't use the <xsl:comment> on the first place), but this is still wrong.
First of all, why do you want to wrap the contents of the style element inside comment? That used to be a trick to deal with browsers that didn't support that element, but there aren't any such browsers today. And there are certainly no browsers that support XSLT but don't support <style>. So just remove the comment and things will work fine. The technical reason this doesn't work: Comments inside style, and everywhere else, are ignored. As they should be, they are just comments and not something that should affect page rendering. "<!--" and "-->" between <style> and </style> tags is not parsed as comments since the contents of <style> is not markup but rather just text. If you check the DOM you'll see that there is just a textnode inside the <style> element.
Status: UNCONFIRMED → RESOLVED
Closed: 19 years ago
Resolution: --- → INVALID
You need to log in before you can comment on or make changes to this bug.