An HTML5 Shim in an HTML Component
Pull request Compare This branch is even with chjj:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
test
LICENSE
README.md
shim.htc
shim.min.htc

README.md

shim.htc: An HTML5 Shim

shim.htc is an HTML Component and html5 "shim" to fix bugged HTML5 elements in IE.

UPDATE: It is better to put the behavior property on the body element as opposed to the html element.

Technically speaking, it's not actually a shim: The traditional html5 shim works by using document.createElement to essentially fix IE's HTML parser. This .htc file is different in that it will go in after the fact and fix the DOM structure by hand. This is the only way to do it because .htc's can only be executed after the document has loaded. It's not as elegant, no, but you don't have to muddy up your markup. It's a little hacksy, but this is all it requires:

body { behavior: url(shim.htc); }

Obviously, all non-IE browsers will completely ignore that property.

It arguably saves more bandwidth in the long run because a .css and .htc file can be cached, whereas conditional comments will linger on every response served. It also seems much better looking than the ugly looking conditional comments which only pollute your markup.

License

(c) Copyright 2011 (MIT Licensed), Christopher Jeffrey.
See LICENSE for more info.