IE conditional not working properly

71 views
Skip to first unread message

Evgeny

unread,
Apr 28, 2008, 4:54:21 AM4/28/08
to Haml
I am trying to use an IE conditional comment, with Haml syntax - but get an error (haml 1.8.2)

!!!
%html
  %body
  /[if !IE]
    You are not in IE
  /[if IE]
    You are in IE

Syntax error on line 4: Illegal Nesting: Nesting within a tag that already has content is illegal.


It's a valid conditional for "if not IE", but it does not work in haml .... 


fix please?

Nathan Weizenbaum

unread,
Apr 28, 2008, 10:58:14 AM4/28/08
to ha...@googlegroups.com
Haml doesn't (and won't) support generating downlevel-revealed
conditional comments. Thus "/[if !IE]" won't be useful; no browser will
respect it.

That said, it should at least generate something. I'll fix it some time
today.

- Nathan

Evgeny

unread,
Apr 28, 2008, 1:47:55 PM4/28/08
to ha...@googlegroups.com
Sorry, but I did not understant what you said. What is a downlevel-revealed-conditional-comment ? :)

The conditional comments I am talking about are the ones defined by M$ :
<!--[if !IE]--> ... <![endif]--> is how it looks like in plain html.

The article on M$ is at : http://msdn2.microsoft.com/en-us/library/ms537512(VS.85).aspx  and you can clearly see that IE supports "The NOT operator".

AFAIK Haml generates these conditional comments, and should not really think they are nested ... for example in HAML

  /[if lte IE 6]
    sometext

will make a block in html that looks like this:
  <!--[if lte IE 6]>
    sometext
  <![endif]-->

Why should /[if !IE] break?

Jarrod Spillers

unread,
Apr 28, 2008, 1:55:02 PM4/28/08
to ha...@googlegroups.com
The problem i see with that is the fact that Internet explorer is the only line of browsers that understand the conditional comments...

if its not IE then it doesn't even understand the conditional comment

/[if !IE 6] would apply to IE 5, 7 etc... but just /[if !IE] would never be evaluated true by any browser, ever.

- Jarrod

Nathan Weizenbaum

unread,
Apr 28, 2008, 2:32:00 PM4/28/08
to ha...@googlegroups.com
Jarrod is right. Microsoft does support "downlevel-revealed" conditionals (http://msdn2.microsoft.com/en-us/library/ms537512%28VS.85%29.aspx#dlrevealed), which is the only case in which [if !IE] would work. These are of the form

<![if !IE]> stuff <![endif]>

which is, of course, invalid XHTML.

Jarrod Spillers

unread,
Apr 28, 2008, 2:45:00 PM4/28/08
to ha...@googlegroups.com
Ahhh... I didn't consider that use... but you are right - that wouldn't validate at all

Nathan Weizenbaum

unread,
Apr 29, 2008, 12:29:39 AM4/29/08
to ha...@googlegroups.com
Okay, I've added the capability to use stuff like ! in conditional
comments in the master branch.

> <http://msdn2.microsoft.com/en-us/library/ms537512%28VS.85%29.aspx>

Reply all
Reply to author
Forward
0 new messages