Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

patch from @itsasbreuk to prevent an error when use it while not sele…

…ction is made. take 2
  • Loading branch information...
commit 583ab6aa2b5ab0f0819cf9a8b024c3b283ebe309 1 parent f8127f3
@caridy authored
Showing with 7 additions and 4 deletions.
  1. +7 −4 src/gallery-get-selection/js/get-selection.js
View
11 src/gallery-get-selection/js/get-selection.js
@@ -19,18 +19,21 @@
*/
Y.getSelection = function () {
var sel,
+ winsel,
frag;
if (Y.config.win.getSelection) {
- sel = Y.config.win.getSelection();
- sel = sel && sel.getRangeAt(0);
+ winsel = Y.config.win.getSelection();
+ if (winsel.rangeCount > 0) {
+ sel = winsel.getRangeAt(0);
+ }
} else if (Y.config.doc.selection) {
sel = Y.config.doc.selection.createRange();
}
- if (sel.cloneContents) {
+ if (sel && sel.cloneContents) {
frag = sel.cloneContents();
- } else if (sel.htmlText) {
+ } else if (sel && sel.htmlText) {
frag = Y.Node.create(sel.htmlText);
}
Please sign in to comment.
Something went wrong with that request. Please try again.