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

WIP – Cleanup & coverage #629

Merged
merged 15 commits into from May 26, 2015
Merged

WIP – Cleanup & coverage #629

merged 15 commits into from May 26, 2015

Conversation

j0k3r
Copy link
Contributor

@j0k3r j0k3r commented May 23, 2015

No description provided.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.33%) to 95.27% when pulling 84ebe09 on cleanup-coverage into 998f71d on master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.67%) to 95.52% when pulling 4c52d48 on cleanup-coverage into 149dde7 on master.

@daviferreira
Copy link
Member

👌

@coveralls
Copy link

Coverage Status

Coverage increased (+0.87%) to 95.72% when pulling 6d58fbb on cleanup-coverage into 149dde7 on master.

@j0k3r
Copy link
Contributor Author

j0k3r commented May 24, 2015

I didn't find a way to test these lines:

// Selection encompasses a single element
if (this.rangeSelectsSingleNode(range) && range.startContainer.childNodes[range.startOffset].nodeType !== 3) {
    return range.startContainer.childNodes[range.startOffset];
}

If anyone got an idea.
I've played with range but didn't find one that match that case.. http://jsfiddle.net/tkatq6Lt/

From https://technet.microsoft.com/fr-fr/ff974693?f=255&MSPPError=-2147217396

About rangeCount: This property always returns a 1 with a valid selection. [...] Calling isCollapsed is recommended to detect an empty range.
If a selection is empty, isCollapsed will return true.
@coveralls
Copy link

Coverage Status

Coverage increased (+0.88%) to 95.73% when pulling 264b664 on cleanup-coverage into 149dde7 on master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.8%) to 95.65% when pulling 9cbbe84 on cleanup-coverage into 149dde7 on master.

j0k3r added 3 commits May 25, 2015 17:22
Thanks to Firefox that shuffle arguments and force me to use `toContains` instead
@coveralls
Copy link

Coverage Status

Coverage remained the same at 95.65% when pulling a5c11c9 on cleanup-coverage into ab697a8 on master.

return selection.getRangeAt(0);
this.deprecated('Util.getSelectionRange', 'Selection.getSelectionRange', 'v5.0.0');

return Selection.getSelectionRange(ownerDocument);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might be a bit dangerous, I believe Util will be defined before Selection...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, are you sure? The demo still works great on my Mac and tests seems to be ok with that. Maybe you can give a try on your own to validate there is no such case.

I really prefer to move these functions in Selection.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, they definitely belong in Selection. I don't believe this code will actually fail, since these functions can't be called until all of the js has loaded.

What I was pointing out though, if you look at the Gruntfile, we are including the JS files in this order:

srcFiles = [
  'src/js/util.js',
  'src/js/defaults/buttons.js',
  'src/js/defaults/options.js',
  'src/js/extension.js',
  ...
]

So we'll be calling into Selection from inside Util, even though Util is defined before Selection. Just something we'll want to remember.

@nmielnik
Copy link
Member

These changes are outstanding, thanks a ton @j0k3r!

Regarding the lines you weren't able to cover, I'm not really sure what they are for either, did you ever figure that out?

@daviferreira
Copy link
Member

Just remove and wait for someone to open an issue? 💣

@j0k3r
Copy link
Contributor Author

j0k3r commented May 26, 2015

@daviferreira I still prefer to let the code like that instead of removing it and wait for an issue 😱

@nmielnik this code is related to retrieve the selected element / content. I guess this is a copy/paste from SO. But I didn't find a case (while playing with jsfiddle) to trigger it ..

nmielnik added a commit that referenced this pull request May 26, 2015
@nmielnik nmielnik merged commit dc27140 into master May 26, 2015
@nmielnik nmielnik deleted the cleanup-coverage branch May 27, 2015 05:18
nysk pushed a commit to nysk/medium-editor that referenced this pull request Aug 10, 2015
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.

None yet

4 participants