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

Chrome and Firefox isusses with range #64

Open
Themonkey180 opened this issue Jul 3, 2014 · 6 comments
Open

Chrome and Firefox isusses with range #64

Themonkey180 opened this issue Jul 3, 2014 · 6 comments

Comments

@Themonkey180
Copy link

I went to update to v0.4.11 and v0.4.12 and have reserved three errors. Two of them are fatal errors in Firefox and one in chrome.

Here is how I am initializing the wysiwyg.

$(document).ready(function () {
    var editor = new wysihtml5.Editor("id", { // id of textarea element
    toolbar: "wysihtml5-toolbarid", // id of toolbar element
    parserRules: wysihtml5ParserRules, // defined in parser rules set 
    name: 'form-control',
    style: true,
    useLineBreaks: true
});

The first two errors are in Firefox. Is there something I need to set up or is there a fix?

TypeError: sel.nativeSelection is null
sel._ranges.length = sel.rangeCount = sel.nativeSelection.rangeCount;
wysiht...3409491 (line 3453)

NS_ERROR_FAILURE:
that.doc.execCommand("enableObjectResizing", false, "false");
wysiht...3409491 (line 12547)

The last error is in Google Chrome which only happens when you refresh the page.

The given range and the current selection belong to two different document fragments. wysihtml5x-toolbar.js?v=635399841143409491:2982
(anonymous function) wysihtml5x-toolbar.js?v=635399841143409491:2982
(anonymous function) wysihtml5x-toolbar.js?v=635399841143409491:3017
(anonymous function) wysihtml5x-toolbar.js?v=635399841143409491:411
Module.init wysihtml5x-toolbar.js?v=635399841143409491:383
init wysihtml5x-toolbar.js?v=635399841143409491:311
loadHandler wysihtml5x-toolbar.js?v=635399841143409491:469

Thanks or the help.

@kasoban
Copy link

kasoban commented Jul 7, 2014

Are you sure this is related to the upgrade to 0.4.12? I encountered a very similar problem before which was related to the rangy core module. I can not find the issue/pull request where I fetched this solution from, but look for the line

sel._ranges.length = sel.rangeCount = sel.nativeSelection.rangeCount;

and change it to

sel._ranges.length = sel.rangeCount = (sel.nativeSelection ? sel.nativeSelection.rangeCount : 0);

This fixed my firefox issues.

Edit: Now I remember where I've seen this before. You already had that same error before and reported it here: #32

It just looks different at first because you used the minified version at the time.

@Themonkey180
Copy link
Author

Thank you for that fixes. It fixed the Firefox issues which were the biggest issue, but I still have the one in chrome to fix.

@bhaak
Copy link

bhaak commented Jul 28, 2014

The nativeSelection issue seems to be related to these Firefox bugs: https://bugzil.la/495230, https://bugzil.la/827585

Although Firefox is violating the spec, judging from the last comment in the second bug report, it's not likely to get fixed soon in Firefox, so the workaround @kasoban used seems to be the way to go for the time being.

pulges pushed a commit that referenced this issue Aug 6, 2014
… from not displayed element on initiation.
pulges pushed a commit that referenced this issue Aug 6, 2014
… initiation

Placeholder simulation should not try to fetch selection from not displayed element on initiation.
Adddesses #64
Fix #32
@Nyholm
Copy link
Contributor

Nyholm commented Apr 15, 2015

Any updates on this? I'm using version 0.5.0-beta8 and I do also get the following error in Chrome.
The given range and the current selection belong to two different document fragments.

@naoisegolden
Copy link

+1

1 similar comment
@kieranklaassen
Copy link

+1

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

No branches or pull requests

6 participants