Thread:Talk:VisualEditor/Software design/Linear model and not DOM?/reply

The editor uses the linear model internally because it's easier to define transactions on. We could've gotten away with using a DOM model or a DOM-like tree instead, but that would have made a future collaborative editing feature a lot harder to implement. It so happens we do actually use a tree, built from the linear model, for some purposes (including rendering and traversal) because it makes more sense to use a tree for those applications.

We also can't use the input DOM directly because it doesn't have a 1:1 mapping to our conceptual nodes, so there has to be some internal data structure that is different from the input DOM, be it a linear model, a tree, or something else. The points where the 1:1 mapping breaks down are mostly "alien nodes" (things we don't understand and render as an uneditable box; in the DOM, these are usually subtrees or sets of adjacent subtrees rather than a single node) and "meta nodes" (things like categories and magic words; these are  tags in the DOM, not present in the editor, but still need to be restored in the right place on output).