PostCSS plugin to shim the pseudo-selectors :required and :optional by using negation (:not) and therefore slightly increase their browser support.
input:required::after {
content: '*'
}
textarea:optional::after {
content: '(optional)';
}
input:not(:optional),
input:required::after {
content: '*'
}
textarea:not(:required)::after,
textarea:optional::after {
content: '(optional)';
}
:required {
color: hotpink;
}
:optional {
color: indianred;
}
:not(:optional),
:required {
color: hotpink;
}
:optional {
color: indianred;
}
:required {
color: hotpink;
}
:optional {
color: indianred;
}
:required {
color: hotpink;
}
:not(:required),
:optional {
color: indianred;
}
##Options
The only available option is method
, with the possible values shim-all
(default), shim-optional
and shim-required
:
Usage
postcss([ require('postcss-substitute-optional-required') ])
postcss([ require('postcss-substitute-optional-required') ])({ method: 'shim-required' })
See PostCSS docs for examples for your environment.