Skip to content

Commit

Permalink
Fix unitless bug
Browse files Browse the repository at this point in the history
  • Loading branch information
MartijnCuppens committed Oct 13, 2018
1 parent 94886c7 commit 35f9482
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 8 deletions.
7 changes: 6 additions & 1 deletion examples/postcss/gulp/dest/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -64,5 +64,10 @@

/* responsive-font-size property without unit */
.selector-8 {
font-size: 32;
font-size: 2rem;
}
@media (max-width: 1200px) {
.selector-8 {
font-size: calc(1.2rem + 1.066667vw);
}
}
7 changes: 6 additions & 1 deletion examples/postcss/node/dest/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -64,5 +64,10 @@

/* responsive-font-size property without unit */
.selector-8 {
font-size: 32;
font-size: 2rem;
}
@media (max-width: 1200px) {
.selector-8 {
font-size: calc(1.2rem + 1.066667vw);
}
}
7 changes: 6 additions & 1 deletion examples/stylus/gulp/dest/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,10 @@
}
/* responsive-font-size property without unit */
.selector-8 {
font-size: 32;
font-size: 2rem;
}
@media (max-width: 1200px) {
.selector-8 {
font-size: calc(1.2rem + 1.066666666666667vw);
}
}
7 changes: 6 additions & 1 deletion examples/stylus/node/dest/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,10 @@
}
/* responsive-font-size property without unit */
.selector-8 {
font-size: 32;
font-size: 2rem;
}
@media (max-width: 1200px) {
.selector-8 {
font-size: calc(1.2rem + 1.066666666666667vw);
}
}
2 changes: 1 addition & 1 deletion postcss/rfs.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ module.exports = postcss.plugin('postcss-rfs', function (opts) {
decl.prop = 'font-size';

// Skip if value is not in px or rem
if (!new RegExp(/(\d*\.?\d+)(px|rem)/g).test(decl.value)) {
if (isNaN(decl.value) && !new RegExp(/(\d*\.?\d+)(px|rem)/g).test(decl.value)) {
return;
}

Expand Down
2 changes: 1 addition & 1 deletion sass/_rfs.sass
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ $rfs-breakpoint-unit: unit($rfs-breakpoint)
$rfs-suffix: if($important, " !important", "")

// If $fs isn't a number (like inherit) or $fs has a unit (not px or rem, like 1.5em) or $ is 0, just print the value
@if not $fs-unit or not $fs-unit != "" and $fs-unit != "px" and $fs-unit != "rem" or $fs == 0
@if not $fs-unit or $fs-unit != "" and $fs-unit != "px" and $fs-unit != "rem" or $fs == 0
font-size: #{$fs}#{$rfs-suffix}
@else
// Variables for storing static and fluid rescaling
Expand Down
2 changes: 1 addition & 1 deletion scss/_rfs.scss
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ $rfs-breakpoint-unit: unit($rfs-breakpoint);
$rfs-suffix: if($important, " !important", "");

// If $fs isn't a number (like inherit) or $fs has a unit (not px or rem, like 1.5em) or $ is 0, just print the value
@if not $fs-unit or not $fs-unit != "" and $fs-unit != "px" and $fs-unit != "rem" or $fs == 0 {
@if not $fs-unit or $fs-unit != "" and $fs-unit != "px" and $fs-unit != "rem" or $fs == 0 {
font-size: #{$fs}#{$rfs-suffix};
}
@else {
Expand Down
2 changes: 1 addition & 1 deletion stylus/rfs.styl
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ rfs($fs, $important = false)
$rfs-suffix = !important

// If $fs isn't a number (like inherit) or $fs has a unit (not px or rem, like 1.5em) or $ is 0, just print the value
if type-of($fs) != "unit" or (unit($fs) != "px" and unit($fs) != "rem") or $fs == 0
if type-of($fs) != "unit" or (unit($fs) != "" and unit($fs) != "px" and unit($fs) != "rem") or $fs == 0
font-size: "%s%s" % ($fs $rfs-suffix)
else
// Variables for storing static and fluid rescaling
Expand Down

0 comments on commit 35f9482

Please sign in to comment.