Support CloneIndependentRoot feature#3170
Merged
Merged
Conversation
JiuqingSong
requested review from
BryanValverdeU,
Copilot,
flyingbee2012,
ianeli1,
juliaroldi and
vinguyen12
October 2, 2025 21:11
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR introduces the CloneIndependentRoot experimental feature to prevent network requests when cloning DOM elements during HTML export. When enabled, the feature creates an independent HTML document context for cloned elements, avoiding browser behavior that would trigger image downloads when setting src attributes.
Key changes:
- Added
CloneIndependentRootexperimental feature flag - Modified DOM cloning logic to use independent document when feature is enabled
- Added comprehensive test coverage for the new cloning behavior
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| packages/roosterjs-content-model-types/lib/editor/ExperimentalFeature.ts | Added CloneIndependentRoot feature flag definition |
| packages/roosterjs-content-model-core/lib/editor/core/DOMHelperImpl.ts | Implemented independent document cloning logic and updated constructor |
| packages/roosterjs-content-model-core/lib/editor/core/createEditorCore.ts | Integrated feature flag with DOMHelper creation |
| packages/roosterjs-content-model-core/test/editor/core/DOMHelperImplTest.ts | Added test coverage for independent root cloning |
| demo/scripts/controlsV2/sidePane/editorOptions/ExperimentalFeatures.tsx | Added UI control for the new feature |
| demo/scripts/controlsV2/sidePane/editorOptions/EditorOptionsPlugin.ts | Enabled feature in demo configuration |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
juliaroldi
approved these changes
Oct 2, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Today when we extract HTML from editor using ExportHTMLFast feature, we first clone a DOM tree, then pass it to plugins to do clean up. However, if plugin wants to set src of image, it will trigger an image downloading service call. This is a browser behavior.
In this change, I create a new experimental feature
CloneIndependentRoot, when set, we will create an independent HTML document usingdocument.implementation.createHTMLDocument(), then callimportNode()to clone the DOM tree, this makes the cloned tree to be under this independent document context, so setting src of IMG won't really download it.