diff options
author | Mark Otto <otto@github.com> | 2019-04-25 17:01:50 +0300 |
---|---|---|
committer | XhmikosR <xhmikosr@gmail.com> | 2019-04-25 17:01:50 +0300 |
commit | 60d826a305f5aec8d202a7ad6b98cc1cde8421a9 (patch) | |
tree | 923cc4a4e536b7f86148c40fa093b1a2f9d3ee87 /scss | |
parent | 2d0f2feb10714ff83cb2c0d94a63ac1dcb413090 (diff) |
Prevent form validation mixin from generating invalid CSS (#28447)
Extrapolates the previously used selector into a new mixin that only generates valid CSS by creating psuedo-classes for `valid` and `invalid`, and nothing else.
Fixes #28380.
Diffstat (limited to 'scss')
-rw-r--r-- | scss/mixins/_forms.scss | 33 |
1 files changed, 19 insertions, 14 deletions
diff --git a/scss/mixins/_forms.scss b/scss/mixins/_forms.scss index 1b51a6439f..248ba60f22 100644 --- a/scss/mixins/_forms.scss +++ b/scss/mixins/_forms.scss @@ -26,6 +26,18 @@ @include deprecate("The `form-control-focus()` mixin", "v4.3.2", "v5", $ignore-warning); } +@mixin form-validation-state-selector($state) { + @if ($state == "valid" or $state == "invalid") { + .was-validated &:#{$state}, + &.is-#{$state} { + @content; + } + } @else { + &.is-#{$state} { + @content; + } + } +} @mixin form-validation-state($state, $color, $icon) { .#{$state}-feedback { @@ -52,8 +64,7 @@ } .form-control { - .was-validated &:#{$state}, - &.is-#{$state} { + @include form-validation-state-selector($state) { border-color: $color; @if $enable-validation-icons { @@ -78,8 +89,7 @@ // stylelint-disable-next-line selector-no-qualifying-type textarea.form-control { - .was-validated &:#{$state}, - &.is-#{$state} { + @include form-validation-state-selector($state) { @if $enable-validation-icons { padding-right: $input-height-inner; background-position: top $input-height-inner-quarter right $input-height-inner-quarter; @@ -88,8 +98,7 @@ } .custom-select { - .was-validated &:#{$state}, - &.is-#{$state} { + @include form-validation-state-selector($state) { border-color: $color; @if $enable-validation-icons { @@ -111,8 +120,7 @@ .form-control-file { - .was-validated &:#{$state}, - &.is-#{$state} { + @include form-validation-state-selector($state) { ~ .#{$state}-feedback, ~ .#{$state}-tooltip { display: block; @@ -121,8 +129,7 @@ } .form-check-input { - .was-validated &:#{$state}, - &.is-#{$state} { + @include form-validation-state-selector($state) { ~ .form-check-label { color: $color; } @@ -135,8 +142,7 @@ } .custom-control-input { - .was-validated &:#{$state}, - &.is-#{$state} { + @include form-validation-state-selector($state) { ~ .custom-control-label { color: $color; @@ -171,8 +177,7 @@ // custom file .custom-file-input { - .was-validated &:#{$state}, - &.is-#{$state} { + @include form-validation-state-selector($state) { ~ .custom-file-label { border-color: $color; } |