Why was the CSS function clamp written into an Sass unquote function?


In a project I took over, the style was written with SCSS. At one point I wonder why the CSS clamp() function was written with an unquote. If I remove unquote there is no difference.

div {
  font-size:unquote("clamp(30px, 10px + 2%, 30px)");

And without unquote

div {
  font-size:clamp(30px, 10px + 2%, 30px);


Why did you put the clamp function into an unquote function again? If it works without!


Well there are many theories…

Just kidding, this is what the documentation says:

You can convert a quoted string to an unquoted string using the string.unquote() function, and you can convert an unquoted string to a quoted string using the string.quote() function.

So this means that the unquote function is basically useless, because the only thing it does is unquoting "clamp(30px, 10px + 2%, 30px)" which will result in clamp(30px, 10px + 2%, 30px) which is the exact same.

A reason someone can do this, is for bug reasons, if there is a bug in sass itself (the clamp function only works with unquote), so maybe that is the reason why the programmer has added this.

The probability of this specific bug is offcourse very low, but it is just a theory…

Hope this answers your question


Answered By – Emiel VdV

Answer Checked By – Pedro (AngularFixing Volunteer)

Leave a Reply

Your email address will not be published.