Re: [css-houdini-drafts] [css-typed-om] Will need to handle min()/max()

Ugh I don't like any of this.

Okay, so refresh.  There's not really any use-case for allowing authors to *change* the operator; I don't think there's a reasonable case for swapping from `calc(1 + 2 + 3)` to `calc(1 * 2 * 3)`, for example.

So, instead, I can have six classes, one for each operation: `CSSMathAdd`, `CSSMathMul`, `CSSMathNeg`, `CSSMathInv`, `CSSMathMin`, and `CSSMathMax`.  Add/mul/min/max take 1+ arguments, neg/inv take exactly one argument.  Structure is like:

```
interface CSSMathAdd {
  attribute CSSNumericList arguments;
  readonly attribute CSSMathOperator operator;
  readonly attribute DOMString type;
}
// or
interface CSSMathNeg {
  attribute CSSNumericValue argument;
  readonly attribute CSSMathOperator operator;
  readonly attribute DOMString type;
}
```

`operator` returns "+", "-", "*", "/", "min", or "max". It's redundant with the interface itself, but makes it easier to handle in general. (For example, you can drop it into a switch statement, which you can't do as easily with a type test.)

-- 
GitHub Notification of comment by tabatkins
Please view or discuss this issue at https://github.com/w3c/css-houdini-drafts/issues/359#issuecomment-297868881 using your GitHub account

Received on Thursday, 27 April 2017 23:43:13 UTC