FIX: No JIT when quoting a mention (PR #12835)

GitHub

if I read this correctly you want to check element and element.parentElement right?

I think a more readable solution would be:

[element, element.parentElement].forEach(e => {
  // code
});

I think the for loop here go back up the whole tree. Not just one parent :wink:

yes indeed, hmmm well then ok :man_shrugging:

Such loops implemented with for can be confusing. I have this version with while more self explainable:

  _isInQuote(element) {
    let parent = element.parentElement;
    while (parent && !this._isPreviewRoot(parent)) {
      if (this._isQuote(parent)) {
        return true;
      }

      parent = parent.parentElement;
    }

    return false;
  },

  _isPreviewRoot(element) {
    return (
      element.tagName === "DIV" &&
      element.classList.contains("d-editor-preview")
    );
  },

  _isQuote(element) {
    return element.tagName === "ASIDE" && element.classList.contains("quote");
  },