Hacker News new | ask | show | jobs
by Retr0id 832 days ago
Sure, but why do you want order to be preserved? The spec never says the order of nodes is pertinent. Is there undocumented z-index behavior?
3 comments

Sometimes you have nodes that overlap each other, so you want to control whether or not a node is in front of or behind another node.

Though yes, they could have explicitly defined a z-index or defined a convention on how the ordering should work (first nodes top and last nodes bottom or vice versa?). It's interesting to think about the trade offs between explicitly defining these things vs. leaving the application to implicitly make the choice. JSON Canvas seems to be designed to use in tandem with markdown files in a note taking app, so it makes sense why they opted for the more implicit design to be similar to markdown

Looking at their reference impl, it does seem that array index implies z-index, in which case fair enough, I suppose an array does make the most sense - they should probably document the z-indexing though!
This clarification has been added to the spec:

> Nodes are placed in the array in ascending order by z-index. The first node in the array should be displayed below all other nodes, and the last node in the array should be displayed on top of all other nodes.