| 3458 | } |
| 3459 | |
| 3460 | operate(env, op, other) { |
| 3461 | if (this.unit === '%' && other.unit !== '%') { |
| 3462 | env.error({ |
| 3463 | message: 'If two operands differ, the first must not be %', |
| 3464 | index: this.index |
| 3465 | }); |
| 3466 | return { |
| 3467 | is: 'undefined', |
| 3468 | value: 'undefined' |
| 3469 | }; |
| 3470 | } |
| 3471 | |
| 3472 | if (this.unit !== '%' && other.unit === '%') { |
| 3473 | if (op === '*' || op === '/' || op === '%') { |
| 3474 | env.error({ |
| 3475 | message: 'Percent values can only be added or subtracted from other values', |
| 3476 | index: this.index |
| 3477 | }); |
| 3478 | return { |
| 3479 | is: 'undefined', |
| 3480 | value: 'undefined' |
| 3481 | }; |
| 3482 | } |
| 3483 | |
| 3484 | return new CartoCSS.Tree.Dimension(CartoCSS.Tree.operate(op, |
| 3485 | this.value, this.value * other.value * 0.01), |
| 3486 | this.unit); |
| 3487 | } |
| 3488 | |
| 3489 | //here the operands are either the same (% or undefined or px), or one is undefined and the other is px |
| 3490 | return new CartoCSS.Tree.Dimension(CartoCSS.Tree.operate(op, this.value, other.value), |
| 3491 | this.unit || other.unit); |
| 3492 | } |
| 3493 | }; |
| 3494 | |
| 3495 | CartoCSS.Tree.Element = class Element { |