}
}
- while ($current !== null && $current !== this.$editor[0]) {
+ while ($current && $current !== this.$editor[0]) {
if ($current.nodeType === Node.ELEMENT_NODE) {
if ($current.tagName === 'BLOCKQUOTE' || ($current.tagName === 'DIV' && /\bcodeBox\b/.test($current.className))) {
var $offset = $($current).offset();
if (getSelection().getRangeAt(0).collapsed) {
var $startContainer = getSelection().getRangeAt(0).startContainer;
- if ($startContainer.nodeType === Node.TEXT_NODE && $startContainer.textContent === '\u200b' && $startContainer.parentElement.tagName === 'P' && $startContainer.parentElement.parentElement === this.$editor[0]) {
+ if ($startContainer.nodeType === Node.TEXT_NODE && $startContainer.textContent === '\u200b' && $startContainer.parentElement && $startContainer.parentElement.tagName === 'P' && $startContainer.parentElement.parentElement === this.$editor[0]) {
// caret position is fine
return;
}