Provide method for filtering toolbox XML #461
Merged
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.
Resolves
For scratchfoundation/scratch-gui#16
Proposed Changes
Provides a method to transform Blockly toolbox XML to only contain blocks which the VM can handle. It does this by removing any blocks in the toolbox for which it does not have a registered opcode.
Reason for Changes
We need this method so that we can strip a given toolbox to only the blocks that the VM is capable of running. This is a temporary solution until we have a way to generate the toolbox based on the editing target.
Test Coverage
I would like to include tests, but I didn't want to require
jsdom
or a similar DOM-simulating library just for this one hacky method... Any suggestions for a lighter DOM-mocking method would be appreciated!I considered the possibility that the fact that I would need to include a library to test this may indicate that I'm putting this method in the wrong place. However, given the other parts of the VM that interact with Blockly, this seems like the right place for now.