myth
Version:
A CSS preprocessor that acts like a polyfill for future versions of the spec.
1,622 lines (1,309 loc) • 1.56 MB
JavaScript
!function(e){if("object"==typeof exports)module.exports=e();else if("function"==typeof define&&define.amd)define(e);else{var f;"undefined"!=typeof window?f=window:"undefined"!=typeof global?f=global:"undefined"!=typeof self&&(f=self),f.myth=e()}}(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(_dereq_,module,exports){
var autoprefixer = _dereq_('autoprefixer-core');
var calc = _dereq_('rework-calc');
var clone = _dereq_('clone-component');
var color = _dereq_('rework-color-function');
var customMedia = _dereq_('rework-custom-media');
var dirname = _dereq_('path').dirname;
var fontVariant = _dereq_('rework-font-variant');
var hexAlpha = _dereq_('rework-hex-alpha');
var importer = _dereq_('rework-import');
var postcss = _dereq_('postcss');
var rebeccapurple = _dereq_('rework-rebeccapurple');
var Rework = _dereq_('rework');
var variables = _dereq_('rework-vars');
/**
* Import.
*
* @param {Object} options
* @param {String} source
* @return {Function}
*/
exports.import = function(options){
return 'undefined' == typeof window && options.source
? importer()
: function(){};
};
/**
* Variables.
*
* @param {Object} options
* @param {Object} variables
* @param {Boolean} preserve
* @return {Function}
*/
exports.variables = function(options){
return variables({
map: options.variables,
preserve: options.preserve
});
};
/**
* Custom media.
*
* @param {Object} options
* @return {Function}
*/
exports.customMedia = function(options){
return customMedia;
};
/**
* Hex alpha.
*
* @param {Object} options
* @return {Function}
*/
exports.hexAlpha = function(options){
return hexAlpha;
};
/**
* Color.
*
* @param {Object} options
* @return {Function}
*/
exports.color = function(options){
return color;
};
/**
* Calc.
*
* @param {Object} options
* @return {Function}
*/
exports.calc = function(options){
return calc;
};
/**
* Font variant.
*
* @param {Object} options
* @return {Function}
*/
exports.fontVariant = function(options){
return fontVariant;
};
/**
* Rebecca purple.
*
* @param {Object} options
* @return {Function}
*/
exports.rebeccapurple = function(options){
return rebeccapurple;
};
/**
* Prefixes.
*
* Unfortunately, Autoprefixer uses a different preprocessor, so we have to give
* it the CSS string and re-parse it again afterwards.
*
* @param {Object} options
* @param {Array} browsers
* @return {Function}
*/
exports.prefixes = function(options){
var opts = clone(options);
var src = options.source;
var prefixes = autoprefixer({ browsers: options.browsers });
var processor = postcss(prefixes);
return function(stylesheet, rework){
var str = rework.toString(options);
var css = processor.process(str, { from: src, to: src }).css;
// we don't need source mapping the second time reparsing
delete opts.source;
rework.obj = Rework(css, opts).obj;
};
};
},{"autoprefixer-core":5,"clone-component":136,"path":134,"postcss":150,"rework":226,"rework-calc":175,"rework-color-function":178,"rework-custom-media":191,"rework-font-variant":192,"rework-hex-alpha":194,"rework-import":196,"rework-rebeccapurple":222,"rework-vars":223}],2:[function(_dereq_,module,exports){
var features = _dereq_('./features');
var Rework = _dereq_('rework');
/**
* Expose `myth`.
*/
module.exports = exports = myth;
/**
* Expose `features`.
*/
exports.features = Object.keys(features);
/**
* Rework a CSS `string`, or return the Myth rework plugin.
*
* @param {String} string (optional)
* @param {Object} options (optional)
* @property {String} source
* @property {Array} browsers
* @property {Boolean} compress
* @property {Object} features
* @return {String}
*/
function myth(string, options){
if ('object' == typeof string) options = string, string = null;
options = options || {};
if ('string' != typeof string) return plugin(options);
return Rework(string, options)
.use(plugin(options))
.toString(options);
}
/**
* Generate a Myth rework plugin with `options`.
*
* @param {Object} options
* @return {Function}
*/
function plugin(options){
return function(stylesheet, rework){
var enabled = options.features || {};
exports.features.forEach(function(key){
if (enabled[key] === false) return;
var plugin = features[key](options);
rework.use(plugin);
});
};
}
},{"./features":1,"rework":226}],3:[function(_dereq_,module,exports){
(function() {
var add, crispedges, feature, flexbox, gradients, logicalProps, prefix, resolution, result, sort,
slice = [].slice;
sort = function(array) {
return array.sort(function(a, b) {
var d;
a = a.split(' ');
b = b.split(' ');
if (a[0] > b[0]) {
return 1;
} else if (a[0] < b[0]) {
return -1;
} else {
d = parseFloat(a[1]) - parseFloat(b[1]);
if (d > 0) {
return 1;
} else if (d < 0) {
return -1;
} else {
return 0;
}
}
});
};
feature = function(data, opts, callback) {
var browser, match, need, ref, ref1, support, version, versions;
if (!callback) {
ref = [opts, {}], callback = ref[0], opts = ref[1];
}
match = opts.match || /\sx($|\s)/;
need = [];
ref1 = data.stats;
for (browser in ref1) {
versions = ref1[browser];
for (version in versions) {
support = versions[version];
if (support.match(match)) {
need.push(browser + ' ' + version);
}
}
}
return callback(sort(need));
};
result = {};
prefix = function() {
var data, i, j, k, len, name, names, results;
names = 2 <= arguments.length ? slice.call(arguments, 0, j = arguments.length - 1) : (j = 0, []), data = arguments[j++];
results = [];
for (k = 0, len = names.length; k < len; k++) {
name = names[k];
result[name] = {};
results.push((function() {
var results1;
results1 = [];
for (i in data) {
results1.push(result[name][i] = data[i]);
}
return results1;
})());
}
return results;
};
add = function() {
var data, j, k, len, name, names, results;
names = 2 <= arguments.length ? slice.call(arguments, 0, j = arguments.length - 1) : (j = 0, []), data = arguments[j++];
results = [];
for (k = 0, len = names.length; k < len; k++) {
name = names[k];
results.push(result[name].browsers = sort(result[name].browsers.concat(data.browsers)));
}
return results;
};
module.exports = result;
feature(_dereq_('caniuse-db/features-json/border-radius'), function(browsers) {
return prefix('border-radius', 'border-top-left-radius', 'border-top-right-radius', 'border-bottom-right-radius', 'border-bottom-left-radius', {
mistakes: ['-ms-', '-o-'],
transition: true,
browsers: browsers
});
});
feature(_dereq_('caniuse-db/features-json/css-boxshadow'), function(browsers) {
return prefix('box-shadow', {
transition: true,
browsers: browsers
});
});
feature(_dereq_('caniuse-db/features-json/css-animation'), function(browsers) {
return prefix('animation', 'animation-name', 'animation-duration', 'animation-delay', 'animation-direction', 'animation-fill-mode', 'animation-iteration-count', 'animation-play-state', 'animation-timing-function', '@keyframes', {
mistakes: ['-ms-'],
browsers: browsers
});
});
feature(_dereq_('caniuse-db/features-json/css-transitions'), function(browsers) {
return prefix('transition', 'transition-property', 'transition-duration', 'transition-delay', 'transition-timing-function', {
mistakes: ['-ms-'],
browsers: browsers
});
});
feature(_dereq_('caniuse-db/features-json/transforms2d'), function(browsers) {
return prefix('transform', 'transform-origin', {
transition: true,
browsers: browsers
});
});
feature(_dereq_('caniuse-db/features-json/transforms3d'), function(browsers) {
prefix('perspective', 'perspective-origin', {
transition: true,
browsers: browsers
});
return prefix('transform-style', 'backface-visibility', {
browsers: browsers
});
});
gradients = _dereq_('caniuse-db/features-json/css-gradients');
feature(gradients, {
match: /y\sx/
}, function(browsers) {
return prefix('linear-gradient', 'repeating-linear-gradient', 'radial-gradient', 'repeating-radial-gradient', {
props: ['background', 'background-image', 'border-image', 'list-style', 'list-style-image', 'content', 'mask-image', 'mask'],
mistakes: ['-ms-'],
browsers: browsers
});
});
feature(gradients, {
match: /a\sx/
}, function(browsers) {
browsers = browsers.map(function(i) {
if (/op/.test(i)) {
return i;
} else {
return i + " old";
}
});
return add('linear-gradient', 'repeating-linear-gradient', 'radial-gradient', 'repeating-radial-gradient', {
browsers: browsers
});
});
feature(_dereq_('caniuse-db/features-json/css3-boxsizing'), function(browsers) {
return prefix('box-sizing', {
browsers: browsers
});
});
feature(_dereq_('caniuse-db/features-json/css-filters'), function(browsers) {
return prefix('filter', {
transition: true,
browsers: browsers
});
});
feature(_dereq_('caniuse-db/features-json/multicolumn'), function(browsers) {
prefix('columns', 'column-width', 'column-gap', 'column-rule', 'column-rule-color', 'column-rule-width', {
transition: true,
browsers: browsers
});
return prefix('column-count', 'column-rule-style', 'column-span', 'column-fill', 'break-before', 'break-after', 'break-inside', {
browsers: browsers
});
});
feature(_dereq_('caniuse-db/features-json/user-select-none'), function(browsers) {
return prefix('user-select', {
browsers: browsers
});
});
flexbox = _dereq_('caniuse-db/features-json/flexbox');
feature(flexbox, {
match: /a\sx/
}, function(browsers) {
browsers = browsers.map(function(i) {
if (/ie|firefox/.test(i)) {
return i;
} else {
return i + " 2009";
}
});
prefix('display-flex', 'inline-flex', {
props: ['display'],
browsers: browsers
});
prefix('flex', 'flex-grow', 'flex-shrink', 'flex-basis', {
transition: true,
browsers: browsers
});
return prefix('flex-direction', 'flex-wrap', 'flex-flow', 'justify-content', 'order', 'align-items', 'align-self', 'align-content', {
browsers: browsers
});
});
feature(flexbox, {
match: /y\sx/
}, function(browsers) {
add('display-flex', 'inline-flex', {
browsers: browsers
});
add('flex', 'flex-grow', 'flex-shrink', 'flex-basis', {
browsers: browsers
});
return add('flex-direction', 'flex-wrap', 'flex-flow', 'justify-content', 'order', 'align-items', 'align-self', 'align-content', {
browsers: browsers
});
});
feature(_dereq_('caniuse-db/features-json/calc'), function(browsers) {
return prefix('calc', {
props: ['*'],
browsers: browsers
});
});
feature(_dereq_('caniuse-db/features-json/background-img-opts'), function(browsers) {
return prefix('background-clip', 'background-origin', 'background-size', {
browsers: browsers
});
});
feature(_dereq_('caniuse-db/features-json/font-feature'), function(browsers) {
return prefix('font-feature-settings', 'font-variant-ligatures', 'font-language-override', 'font-kerning', {
browsers: browsers
});
});
feature(_dereq_('caniuse-db/features-json/border-image'), function(browsers) {
return prefix('border-image', {
browsers: browsers
});
});
feature(_dereq_('caniuse-db/features-json/css-selection'), function(browsers) {
return prefix('::selection', {
selector: true,
browsers: browsers
});
});
feature(_dereq_('caniuse-db/features-json/css-placeholder'), function(browsers) {
browsers = browsers.map(function(i) {
var name, ref, version;
ref = i.split(' '), name = ref[0], version = ref[1];
if (name === 'firefox' && parseFloat(version) <= 18) {
return i + ' old';
} else {
return i;
}
});
return prefix('::placeholder', {
selector: true,
browsers: browsers
});
});
feature(_dereq_('caniuse-db/features-json/css-hyphens'), function(browsers) {
return prefix('hyphens', {
browsers: browsers
});
});
feature(_dereq_('caniuse-db/features-json/fullscreen'), function(browsers) {
return prefix(':fullscreen', {
selector: true,
browsers: browsers
});
});
feature(_dereq_('caniuse-db/features-json/css3-tabsize'), function(browsers) {
return prefix('tab-size', {
browsers: browsers
});
});
feature(_dereq_('caniuse-db/features-json/intrinsic-width'), function(browsers) {
return prefix('max-content', 'min-content', 'fit-content', 'fill-available', {
props: ['width', 'min-width', 'max-width', 'height', 'min-height', 'max-height'],
browsers: browsers
});
});
feature(_dereq_('caniuse-db/features-json/css3-cursors-newer'), function(browsers) {
prefix('zoom-in', 'zoom-out', {
props: ['cursor'],
browsers: browsers.concat(['chrome 3'])
});
return prefix('grab', 'grabbing', {
props: ['cursor'],
browsers: browsers.concat(['firefox 24', 'firefox 25', 'firefox 26'])
});
});
feature(_dereq_('caniuse-db/features-json/css-sticky'), function(browsers) {
return prefix('sticky', {
props: ['position'],
browsers: browsers
});
});
feature(_dereq_('caniuse-db/features-json/pointer'), function(browsers) {
return prefix('touch-action', {
browsers: browsers
});
});
feature(_dereq_('caniuse-db/features-json/text-decoration'), function(browsers) {
return prefix('text-decoration-style', 'text-decoration-line', 'text-decoration-color', {
browsers: browsers
});
});
feature(_dereq_('caniuse-db/features-json/text-size-adjust'), function(browsers) {
return prefix('text-size-adjust', {
browsers: browsers
});
});
feature(_dereq_('caniuse-db/features-json/css-masks'), function(browsers) {
prefix('mask-clip', 'mask-composite', 'mask-image', 'mask-origin', 'mask-repeat', {
browsers: browsers
});
return prefix('clip-path', 'mask', 'mask-position', 'mask-size', {
transition: true,
browsers: browsers
});
});
feature(_dereq_('caniuse-db/features-json/css-boxdecorationbreak'), function(brwsrs) {
return prefix('box-decoration-break', {
browsers: brwsrs
});
});
feature(_dereq_('caniuse-db/features-json/object-fit'), function(browsers) {
return prefix('object-fit', 'object-position', {
browsers: browsers
});
});
feature(_dereq_('caniuse-db/features-json/css-shapes'), function(browsers) {
return prefix('shape-margin', 'shape-outside', 'shape-image-threshold', {
browsers: browsers
});
});
feature(_dereq_('caniuse-db/features-json/text-overflow'), function(browsers) {
return prefix('text-overflow', {
browsers: browsers
});
});
feature(_dereq_('caniuse-db/features-json/text-emphasis'), function(browsers) {
return prefix('text-emphasis', {
browsers: browsers
});
});
feature(_dereq_('caniuse-db/features-json/css-deviceadaptation'), function(browsers) {
return prefix('@viewport', {
browsers: browsers
});
});
resolution = _dereq_('caniuse-db/features-json/css-media-resolution');
feature(resolution, {
match: /( x($| )|a #3)/
}, function(browsers) {
return prefix('@resolution', {
browsers: browsers
});
});
feature(_dereq_('caniuse-db/features-json/css-text-align-last'), function(browsers) {
return prefix('text-align-last', {
browsers: browsers
});
});
crispedges = _dereq_('caniuse-db/features-json/css-crisp-edges');
feature(crispedges, {
match: /y x/
}, function(browsers) {
return prefix('pixelated', {
props: ['image-rendering'],
browsers: browsers
});
});
feature(crispedges, {
match: /a x #2/
}, function(browsers) {
return prefix('image-rendering', {
browsers: browsers
});
});
logicalProps = _dereq_('caniuse-db/features-json/css-logical-props');
feature(logicalProps, function(browsers) {
return prefix('border-inline-start', 'border-inline-end', 'margin-inline-start', 'margin-inline-end', 'padding-inline-start', 'padding-inline-end', {
transition: true,
browsers: browsers
});
});
feature(logicalProps, {
match: /x\s#2/
}, function(browsers) {
return prefix('border-block-start', 'border-block-end', 'margin-block-start', 'margin-block-end', 'padding-block-start', 'padding-block-end', {
transition: true,
browsers: browsers
});
});
feature(_dereq_('caniuse-db/features-json/css-appearance'), function(browsers) {
return prefix('appearance', {
browsers: browsers
});
});
}).call(this);
},{"caniuse-db/features-json/background-img-opts":53,"caniuse-db/features-json/border-image":54,"caniuse-db/features-json/border-radius":55,"caniuse-db/features-json/calc":56,"caniuse-db/features-json/css-animation":57,"caniuse-db/features-json/css-appearance":58,"caniuse-db/features-json/css-boxdecorationbreak":59,"caniuse-db/features-json/css-boxshadow":60,"caniuse-db/features-json/css-crisp-edges":61,"caniuse-db/features-json/css-deviceadaptation":62,"caniuse-db/features-json/css-filters":63,"caniuse-db/features-json/css-gradients":64,"caniuse-db/features-json/css-hyphens":65,"caniuse-db/features-json/css-logical-props":66,"caniuse-db/features-json/css-masks":67,"caniuse-db/features-json/css-media-resolution":68,"caniuse-db/features-json/css-placeholder":69,"caniuse-db/features-json/css-selection":70,"caniuse-db/features-json/css-shapes":71,"caniuse-db/features-json/css-sticky":72,"caniuse-db/features-json/css-text-align-last":73,"caniuse-db/features-json/css-transitions":74,"caniuse-db/features-json/css3-boxsizing":75,"caniuse-db/features-json/css3-cursors-newer":76,"caniuse-db/features-json/css3-tabsize":77,"caniuse-db/features-json/flexbox":78,"caniuse-db/features-json/font-feature":79,"caniuse-db/features-json/fullscreen":80,"caniuse-db/features-json/intrinsic-width":81,"caniuse-db/features-json/multicolumn":82,"caniuse-db/features-json/object-fit":83,"caniuse-db/features-json/pointer":84,"caniuse-db/features-json/text-decoration":85,"caniuse-db/features-json/text-emphasis":86,"caniuse-db/features-json/text-overflow":87,"caniuse-db/features-json/text-size-adjust":88,"caniuse-db/features-json/transforms2d":89,"caniuse-db/features-json/transforms3d":90,"caniuse-db/features-json/user-select-none":91}],4:[function(_dereq_,module,exports){
(function() {
var AtRule, Prefixer,
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
hasProp = {}.hasOwnProperty;
Prefixer = _dereq_('./prefixer');
AtRule = (function(superClass) {
extend(AtRule, superClass);
function AtRule() {
return AtRule.__super__.constructor.apply(this, arguments);
}
AtRule.prototype.add = function(rule, prefix) {
var already, cloned, prefixed;
prefixed = prefix + rule.name;
already = rule.parent.some(function(i) {
return i.name === prefixed && i.params === rule.params;
});
if (already) {
return;
}
cloned = this.clone(rule, {
name: prefixed
});
return rule.parent.insertBefore(rule, cloned);
};
AtRule.prototype.process = function(node) {
var j, len, parent, prefix, ref, results;
parent = this.parentPrefix(node);
ref = this.prefixes;
results = [];
for (j = 0, len = ref.length; j < len; j++) {
prefix = ref[j];
if (parent && parent !== prefix) {
continue;
}
results.push(this.add(node, prefix));
}
return results;
};
return AtRule;
})(Prefixer);
module.exports = AtRule;
}).call(this);
},{"./prefixer":43}],5:[function(_dereq_,module,exports){
(function() {
var Browsers, Prefixes, browserslist, cache, isPlainObject, postcss,
slice = [].slice;
browserslist = _dereq_('browserslist');
postcss = _dereq_('postcss');
Browsers = _dereq_('./browsers');
Prefixes = _dereq_('./prefixes');
isPlainObject = function(obj) {
return Object.prototype.toString.apply(obj) === '[object Object]';
};
cache = {};
module.exports = postcss.plugin('autoprefixer', function() {
var loadPrefixes, options, plugin, reqs;
reqs = 1 <= arguments.length ? slice.call(arguments, 0) : [];
if (reqs.length === 1 && isPlainObject(reqs[0])) {
options = reqs[0];
reqs = void 0;
} else if (reqs.length === 0 || (reqs.length === 1 && (reqs[0] == null))) {
reqs = void 0;
} else if (reqs.length <= 2 && (reqs[0] instanceof Array || (reqs[0] == null))) {
options = reqs[1];
reqs = reqs[0];
} else if (typeof reqs[reqs.length - 1] === 'object') {
options = reqs.pop();
}
options || (options = {});
if (options.browsers != null) {
reqs = options.browsers;
}
loadPrefixes = function(opts) {
var browsers, key;
browsers = new Browsers(module.exports.data.browsers, reqs, opts);
key = browsers.selected.join(', ') + options.cascade;
return cache[key] || (cache[key] = new Prefixes(module.exports.data.prefixes, browsers, options));
};
plugin = function(css, result) {
var prefixes;
prefixes = loadPrefixes({
from: css.source.input.file
});
if (options.remove !== false) {
prefixes.processor.remove(css);
}
if (options.add !== false) {
return prefixes.processor.add(css, result);
}
};
plugin.options = options;
plugin.process = function(str, options) {
if (options == null) {
options = {};
}
if (typeof console !== "undefined" && console !== null) {
if (typeof console.warn === "function") {
console.warn('Autoprefixer\'s process() method is deprecated ' + 'and will removed in next major release. ' + 'Use postcss([autoprefixer]).process() instead');
}
}
return postcss(plugin).process(str, options);
};
plugin.info = function(opts) {
return _dereq_('./info')(loadPrefixes(opts));
};
return plugin;
});
module.exports.data = {
browsers: _dereq_('caniuse-db/data').agents,
prefixes: _dereq_('../data/prefixes')
};
module.exports.defaults = browserslist.defaults;
module.exports.process = function(css, options) {
return module.exports().process(css, options);
};
module.exports.info = function() {
return module.exports().info();
};
}).call(this);
},{"../data/prefixes":3,"./browsers":6,"./info":40,"./prefixes":44,"browserslist":51,"caniuse-db/data":52,"postcss":105}],6:[function(_dereq_,module,exports){
(function() {
var Browsers, browserslist, utils;
browserslist = _dereq_('browserslist');
utils = _dereq_('./utils');
Browsers = (function() {
Browsers.prefixes = function() {
var data, i, name;
if (this.prefixesCache) {
return this.prefixesCache;
}
data = _dereq_('caniuse-db/data').agents;
return this.prefixesCache = utils.uniq((function() {
var results;
results = [];
for (name in data) {
i = data[name];
results.push("-" + i.prefix + "-");
}
return results;
})()).sort(function(a, b) {
return b.length - a.length;
});
};
Browsers.withPrefix = function(value) {
if (!this.prefixesRegexp) {
this.prefixesRegexp = RegExp("" + (this.prefixes().join('|')));
}
return this.prefixesRegexp.test(value);
};
function Browsers(data1, requirements, options) {
this.data = data1;
this.options = options;
this.selected = this.parse(requirements);
}
Browsers.prototype.parse = function(requirements) {
var ref;
return browserslist(requirements, {
path: (ref = this.options) != null ? ref.from : void 0
});
};
Browsers.prototype.browsers = function(criteria) {
var browser, data, ref, selected, versions;
selected = [];
ref = this.data;
for (browser in ref) {
data = ref[browser];
versions = criteria(data).map(function(version) {
return browser + " " + version;
});
selected = selected.concat(versions);
}
return selected;
};
Browsers.prototype.prefix = function(browser) {
var data, name, prefix, ref, version;
ref = browser.split(' '), name = ref[0], version = ref[1];
data = this.data[name];
if (data.prefix_exceptions) {
prefix = data.prefix_exceptions[version];
}
prefix || (prefix = data.prefix);
return '-' + prefix + '-';
};
Browsers.prototype.isSelected = function(browser) {
return this.selected.indexOf(browser) !== -1;
};
return Browsers;
})();
module.exports = Browsers;
}).call(this);
},{"./utils":49,"browserslist":51,"caniuse-db/data":52}],7:[function(_dereq_,module,exports){
(function() {
var Browsers, Declaration, Prefixer, utils, vendor,
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
hasProp = {}.hasOwnProperty;
Prefixer = _dereq_('./prefixer');
Browsers = _dereq_('./browsers');
vendor = _dereq_('postcss/lib/vendor');
utils = _dereq_('./utils');
Declaration = (function(superClass) {
extend(Declaration, superClass);
function Declaration() {
return Declaration.__super__.constructor.apply(this, arguments);
}
Declaration.prototype.check = function(decl) {
return true;
};
Declaration.prototype.prefixed = function(prop, prefix) {
return prefix + prop;
};
Declaration.prototype.normalize = function(prop) {
return prop;
};
Declaration.prototype.otherPrefixes = function(value, prefix) {
var j, len, other, ref;
ref = Browsers.prefixes();
for (j = 0, len = ref.length; j < len; j++) {
other = ref[j];
if (other === prefix) {
continue;
}
if (value.indexOf(other) !== -1) {
return true;
}
}
return false;
};
Declaration.prototype.set = function(decl, prefix) {
decl.prop = this.prefixed(decl.prop, prefix);
return decl;
};
Declaration.prototype.needCascade = function(decl) {
return decl._autoprefixerCascade || (decl._autoprefixerCascade = this.all.options.cascade !== false && decl.style('before').indexOf('\n') !== -1);
};
Declaration.prototype.maxPrefixed = function(prefixes, decl) {
var j, len, max, prefix;
if (decl._autoprefixerMax) {
return decl._autoprefixerMax;
}
max = 0;
for (j = 0, len = prefixes.length; j < len; j++) {
prefix = prefixes[j];
prefix = utils.removeNote(prefix);
if (prefix.length > max) {
max = prefix.length;
}
}
return decl._autoprefixerMax = max;
};
Declaration.prototype.calcBefore = function(prefixes, decl, prefix) {
var before, diff, i, j, max, ref;
if (prefix == null) {
prefix = '';
}
before = decl.style('before');
max = this.maxPrefixed(prefixes, decl);
diff = max - utils.removeNote(prefix).length;
for (i = j = 0, ref = diff; 0 <= ref ? j < ref : j > ref; i = 0 <= ref ? ++j : --j) {
before += ' ';
}
return before;
};
Declaration.prototype.restoreBefore = function(decl) {
var lines, min;
lines = decl.style('before').split("\n");
min = lines[lines.length - 1];
this.all.group(decl).up(function(prefixed) {
var array, last;
array = prefixed.style('before').split("\n");
last = array[array.length - 1];
if (last.length < min.length) {
return min = last;
}
});
lines[lines.length - 1] = min;
return decl.before = lines.join("\n");
};
Declaration.prototype.insert = function(decl, prefix, prefixes) {
var cloned;
cloned = this.set(this.clone(decl), prefix);
if (!cloned) {
return;
}
if (this.needCascade(decl)) {
cloned.before = this.calcBefore(prefixes, decl, prefix);
}
return decl.parent.insertBefore(decl, cloned);
};
Declaration.prototype.add = function(decl, prefix, prefixes) {
var already, prefixed;
prefixed = this.prefixed(decl.prop, prefix);
already = this.all.group(decl).up(function(i) {
return i.prop === prefixed;
});
already || (already = this.all.group(decl).down(function(i) {
return i.prop === prefixed;
}));
if (already || this.otherPrefixes(decl.value, prefix)) {
return;
}
return this.insert(decl, prefix, prefixes);
};
Declaration.prototype.process = function(decl) {
var prefixes;
if (this.needCascade(decl)) {
prefixes = Declaration.__super__.process.apply(this, arguments);
if (prefixes != null ? prefixes.length : void 0) {
this.restoreBefore(decl);
return decl.before = this.calcBefore(prefixes, decl);
}
} else {
return Declaration.__super__.process.apply(this, arguments);
}
};
Declaration.prototype.old = function(prop, prefix) {
return [this.prefixed(prop, prefix)];
};
return Declaration;
})(Prefixer);
module.exports = Declaration;
}).call(this);
},{"./browsers":6,"./prefixer":43,"./utils":49,"postcss/lib/vendor":112}],8:[function(_dereq_,module,exports){
(function() {
var AlignContent, Declaration, flexSpec,
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
hasProp = {}.hasOwnProperty;
flexSpec = _dereq_('./flex-spec');
Declaration = _dereq_('../declaration');
AlignContent = (function(superClass) {
extend(AlignContent, superClass);
function AlignContent() {
return AlignContent.__super__.constructor.apply(this, arguments);
}
AlignContent.names = ['align-content', 'flex-line-pack'];
AlignContent.oldValues = {
'flex-end': 'end',
'flex-start': 'start',
'space-between': 'justify',
'space-around': 'distribute'
};
AlignContent.prototype.prefixed = function(prop, prefix) {
var ref, spec;
ref = flexSpec(prefix), spec = ref[0], prefix = ref[1];
if (spec === 2012) {
return prefix + 'flex-line-pack';
} else {
return AlignContent.__super__.prefixed.apply(this, arguments);
}
};
AlignContent.prototype.normalize = function(prop) {
return 'align-content';
};
AlignContent.prototype.set = function(decl, prefix) {
var spec;
spec = flexSpec(prefix)[0];
if (spec === 2012) {
decl.value = AlignContent.oldValues[decl.value] || decl.value;
return AlignContent.__super__.set.call(this, decl, prefix);
} else if (spec === 'final') {
return AlignContent.__super__.set.apply(this, arguments);
}
};
return AlignContent;
})(Declaration);
module.exports = AlignContent;
}).call(this);
},{"../declaration":7,"./flex-spec":26}],9:[function(_dereq_,module,exports){
(function() {
var AlignItems, Declaration, flexSpec,
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
hasProp = {}.hasOwnProperty;
flexSpec = _dereq_('./flex-spec');
Declaration = _dereq_('../declaration');
AlignItems = (function(superClass) {
extend(AlignItems, superClass);
function AlignItems() {
return AlignItems.__super__.constructor.apply(this, arguments);
}
AlignItems.names = ['align-items', 'flex-align', 'box-align'];
AlignItems.oldValues = {
'flex-end': 'end',
'flex-start': 'start'
};
AlignItems.prototype.prefixed = function(prop, prefix) {
var ref, spec;
ref = flexSpec(prefix), spec = ref[0], prefix = ref[1];
if (spec === 2009) {
return prefix + 'box-align';
} else if (spec === 2012) {
return prefix + 'flex-align';
} else {
return AlignItems.__super__.prefixed.apply(this, arguments);
}
};
AlignItems.prototype.normalize = function(prop) {
return 'align-items';
};
AlignItems.prototype.set = function(decl, prefix) {
var spec;
spec = flexSpec(prefix)[0];
if (spec === 2009 || spec === 2012) {
decl.value = AlignItems.oldValues[decl.value] || decl.value;
return AlignItems.__super__.set.call(this, decl, prefix);
} else {
return AlignItems.__super__.set.apply(this, arguments);
}
};
return AlignItems;
})(Declaration);
module.exports = AlignItems;
}).call(this);
},{"../declaration":7,"./flex-spec":26}],10:[function(_dereq_,module,exports){
(function() {
var AlignSelf, Declaration, flexSpec,
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
hasProp = {}.hasOwnProperty;
flexSpec = _dereq_('./flex-spec');
Declaration = _dereq_('../declaration');
AlignSelf = (function(superClass) {
extend(AlignSelf, superClass);
function AlignSelf() {
return AlignSelf.__super__.constructor.apply(this, arguments);
}
AlignSelf.names = ['align-self', 'flex-item-align'];
AlignSelf.oldValues = {
'flex-end': 'end',
'flex-start': 'start'
};
AlignSelf.prototype.prefixed = function(prop, prefix) {
var ref, spec;
ref = flexSpec(prefix), spec = ref[0], prefix = ref[1];
if (spec === 2012) {
return prefix + 'flex-item-align';
} else {
return AlignSelf.__super__.prefixed.apply(this, arguments);
}
};
AlignSelf.prototype.normalize = function(prop) {
return 'align-self';
};
AlignSelf.prototype.set = function(decl, prefix) {
var spec;
spec = flexSpec(prefix)[0];
if (spec === 2012) {
decl.value = AlignSelf.oldValues[decl.value] || decl.value;
return AlignSelf.__super__.set.call(this, decl, prefix);
} else if (spec === 'final') {
return AlignSelf.__super__.set.apply(this, arguments);
}
};
return AlignSelf;
})(Declaration);
module.exports = AlignSelf;
}).call(this);
},{"../declaration":7,"./flex-spec":26}],11:[function(_dereq_,module,exports){
(function() {
var Appearance, Declaration,
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
hasProp = {}.hasOwnProperty;
Declaration = _dereq_('../declaration');
Appearance = (function(superClass) {
extend(Appearance, superClass);
function Appearance() {
return Appearance.__super__.constructor.apply(this, arguments);
}
Appearance.names = ['appearance'];
Appearance.prototype.check = function(decl) {
return decl.value.toLowerCase() === 'none';
};
return Appearance;
})(Declaration);
module.exports = Appearance;
}).call(this);
},{"../declaration":7}],12:[function(_dereq_,module,exports){
(function() {
var BackgroundSize, Declaration,
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
hasProp = {}.hasOwnProperty;
Declaration = _dereq_('../declaration');
BackgroundSize = (function(superClass) {
extend(BackgroundSize, superClass);
function BackgroundSize() {
return BackgroundSize.__super__.constructor.apply(this, arguments);
}
BackgroundSize.names = ['background-size'];
BackgroundSize.prototype.set = function(decl, prefix) {
var value;
value = decl.value.toLowerCase();
if (prefix === '-webkit-' && value.indexOf(' ') === -1 && value !== 'contain' && value !== 'cover') {
decl.value = decl.value + ' ' + decl.value;
}
return BackgroundSize.__super__.set.call(this, decl, prefix);
};
return BackgroundSize;
})(Declaration);
module.exports = BackgroundSize;
}).call(this);
},{"../declaration":7}],13:[function(_dereq_,module,exports){
(function() {
var BlockLogical, Declaration,
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
hasProp = {}.hasOwnProperty;
Declaration = _dereq_('../declaration');
BlockLogical = (function(superClass) {
extend(BlockLogical, superClass);
function BlockLogical() {
return BlockLogical.__super__.constructor.apply(this, arguments);
}
BlockLogical.names = ['border-block-start', 'border-block-end', 'margin-block-start', 'margin-block-end', 'padding-block-start', 'padding-block-end', 'border-before', 'border-after', 'margin-before', 'margin-after', 'padding-before', 'padding-after'];
BlockLogical.prototype.prefixed = function(prop, prefix) {
return prefix + (prop.indexOf('-start') !== -1 ? prop.replace('-block-start', '-before') : prop.replace('-block-end', '-after'));
};
BlockLogical.prototype.normalize = function(prop) {
if (prop.indexOf('-before') !== -1) {
return prop.replace('-before', '-block-start');
} else {
return prop.replace('-after', '-block-end');
}
};
return BlockLogical;
})(Declaration);
module.exports = BlockLogical;
}).call(this);
},{"../declaration":7}],14:[function(_dereq_,module,exports){
(function() {
var BorderImage, Declaration,
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
hasProp = {}.hasOwnProperty;
Declaration = _dereq_('../declaration');
BorderImage = (function(superClass) {
extend(BorderImage, superClass);
function BorderImage() {
return BorderImage.__super__.constructor.apply(this, arguments);
}
BorderImage.names = ['border-image'];
BorderImage.prototype.set = function(decl, prefix) {
decl.value = decl.value.replace(/\s+fill(\s)/, '$1');
return BorderImage.__super__.set.call(this, decl, prefix);
};
return BorderImage;
})(Declaration);
module.exports = BorderImage;
}).call(this);
},{"../declaration":7}],15:[function(_dereq_,module,exports){
(function() {
var BorderRadius, Declaration,
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
hasProp = {}.hasOwnProperty;
Declaration = _dereq_('../declaration');
BorderRadius = (function(superClass) {
var hor, i, j, len, len1, mozilla, normal, ref, ref1, ver;
extend(BorderRadius, superClass);
function BorderRadius() {
return BorderRadius.__super__.constructor.apply(this, arguments);
}
BorderRadius.names = ['border-radius'];
BorderRadius.toMozilla = {};
BorderRadius.toNormal = {};
ref = ['top', 'bottom'];
for (i = 0, len = ref.length; i < len; i++) {
ver = ref[i];
ref1 = ['left', 'right'];
for (j = 0, len1 = ref1.length; j < len1; j++) {
hor = ref1[j];
normal = "border-" + ver + "-" + hor + "-radius";
mozilla = "border-radius-" + ver + hor;
BorderRadius.names.push(normal);
BorderRadius.names.push(mozilla);
BorderRadius.toMozilla[normal] = mozilla;
BorderRadius.toNormal[mozilla] = normal;
}
}
BorderRadius.prototype.prefixed = function(prop, prefix) {
if (prefix === '-moz-') {
return prefix + (BorderRadius.toMozilla[prop] || prop);
} else {
return BorderRadius.__super__.prefixed.apply(this, arguments);
}
};
BorderRadius.prototype.normalize = function(prop) {
return BorderRadius.toNormal[prop] || prop;
};
return BorderRadius;
})(Declaration);
module.exports = BorderRadius;
}).call(this);
},{"../declaration":7}],16:[function(_dereq_,module,exports){
(function() {
var BreakInside, Declaration,
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
hasProp = {}.hasOwnProperty;
Declaration = _dereq_('../declaration');
BreakInside = (function(superClass) {
extend(BreakInside, superClass);
function BreakInside() {
return BreakInside.__super__.constructor.apply(this, arguments);
}
BreakInside.names = ['break-inside', 'page-break-inside', 'column-break-inside'];
BreakInside.prototype.prefixed = function(prop, prefix) {
if (prefix === '-webkit-') {
return prefix + 'column-break-inside';
} else if (prefix === '-moz-') {
return 'page-break-inside';
} else {
return BreakInside.__super__.prefixed.apply(this, arguments);
}
};
BreakInside.prototype.normalize = function() {
return 'break-inside';
};
BreakInside.prototype.set = function(decl, prefix) {
if (decl.value === 'avoid-column' || decl.value === 'avoid-page') {
decl.value = 'avoid';
}
return BreakInside.__super__.set.apply(this, arguments);
};
BreakInside.prototype.insert = function(decl, prefix, prefixes) {
if (decl.value === 'avoid-region') {
} else if (decl.value === 'avoid-page' && prefix === '-webkit-') {
} else {
return BreakInside.__super__.insert.apply(this, arguments);
}
};
return BreakInside;
})(Declaration);
module.exports = BreakInside;
}).call(this);
},{"../declaration":7}],17:[function(_dereq_,module,exports){
(function() {
var DisplayFlex, OldDisplayFlex, OldValue, Value, flexSpec,
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
hasProp = {}.hasOwnProperty;
flexSpec = _dereq_('./flex-spec');
OldValue = _dereq_('../old-value');
Value = _dereq_('../value');
OldDisplayFlex = (function(superClass) {
extend(OldDisplayFlex, superClass);
function OldDisplayFlex(unprefixed, prefixed1) {
this.unprefixed = unprefixed;
this.prefixed = prefixed1;
}
OldDisplayFlex.prototype.check = function(value) {
return value === this.name;
};
return OldDisplayFlex;
})(OldValue);
DisplayFlex = (function(superClass) {
extend(DisplayFlex, superClass);
DisplayFlex.names = ['display-flex', 'inline-flex'];
function DisplayFlex(name, prefixes) {
DisplayFlex.__super__.constructor.apply(this, arguments);
if (name === 'display-flex') {
this.name = 'flex';
}
}
DisplayFlex.prototype.check = function(decl) {
return decl.value === this.name;
};
DisplayFlex.prototype.prefixed = function(prefix) {
var ref, spec;
ref = flexSpec(prefix), spec = ref[0], prefix = ref[1];
return prefix + (spec === 2009 ? this.name === 'flex' ? 'box' : 'inline-box' : spec === 2012 ? this.name === 'flex' ? 'flexbox' : 'inline-flexbox' : spec === 'final' ? this.name : void 0);
};
DisplayFlex.prototype.replace = function(string, prefix) {
return this.prefixed(prefix);
};
DisplayFlex.prototype.old = function(prefix) {
var prefixed;
prefixed = this.prefixed(prefix);
if (prefixed) {
return new OldValue(this.name, prefixed);
}
};
return DisplayFlex;
})(Value);
module.exports = DisplayFlex;
}).call(this);
},{"../old-value":42,"../value":50,"./flex-spec":26}],18:[function(_dereq_,module,exports){
(function() {
var FillAvailable, OldValue, Value,
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
hasProp = {}.hasOwnProperty;
OldValue = _dereq_('../old-value');
Value = _dereq_('../value');
FillAvailable = (function(superClass) {
extend(FillAvailable, superClass);
function FillAvailable() {
return FillAvailable.__super__.constructor.apply(this, arguments);
}
FillAvailable.names = ['fill-available'];
FillAvailable.prototype.replace = function(string, prefix) {
if (prefix === '-moz-') {
return string.replace(this.regexp(), '$1-moz-available$3');
} else {
return FillAvailable.__super__.replace.apply(this, arguments);
}
};
FillAvailable.prototype.old = function(prefix) {
if (prefix === '-moz-') {
return new OldValue(this.name, '-moz-available');
} else {
return FillAvailable.__super__.old.apply(this, arguments);
}
};
return FillAvailable;
})(Value);
module.exports = FillAvailable;
}).call(this);
},{"../old-value":42,"../value":50}],19:[function(_dereq_,module,exports){
(function() {
var FilterValue, OldFilterValue, OldValue, Value, utils,
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
hasProp = {}.hasOwnProperty;
OldValue = _dereq_('../old-value');
Value = _dereq_('../value');
utils = _dereq_('../utils');
OldFilterValue = (function(superClass) {
extend(OldFilterValue, superClass);
function OldFilterValue() {
return OldFilterValue.__super__.constructor.apply(this, arguments);
}
OldFilterValue.prototype.clean = function(decl) {
return decl.value = utils.editList(decl.value, (function(_this) {
return function(props) {
if (props.every(function(i) {
return i.indexOf(_this.unprefixed) !== 0;
})) {
return props;
}
return props.filter(function(i) {
return i.indexOf(_this.prefixed) === -1;
});
};
})(this));
};
return OldFilterValue;
})(OldValue);
FilterValue = (function(superClass) {
extend(FilterValue, superClass);
function FilterValue() {
return FilterValue.__super__.constructor.apply(this, arguments);
}
FilterValue.names = ['filter'];
FilterValue.prototype.replace = function(value, prefix) {
if (prefix === '-webkit-') {
if (value.indexOf('-webkit-filter') === -1) {
return FilterValue.__super__.replace.apply(this, arguments) + ', ' + value;
} else {
return value;
}
} else {
return FilterValue.__super__.replace.apply(this, arguments);
}
};
FilterValue.prototype.old = function(prefix) {
return new OldFilterValue(this.name, prefix + this.name);
};
return FilterValue;
})(Value);
module.exports = FilterValue;
}).call(this);
},{"../old-value":42,"../utils":49,"../value":50}],20:[function(_dereq_,module,exports){