Ticket #217 (new defect)

Opened 1 year ago

Last modified 1 year ago

IE - elementPosition triggers error with elements not appended to DOM

Reported by: mrrau Assigned to: somebody
Priority: high Milestone: MochiKit 1.5
Component: component1 Version:
Severity: normal Keywords:
Cc:

Description

Check this simple code in IE:

    addLoadEvent(function (){
    var e1 = DIV(null, 'somestuff');
    var e2 = DIV(null, BR(), BR(), e1);

    alert(elementPosition(e2));
    });

it triggers: 'tagName' is null or not an object

it is because root node of 'e2' element is #document-fragment (nodeType == 11) and it has not 'tagName' property.

IMHO this function should check for it in "while (parent)" loop, ex. while (parent&&parent.tagName)

Change History

01/24/07 09:52:16 changed by therve@gmail.com

  • milestone changed from MochiKit 1.4 to MochiKit 1.5.

What do you expect it to return if the node is not in the DOM ? We can't really say what will be its position until it's attached to a full page.

01/25/07 04:54:23 changed by mrrau

Yes, I agree with you. But I think it should prevent triggering common JS error.

For me it can return {w:0,h:0} or (maybe it is safer) throw exception.