123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319 |
- 'use strict';
- const htmlTags = require('html-tags');
- const uniteSets = require('../utils/uniteSets.js');
- const deprecatedHtmlTypeSelectors = new Set([
- 'acronym',
- 'applet',
- 'basefont',
- 'big',
- 'blink',
- 'center',
- 'content',
- 'dir',
- 'font',
- 'frame',
- 'frameset',
- 'hgroup',
- 'isindex',
- 'keygen',
- 'listing',
- 'marquee',
- 'nobr',
- 'noembed',
- 'plaintext',
- 'spacer',
- 'strike',
- 'tt',
- 'xmp',
- ]);
- // typecasting htmlTags to be more generic; see https://github.com/stylelint/stylelint/pull/6013 for discussion
- /** @type {Set<string>} */
- const standardHtmlTypeSelectors = new Set(htmlTags);
- const htmlTypeSelectors = uniteSets(deprecatedHtmlTypeSelectors, standardHtmlTypeSelectors);
- const mixedCaseSvgTypeSelectors = new Set([
- 'altGlyph',
- 'altGlyphDef',
- 'altGlyphItem',
- 'animateColor',
- 'animateMotion',
- 'animateTransform',
- 'clipPath',
- 'feBlend',
- 'feColorMatrix',
- 'feComponentTransfer',
- 'feComposite',
- 'feConvolveMatrix',
- 'feDiffuseLighting',
- 'feDisplacementMap',
- 'feDistantLight',
- 'feDropShadow',
- 'feFlood',
- 'feFuncA',
- 'feFuncB',
- 'feFuncG',
- 'feFuncR',
- 'feGaussianBlur',
- 'feImage',
- 'feMerge',
- 'feMergeNode',
- 'feMorphology',
- 'feOffset',
- 'fePointLight',
- 'feSpecularLighting',
- 'feSpotLight',
- 'feTile',
- 'feTurbulence',
- 'foreignObject',
- 'glyphRef',
- 'linearGradient',
- 'radialGradient',
- 'textPath',
- ]);
- // These are the ones that can have single-colon notation
- const levelOneAndTwoPseudoElements = new Set(['before', 'after', 'first-line', 'first-letter']);
- const shadowTreePseudoElements = new Set(['part']);
- const webkitScrollbarPseudoElements = new Set([
- '-webkit-resizer',
- '-webkit-scrollbar',
- '-webkit-scrollbar-button',
- '-webkit-scrollbar-corner',
- '-webkit-scrollbar-thumb',
- '-webkit-scrollbar-track',
- '-webkit-scrollbar-track-piece',
- ]);
- const vendorSpecificPseudoElements = uniteSets(webkitScrollbarPseudoElements, [
- '-moz-focus-inner',
- '-moz-focus-outer',
- '-moz-list-bullet',
- '-moz-meter-bar',
- '-moz-placeholder',
- '-moz-progress-bar',
- '-moz-range-progress',
- '-moz-range-thumb',
- '-moz-range-track',
- '-ms-browse',
- '-ms-check',
- '-ms-clear',
- '-ms-expand',
- '-ms-fill',
- '-ms-fill-lower',
- '-ms-fill-upper',
- '-ms-reveal',
- '-ms-thumb',
- '-ms-ticks-after',
- '-ms-ticks-before',
- '-ms-tooltip',
- '-ms-track',
- '-ms-value',
- '-webkit-color-swatch',
- '-webkit-color-swatch-wrapper',
- '-webkit-calendar-picker-indicator',
- '-webkit-clear-button',
- '-webkit-date-and-time-value',
- '-webkit-datetime-edit',
- '-webkit-datetime-edit-ampm-field',
- '-webkit-datetime-edit-day-field',
- '-webkit-datetime-edit-fields-wrapper',
- '-webkit-datetime-edit-hour-field',
- '-webkit-datetime-edit-millisecond-field',
- '-webkit-datetime-edit-minute-field',
- '-webkit-datetime-edit-month-field',
- '-webkit-datetime-edit-second-field',
- '-webkit-datetime-edit-text',
- '-webkit-datetime-edit-week-field',
- '-webkit-datetime-edit-year-field',
- '-webkit-details-marker',
- '-webkit-distributed',
- '-webkit-file-upload-button',
- '-webkit-input-placeholder',
- '-webkit-keygen-select',
- '-webkit-meter-bar',
- '-webkit-meter-even-less-good-value',
- '-webkit-meter-inner-element',
- '-webkit-meter-optimum-value',
- '-webkit-meter-suboptimum-value',
- '-webkit-progress-bar',
- '-webkit-progress-inner-element',
- '-webkit-progress-value',
- '-webkit-search-cancel-button',
- '-webkit-search-decoration',
- '-webkit-search-results-button',
- '-webkit-search-results-decoration',
- '-webkit-slider-runnable-track',
- '-webkit-slider-thumb',
- '-webkit-textfield-decoration-container',
- '-webkit-validation-bubble',
- '-webkit-validation-bubble-arrow',
- '-webkit-validation-bubble-arrow-clipper',
- '-webkit-validation-bubble-heading',
- '-webkit-validation-bubble-message',
- '-webkit-validation-bubble-text-block',
- ]);
- const pseudoElements = uniteSets(
- levelOneAndTwoPseudoElements,
- vendorSpecificPseudoElements,
- shadowTreePseudoElements,
- [
- 'backdrop',
- 'content',
- 'cue',
- 'file-selector-button',
- 'grammar-error',
- 'highlight',
- 'marker',
- 'placeholder',
- 'selection',
- 'shadow',
- 'slotted',
- 'spelling-error',
- 'target-text',
- ],
- );
- const aNPlusBNotationPseudoClasses = new Set([
- 'nth-column',
- 'nth-last-column',
- 'nth-last-of-type',
- 'nth-of-type',
- ]);
- const aNPlusBOfSNotationPseudoClasses = new Set(['nth-child', 'nth-last-child']);
- const atRulePagePseudoClasses = new Set(['first', 'right', 'left', 'blank']);
- const linguisticPseudoClasses = new Set(['dir', 'lang']);
- const logicalCombinationsPseudoClasses = new Set(['has', 'is', 'matches', 'not', 'where']);
- const vendorSpecificPseudoClasses = new Set([
- '-khtml-drag',
- '-moz-any',
- '-moz-any-link',
- '-moz-broken',
- '-moz-drag-over',
- '-moz-first-node',
- '-moz-focusring',
- '-moz-full-screen',
- '-moz-full-screen-ancestor',
- '-moz-last-node',
- '-moz-loading',
- '-moz-meter-optimum',
- '-moz-meter-sub-optimum',
- '-moz-meter-sub-sub-optimum',
- '-moz-placeholder',
- '-moz-submit-invalid',
- '-moz-suppressed',
- '-moz-ui-invalid',
- '-moz-ui-valid',
- '-moz-user-disabled',
- '-moz-window-inactive',
- '-ms-fullscreen',
- '-ms-input-placeholder',
- '-webkit-drag',
- '-webkit-any',
- '-webkit-any-link',
- '-webkit-autofill',
- '-webkit-full-screen',
- '-webkit-full-screen-ancestor',
- ]);
- // https://webkit.org/blog/363/styling-scrollbars/
- const webkitScrollbarPseudoClasses = new Set([
- 'horizontal',
- 'vertical',
- 'decrement',
- 'increment',
- 'start',
- 'end',
- 'double-button',
- 'single-button',
- 'no-button',
- 'corner-present',
- 'window-inactive',
- ]);
- const pseudoClasses = uniteSets(
- aNPlusBNotationPseudoClasses,
- linguisticPseudoClasses,
- logicalCombinationsPseudoClasses,
- aNPlusBOfSNotationPseudoClasses,
- vendorSpecificPseudoClasses,
- [
- 'active',
- 'any-link',
- 'autofill',
- 'blank',
- 'checked',
- 'current',
- 'default',
- 'defined',
- 'disabled',
- 'empty',
- 'enabled',
- 'first-child',
- 'first-of-type',
- 'focus',
- 'focus-within',
- 'focus-visible',
- 'fullscreen',
- 'fullscreen-ancestor',
- 'future',
- 'host',
- 'host-context',
- 'hover',
- 'indeterminate',
- 'in-range',
- 'invalid',
- 'last-child',
- 'last-of-type',
- 'link',
- 'only-child',
- 'only-of-type',
- 'optional',
- 'out-of-range',
- 'past',
- 'placeholder-shown',
- 'playing',
- 'picture-in-picture',
- 'paused',
- 'read-only',
- 'read-write',
- 'required',
- 'root',
- 'scope',
- 'state',
- 'target',
- 'unresolved',
- 'user-invalid',
- 'user-valid',
- 'valid',
- 'visited',
- 'window-inactive', // for ::selection (chrome)
- ],
- );
- module.exports = {
- aNPlusBNotationPseudoClasses,
- aNPlusBOfSNotationPseudoClasses,
- atRulePagePseudoClasses,
- levelOneAndTwoPseudoElements,
- linguisticPseudoClasses,
- logicalCombinationsPseudoClasses,
- mixedCaseSvgTypeSelectors,
- pseudoClasses,
- pseudoElements,
- shadowTreePseudoElements,
- htmlTypeSelectors,
- webkitScrollbarPseudoClasses,
- webkitScrollbarPseudoElements,
- };
|