Add functions to manage math items within a given container. (#351) #502
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds API calls to allow managing of math items with container elements in the DOM. For example, if you are updating a portion of the DOM (by setting its
innerHTML
for example) and typeset math is removed, you want to be able to remove the associated MathItems from the list of MathItems held in the MathDocument. Previously there was no API for that.There two new main calls added to the base MathDocument class:
clearMathItemsWithin()
andgetMathItemsWithin()
. Both take a container element; the first removes the MathItems from the MathList that are found within the container, and the second returns an array of MathItems found within the container.There is also a new LinkedList method,
remove()
for removing an item from the list.Finally, there is a new DOMAdaptor method (
contains()
) to determine if an element is contained in another element.This PR also fixes a bug in the liteAdaptor's
replace()
call where the parent elements weren't being set for the new nodes being inserted into the LiteDOM.Resolves issue #351.