Details
-
Improvement
-
Resolution: Fixed
-
Minor
-
1.9 RC1
-
None
-
Unit
-
Unknown
-
Description
The problem with the current implementation is that you cannot write:
for (LinkBlock block : xdom.getChildrenByType(LinkBlock.class, true))
Unknown macro: { Block newBlock = new FormatBlock(Collections.<Block>singletonList(block), Format.ITALIC); block.replace(newBlock); }This fails because when the "block" is added in FormatBlock, its parent is set to be the FormatBlock and thus when block.replace() executes the parent of the new block is set to be the format block instead of its parent.
I thus propose an API that is inline with the w3c DOM API:
/**
- Replaces an existing children block with the passed new block.
- Also sets the new block's parent to be the current block.
*- @param newBlock the new block to replace the old block with
*/
void replaceChild(Block newBlock, Block oldBlock);/**
- Replaces an existing children block with the passed new blocks.
- Also sets the new block's parents to be the current block.
*- @param newBlocks the new blocks to replace the old block with
*/
void replaceChild(List<Block> newBlocks, Block oldBlock);