desmosinc / mathquill

Magic textboxes where you can type math as easily as writing!
mathquill.com
137 stars 42 forks source link

Avoid storing DOMFragment #223

Closed jwmerrill closed 2 years ago

jwmerrill commented 2 years ago

A DOMFragment can be invalidated if one of its ends is moved to no longer be a sibling of its other end. In practice, we see this when one end of (the children of) a math block is selected (which wraps it in a selection span) and the other end is not selected.

Make it clearer that we are not working with invalidated DOMFragments by not storing them. Instead, store direct references to DOM nodes and construct DOMFragments in the .domFrag() getters.

This doesn't make the selection problem impossible, but it does mean we'll notice it immediately in the validation of the DOMFragment constructor, instead of possibly operating on a DOMFragment that was valid when it was created but has become invalid.