Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

NS_ERROR_FAILURE in Firefox for every keystroke in Custom Element #1000

Closed
csuwildcat opened this issue Mar 5, 2016 · 6 comments
Closed

Comments

@csuwildcat
Copy link

I have wrapped Medium Editor in a generic Web Component Custom Element (<x-medium-editor> is the node the editor is instantiated on) which somehow causes Firefox to throw an error every time the user enters text. When pressing enter, the entire outerHTML is duplicated resulting in a copy of the editor element itself. Here's the code point flagged in dev tools:

if (MediumEditor.util.isMediumEditorElement(node) && node.children.length === 0) {
  this.options.ownerDocument.execCommand('formatBlock', false, 'p');
} 
@nmielnik
Copy link
Member

nmielnik commented Mar 8, 2016

First @csuwildcat congrats on owning issue #1000 .

So, I've run into this issue quite a few times with firefox. Generally, when I've gotten the dubious NS_ERROR_FAILURE when calling execCommand() it has been when focus and/or selection has not been set properly. Basically, trying to call document.execCommand() if the focus/selection is not properly set within a contenteditable element in firefox often gives this error.

If you were able to narrow it down to this line, could you debug and just call document.getSelection() to make sure the selection and focus is within the right element?

@NickBlow
Copy link

NickBlow commented Apr 4, 2016

I have the same issue - I called document.getSelection() and the focus was definitely in the right element.

The error occured for me when I pressed return (shift + return was fine).

The lines of code that caused the error for me were as below, but it was browserified and uglified so it's a bit hard to pin down:

this.relativeContainer.appendChild(this.getToolbarElement()):this.getEditorOption("elementsContainer").appendChild(this.getToolbarElement());

@nmielnik
Copy link
Member

This may have been a duplicate of #994 , and thus could have been fixed by #1052 (and available starting with version 5.16.1 of medium-editor)

@NickBlow or @csuwildcat could you test out the newest version of medium-editor and see if this issue has been resolved for you?

@josefromsanjose
Copy link

I get this issue when using the editor with Angular. Error happens only when using the ordered list and unordered list buttons side the function function execActionInternal(action, opts) {}. Does anyone have a solution for this, specifically with Angular. The error does not happen without the framework.

@mrsweaters
Copy link

I'm experiencing this issue with medium-editor 5.23.2 and Angular 1.6.6.

@mrsweaters
Copy link

Ah okay, so it appears that my issue is that my editor is on a div but is not being recognized as a block level element by the editor:

blockContainerElementNames: [

Is there a reason, why div is not in this list?

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

No branches or pull requests

6 participants