123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339 |
- 'use strict';
- const vendor = require('./vendor');
- /**
- * Extract each list using the internal API of Autoprefixer 10.2.5.
- *
- * @see https://github.com/postcss/autoprefixer/tree/10.2.5
- *
- * @example
- * const autoprefixer = require('autoprefixer');
- * const Browsers = require('autoprefixer/lib/browsers');
- * const Prefixes = require('autoprefixer/lib/prefixes');
- * const utils = require('autoprefixer/lib/utils');
- *
- * const prefixes = new Prefixes(autoprefixer.data.prefixes, new Browsers(autoprefixer.data.browsers, []));
- */
- /**
- * @example
- * Object.keys(prefixes.remove).filter((s) => s.startsWith('@'));
- */
- const AT_RULES = new Set([
- '@-khtml-keyframes',
- '@-moz-keyframes',
- '@-ms-keyframes',
- '@-ms-viewport',
- '@-o-keyframes',
- '@-o-viewport',
- '@-webkit-keyframes',
- '@resolution',
- ]);
- /**
- * @example
- * prefixes.remove.selectors.map((s) => s.prefixed);
- */
- const SELECTORS = new Set([
- ':-moz-any-link',
- ':-moz-full-screen',
- ':-moz-placeholder',
- ':-moz-placeholder-shown',
- ':-moz-read-only',
- ':-moz-read-write',
- ':-ms-fullscreen',
- ':-ms-input-placeholder',
- ':-webkit-any-link',
- ':-webkit-full-screen',
- '::-moz-placeholder',
- '::-moz-selection',
- '::-ms-input-placeholder',
- '::-webkit-backdrop',
- '::-webkit-input-placeholder',
- ]);
- /**
- * @example
- * Object.entries(autoprefixer.data.prefixes)
- * .filter(([key, value]) => !value.selector && !value.props && !key.startsWith('@'))
- * .map(([key, value]) => key);
- */
- const PROPERTIES = new Set([
- 'align-content',
- 'align-items',
- 'align-self',
- 'animation',
- 'animation-delay',
- 'animation-direction',
- 'animation-duration',
- 'animation-fill-mode',
- 'animation-iteration-count',
- 'animation-name',
- 'animation-play-state',
- 'animation-timing-function',
- 'appearance',
- 'backdrop-filter',
- 'backface-visibility',
- 'background-clip',
- 'background-origin',
- 'background-size',
- 'border-block-end',
- 'border-block-start',
- 'border-bottom-left-radius',
- 'border-bottom-right-radius',
- 'border-image',
- 'border-inline-end',
- 'border-inline-start',
- 'border-radius',
- 'border-top-left-radius',
- 'border-top-right-radius',
- 'box-decoration-break',
- 'box-shadow',
- 'box-sizing',
- 'break-after',
- 'break-before',
- 'break-inside',
- 'clip-path',
- 'color-adjust',
- 'column-count',
- 'column-fill',
- 'column-gap',
- 'column-rule',
- 'column-rule-color',
- 'column-rule-style',
- 'column-rule-width',
- 'column-span',
- 'column-width',
- 'columns',
- 'filter',
- 'flex',
- 'flex-basis',
- 'flex-direction',
- 'flex-flow',
- 'flex-grow',
- 'flex-shrink',
- 'flex-wrap',
- 'flow-from',
- 'flow-into',
- 'font-feature-settings',
- 'font-kerning',
- 'font-language-override',
- 'font-variant-ligatures',
- 'grid-area',
- 'grid-column',
- 'grid-column-align',
- 'grid-column-end',
- 'grid-column-start',
- 'grid-row',
- 'grid-row-align',
- 'grid-row-end',
- 'grid-row-start',
- 'grid-template',
- 'grid-template-areas',
- 'grid-template-columns',
- 'grid-template-rows',
- 'hyphens',
- 'image-rendering',
- 'justify-content',
- 'margin-block-end',
- 'margin-block-start',
- 'margin-inline-end',
- 'margin-inline-start',
- 'mask',
- 'mask-border',
- 'mask-border-outset',
- 'mask-border-repeat',
- 'mask-border-slice',
- 'mask-border-source',
- 'mask-border-width',
- 'mask-clip',
- 'mask-composite',
- 'mask-image',
- 'mask-origin',
- 'mask-position',
- 'mask-repeat',
- 'mask-size',
- 'object-fit',
- 'object-position',
- 'order',
- 'overscroll-behavior',
- 'padding-block-end',
- 'padding-block-start',
- 'padding-inline-end',
- 'padding-inline-start',
- 'perspective',
- 'perspective-origin',
- 'place-self',
- 'region-fragment',
- 'scroll-snap-coordinate',
- 'scroll-snap-destination',
- 'scroll-snap-points-x',
- 'scroll-snap-points-y',
- 'scroll-snap-type',
- 'shape-image-threshold',
- 'shape-margin',
- 'shape-outside',
- 'tab-size',
- 'text-align-last',
- 'text-decoration',
- 'text-decoration-color',
- 'text-decoration-line',
- 'text-decoration-skip',
- 'text-decoration-skip-ink',
- 'text-decoration-style',
- 'text-emphasis',
- 'text-emphasis-color',
- 'text-emphasis-position',
- 'text-emphasis-style',
- 'text-orientation',
- 'text-overflow',
- 'text-size-adjust',
- 'text-spacing',
- 'touch-action',
- 'transform',
- 'transform-origin',
- 'transform-style',
- 'transition',
- 'transition-delay',
- 'transition-duration',
- 'transition-property',
- 'transition-timing-function',
- 'user-select',
- 'writing-mode',
- ]);
- /**
- * @example
- * Object.values(prefixes.remove)
- * .filter((p) => Array.isArray(p.values))
- * .flatMap((p) => p.values)
- * .map((p) => utils.removeNote(p.prefixed)) // normalize '-webkit- old'
- * .filter((p) => !p.endsWith('-')); // remove '-webkit-' only
- *
- * @see https://github.com/stylelint/stylelint/pull/5312/files#r636018013
- */
- const PROPERTY_VALUES = new Set([
- '-moz-available',
- '-moz-box',
- '-moz-calc',
- '-moz-crisp-edges',
- '-moz-element',
- '-moz-fit-content',
- '-moz-grab',
- '-moz-grabbing',
- '-moz-inline-box',
- '-moz-isolate',
- '-moz-isolate-override',
- '-moz-linear-gradient',
- '-moz-max-content',
- '-moz-min-content',
- '-moz-plaintext',
- '-moz-radial-gradient',
- '-moz-repeating-linear-gradient',
- '-moz-repeating-radial-gradient',
- '-moz-zoom-in',
- '-moz-zoom-out',
- '-ms-flexbox',
- '-ms-grid',
- '-ms-inline-flexbox',
- '-ms-inline-grid',
- '-ms-linear-gradient',
- '-ms-radial-gradient',
- '-ms-repeating-linear-gradient',
- '-ms-repeating-radial-gradient',
- '-o-linear-gradient',
- '-o-pixelated',
- '-o-radial-gradient',
- '-o-repeating-linear-gradient',
- '-o-repeating-radial-gradient',
- '-webkit-box',
- '-webkit-calc',
- '-webkit-cross-fade',
- '-webkit-fill-available',
- '-webkit-filter',
- '-webkit-fit-content',
- '-webkit-flex',
- '-webkit-grab',
- '-webkit-grabbing',
- '-webkit-image-set',
- '-webkit-inline-box',
- '-webkit-inline-flex',
- '-webkit-isolate',
- '-webkit-linear-gradient',
- '-webkit-max-content',
- '-webkit-min-content',
- '-webkit-optimize-contrast',
- '-webkit-radial-gradient',
- '-webkit-repeating-linear-gradient',
- '-webkit-repeating-radial-gradient',
- '-webkit-sticky',
- '-webkit-zoom-in',
- '-webkit-zoom-out',
- ]);
- /**
- * Most identifier types have to be looked up in a unique way,
- * so we're exposing special functions for each.
- */
- module.exports = {
- /**
- * @param {string} identifier
- * @returns {boolean}
- */
- atRuleName(identifier) {
- return AT_RULES.has(`@${identifier.toLowerCase()}`);
- },
- /**
- * @param {string} identifier
- * @returns {boolean}
- */
- selector(identifier) {
- return SELECTORS.has(identifier.toLowerCase());
- },
- /**
- * @param {string} identifier
- * @returns {boolean}
- */
- mediaFeatureName(identifier) {
- return identifier.toLowerCase().includes('device-pixel-ratio');
- },
- /**
- * @param {string} identifier
- * @returns {boolean}
- */
- property(identifier) {
- const ident = identifier.toLowerCase();
- // HACK: `interpolation-mode` does not exist. This is an IE extension for `image-rendering`.
- // See <https://developer.mozilla.org/en-US/docs/Web/CSS/image-rendering#examples>
- if (ident === '-ms-interpolation-mode') {
- return true;
- }
- if (vendor.prefix(ident).length === 0) {
- return false;
- }
- return PROPERTIES.has(vendor.unprefixed(ident));
- },
- /**
- * @param {string} value
- * @returns {boolean}
- */
- propertyValue(value) {
- return PROPERTY_VALUES.has(value.toLowerCase());
- },
- /**
- * @param {string} value
- * @returns {string}
- */
- unprefix(value) {
- return value.replace(/-\w+-/, '');
- },
- };
|