Ticket #255 (closed defect: fixed)

Opened 1 year ago

Last modified 1 week ago

getElementsByTagAndClassName("div", "portlet", null) errors with _2fe has no properties

Reported by: Curtis Hovey <curtis@hovey.name> Assigned to: somebody
Priority: normal Milestone: MochiKit 1.4
Component: component1 Version:
Severity: normal Keywords:
Cc:

Description

When getElementsByTagAndClassName() is called with the parent id (a string) and that element does not exist in the the DOM, MockiKit? errors with '_2fe has no properties'

This is the traceback for an call to retrieve divs that have the class 'portlet' that are children of 'portlets'. The page does not have an element with the id of 'portlets'.

getElementsByTagAndClassName('div', 'portlet', 'portlets');

https://launchpad.net/+icing/rev117/MochaKit.js

2880 var _300=(_2fe.getElementsByTagName(_2fc)self._document.all);

Traceback: #0: function anonymous(_2fc=string:"*", _2fd=string:"foldable", _2fe=HTMLDocument:{0}) in <https://launchpad.net/+icing/rev117/MochiKit.js> line 2879 #1: function activateFoldables() in <https://launchpad.net/+icing/rev117/launchpad.js> line 226 #3: function anonymous(_3de=Event:{0}) in <https://launchpad.net/+icing/rev117/MochiKit.js> line 3863

If the parent element is null, the method should return an empty array.

Change History

05/13/08 14:13:28 changed by cederberg@gmail.com

  • milestone set to MochiKit 1.4.

This issue really affects most DOM related functions in MochiKit. It seems somewhat impractical to implement null input checks everywhere, so I don't think this issue will be fixed. And if so, all of MochiKit.DOM, MochiKit.Style and MochiKit.Visual (and other users of MochiKit.DOM.getElement) must be reviewed.

Moving this to the MochiKit 1.4 milestone for consideration before the release.

10/06/08 03:31:06 changed by cederberg@gmail.com

  • status changed from new to closed.
  • resolution set to fixed.

Fixed in r1414. I've added null checks to the following MochiKit.DOM functions:

getElementsByTagAndClassName hasElementClass getFirstElementByTagAndClassName isParent

I've chosen to only add this check to non-mutating functions, since I believe that it might be poor design for the mutator functions to fail silently.