- From: François REMY via GitHub <sysbot+gh@w3.org>
- Date: Mon, 23 May 2016 17:20:28 +0000
- To: public-houdini-archive@w3.org
My issue with this is that it makes the whole API rather useless. If
you receive unparsed strings back when you parse some values, then
ultimately it means you will need to come up with your own parser to
deal with those, like you have to do for every style today already. If
I have to ship my own parser to handle certain values, this entire
API is not really useful anymore: why not handle all values through my
own parser in this case?
I really think we should do better. I would be okay with something
intermediate that only supports the following things:
- values are at least broken apart by AST roots: ```5px url(...)
center``` would become three values featuring their own cssText:
```5px```, ```url(...)``` and ```center```. We can do this without
loss of generality based on whitespace and block processing in
css-syntax.
- values like numbers and numbers+units get parsed properly based on
their unit if it is known, as {value:number,unit:string} if not, and
we make the promise css will never overload this class of values,
which I think makes sense going forward
- blocks and functions can be introspected (blocks as ```{
openingChar, content:CSSValue[], closingChar }``` and functions as
```{ functionName, arguments:CSSValue[] }```), content is parsed the
same way as described here
Everything else remains a dummy value that can only be analyzed
through cssText. That would be sufficient to solve the efficiency
problem when you need to update the numeric value of something and
needs to resort to string manipulation to do so now. As far as I know
is the aim of this api.
Now, if things need to go further, because things have been broken
apart, authors can decide to subparse the various cssText blocks based
on additional knowledge, like "#f00" or "red" to colors by using
CSSValue.parse("color",...) but they are not forced to if what they
wanted to change was the background-position part of the background
(which uses a variable).
--
GitHub Notification of comment by FremyCompany
Please view or discuss this issue at
https://github.com/w3c/css-houdini-drafts/issues/193#issuecomment-221036514
using your GitHub account
Received on Monday, 23 May 2016 17:20:31 UTC