none
Bug: Invalid argument on Line: 2 Char: 141544 in sp.ui.rte.js

    Question

  • Hi there people,

    Just wondering if there is any way to avoid this javascript error in SharePoint 2010:

    Invalid argument on Line: 2 Char: 141544 in sp.ui.rte.js

    or if you have debug switched on:

    Invalid argument on Line 7353 in sp.ui.rte.debug.js

    Steps to reproduce with a vanilla SharePoint 2010 installation:

    On any SharePoint 2010 site:

    1. Create a new Custom List
    2. Add a Multi-Line Text Box field
      1. Set type to “Rich Text (Bold, italics, text alignment, hyperlinks)”
      2. Set Required to true.
    3. Create a new item
    4. Don’t put any data in and press save

    The validators fire, but a JavaScript error orrcurs.  This is only one way to produce this bug, there are others - including in some scenarios having a non-text field as the first field in a list, or having a custom field perform a post-back also triggers it.

    The December 2010 CU does not help.

    I have manually fixed the JavaScript for now (details here), but I would really like know if there is a way to avoid this error from occuring for OOB SharePoint customers.

    Thanks,

        James.


    Software Consultant - iPMO
    Friday, February 18, 2011 4:25 AM

Answers

  • Hey there again people,

    I guess there is not much interest in this bug, but I have created an Installable/Uninstallable WSP with the JavaScript fix for this, so that you can easily uninstall it prior to applying Cumulative Updates and ServicePacks.

    If you need the WSP package, you can get it from the end of my blog post here.

    Cheers,

        James.


    Software Consultant - iPMO
    • Marked as answer by James Boman Monday, February 21, 2011 6:25 AM
    Monday, February 21, 2011 6:24 AM

All replies

  • Hey there again people,

    I guess there is not much interest in this bug, but I have created an Installable/Uninstallable WSP with the JavaScript fix for this, so that you can easily uninstall it prior to applying Cumulative Updates and ServicePacks.

    If you need the WSP package, you can get it from the end of my blog post here.

    Cheers,

        James.


    Software Consultant - iPMO
    • Marked as answer by James Boman Monday, February 21, 2011 6:25 AM
    Monday, February 21, 2011 6:24 AM
  • We've been hitting a similar issue in editor:

    Agent utilisateur : Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; MS-RTC LM 8; .NET4.0C; .NET4.0E; InfoPath.3; Zune 4.7)
    Horodateur : Fri, 4 Mar 2011 16:26:33 UTC


    Message : Argument non valide.
    Ligne : 2
    Caractère : 177318
    Code : 0
    URI : http://server/_layouts/sp.ui.rte.js?rev=uY%2BcHuH6ine5hasQwHX1cw%3D%3D

    Users are encoutering strange behaviours while using the editor. i.e. Text is unselecting by itself, unable to apply certain markup styles consistently.

    Friday, March 04, 2011 4:40 PM
  • We have also a similar problem, in a custom application page with some InputFormTextBox and TaxonomyWebTaggingControl, when there is a lot of text in the text box, putting the cursor at the end after some times the cursor move itself some lines up! The browser report an error on that script on the same method:

      parentElement: function() {
        ULSNVe: ;
        var b = this.$8;
        if (b.parentElement) {
          var a = b.parentElement(),
          c = RTE.DomHelper.createRange(window.document);
          a && c.moveToElementText(a);
          while (a && !c.inRange(b)) {
            a = a.parentNode;
            try {
              c.moveToElementText(a)
              } catch(g) {}
          }
          if (a) {
            var e = true;
            while (e) {
              e = false;
              for (var h = a.childNodes.length, d = 0; d < h; d++)
                if (!SP.UI.UIUtility.isTextNode(a.childNodes[d])) {
                c.moveToElementText(a.childNodes[d]);
                if (c.inRange(b)) {
                  a = a.childNodes[d];
                  e = true;
                  break
                }
              }
            }
          }
          return a
        }
        var f = b.commonAncestorContainer;
        if (f)
          return f;
        return null
      },
    

    The error is caused by the line

    a && c.moveToElementText(a);

    the a object is null. The error occur both with IE8 and Firefox.

    What can I do to fix this problem?

    Wednesday, March 16, 2011 2:56 PM
  • Has anyone resolved this error?
    Monday, March 12, 2012 3:54 AM
  • I have not checked if any of the more recent patches have fixed this problem.  Perhaps the Dec 2011 CU may contain something relevant.

    I have to say that I wrote the WSP to patch their JavaScipt and moved on.

    I am really hoping that the quality of the JavaScript in SharePoint 15 improves over 2010.

    Please post here if you have found that it is fixed in a CU.

    Cheers,

        J.


    James Boman - http://www.boman.biz Software Consultant for IPMO - http://www.ipmo.com.au

    Monday, March 12, 2012 6:25 AM
  • Same here, but happens even with no text on a simple page with one TextBox.
    Friday, April 20, 2012 4:58 PM
  • The disadvantage of the James Boman's solution is that if this gets fixed by MS the new js will be overridden when you redeploy the wsp.

    Another option would be to put the function call within a try/catch block without actually modifying the function or editing the sharpeoint js file.

    function SubstituteRTERangeParentElement() {

    var originalRTERangeParentElement = RTE.Range.prototype.parentElement;
    RTE.Range.prototype.parentElement = function () {
    try {
    originalRTERangeParentElement();
    } catch (e) {
    }
    }
    }

    ExecuteOrDelayUntilScriptLoaded(SubstituteRTERangeParentElement, "sp.ui.rte.js");

    • Proposed as answer by Nelson L Tuesday, June 05, 2012 7:29 PM
    Friday, April 20, 2012 8:20 PM
  • The disadvantage of the James Boman's solution is that if this gets fixed by MS the new js will be overridden when you redeploy the wsp.

    Another option would be to put the function call within a try/catch block without actually modifying the function or editing the sharpeoint js file.

    function SubstituteRTERangeParentElement() {

    var originalRTERangeParentElement = RTE.Range.prototype.parentElement;
    RTE.Range.prototype.parentElement = function () {
    try {
    originalRTERangeParentElement();
    } catch (e) {
    }
    }
    }

    ExecuteOrDelayUntilScriptLoaded(SubstituteRTERangeParentElement, "sp.ui.rte.js");

    This is actually a better idea - as LeCamarade says, this will survive Service Packs and CU's much better.

    Cheers,

        J.


    James Boman - http://www.boman.biz Software Consultant for IPMO - http://www.ipmo.com.au

    • Proposed as answer by Nelson L Tuesday, June 05, 2012 7:29 PM
    • Unproposed as answer by Nelson L Tuesday, June 05, 2012 7:29 PM
    Sunday, April 22, 2012 1:58 AM