Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[macOS/Safari] Test "EditorView selection / syncs the DOM selection with the editor selection" #88

Closed
FrankReh opened this issue Mar 16, 2019 · 3 comments

Comments

@FrankReh
Copy link

Issue might be better labeled, inconsistent return of getSelection().

Here is an old w3c/editing task force issue that seems to be indicating the same thing: w3c/editing#156

In the CM6 unit test in question, the call to window.getSelection() returns the text node rather than the div node. The test passes for Chrome and Firefox on my macOS system.

The unit test actually tests seven different selections and by commenting out the rest so just one at a time is tried, one can see four are returning the text node itself rather than the expected text node's parent. Those four are shown with an extra arrow comment here.

test(0, abc.parentNode, 0); // <-- fails Safari
test(1, abc, 1);
test(2, abc, 2);
test(3, abc.parentNode, 1); // <-- fails Safari
test(4, cm.contentDOM.childNodes[1], 0);
test(5, def.parentNode, 0); // <-- fails Safari
test(6, def, 1);
test(8, def.parentNode, 1); // <-- fails Safari

In fact, if window.getSelection() is called immediately after the test's requireFocus() call to setup things, the difference can also be seen.

@marijnh
Copy link
Member

marijnh commented Mar 17, 2019

I'd say I wrote the test in a too restrictive way and it should use something similar to isEquivalentPosition in view/src/dom.js to test this.

@marijnh
Copy link
Member

marijnh commented Mar 17, 2019

Does attached patch make the test pass?

@FrankReh
Copy link
Author

Yes it does. Nice.

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

No branches or pull requests

2 participants