#1975 new
Matt Hoyle

Firefox 16.0.2 throwing NS_ERROR_ILLEGAL_VALUE 0x80070057 in Element.descendantOf

Reported by Matt Hoyle | March 20th, 2013 @ 11:15 AM

In Prototype 1.7.0 (scriptaculous requirement) I receive the following exception.

[09:42:59.903] NS_ERROR_ILLEGAL_VALUE: Component returned failure code: 0x80070057 (NS_ERROR_ILLEGAL_VALUE) [nsIDOMHTMLDivElement.compareDocumentPosition] @ http://10.1.1.70:3000/static/js/prototype.js:2349

After a new Element div had been created and inserted to a page and made Draggable. This exception occurs on the exit of my outer "add" div function. The error relates to undefined values being passed to function in Mozilla. The same code works in Chrome.

descendantOf()prototype.js (line 2343) element = div#a1234.mobject ancestor = null
initialize()dragdrop.js (line 276) element = "a1234"
klass()prototype.js (line 80)
makeDragObj()obj.js (line 31) id = "a1234"
mobj()obj.js (line 276) options = Object { id="a1234", name="objectName", fields={...}}
add()obj.js (line 182) arg = Object { id="a1234", name="objectName", fields={...}}
obj.js()obj.js (line 340)

My workaround was to add a check for a null ancestor in descendantOf in prototype.js: if (!ancestor) return false;

  descendantOf: function(element, ancestor) {
    element = $(element), ancestor = $(ancestor);

    if (!ancestor) return false;

    if (element.compareDocumentPosition)
      return (element.compareDocumentPosition(ancestor) & 8) === 8;

    if (ancestor.contains)
      return ancestor.contains(element) && ancestor !== element;

    while (element = element.parentNode)
      if (element == ancestor) return true;

    return false;
  },

It looks like the code has changed slightly in 1.7.1 but the same null flow could be possible in descendantOf_compareDocumentPosition:

  function descendantOf_compareDocumentPosition(element, ancestor) {
    element = $(element), ancestor = $(ancestor);
    return (element.compareDocumentPosition(ancestor) & 8) === 8;
  }

Comments and changes to this ticket

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

The Prototype JavaScript library.

Shared Ticket Bins

Pages