GoScrobble/web/node_modules/jss-plugin-vendor-prefixer/dist/jss-plugin-vendor-prefixer.cjs.js

64 lines
1.5 KiB
JavaScript
Raw Permalink Normal View History

2022-04-25 02:47:15 +00:00
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var vendor = require('css-vendor');
var jss = require('jss');
/**
* Add vendor prefix to a property name when needed.
*
* @api public
*/
function jssVendorPrefixer() {
function onProcessRule(rule) {
if (rule.type === 'keyframes') {
var atRule = rule;
atRule.at = vendor.supportedKeyframes(atRule.at);
}
}
function prefixStyle(style) {
for (var prop in style) {
var value = style[prop];
if (prop === 'fallbacks' && Array.isArray(value)) {
style[prop] = value.map(prefixStyle);
continue;
}
var changeProp = false;
var supportedProp = vendor.supportedProperty(prop);
if (supportedProp && supportedProp !== prop) changeProp = true;
var changeValue = false;
var supportedValue = vendor.supportedValue(supportedProp, jss.toCssValue(value));
if (supportedValue && supportedValue !== value) changeValue = true;
if (changeProp || changeValue) {
if (changeProp) delete style[prop];
style[supportedProp || prop] = supportedValue || value;
}
}
return style;
}
function onProcessStyle(style, rule) {
if (rule.type !== 'style') return style;
return prefixStyle(style);
}
function onChangeValue(value, prop) {
return vendor.supportedValue(prop, jss.toCssValue(value)) || value;
}
return {
onProcessRule: onProcessRule,
onProcessStyle: onProcessStyle,
onChangeValue: onChangeValue
};
}
exports.default = jssVendorPrefixer;