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
The <!--[if gt IE 8]><!--> is unecessary #1437
Comments
That would result in 2 opening |
Below I paste a screenshot from the IE8’s DOM inspector parsing the H5BP Hellow World page, with the change that I proposed. As you can see, the result (in the DOM) is just a single HTML start tag. |
Re: this https://twitter.com/komputist/status/382308854731509760. Yeah, I know how the parser works, thanks (http://nicolasgallagher.com/better-conditional-classnames-for-hack-free-css/). We're getting rid of the conditional comments in the next release anyway. |
I didn't realize there was going to be a test. |
Regarding, "removing anyway": Yes, my bug report is about what happens before that removal. Regarding the bubbling up effect that you describe in that article, cool, then I can set e.g. the language attribute on the uncommented element, and get it to bubble up to the conditionally commented start tags:
Meanwhile, feel free to treat my input as an answer to the final words of that article:
|
@komputist as @necolas already pointed out: that will result in two opening html tags in IE6-8. |
Well, @TheDutchCoder
|
I just tested it out quickly and at least in IE10 running in IE8 mode the behavior is as expected With this markup: <!DOCTYPE html>
<!--[if lt IE 7]><html class="no-js ie6"><![endif]-->
<!--[if IE 7]><html class="no-js ie7"><![endif]-->
<!--[if IE 8]><html class="no-js ie8"><![endif]-->
<html class="no-js" lang="en" > Running >> console.log(document.getElementsByTagName("html")[0].className)
no-js ie8
>> console.log(document.getElementsByTagName("html").length)
1
>> console.log(document.documentMode)
8 which is as expected. I'd be curious to try it in real IE8 to see if that behaves the same way. Not that any of this matters, since we're dropping it anyway, but it's interesting to play around with. Yet another wrinkle in this godrosaken corner of web development. Too bad it came up now and not years ago when we were first crafting this. We could have saved BYTES. |
Real IE8 returns the same thing, browsers are smart enough (yes even older IE) to drop double tags. They also try to fix other mark-up errors, but that doesn't mean they should be put in the source ;-) Just because something works, doesn't mean it's a good idea ;-) And you're right, since they will be dropped, it's kind of a moot discussion. |
Don't be so ”aunty”. Conditional comments are a hack. That is the problem. If you accept CCs and admit that the entire legacy IE6-8 browsers are on their way to the dustbin of the Internet, then it is beyond me why you defend that we sent “clean” code to IE8. (But I realize that I probably ain't going to convince you.) |
No need to get insulting here. Yes, CC's are a 'hack', but IE8 will still be here for a while, especially in the Government (hell, the Canadian Government just 'upgraded' to it for a lot of their departments). There's a difference between using a hack which doesn't interfere with the actual HTML output, and those that do (like in this case). As I said before, it doesn't matter if a browser ignores and/or fixes certain things, it can still be a bad practice. Feel free to remove the CC's in your own projects, nobody is stopping you. |
Above @roblarsen proved that it does not interfere with “the actual HTML output”. I understand the argument that "we are anyway not going to use CC in H5BP anymore" (for whatever reason). I continue to not understand the other argments. |
Well, I didn't prove anything yet. I ran a quick test in IE10 using the f12 tools. I'll test with with webpagetest tonight to see how well it works falling back to ie6 and across different os/browser versions, etc. This being IE, I wouldn't be surprised if something weird shook out :) While I think it's academic here (and thankfully at my job, since we're now IE9+-- yes, there's hope even in financial services) I think it's a nicer looking pattern and like the fact that it clearly separates the oldie stuff from the normal stuff. It also satisfies the dreamweaver bug which ended up making the pattern even uglier for a while. Also, fewer bytes. If this were 2010 I'd be really intrigued by this. As it stands it might be a better way forward for anyone still using this. |
@roblarsen The ”bubbling” effect does apparently not “bubble” attributes that begins with the letters “xml” or which are prefixed. So for instance, if we have this:
then the resultig DOM in IE6-9, is a s folllows:
In IE10 and all other browsers, then everything bubbles up. Depending on how one views it, this difference can be seen as a feature. E.g. it would mean that the selector
would only have effect in “modern” browsers. |
@roblarsen You said:
@necolas in his article in May 2011 essentially had what I propose in his hands, but dismissed it for more or less puristic reasons:
@roblarsen, you also said:
Indeed. Please note that I have only proposed this as an incremental improvement of the current version of H5BP. Thus, I realize that next version perhaps should not use conditional classnames the way H5BP is known for. |
I didn't read the article when it was originally released. I also don't like the pattern as presented in that article so I wouldn't have had the same reaction as I have to yours. Two separate blocks of HTML with one block following two meta elements is super weird looking and would require even more discussion and explanation than the current pattern. The way you've shown it is easier on both counts ("This stuff is for old ie, this stuff is for normal browsers") |
Thanks for your kind words! Since you are so positive, here is another variant:
Explanation:The above method com does the following:
Advantages:
|
@komputist
Which kind of advantage is that? |
The CDATA declaration prolongs the code by 12 characters.
While it is possible to not use the script element,
the advantages of using the script element are:
Btw, for the record and for the fun, if you only want to target all legacy IE’s, then the scrip method allows you to drop the <![if ie]> statements inside the script element:
Also, here is another variant, with only a single <!--[if foo]> statements.
|
The XHTML thing was just an example, in the end everything is pretty irrelevant for day to day use. Interesting research though, make me realize how happy I am not having to support oldIE 💃 |
I don't find this method more verbose than the code that H5BP currently uses. But it is of course more verbose than not using conditional comments. Indeed the day is nearing when cond.coms are irrelevant. So I just had to “get this out” before that day! ;) |
The advantage is that if we replace the EXAMPLE:
Add a negative conditional comment to target IE9 and IE8 (howver, it does not remove the compatibility button in those browsers):
To remove the compatibility button in IE8 and IE9 (I assume IE9 works like IE8 in this regard – I have not fully tested it – others probably have tested it already), one can add an empty conditional comment before the DOCTYPE:
And also, for an HTML5 Shiv alike effect in IE8 (and in IE8 mode in IE9+), we can as well add a unknown element with a
Or inside the
Which place choose? If one plans to run any other mode than Edge mode (in the examples above I picked IE7 mode, to make it easy to check if it works in both IE8, IE9 and IE10), then the But since the boiler plate is focused on Edge mode, we can move it out of Finally: Yeah, you can place e.g. conditional comment inside the style element and let the conent ”bubble up”:
All in all, this (that is: the use of |
The Hello World page of H5bp begins like so:
But what use is the for the conditional comment on that last line? The HTML parser will use the first start tag that it sees and disappare any other identical start tag that it might see.
The h5bp shoudl take advantage of how the HTML paraser actually works and delete the conditional comments on the last line - so that we get this:
The text was updated successfully, but these errors were encountered: