Skip to content

Preserve Range ownership for detached nodes - #869

Merged
wieslawsoltes merged 1 commit into
mainfrom
fix/range-detached-owner-863
Sep 20, 2026
Merged

wieslawsoltes merged 1 commit into
mainfrom
fix/range-detached-owner-863

Conversation

@wieslawsoltes

Copy link
Copy Markdown
Collaborator

Problem

The first #863 fix made Document.createRange() honor the receiver document, but unchanged Code OSS still raised WrongDocumentError from Monaco's _detachRange(). Monaco's _textRangeRestingSpot is created with document.createElement('div') and deliberately never connected, while WebScene used ancestor connectivity as document ownership.

Change

  • retain the creating Document root for nodes produced by Document factories and imported/contextual fragments;
  • validate Range endpoints using retained document identity as well as live ancestry;
  • return the correct ownerDocument for detached nodes created by detached documents and iframe documents;
  • discard ownership records with detached-subtree collection and navigation teardown;
  • extend the Keep Range endpoints owned by the creating document during Monaco layout #863 native regression with Monaco's exact never-connected resting-node sequence and a detached cross-document rejection.

No style, layout, scene publication, timer, or VS Code source behavior is changed.

Focused validation

Release native target built successfully with the current V8 configuration.

WEBSCENE_NATIVE_ENGINE_TEST_FILTER=range-document-owner webscene_native_engine_tests
Range document-owner reuse gate: cycles=10000 durationMs=2.94804096221924

Closes #863.

@wieslawsoltes
wieslawsoltes merged commit c356c5a into main Sep 20, 2026
1 of 7 checks passed
@wieslawsoltes
wieslawsoltes deleted the fix/range-detached-owner-863 branch September 20, 2026 17:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Keep Range endpoints owned by the creating document during Monaco layout

1 participant