@@ -136,6 +136,31 @@ public void setValue(CssExpression exp, ApplContext ac)
136136 val .toString (), "attr()" , ac );
137137 case COMMA :
138138 fallback_value = val ;
139+ // we should have a computed_type by then.
140+ // let's check the value.
141+ if (fallback_value .getType () != computed_type ) {
142+ // deal with percentage and numbers
143+ int fb_type = fallback_value .getType ();
144+ // only 0 can be something else than a plain number.
145+ if (fb_type == CssTypes .CSS_NUMBER ) {
146+ // TODO check if zero in CssCheckableValue
147+ if (true /*fallback_value.getCheckableValue().isZero()(*/ ) {
148+ break ;
149+ }
150+ }
151+ if (fb_type == CssTypes .CSS_PERCENTAGE ) {
152+ if ((computed_type == CssTypes .CSS_LENGTH ) ||
153+ (computed_type == CssTypes .CSS_ANGLE ) ||
154+ (computed_type == CssTypes .CSS_FREQUENCY ) ||
155+ (computed_type == CssTypes .CSS_NUMBER ) ||
156+ (computed_type == CssTypes .CSS_TIME )) {
157+ break ;
158+ }
159+ }
160+ // else, invalid type
161+ throw new InvalidParamException ("typevaluemismatch" ,
162+ fallback_value , value_type , ac );
163+ }
139164 break ;
140165 default :
141166 throw new InvalidParamException ("operator" ,
@@ -145,7 +170,6 @@ public void setValue(CssExpression exp, ApplContext ac)
145170 op = exp .getOperator ();
146171 exp .next ();
147172 }
148- // TODO do type checking between the fallback value and the type
149173 }
150174
151175 private int _checkType (CssIdent ident )
@@ -175,7 +199,7 @@ public String toString() {
175199 sb .append (' ' ).append (value_type );
176200 }
177201 if (fallback_value != null ) {
178- sb .append (" , " ).append (fallback_value );
202+ sb .append (", " ).append (fallback_value );
179203 }
180204 sb .append (')' );
181205 _ts = sb .toString ();
0 commit comments