←back to thread

197 points OuterVale | 1 comments | | HN request time: 0.223s | source
Show context
yread ◴[] No.46229304[source]
I don't understand the point about comments. Why shouldn't they be allowed? What object model?

>Comments shouldn't have been allowed basically everywhere in CSS (compare to HTML, which basically only allows them where content goes), because it makes them basically unrepresentable in the object model, which in turn makes building editing directly on top of the object model impossible

replies(5): >>46229365 #>>46229381 #>>46229430 #>>46229509 #>>46231920 #
1. DonHopkins ◴[] No.46231920[source]
Same reason why JSON prohibits comments: When you parse it, there is no place to represent the comments in the JavaScript object and array tree, so they must be thrown away, therefore it's impossible to write it out with the same comments in the same places.

Same thing with white space: JSON can not round trip white space or comments the way XML or HTML can, because XML and HTML DOM represents comments and white space explicitly.

Also you can't put comments inside elements like <div <--! comment --> class="foo">. There is no way to represent a comment inside an element in XML or HTML DOM.

But CSS lets you, so you can't round trip comments in CSS.