user1631995
user1631995

Reputation:

What is really needed for HTML5 support?

I am using HTML5 tags like header and was using html5shiv: http://code.google.com/p/html5shiv/.

Looking through the files, it's seemed like everything is overdone with a bunch of unnecessary files, so I researched of an easier way through html5shiv http://css-tricks.com/snippets/javascript/make-html5-elements-work-in-old-ie/ and simply adding the "hotlink": http://html5shiv.googlecode.com/svn/trunk/html5.js and letting them host the rest.

Then I was thinking, even this code seems overdone. Why can't I just use createelement http://reference.sitepoint.com/javascript/Document/createElement, why do I need all the html5shiv code in general?

Here is some of the code from: http://html5shiv.googlecode.com/svn/trunk/html5.js

.cloneNode():f=c(a),f.canHaveChildren&&!d.test(a)?
g.appendChild(f):f},a.createDocumentFragment=Function("h,f","return function(){var 
n=f.cloneNode(),c=n.createElement;h.shivMethods&&("+i().join()

I am not a professional at JavaScript, but I don't understand why this is necessary?

Upvotes: 0

Views: 111

Answers (1)

Spudley
Spudley

Reputation: 168685

HTML5Shiv fixes several issues with using HTML5 element in IE, not just the obvious one of being able to create the elements in the first place. The first version was just that, but later versions have added further fixes for other issues.

The two other issues that I know of are:

  • Bugs with printing pages containing HTML5 elements.
  • A bug with .innerHTML when used with an HTML5 element.

The basic issue of allowing these elements to be added to the page is a pretty short and easy bit of code, but these other two issues are where the bulk of the HTML5Shiv code comes from.

A full write-up of the history of HTML5Shiv and when these things were added can be found here: http://paulirish.com/2011/the-history-of-the-html5-shiv/

Upvotes: 1

Related Questions