don't error out if no range is selected
This commit is contained in:
parent
c29390386f
commit
ab9c55689e
|
@ -35,8 +35,13 @@ Discourse.QuoteButtonController = Discourse.Controller.extend({
|
||||||
// don't display the "quote-reply" button if we can't create a post
|
// don't display the "quote-reply" button if we can't create a post
|
||||||
if (!this.get('controllers.topic.content.can_create_post')) return;
|
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
|
// retrieve the selected range
|
||||||
var range = window.getSelection().getRangeAt(0),
|
var range = selection.getRangeAt(0),
|
||||||
cloned = range.cloneRange(),
|
cloned = range.cloneRange(),
|
||||||
$ancestor = $(range.commonAncestorContainer);
|
$ancestor = $(range.commonAncestorContainer);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue