SteveSanderson/knockout — Issue #194: HTML5 elements cannot be rendered on IE8 and below
Author: mattfeury
Created: 2011-11-02 18:14:44+00:00
State: open

Greetings,

Most people using HTML5 on IE8 and below are aware of the need to include "innershiv" to have IE actually style and append child nodes to HTML5 elements. I believe the Knockout is suffering from the same problem.

See innershiv here: http://jdbartlett.com/innershiv/

KO will barf on these elements and not append any children to them, thus ruining the template. I'm not sure if you want to rely on another JS dependency, but since, theoretically, anyone with HTML5 on IE8- will need this script anyway, it probably does not create any more baggage. Here is how I fixed it:

1. Add an innershiv + jquery helper function somewhere in your code:
```window.$shivIe = function(contents) {
return (typeof(innerShiv) == "undefined") ? $(contents) : $(innerShiv(contents, false));
}
```

2. Find 'ko.utils.parseHtmlFragment' on line 552 (of the debug version) and have it prefer to use this instead of jQuery.clean:
```ko.utils.parseHtmlFragment = function(html) {
return typeof jQuery != 'undefined' ? $shivIe(html) // As below, benefit from jQuery's optimisations where possible
: simpleHtmlParse(html); // ... otherwise, this simple logic will do in most common cases.
};
```

You can see an example of this issue here: http://jsfiddle.net/2QcXE/3/ (IE8 and below will not color the border on the section elements because they are empty)
Previously posted this on the KO forum: https://groups.google.com/forum/#!topic/knockoutjs/I9AsRNmqU7E