IsLength returns true if the token is a length.
()
| 114 | |
| 115 | // IsLength returns true if the token is a length. |
| 116 | func (t Token) IsLength() bool { |
| 117 | if t.TokenType == css.DimensionToken { |
| 118 | return true |
| 119 | } else if t.TokenType == css.NumberToken && t.Data[0] == '0' { |
| 120 | return true |
| 121 | } else if t.TokenType == css.FunctionToken { |
| 122 | fun := ToHash(t.Data[:len(t.Data)-1]) |
| 123 | if fun == Calc || fun == Min || fun == Max || fun == Clamp || fun == Attr || fun == Var || fun == Env { |
| 124 | return true |
| 125 | } |
| 126 | } |
| 127 | return false |
| 128 | } |
| 129 | |
| 130 | // IsLengthPercentage returns true if the token is a length or percentage token. |
| 131 | func (t Token) IsLengthPercentage() bool { |
no test coverage detected