Re: [csswg-drafts] [cssom] Serialization of CSS declaration block returned from getComputedStyle

> however, shorthand serialization algorithms are usually written to handle declaration block of specified values.

Omit the shorthands like Chrome does, then. I'm asking for a _meaningful_ serialization, and not necessarily one with shorthands. IMHO a gCS serialization with only longhands may make more sense than one with shorthands, given the nature of the potential use cases.

> However, many properties are required to serialize differently for gCS, and the "uncompute" mechanism may not exactly match that requirement, so reusing it can potentially further complicate things.

But you already implement ```getProperyValue```. All that you need is to add it to a buffer. Does not sound overly complex.

> From the use case side, I'd argue that getting a serialization of a declaration block containing every property with shorthand serialized properly is hardly the ideal way for anything.

Agreed.

> If you just want to persist and restore all values, you should just iterate all properties in that block, that would almost certainly be faster than relying on browser to generate the serialization of the huge declaration block, then parsing this huge serialization again

Persist and restore is just one use case. The fact that doing it that way can be inefficient does not mean that gCS serializations are useless.

> Also, shorthand serialization are usually for human readability, but would anyone want to read a declaration block serialization containing hundreds of properties?

My serializations do not (generally) contain hundreds of properties. I do not include properties that take their initial values due to defaulting (and the count of properties that are cascaded or inherited is what I return in ```getLength()```, and not the total amount of properties known to my library).

> Given that this needs probably non-trivial extra work on implementations, while it doesn't seem to be very useful, we should probably just make it as simple as possible so that implementations can be interoperable on the behavior.

On UAs, that serialization is IMHO useful for debugging purposes, and for CSS tools (like mine) it can have other uses (although I do know that the WG is not very concerned about non-UA use cases).

I have use cases about putting the serialization in the ```style``` attribute of a DOM document and passing it to a rendering library that does not know how to compute styles, but can retrieve them from the attributes. It can also be useful to write tools that monitor changes in the styling of the elements in the DOM tree of a web page.

That is, on UAs gCS serialization can be useful, and on other type of implementations it **is** definitely useful.

And to me, "make it as simple as possible" means the Chrome behaviour (but I do not know whether it serializes all the properties or only the cascaded-or-inherited, as I mentioned).

-- 
GitHub Notification of comment by carlosame
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/1033#issuecomment-386222578 using your GitHub account

Received on Thursday, 3 May 2018 08:19:45 UTC