guard against a few possible typeErrors

pull/1/head
ansuz 2020-06-25 14:38:21 -04:00
parent 6a8ab6bc55
commit d5d30c2e09
1 changed files with 4 additions and 1 deletions

View File

@ -56,7 +56,10 @@
path = path || editor.elementPath();
sel = sel || editor.getSelection();
var applicable = removeStyle.checkApplicable(path, editor);
var hasComments = editor.getSelectedHtml().$.querySelectorAll('comment').length;
var selectedHtml = editor.getSelectedHtml();
if (selectedHtml === null) { return; }
var comments = selectedHtml.$.querySelectorAll('comment');
var hasComments = comments && comments.length;
var isComment = removeStyle.checkActive(path, editor);
var empty = !sel.getSelectedText();
return applicable && !empty && !hasComments && !isComment;