Skip to content

Conversation

@ewilligers
Copy link
Contributor

We no longer rely on 'eval'. Instead, we parse the calc expression
and compute the value.

We take advantage of the requirement that + and - operators must
be surrounded by whitespace. This lets us detect each of the five tokens
in -1.23e+45 + -1.23e+45 - -1.23e+45 using a simple regular expression.

Spec:
https://www.w3.org/TR/css3-values/#calc-syntax

This adds 449 bytes to web-animations-next-lite.min.js

resolves #74

This was referenced Jul 18, 2017
@ewilligers ewilligers force-pushed the process-calc-expression branch from ee288bd to 65721b0 Compare July 18, 2017 21:25
@alancutter
Copy link
Contributor

Nice! Though unfortunately this fails one of the calc unit tests.

We no longer rely on 'eval'. Instead, we parse the calc expression
and compute the value.

We take advantage of the requirement that + and - operators must
be surrounded by whitespace. This lets us detect each of the five tokens
in -1.23e+45 + -1.23e+45 - -1.23e+45 using a simple regular expression.

Spec:
https://www.w3.org/TR/css3-values/#calc-syntax

resolves web-animations#74
@ewilligers ewilligers force-pushed the process-calc-expression branch from 65721b0 to a081deb Compare July 19, 2017 05:58
@ewilligers
Copy link
Contributor Author

ewilligers commented Jul 19, 2017

Nice! Though unfortunately this fails one of the calc unit tests.

That is a new unit test that uses scientific notation. I have updated typeCheck's regular expression to allow scientific notation.

@darrnshn
Copy link
Contributor

lgtm!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

use of eval() in dimension-handler.js requires undesirable CSP script-src 'unsafe-eval'

4 participants