Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Error when cursor places next to video embed #644

Closed
benbro opened this issue May 4, 2016 · 2 comments
Closed

Error when cursor places next to video embed #644

benbro opened this issue May 4, 2016 · 2 comments

Comments

@benbro
Copy link
Contributor

benbro commented May 4, 2016

When I focus the editor in the beta-0 example I'm getting an error:
http://beta.quilljs.com/

TypeError: Argument 1 of Node.contains does not implement interface Node.
return parent.contains(descendant);
quill.js (line 5184, col 11)

Tested with Firefox 46.0.1 on Windows 7.

@jhchen jhchen changed the title Node.contains does not implement interface Node error in beta-0 example Error when cursor places next to video embed May 10, 2016
@jhchen jhchen closed this as completed in a9153dc May 10, 2016
@earshinov
Copy link

earshinov commented Jan 29, 2019

@jhchen , Please, please, please change this

function contains(parent, descendant) {
  try {
    // Firefox inserts inaccessible nodes around video elements
    descendant.parentNode;
  } catch (e) {
    return false;
  }
  // IE11 has bug with Text nodes
  // https://connect.microsoft.com/IE/feedback/details/780874/node-contains-is-incorrect
  if (descendant instanceof Text) {
    descendant = descendant.parentNode;
  }
  return parent.contains(descendant);
}

into

function contains(parent, descendant) {
  try {
    // IE11 has bug with Text nodes
    // https://connect.microsoft.com/IE/feedback/details/780874/node-contains-is-incorrect
    if (descendant instanceof Text) {
      descendant = descendant.parentNode;
    }
    return parent.contains(descendant);
  } catch (e) {
    // Firefox inserts inaccessible nodes around video elements
    return false;
  }
}

A try..catch block containing nothing but e.parentNode gets optimized away by Angular compiler:

function g(t,e){return e instanceof Text&&(e=e.parentNode),t.contains(e)}

As a result, we still get the error from the issue description.

@earshinov
Copy link

Ah, nevermind. It is a known issue of the Angular compiler: angular/angular-cli#11439

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

3 participants