Skip to content

Commit

Permalink
patch from @ItsAsbreuk to prevent an error when use it while not sele…
Browse files Browse the repository at this point in the history
…ction is made. take 2
  • Loading branch information
caridy committed Oct 16, 2012
1 parent f8127f3 commit 583ab6a
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/gallery-get-selection/js/get-selection.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down

0 comments on commit 583ab6a

Please sign in to comment.