don't error out if no range is selected

This commit is contained in:
Sam 2013-04-10 17:49:25 +10:00
parent c29390386f
commit ab9c55689e

View file

@ -35,8 +35,13 @@ Discourse.QuoteButtonController = Discourse.Controller.extend({
// don't display the "quote-reply" button if we can't create a post
if (!this.get('controllers.topic.content.can_create_post')) return;
var selection = window.getSelection();
// no selections
if (selection.type !== "Range") return;
// retrieve the selected range
var range = window.getSelection().getRangeAt(0),
var range = selection.getRangeAt(0),
cloned = range.cloneRange(),
$ancestor = $(range.commonAncestorContainer);