(function(){
if(![Link]) {
return;
}
var self = [Link] = {
link: function(link) {
var url = [Link] || [Link]('data-
href');
try {
// Ignore stylesheets with data-noprefix
attribute as well as alternate stylesheets or without (data-)href
attribute
if(!url || [Link] !== 'stylesheet' ||
[Link]('data-noprefix')) {
return;
}
}
catch(e) {
return;
}
var base = [Link](/[^\/]+$/, ''),
base_scheme = (/^[a-z]{3,10}:/.exec(base) ||
[''])[0],
base_domain = (/^[a-
z]{3,10}:\/\/[^\/]+/.exec(base) || [''])[0],
base_query = /^([^?]*)\??/.exec(url)[1],
parent = [Link],
xhr = new XMLHttpRequest(),
process;
[Link] = function() {
if([Link] === 4) {
process();
}
};
process = function() {
var css = [Link];
if(css && [Link] &&
(![Link] || [Link] < 400 || [Link] > 600)) {
css = [Link](css, true, link);
// Convert relative URLs to
absolute, if needed
if(css && base) {
css =
[Link](/url\(\s*?((?:"|')?)(.+?)\1\s*?\)/gi, function($0,
quote, url) {
if(/^([a-
z]{3,10}:|#)/[Link](url)) { // Absolute & or hash-relative
return $0;
}
else
if(/^\/\//.test(url)) { // Scheme-relative
// May
contain sequences like /../ and /./ but those DO work
return
'url("' + base_scheme + url + '")';
}
else
if(/^\//.test(url)) { // Domain-relative
return
'url("' + base_domain + url + '")';
}
else
if(/^\?/.test(url)) { // Query-relative
return
'url("' + base_query + url + '")';
}
else {
// Path-
relative
return
'url("' + base + url + '")';
}
});
// behavior URLs
shoudnt be converted (Issue #19)
// base should be
escaped before added to RegExp (Issue #81)
var escaped_base =
[Link](/([\\\^\$*+[\]?{}.=!:(|)])/g,"\\$1");
css =
[Link](RegExp('\\b(behavior:\\s*?url\\(\'?"?)' + escaped_base,
'gi'), '$1');
}
var style =
[Link]('style');
[Link] = '/*#
sourceURL='+[Link]('href')+' */\n/*@
sourceURL='+[Link]('href')+' */\n' + css;
[Link] = [Link];
[Link] = [Link];
[Link]('data-href',
[Link]('href'));
if([Link]) [Link] = [Link];
[Link](style,
link);
[Link](link);
[Link] = [Link]; //
Duplicate is intentional. See issue #31
}
};
try {
[Link]('GET', url);
[Link](null);
} catch (e) {
// Fallback to XDomainRequest if available
if (typeof XDomainRequest != "undefined") {
xhr = new XDomainRequest();
[Link] = [Link] =
function() {};
[Link] = process;
[Link]("GET", url);
[Link](null);
}
}
[Link]('data-inprogress', '');
},
styleElement: function(style) {
if ([Link]('data-noprefix')) {
return;
}
var disabled = [Link];
[Link] = [Link]([Link], true,
style);
[Link] = disabled;
},
styleAttribute: function(element) {
var css = [Link]('style');
css = [Link](css, false, element);
[Link]('style', css);
},
process: function() {
// Linked stylesheets
$('link[rel="stylesheet"]:not([data-
inprogress])').forEach([Link]);
// Inline stylesheets
$('style').forEach([Link]);
// Inline styles
$('[style]').forEach([Link]);
},
register: function(fixer, index) {
([Link] = [Link] || [])
.splice(index === undefined?
[Link] : index, 0, fixer);
},
fix: function(css, raw, element) {
if([Link]) {
for(var i=0; i<[Link]; i++) {
css = [Link][i](css, raw, element) ||
css;
}
}
return css;
},
camelCase: function(str) {
return [Link](/-([a-z])/g, function($0, $1) {
return $[Link](); }).replace('-','');
},
deCamelCase: function(str) {
return [Link](/[A-Z]/g, function($0) { return '-
' + $[Link]() });
}
};
/**************************************
* Process styles
**************************************/
(function(){
setTimeout(function(){
$('link[rel="stylesheet"]').forEach([Link]);
}, 10);
[Link]('DOMContentLoaded',
[Link], false);
})();
function $(expr, con) {
return [].[Link]((con ||
document).querySelectorAll(expr));
}
})();
/**
* PrefixFree
*/
(function(root){
if(![Link] || ![Link]) {
return;
}
// Private helper
function fix(what, before, after, replacement, css) {
what = self[what];
if([Link]) {
var regex = RegExp(before + '(' + [Link]('|') +
')' + after, 'gi');
css = [Link](regex, replacement);
}
return css;
}
var self = [Link] = {
prefixCSS: function(css, raw, element) {
var prefix = [Link];
// Gradient angles hotfix
if([Link]('linear-gradient') > -1) {
// Gradients are supported with a prefix,
convert angles to legacy
css = [Link](/(\s|:|,)(repeating-
)?linear-gradient\(\s*(-?\d*\.?\d*)deg/ig, function ($0, delim,
repeating, deg) {
return delim + (repeating || '') +
'linear-gradient(' + (90-deg) + 'deg';
});
}
css = fix('functions', '(\\s|:|,)', '\\s*\\(', '$1' +
prefix + '$2(', css);
css = fix('keywords', '(\\s|:)', '(\\s|;|\\}|$)',
'$1' + prefix + '$2$3', css);
css = fix('properties', '(^|\\{|\\s|;)', '\\s*:',
'$1' + prefix + '$2:', css);
// Prefix properties *inside* values (issue #8)
if ([Link]) {
var regex = RegExp('\\b(' +
[Link]('|') + ')(?!:)', 'gi');
css = fix('valueProperties', '\\b', ':(.+?);',
function($0) {
return $[Link](regex, prefix + "$1")
}, css);
}
if(raw) {
css = fix('selectors', '', '\\b',
[Link], css);
css = fix('atrules', '@', '\\b', '@' + prefix
+ '$1', css);
}
// Fix double prefixing
css = [Link](RegExp('-' + prefix, 'g'), '-');
// Prefix wildcard
css = [Link](/-\*-(?=[a-z]+)/gi, [Link]);
return css;
},
property: function(property) {
return ([Link](property) >=0 ?
[Link] : '') + property;
},
value: function(value, property) {
value = fix('functions', '(^|\\s|,)', '\\s*\\(', '$1'
+ [Link] + '$2(', value);
value = fix('keywords', '(^|\\s)', '(\\s|$)', '$1' +
[Link] + '$2$3', value);
if([Link](property) >= 0) {
value = fix('properties', '(^|\\s|,)',
'($|\\s|,)', '$1'+[Link]+'$2$3', value);
}
return value;
},
prefixSelector: function(selector) {
return [Link][selector] || selector
},
// Warning: Prefixes no matter what, even if the property is
supported prefix-less
prefixProperty: function(property, camelCase) {
var prefixed = [Link] + property;
return camelCase? [Link](prefixed) :
prefixed;
}
};
/**************************************
* Properties
**************************************/
(function() {
var prefixes = {},
properties = [],
shorthands = {},
style = getComputedStyle([Link],
null),
dummy = [Link]('div').style;
// Why are we doing this instead of iterating over
properties in a .style object? Because Webkit.
// 1. Older Webkit won't iterate over those.
// 2. Recent Webkit will, but the 'Webkit'-prefixed
properties are not enumerable. The 'webkit'
// (lower case 'w') ones are, but they don't
`deCamelCase()` into a prefix that we can detect.
var iterate = function(property) {
if([Link](0) === '-') {
[Link](property);
var parts = [Link]('-'),
prefix = parts[1];
// Count prefix uses
prefixes[prefix] = ++prefixes[prefix] || 1;
// This helps determining shorthands
while([Link] > 3) {
[Link]();
var shorthand = [Link]('-');
if(supported(shorthand) &&
[Link](shorthand) === -1) {
[Link](shorthand);
}
}
}
},
supported = function(property) {
return [Link](property) in dummy;
}
// Some browsers have numerical indices for the properties,
some don't
if(style && [Link] > 0) {
for(var i=0; i<[Link]; i++) {
iterate(style[i])
}
}
else {
for(var property in style) {
iterate([Link](property));
}
}
// Find most frequently used prefix
var highest = {uses:0};
for(var prefix in prefixes) {
var uses = prefixes[prefix];
if([Link] < uses) {
highest = {prefix: prefix, uses: uses};
}
}
[Link] = '-' + [Link] + '-';
[Link] = [Link]([Link]);
[Link] = [];
// Get properties ONLY supported with a prefix
for(var i=0; i<[Link]; i++) {
var property = properties[i];
if([Link]([Link]) === 0) { // we might
have multiple prefixes, like Opera
var unprefixed =
[Link]([Link]);
if(!supported(unprefixed)) {
[Link](unprefixed);
}
}
}
// IE fix
if([Link] == 'Ms'
&& !('transform' in dummy)
&& !('MsTransform' in dummy)
&& ('msTransform' in dummy)) {
[Link]('transform', 'transform-
origin');
}
[Link]();
})();
/**************************************
* Values
**************************************/
(function() {
// Values that might need prefixing
var functions = {
'linear-gradient': {
property: 'backgroundImage',
params: 'red, teal'
},
'calc': {
property: 'width',
params: '1px + 5%'
},
'element': {
property: 'backgroundImage',
params: '#foo'
},
'cross-fade': {
property: 'backgroundImage',
params: 'url([Link]), url([Link]), 50%'
},
'image-set': {
property: 'backgroundImage',
params: 'url([Link]) 1x, url([Link]) 2x'
}
};
functions['repeating-linear-gradient'] =
functions['repeating-radial-gradient'] =
functions['radial-gradient'] =
functions['linear-gradient'];
// Note: The properties assigned are just to *test* support.
// The keywords will be prefixed everywhere.
var keywords = {
'initial': 'color',
'grab': 'cursor',
'grabbing': 'cursor',
'zoom-in': 'cursor',
'zoom-out': 'cursor',
'box': 'display',
'flexbox': 'display',
'inline-flexbox': 'display',
'flex': 'display',
'inline-flex': 'display',
'grid': 'display',
'inline-grid': 'display',
'max-content': 'width',
'min-content': 'width',
'fit-content': 'width',
'fill-available': 'width',
'contain-floats': 'width'
};
[Link] = [];
[Link] = [];
var style = [Link]('div').style;
function supported(value, property) {
style[property] = '';
style[property] = value;
return !!style[property];
}
for (var func in functions) {
var test = functions[func],
property = [Link],
value = func + '(' + [Link] + ')';
if (!supported(value, property)
&& supported([Link] + value, property)) {
// It's supported, but with a prefix
[Link](func);
}
}
for (var keyword in keywords) {
var property = keywords[keyword];
if (!supported(keyword, property)
&& supported([Link] + keyword, property)) {
// It's supported, but with a prefix
[Link](keyword);
}
}
})();
/**************************************
* Selectors and @-rules
**************************************/
(function() {
var
selectors = {
':any-link': null,
'::backdrop': null,
':fullscreen': null,
':full-screen': ':fullscreen',
//sigh
'::placeholder': null,
':placeholder': '::placeholder',
'::input-placeholder': '::placeholder',
':input-placeholder': '::placeholder',
':read-only': null,
':read-write': null,
'::selection': null
},
atrules = {
'keyframes': 'name',
'viewport': null,
'document': 'regexp(".")'
};
[Link] = [];
[Link] = {};
[Link] = [];
var style = [Link]([Link]('style'));
function supported(selector) {
[Link] = selector + '{}'; // Safari 4 has issues
with [Link]
return !![Link];
}
for(var selector in selectors) {
var standard = selectors[selector] || selector
var prefixed = [Link](/::?/, function($0) { return
$0 + [Link] })
if(!supported(standard) && supported(prefixed)) {
[Link](standard);
[Link][standard] = prefixed;
}
}
for(var atrule in atrules) {
var test = atrule + ' ' + (atrules[atrule] || '');
if(!supported('@' + test) && supported('@' + [Link] +
test)) {
[Link](atrule);
}
}
[Link](style);
})();
// Properties that accept properties as their value
[Link] = [
'transition',
'transition-property',
'will-change'
]
// Add class for current prefix
[Link] += ' ' + [Link];
[Link]([Link]);
})([Link]);