1 2;(function(window, document) { 3/*jshint evil:true */ 4 /** version */ 5 var version = '3.7.2
vendor: 9,986 bytes, lines 5-319
5'; 6 7 /** Preset options */ 8 var options = window.html5 || {}; 9 10 /** Used to skip problem elements */ 11 var reSkip = /^<|^(?:button|map|select|textarea|object|iframe|option|optgroup)$/i; 12 13 /** Not all elements can be cloned in IE **/ 14 var saveClones = /^(?:a|b|code|div|fieldset|h1|h2|h3|h4|h5|h6|i|label|li|ol|p|q|span|strong|style|table|tbody|td|th|tr|ul)$/i; 15 16 /** Detect whether the browser supports default html5 styles */ 17 var supportsHtml5Styles; 18 19 /** Name of the expando, to work with multiple documents or to re-shiv one document */ 20 var expando = '_html5shiv'; 21 22 /** The id for the the documents expando */ 23 var expanID = 0; 24 25 /** Cached data for each document */ 26 var expandoData = {}; 27 28 /** Detect whether the browser supports unknown elements */ 29 var supportsUnknownElements; 30 31 (function() { 32 try { 33 var a = document.createElement('a'); 34 a.innerHTML = '<xyz></xyz>'; 35 //if the hidden property is implemented we can assume, that the browser supports basic HTML5 Styles 36 supportsHtml5Styles = ('hidden' in a); 37 38 supportsUnknownElements = a.childNodes.length == 1 || (function() { 39 // assign a false positive if unable to shiv 40 (document.createElement)('a'); 41 var frag = document.createDocumentFragment(); 42 return ( 43 typeof frag.cloneNode == 'undefined' || 44 typeof frag.createDocumentFragment == 'undefined' || 45 typeof frag.createElement == 'undefined' 46 ); 47 }()); 48 } catch(e) { 49 // assign a false positive if detection fails => unable to shiv 50 supportsHtml5Styles = true; 51 supportsUnknownElements = true; 52 } 53 54 }()); 55 56 /*--------------------------------------------------------------------------*/ 57 58 /** 59 * Creates a style sheet with the given CSS text and adds it to the document. 60 * @private 61 * @param {Document} ownerDocument The document. 62 * @param {String} cssText The CSS text. 63 * @returns {StyleSheet} The style element. 64 */ 65 function addStyleSheet(ownerDocument, cssText) { 66 var p = ownerDocument.createElement('p'), 67 parent = ownerDocument.getElementsByTagName('head')[0] || ownerDocument.documentElement; 68 69 p.innerHTML = 'x<style>' + cssText + '</style>'; 70 return parent.insertBefore(p.lastChild, parent.firstChild); 71 } 72 73 /** 74 * Returns the value of `html5.elements` as an array. 75 * @private 76 * @returns {Array} An array of shived element node names. 77 */ 78 function getElements() { 79 var elements = html5.elements; 80 return typeof elements == 'string' ? elements.split(' ') : elements; 81 } 82 83 /** 84 * Extends the built-in list of html5 elements 85 * @memberOf html5 86 * @param {String|Array} newElements whitespace separated list or array of new element names to shiv 87 * @param {Document} ownerDocument The context document. 88 */ 89 function addElements(newElements, ownerDocument) { 90 var elements = html5.elements; 91 if(typeof elements != 'string'){ 92 elements = elements.join(' '); 93 } 94 if(typeof newElements != 'string'){ 95 newElements = newElements.join(' '); 96 } 97 html5.elements = elements +' '+ newElements; 98 shivDocument(ownerDocument); 99 } 100 101 /** 102 * Returns the data associated to the given document 103 * @private 104 * @param {Document} ownerDocument The document. 105 * @returns {Object} An object of data. 106 */ 107 function getExpandoData(ownerDocument) { 108 var data = expandoData[ownerDocument[expando]]; 109 if (!data) { 110 data = {}; 111 expanID++; 112 ownerDocument[expando] = expanID; 113 expandoData[expanID] = data; 114 } 115 return data; 116 } 117 118 /** 119 * returns a shived element for the given nodeName and document 120 * @memberOf html5 121 * @param {String} nodeName name of the element 122 * @param {Document} ownerDocument The context document. 123 * @returns {Object} The shived element. 124 */ 125 function createElement(nodeName, ownerDocument, data){ 126 if (!ownerDocument) { 127 ownerDocument = document; 128 } 129 if(supportsUnknownElements){ 130 return ownerDocument.createElement(nodeName); 131 } 132 if (!data) { 133 data = getExpandoData(ownerDocument); 134 } 135 var node; 136 137 if (data.cache[nodeName]) { 138 node = data.cache[nodeName].cloneNode(); 139 } else if (saveClones.test(nodeName)) { 140 node = (data.cache[nodeName] = data.createElem(nodeName)).cloneNode(); 141 } else { 142 node = data.createElem(nodeName); 143 } 144 145 // Avoid adding some elements to fragments in IE < 9 because 146 // * Attributes like `name` or `type` cannot be set/changed once an element 147 // is inserted into a document/fragment 148 // * Link elements with `src` attributes that are inaccessible, as with 149 // a 403 response, will cause the tab/window to crash 150 // * Script elements appended to fragments will execute when their `src` 151 // or `text` property is set 152 return node.canHaveChildren && !reSkip.test(nodeName) && !node.tagUrn ? data.frag.appendChild(node) : node; 153 } 154 155 /** 156 * returns a shived DocumentFragment for the given document 157 * @memberOf html5 158 * @param {Document} ownerDocument The context document. 159 * @returns {Object} The shived DocumentFragment. 160 */ 161 function createDocumentFragment(ownerDocument, data){ 162 if (!ownerDocument) { 163 ownerDocument = document; 164 } 165 if(supportsUnknownElements){ 166 return ownerDocument.createDocumentFragment(); 167 } 168 data = data || getExpandoData(ownerDocument); 169 var clone = data.frag.cloneNode(), 170 i = 0, 171 elems = getElements(), 172 l = elems.length; 173 for(;i<l;i++){ 174 clone.createElement(elems[i]); 175 } 176 return clone; 177 } 178 179 /** 180 * Shivs the `createElement` and `createDocumentFragment` methods of the document. 181 * @private 182 * @param {Document|DocumentFragment} ownerDocument The document. 183 * @param {Object} data of the document. 184 */ 185 function shivMethods(ownerDocument, data) { 186 if (!data.cache) { 187 data.cache = {}; 188 data.createElem = ownerDocument.createElement; 189 data.createFrag = ownerDocument.createDocumentFragment; 190 data.frag = data.createFrag(); 191 } 192 193 194 ownerDocument.createElement = function(nodeName) { 195 //abort shiv 196 if (!html5.shivMethods) { 197 return data.createElem(nodeName); 198 } 199 return createElement(nodeName, ownerDocument, data); 200 }; 201 202 ownerDocument.createDocumentFragment = Function('h,f', 'return function(){' + 203 'var n=f.cloneNode(),c=n.createElement;' + 204 'h.shivMethods&&(' + 205 // unroll the `createElement` calls 206 getElements().join().replace(/[\w\-:]+/g, function(nodeName) { 207 data.createElem(nodeName); 208 data.frag.createElement(nodeName); 209 return 'c("' + nodeName + '")'; 210 }) + 211 ');return n}' 212 )(html5, data.frag); 213 } 214 215 /*--------------------------------------------------------------------------*/ 216 217 /** 218 * Shivs the given document. 219 * @memberOf html5 220 * @param {Document} ownerDocument The document to shiv. 221 * @returns {Document} The shived document. 222 */ 223 function shivDocument(ownerDocument) { 224 if (!ownerDocument) { 225 ownerDocument = document; 226 } 227 var data = getExpandoData(ownerDocument); 228 229 if (html5.shivCSS && !supportsHtml5Styles && !data.hasCSS) { 230 data.hasCSS = !!addStyleSheet(ownerDocument, 231 // corrects block display not defined in IE6/7/8/9 232 'article,aside,dialog,figcaption,figure,footer,header,hgroup,main,nav,section{display:block}' + 233 // adds styling not present in IE6/7/8/9 234 'mark{background:#FF0;color:#000}' + 235 // hides non-rendered elements 236 'template{display:none}' 237 ); 238 } 239 if (!supportsUnknownElements) { 240 shivMethods(ownerDocument, data); 241 } 242 return ownerDocument; 243 } 244 245 /*--------------------------------------------------------------------------*/ 246 247 /** 248 * The `html5` object is exposed so that more elements can be shived and 249 * existing shiving can be detected on iframes. 250 * @type Object 251 * @example 252 * 253 * // options can be changed before the script is included 254 * html5 = { 'elements': 'mark section', 'shivCSS': false, 'shivMethods': false }; 255 */ 256 var html5 = { 257 258 /** 259 * An array or space separated string of node names of the elements to shiv. 260 * @memberOf html5 261 * @type Array|String 262 */ 263 'elements': options.elements || 'abbr article aside audio bdi canvas data datalist details dialog figcaption figure footer header hgroup main mark meter nav output picture progress section summary template time video', 264 265 /** 266 * current version of html5shiv 267 */ 268 'version': version, 269 270 /** 271 * A flag to indicate that the HTML5 style sheet should be inserted. 272 * @memberOf html5 273 * @type Boolean 274 */ 275 'shivCSS': (options.shivCSS !== false), 276 277 /** 278 * Is equal to true if a browser supports creating unknown/HTML5 elements 279 * @memberOf html5 280 * @type boolean 281 */ 282 'supportsUnknownElements': supportsUnknownElements, 283 284 /** 285 * A flag to indicate that the document's `createElement` and `createDocumentFragment` 286 * methods should be overwritten. 287 * @memberOf html5 288 * @type Boolean 289 */ 290 'shivMethods': (options.shivMethods !== false), 291 292 /** 293 * A string to describe the type of `html5` object ("default" or "default print"). 294 * @memberOf html5 295 * @type String 296 */ 297 'type': 'default', 298 299 // shivs the document according to the specified `html5` object options 300 'shivDocument': shivDocument, 301 302 //creates a shived element 303 createElement: createElement, 304 305 //creates a shived documentFragment 306 createDocumentFragment: createDocumentFragment, 307 308 //extends list of elements 309 addElements: addElements 310 }; 311 312 /*--------------------------------------------------------------------------*/ 313 314 // expose html5 315 window.html5 = html5; 316 317 // shiv the document 318 shivDocument(document); 319
320}(this, document));
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.