Skip to content
This repository has been archived by the owner on Jun 15, 2021. It is now read-only.

Commit

Permalink
Sanity-check scribe.el.lastChild
Browse files Browse the repository at this point in the history
  • Loading branch information
danburzo committed Jul 22, 2016
1 parent 6f06947 commit 7af4b81
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/plugins/core/inline-elements-mode.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ define(['../../node'], function (nodeHelpers) {
* We have to do this because otherwise the browser will believe
* there is content to the right of the selection.
*/
if (scribe.el.lastChild.nodeName === 'BR') {
if (scribe.el.lastChild && scribe.el.lastChild.nodeName === 'BR') {
scribe.el.removeChild(scribe.el.lastChild);
}

Expand Down Expand Up @@ -86,7 +86,9 @@ define(['../../node'], function (nodeHelpers) {
*/

var contentToEndRange = range.cloneRange();
contentToEndRange.setEndAfter(scribe.el.lastChild);
if (scribe.el.lastChild) {
contentToEndRange.setEndAfter(scribe.el.lastChild);
}

// Get the content from the range to the end of the heading
var contentToEndFragment = contentToEndRange.cloneContents();
Expand Down

0 comments on commit 7af4b81

Please sign in to comment.