13

How can I resolve this error? I see this in Firebug's Javascript Console for sp.ui.rte.js on every Sharepoint Page that's loaded. It persists through an iisreset. And it is always the very last thing that happens in page load.

HierarchyRequestError: Node cannot be inserted at the specified point in the hierarchy ...egenerate-skip")};RTE.RteUtility.$DK=function(a,b){ULSNVe:;a.push("");a.push...

How can I trace this error?

I found this page which suggests and answer, but I'm not sure if it is the same problem. But I've tried several of these FixRTEBug attempts, all to no avail.

[update]

After testing various pages, I have concluded that the error only happens in wiki pages. It does not happen on webpart pages containing Content Editors. Wiki Home Pages, Wiki Libraries, etc.

In the console, the last call before this error is a GET statement for

https://my.portal.org/helpdesk/_layouts/commandui.ashx?ver=-780422973&id=Ribbon.ListForm.Edit&lcid=1033&qt=ribbonvisibletabdeep

[update before my bounty expires]

Here is a screenshot of IE's debugger:

IE's Debugger

Does anyone have any clue at all? My bounty is going to expire...

1
  • My bounty is almost over. I don't want it to go to waste, so I'm going to award it even if I don't solve my problem.
    – bgmCoder
    Dec 15, 2015 at 3:09

1 Answer 1

5
+50

Judging from what the console is saying, it seems that the method RTE.Canvas.checkCurrentFocus fails because the element passed is null and the method doesn't expect it to be, so you get an error when it tries to call null.parentElement since parentElement is not a valid property of the object.

Searching on Google it seems to be a issue several others are also having with SP 2010:

https://www.google.com/#q=RTE.Canvas.checkCurrentFocus

Their fix seems to be overwriting the method. Not the ideal solution but if you too are on SP 2010 then that might be the solution to your issue as well.

I don't have the source files in front of me, but maybe this napkin code gets you on the path to fixing the issue:

SP.SOD.executeFunc('sp.ui.rte.js', null, function() {
    var backup = RTE.Canvas.checkCurrentFocus;
    RTE.Canvas.checkCurrentFocus = function(a) {
        if (a !== null) {
            return backup.apply(this, arguments);
        }
    };
});

Edit: adding a followup to the comments below.

If SP.SOD.executeFunc isn't available when your code runs, either because it loads too quickly, or if it loads but the error already occurs because the method was used before the hotfix was applied, try running this code right after sp.ui.rte.js is loaded. Preferably if the master file allows for it, load yours right after it loads with the following script:

(function() {
  var backup = RTE.Canvas.checkCurrentFocus;
  RTE.Canvas.checkCurrentFocus = function(a) {
      if (a !== null) {
          return backup.apply(this, arguments);
      }
  };
})();

Alternatively if loading after is too late, and loading before will of course not work, we could do something like this to wait for it to load so we inject our code as soon it is available. Note that this is not the ideal solution, but at this stage I am curious if it will actually fix your problem at all. Load this when ever, preferably as soon as possible:

(function() {
  var handle;
  if (!check()) {
      handle = setInterval(check, 0);
  }
  function check() {
      if ('RTE' in window) {
          clearInterval(handle);
          inject();
      }
  }
  function inject() {
      var backup = RTE.Canvas.checkCurrentFocus;
      RTE.Canvas.checkCurrentFocus = function(a) {
          if (a !== null) {
              return backup.apply(this, arguments);
          }
      };
  }
})();
6
  • Thanks for taking a look at this. I tried other fixes too. So, in my master page I have two custom js files in the head just after jQuery is loaded. One loads normally, the other has LoadAfterUI="false" set. If I put it in the first load, I get SP is not defined, and if I put it in the second one, it seems to be too late and the napkin does not cover the error. Should I put it somewhere else or do something different?
    – bgmCoder
    Dec 14, 2015 at 15:10
  • This doesn't solve it for me. Maybe there's another solution?
    – bgmCoder
    Dec 15, 2015 at 2:18
  • Well, I awarded my bounty to you even though I haven't solved my problem. Hopefully, you might find the time to assist me a bit further.
    – bgmCoder
    Dec 16, 2015 at 2:28
  • You would need to execute the overriding part the moment the sp.ui.rte.js loads. You can unwrap the code, SP.SOD... wrapper won't work in this case. But you want to use the code inside and make sure that runs right after the original file. Alternatively we would need to wrap it and load it first in such way that we override as soon the object RTE exists. I don't like to suggest a setInterval, but worst case there is no other way. Its hard when I don't have access to your environment. :) Dec 16, 2015 at 15:44
  • I updated my original post with some more examples based on your feedback. Dec 17, 2015 at 11:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.