{"id":20065502,"url":"https://github.com/afarkas/html5shiv","last_synced_at":"2025-05-13T18:04:57.827Z","repository":{"id":45772550,"uuid":"1358497","full_name":"aFarkas/html5shiv","owner":"aFarkas","description":"This script is the defacto way to enable use of HTML5 sectioning elements in legacy Internet Explorer.","archived":false,"fork":false,"pushed_at":"2024-07-07T13:46:38.000Z","size":5145,"stargazers_count":9866,"open_issues_count":73,"forks_count":2548,"subscribers_count":558,"default_branch":"master","last_synced_at":"2025-05-06T17:13:53.785Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://paulirish.com/2011/the-history-of-the-html5-shiv/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/aFarkas.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2011-02-12T12:21:10.000Z","updated_at":"2025-05-05T03:31:08.000Z","dependencies_parsed_at":"2024-11-13T14:02:16.543Z","dependency_job_id":null,"html_url":"https://github.com/aFarkas/html5shiv","commit_stats":{"total_commits":231,"total_committers":35,"mean_commits":6.6,"dds":0.5367965367965368,"last_synced_commit":"daa5fd1169cf8c1b63b0659754b4d13b037c0e54"},"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aFarkas%2Fhtml5shiv","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aFarkas%2Fhtml5shiv/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aFarkas%2Fhtml5shiv/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aFarkas%2Fhtml5shiv/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aFarkas","download_url":"https://codeload.github.com/aFarkas/html5shiv/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254000824,"owners_count":21997441,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-13T13:50:57.991Z","updated_at":"2025-05-13T18:04:57.801Z","avatar_url":"https://github.com/aFarkas.png","language":"JavaScript","readme":"# The HTML5 Shiv\n\nThe HTML5 Shiv enables use of HTML5 sectioning elements in legacy Internet Explorer and provides basic HTML5 styling for Internet Explorer 6-9, Safari 4.x (and iPhone 3.x), and Firefox 3.x.\n\n### What do these files do?\n\n#### `html5shiv.js`\n*  This includes the basic `createElement()` shiv technique, along with monkeypatches for `document.createElement` and `document.createDocumentFragment` for IE6-8. It also applies [basic styling](https://github.com/aFarkas/html5shiv/blob/51da98dabd3c537891b7fe6114633fb10de52473/src/html5shiv.js#L216-220) for HTML5 elements for IE6-9, Safari 4.x and FF 3.x.\n\n#### `html5shiv-printshiv.js` \n*  This includes all of the above, as well as a mechanism allowing HTML5 elements to be styled and contain children while being printed in IE 6-8.\n\n### Who can I get mad at now?\n\nHTML5 Shiv is maintained by [Alexander Farkas](https://github.com/aFarkas/), [Jonathan Neal](https://twitter.com/jon_neal) and [Paul Irish](https://twitter.com/paul_irish), with many contributions from [John-David Dalton](https://twitter.com/jdalton). It is also distributed with [Modernizr](http://modernizr.com/).\n\nIf you have any issues in these implementations, you can report them here! :)\n\nFor the full story of HTML5 Shiv and all of the people involved in making it, read [The Story of the HTML5 Shiv](http://paulirish.com/2011/the-history-of-the-html5-shiv/).\n\n## Installation\n\n### Using [Bower](http://bower.io/)\n\n`bower install html5shiv --save`\n\nThis will clone the latest version of the HTML5 shiv into the `bower_components` directory at the root of your project and also create or update the file `bower.json` which specifies your projects dependencies.\n\nInclude the HTML5 shiv in the `\u003chead\u003e` of your page in a conditional comment and after any stylesheets.\n\n```html\n\u003c!--[if lt IE 9]\u003e\n\t\u003cscript src=\"bower_components/html5shiv/dist/html5shiv.js\"\u003e\u003c/script\u003e\n\u003c![endif]--\u003e\n```\n\n### Manual installation\n\nDownload and extract the [latest zip package](https://github.com/aFarkas/html5shiv/archive/master.zip) from this repositiory and copy the two files `dist/html5shiv.js` and `dist/html5shiv-printshiv.js` into your project. Then include one of them into your `\u003chead\u003e` as above. \n\n## HTML5 Shiv API\n\nHTML5 Shiv works as a simple drop-in solution. In most cases there is no need to configure HTML5 Shiv or use methods provided by HTML5 Shiv.\n\n### `html5.elements` option\n\nThe `elements` option is a space separated string or array, which describes the **full** list of the elements to shiv. see also `addElements`.\n\n**Configuring `elements` before `html5shiv.js` is included.**\n\n```js\n//create a global html5 options object\nwindow.html5 = {\n  'elements': 'mark section customelement' \n};\n```\n**Configuring `elements` after `html5shiv.js` is included.**\n\n```js\n//change the html5shiv options object \nwindow.html5.elements = 'mark section customelement';\n//and re-invoke the `shivDocument` method\nhtml5.shivDocument(document);\n```\n\n### `html5.shivCSS`\n\nIf `shivCSS` is set to `true` HTML5 Shiv will add basic styles (mostly display: block) to sectioning elements (like section, article). In most cases a webpage author should include those basic styles in his normal stylesheet to ensure older browser support (i.e. Firefox 3.6) without JavaScript.\n\nThe `shivCSS` is true by default and can be set false, only before html5shiv.js is included: \n\n```js\n//create a global html5 options object\nwindow.html5 = {\n\t'shivCSS': false\n};\n```\n\n### `html5.shivMethods`\n\nIf the `shivMethods` option is set to `true` (by default) HTML5 Shiv will override `document.createElement`/`document.createDocumentFragment` in Internet Explorer 6-8 to allow dynamic DOM creation of HTML5 elements. \n\nKnown issue: If an element is created using the overridden `createElement` method this element returns a document fragment as its `parentNode`, but should be normally `null`. If a script relies on this behavior, `shivMethods`should be set to `false`.\nNote: jQuery 1.7+ has implemented his own HTML5 DOM creation fix for Internet Explorer 6-8. If all your scripts (including Third party scripts) are using jQuery's manipulation and DOM creation methods, you might want to set this option to `false`.\n\n**Configuring `shivMethods` before `html5shiv.js` is included.**\n\n```js\n//create a global html5 options object\nwindow.html5 = {\n\t'shivMethods': false\n};\n```\n**Configuring `elements` after `html5shiv.js` is included.**\n\n```js\n//change the html5shiv options object \nwindow.html5.shivMethods = false;\n```\n\n### `html5.addElements( newElements [, document] )`\n\nThe `html5.addElements` method extends the list of elements to shiv. The newElements argument can be a whitespace separated list or an array.\n\n```js\n//extend list of elements to shiv\nhtml5.addElements('element content');\n```\n\n### `html5.createElement( nodeName [, document] )`\n\nThe `html5.createElement` method creates a shived element, even if `shivMethods` is set to false.\n\n```js\nvar container = html5.createElement('div');\n//container is shived so we can add HTML5 elements using `innerHTML`\ncontainer.innerHTML = '\u003csection\u003eThis is a section\u003c/section\u003e';\n```\n\n### `html5.createDocumentFragment( [document] )`\n\nThe `html5.createDocumentFragment` method creates a shived document fragment, even if `shivMethods` is set to false.\n\n```js\nvar fragment = html5.createDocumentFragment();\nvar container = document.createElement('div');\nfragment.appendChild(container);\n//fragment is shived so we can add HTML5 elements using `innerHTML`\ncontainer.innerHTML = '\u003csection\u003eThis is a section\u003c/section\u003e';\n```\n\n## HTML5 Shiv Known Issues and Limitations\n\n- The `shivMethods` option (overriding `document.createElement`) and the `html5.createElement` method create elements, which are not disconnected and have a parentNode (see also issue #64)\n- The cloneNode problem is currently not addressed by HTML5 Shiv. HTML5 elements can be dynamically created, but can't be cloned in all cases.\n- The printshiv version of HTML5 Shiv has to alter the print styles and the whole DOM for printing. In case of complex websites and or a lot of print styles this might cause performance and/or styling issues. A possible solution could be the [htc-branch](https://github.com/aFarkas/html5shiv/tree/iepp-htc) of HTML5 Shiv, which uses another technique to implement print styles for Internet Explorer 6-8.\n\n### What about the other HTML5 element projects?\n\n- The original conception and community collaboration story of the project is described at [The History of the HTML5 Shiv](http://paulirish.com/2011/the-history-of-the-html5-shiv/). \n- [IEPP](https://code.google.com/p/ie-print-protector), by Jon Neal, addressed the printing fault of the original `html5shiv`. It was merged into `html5shiv`.\n- **Shimprove**, in April 2010, patched `cloneNode` and `createElement` was later merged into `html5shiv`\n- **innerShiv**, introduced in August 2010 by JD Barlett, addressed dynamically adding new HTML5 elements into the DOM. [jQuery added support](http://blog.jquery.com/2011/11/03/jquery-1-7-released/) that made innerShiv redundant and `html5shiv` addressed the same issues as well, so the project was completed.\n- The **html5shim** and **html5shiv** sites on Google Code are maintained by Remy Sharp and are identical distribution points of this `html5shiv` project.\n- **Modernizr** is developed by the same people as `html5shiv` and can include the latest version in any custom builds created at modernizr.com\n- This `html5shiv` repo now contains tests for all the edge cases pursued by the above libraries and has been extensively tested, both in development and production. \n\nA [detailed changelog of html5shiv](https://github.com/aFarkas/html5shiv/wiki) is available.\n\n### Why is it called a *shiv*?\n\nThe term **shiv** [originates](http://ejohn.org/blog/html5-shiv/) from [John Resig](https://github.com/jeresig), who was thought to have used the word for its slang meaning, *a sharp object used as a knife-like weapon*, intended for Internet Explorer. Truth be known, John probably intended to use the word [shim](http://en.wikipedia.org/wiki/Shim_(computing)), which in computing means *an application compatibility workaround*. Rather than correct his mispelling, most developers familiar with Internet Explorer appreciated the visual imagery. And that, kids, is [etymology](https://en.wikipedia.org/wiki/Etymology).\n","funding_links":[],"categories":["5. 基础模版"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fafarkas%2Fhtml5shiv","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fafarkas%2Fhtml5shiv","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fafarkas%2Fhtml5shiv/lists"}