MCPcopy
hub / github.com/postcss/autoprefixer / remove

Method remove

lib/processor.js:610–694  ·  view source on GitHub ↗

* Remove unnecessary pefixes

(css, result)

Source from the content-addressed store, hash-verified

608 * Remove unnecessary pefixes
609 */
610 remove(css, result) {
611 // At-rules
612 let resolution = this.prefixes.remove['@resolution']
613
614 css.walkAtRules((rule, i) => {
615 if (this.prefixes.remove[`@${rule.name}`]) {
616 if (!this.disabled(rule, result)) {
617 rule.parent.removeChild(i)
618 }
619 } else if (
620 rule.name === 'media' &&
621 rule.params.includes('-resolution') &&
622 resolution
623 ) {
624 resolution.clean(rule)
625 }
626 })
627
628 // Selectors
629 css.walkRules((rule, i) => {
630 if (this.disabled(rule, result)) return
631
632 for (let checker of this.prefixes.remove.selectors) {
633 if (checker.check(rule)) {
634 rule.parent.removeChild(i)
635 return
636 }
637 }
638 })
639
640 return css.walkDecls((decl, i) => {
641 if (this.disabled(decl, result)) return
642
643 let rule = decl.parent
644 let unprefixed = this.prefixes.unprefixed(decl.prop)
645
646 // Transition
647 if (decl.prop === 'transition' || decl.prop === 'transition-property') {
648 this.prefixes.transition.remove(decl)
649 }
650
651 // Properties
652 if (
653 this.prefixes.remove[decl.prop] &&
654 this.prefixes.remove[decl.prop].remove
655 ) {
656 let notHack = this.prefixes.group(decl).down(other => {
657 return this.prefixes.normalize(other.prop) === unprefixed
658 })
659
660 if (unprefixed === 'flex-flow') {
661 notHack = true
662 }
663
664 if (decl.prop === '-webkit-box-orient') {
665 let hacks = { 'flex-direction': true, 'flex-flow': true }
666 if (!decl.parent.some(j => hacks[j.prop])) return
667 }

Callers

nothing calls this directly

Calls 10

disabledMethod · 0.95
withHackValueMethod · 0.95
reduceSpacesMethod · 0.95
cleanMethod · 0.80
unprefixedMethod · 0.80
downMethod · 0.80
groupMethod · 0.80
valuesMethod · 0.80
checkMethod · 0.45
normalizeMethod · 0.45

Tested by

no test coverage detected