/**
* @preserve html5 shiv 3.7.3 | @afarkas @jdalton @jon_neal @rem | mit/gpl2 licensed
*/
;(function(window, document) {
/*jshint evil:true */
/** version */
var version = '3.7.3';
/** preset options */
var options = window.html5 || {};
/** used to skip problem elements */
var reskip = /^<|^(?:button|map|select|textarea|object|iframe|option|optgroup)$/i;
/** not all elements can be cloned in ie **/
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;
/** detect whether the browser supports default html5 styles */
var supportshtml5styles;
/** name of the expando, to work with multiple documents or to re-shiv one document */
var expando = '_html5shiv';
/** the id for the the documents expando */
var expanid = 0;
/** cached data for each document */
var expandodata = {};
/** detect whether the browser supports unknown elements */
var supportsunknownelements;
(function() {
try {
var a = document.createelement('a');
a.innerhtml = '';
//if the hidden property is implemented we can assume, that the browser supports basic html5 styles
supportshtml5styles = ('hidden' in a);
supportsunknownelements = a.childnodes.length == 1 || (function() {
// assign a false positive if unable to shiv
(document.createelement)('a');
var frag = document.createdocumentfragment();
return (
typeof frag.clonenode == 'undefined' ||
typeof frag.createdocumentfragment == 'undefined' ||
typeof frag.createelement == 'undefined'
);
}());
} catch(e) {
// assign a false positive if detection fails => unable to shiv
supportshtml5styles = true;
supportsunknownelements = true;
}
}());
/*--------------------------------------------------------------------------*/
/**
* creates a style sheet with the given css text and adds it to the document.
* @private
* @param {document} ownerdocument the document.
* @param {string} csstext the css text.
* @returns {stylesheet} the style element.
*/
function addstylesheet(ownerdocument, csstext) {
var p = ownerdocument.createelement('p'),
parent = ownerdocument.getelementsbytagname('head')[0] || ownerdocument.documentelement;
p.innerhtml = 'x';
return parent.insertbefore(p.lastchild, parent.firstchild);
}
/**
* returns the value of `html5.elements` as an array.
* @private
* @returns {array} an array of shived element node names.
*/
function getelements() {
var elements = html5.elements;
return typeof elements == 'string' ? elements.split(' ') : elements;
}
/**
* extends the built-in list of html5 elements
* @memberof html5
* @param {string|array} newelements whitespace separated list or array of new element names to shiv
* @param {document} ownerdocument the context document.
*/
function addelements(newelements, ownerdocument) {
var elements = html5.elements;
if(typeof elements != 'string'){
elements = elements.join(' ');
}
if(typeof newelements != 'string'){
newelements = newelements.join(' ');
}
html5.elements = elements +' '+ newelements;
shivdocument(ownerdocument);
}
/**
* returns the data associated to the given document
* @private
* @param {document} ownerdocument the document.
* @returns {object} an object of data.
*/
function getexpandodata(ownerdocument) {
var data = expandodata[ownerdocument[expando]];
if (!data) {
data = {};
expanid++;
ownerdocument[expando] = expanid;
expandodata[expanid] = data;
}
return data;
}
/**
* returns a shived element for the given nodename and document
* @memberof html5
* @param {string} nodename name of the element
* @param {document} ownerdocument the context document.
* @returns {object} the shived element.
*/
function createelement(nodename, ownerdocument, data){
if (!ownerdocument) {
ownerdocument = document;
}
if(supportsunknownelements){
return ownerdocument.createelement(nodename);
}
if (!data) {
data = getexpandodata(ownerdocument);
}
var node;
if (data.cache[nodename]) {
node = data.cache[nodename].clonenode();
} else if (saveclones.test(nodename)) {
node = (data.cache[nodename] = data.createelem(nodename)).clonenode();
} else {
node = data.createelem(nodename);
}
// avoid adding some elements to fragments in ie < 9 because
// * attributes like `name` or `type` cannot be set/changed once an element
// is inserted into a document/fragment
// * link elements with `src` attributes that are inaccessible, as with
// a 403 response, will cause the tab/window to crash
// * script elements appended to fragments will execute when their `src`
// or `text` property is set
return node.canhavechildren && !reskip.test(nodename) && !node.tagurn ? data.frag.appendchild(node) : node;
}
/**
* returns a shived documentfragment for the given document
* @memberof html5
* @param {document} ownerdocument the context document.
* @returns {object} the shived documentfragment.
*/
function createdocumentfragment(ownerdocument, data){
if (!ownerdocument) {
ownerdocument = document;
}
if(supportsunknownelements){
return ownerdocument.createdocumentfragment();
}
data = data || getexpandodata(ownerdocument);
var clone = data.frag.clonenode(),
i = 0,
elems = getelements(),
l = elems.length;
for(;i+~])(' + getelements().join('|') + ')(?=[[\\s,>+~#.:]|$)', 'gi'),
replacement = '$1' + shivnamespace + '\\:$2';
while (index--) {
pair = parts[index] = parts[index].split('}');
pair[pair.length - 1] = pair[pair.length - 1].replace(reelements, replacement);
parts[index] = pair.join('}');
}
return parts.join('{');
}
/**
* removes the given wrappers, leaving the original elements.
* @private
* @params {array} wrappers an array of printable wrappers.
*/
function removewrappers(wrappers) {
var index = wrappers.length;
while (index--) {
wrappers[index].removenode();
}
}
/*--------------------------------------------------------------------------*/
/**
* shivs the given document for print.
* @memberof html5
* @param {document} ownerdocument the document to shiv.
* @returns {document} the shived document.
*/
function shivprint(ownerdocument) {
var shivedsheet,
wrappers,
data = getexpandodata(ownerdocument),
namespaces = ownerdocument.namespaces,
ownerwindow = ownerdocument.parentwindow;
if (!supportsshivablesheets || ownerdocument.printshived) {
return ownerdocument;
}
if (typeof namespaces[shivnamespace] == 'undefined') {
namespaces.add(shivnamespace);
}
function removesheet() {
cleartimeout(data._removesheettimer);
if (shivedsheet) {
shivedsheet.removenode(true);
}
shivedsheet= null;
}
ownerwindow.attachevent('onbeforeprint', function() {
removesheet();
var imports,
length,
sheet,
collection = ownerdocument.stylesheets,
csstext = [],
index = collection.length,
sheets = array(index);
// convert stylesheets collection to an array
while (index--) {
sheets[index] = collection[index];
}
// concat all style sheet css text
while ((sheet = sheets.pop())) {
// ie does not enforce a same origin policy for external style sheets...
// but has trouble with some dynamically created stylesheets
if (!sheet.disabled && remedia.test(sheet.media)) {
try {
imports = sheet.imports;
length = imports.length;
} catch(er){
length = 0;
}
for (index = 0; index < length; index++) {
sheets.push(imports[index]);
}
try {
csstext.push(sheet.csstext);
} catch(er){}
}
}
// wrap all html5 elements with printable elements and add the shived style sheet
csstext = shivcsstext(csstext.reverse().join(''));
wrappers = addwrappers(ownerdocument);
shivedsheet = addstylesheet(ownerdocument, csstext);
});
ownerwindow.attachevent('onafterprint', function() {
// remove wrappers, leaving the original elements, and remove the shived style sheet
removewrappers(wrappers);
cleartimeout(data._removesheettimer);
data._removesheettimer = settimeout(removesheet, 500);
});
ownerdocument.printshived = true;
return ownerdocument;
}
/*--------------------------------------------------------------------------*/
// expose api
html5.type += ' print';
html5.shivprint = shivprint;
// shiv for print
shivprint(document);
if(typeof module == 'object' && module.exports){
module.exports = html5;
}
}(typeof window !== "undefined" ? window : this, document));