scala-js/scala-js-dom

Parsing rule is too strict for HTML color representations

mysticfall opened this issue · 4 comments

Currently, regular expressions used by the Color class is too strict and it causes an MatchError when it tries to parse such strings:

  • " #ff1234"
  • " #1234aa "
  • " #ffff"
  • "rgb(123,234,452)"
  • "rgb(123, 234, 452 )"

It would be better if it at least allows arbitary number of spaces/tabs/line breaks between significant numbers.

I don't mind making it work; if you want to send a PR, we should take a bit of time and crib from something like this to make sure it works properly forever =)

Thanks for the suggestion, but I'm afraid I'm too preoccupied at the moment with my own projects to be able to spend much time with it.

But if you don't mind, I could create a PR just dealing with such a case like not allowing 'rgb(123,234,452)'.

@mysticfall still interested to PR this? Would be much appreciated!!

sjrd commented

Color is going away for 2.x in #458, so I don't think this is worth giving at this point.