colazo / enhancejs

Automatically exported from code.google.com/p/enhancejs
Other
0 stars 0 forks source link

for pseudo IE conditional comment support, use conditional compilation instead of UA string. #3

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
currently, EnhanceJS uses user-agent detection for ieconditions, which serve as 
a replacement 
for conditional comments when loading IE-only scripts or styles. It would be 
great to change this 
to use JS-generated conditional comments instead. Something like...

function wrapInConditionalComment(htmlString,iecondition){
    return document.createDocumentFragment().appendChild(document.createTextNode('<!--[if 
'+ iecondition +']>'+ htmlString +'<![endif]-->'));
}

if (attr === 'iecondition') {
    var linkHTML = document.createElement('div').appendChild(link).innerHTML;
    link = wrapInConditionalComment(linkHTML, name['iecondition']);
 }
//append comment
head.appendChild(link);

Original issue reported on code.google.com by scottj...@gmail.com on 6 Feb 2010 at 3:17

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago

Original comment by scottj...@gmail.com on 2 Apr 2010 at 3:17

GoogleCodeExporter commented 8 years ago

Original comment by scottj...@gmail.com on 2 Apr 2010 at 3:30

GoogleCodeExporter commented 8 years ago
So this works for IE 6-8 (or all):

function isIE(version) {
    return /*@cc_on (version === 'all' || parseFloat('5.' + parseInt(version,10)) === @_jscript_version)@*/;
}

But, unfortunately, IE reports the same jscript versions in both IE8 and IE8 
compatibility mode (which is supposed 
to emulate IE7), so IE8 users browsing a site in compatibility mode would not 
receive IE7-specific assets, which 
might make for a broken page depending on what sort of IE7 workarounds they 
were using. 

Now, I'm not sure if this is worth the tradeoff of replacing UA detect, which 
is more reliable in this case. Moving to 
a Groups discussion thread...

Original comment by scottj...@gmail.com on 5 Apr 2010 at 4:51

GoogleCodeExporter commented 8 years ago
The patch for this change is attached in case we end up going with it.

Groups discussion thread:
http://groups.google.com/group/enhancejs/browse_thread/thread/3846615e875def79

Original comment by scottj...@gmail.com on 5 Apr 2010 at 6:51

Attachments:

GoogleCodeExporter commented 8 years ago

Original comment by scottj...@gmail.com on 5 Apr 2010 at 7:36

GoogleCodeExporter commented 8 years ago
fixed in R83
http://code.google.com/p/enhancejs/source/detail?r=83

Original comment by scottj...@gmail.com on 6 Apr 2010 at 10:11