Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[css-typed-om] "Create a CSSUnitValue from a string" invents its own CSS parsing #600

Closed
dbaron opened this issue Jan 29, 2018 · 3 comments

Comments

@dbaron
Copy link
Member

dbaron commented Jan 29, 2018

The definition of create a CSSUnitValue from a string says:

To create a CSSUnitValue from a string str, return a new CSSUnitValue object with its value internal slot set to the numeric portion of str parsed into a number, and its unit internal slot set to the unit portion of str, or "number" or "percent" if str is a plain number or percent.

This seems to be inventing its own CSS parsing, and does it in a rather vague way (for example, what's a "numeric portion" -- does it support scientific notation?). It seems like it would be better to depend on the way CSS already parses dimensions.

@tabatkins
Copy link
Member

That's solely an internal algorithm, used to make it much more convenient to create numeric values inline in an algorithm. (Currently only used in one place, but I expect it will see more use as we make more of them.)

@tabatkins
Copy link
Member

It might be worth making it more explicitly take two values, a number and a unit. Hm.

@nainar
Copy link
Contributor

nainar commented Jan 30, 2018

Yes, I think it would easier to have the following two ways of constructing CSSUnitValues:

  • double value, string unit
  • string value, string unit

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

No branches or pull requests

3 participants