- From: Axel D. <notifications@github.com>
- Date: Wed, 27 Feb 2019 04:18:54 -0800
- To: w3c/selection-api <selection-api@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
- Message-ID: <w3c/selection-api/issues/102@github.com>
Add function prototypes for recalculating `anchorNode`/`anchorOffset` and `focusNode`/`focusOffset` based on a given anchestor node. That functionality is necessary to track and regain a selection in an editing host when DOM manipulation takes place. <hr/> ### Suggested IDL Interfaces ```js partial interface Selection { Range getRangeAt(unsigned long index, Element contextElement); }; partial interface Window { [Throws] Selection? getSelection(Element contextElement); }; ``` <hr/> ### Details ### 1. ```js const selObj = window.getSelection(contextElement: HTMLElement); ``` Should yield: ```js selObj.anchorNode === selObj.focusNode === contextElement; selObj.anchorOffset = AnchorCharacterOffsetFromContextElement(contextElement); selObj.focusOffset = FocusCharacterOffsetFromContextElement(contextElement); ``` <br/> ### 2. ```js const rngObj = window.getSelection().getRangeAt(index: number, contextElement: HTMLElement); ``` Should yield: ```js rngObj.commonAncestorContainer === rngObj.startContainer === rngObj.endContainer === contextElement; rngObj.startOffset = AnchorCharacterOffsetFromContextElement(contextElement); rngObj.endOffset = FocusCharacterOffsetFromContextElement(contextElement); ``` <hr/> Both suggested functions are supposed to either throw an `ReferenceError` or yield `void 0` when `contextElement` is not an anchestor of both, `selObj.anchorNode`/`selObj.focusNode` and `rngObj.startOffset`/`rngObj.endOffset`, resp. -- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/w3c/selection-api/issues/102
Received on Wednesday, 27 February 2019 12:19:15 UTC