#771 bug

.clonePosition produces JS error in IE 7, P 1.6.1_rc3

Reported by Michal | August 19th, 2009 @ 01:15 PM

In some circumstances clonePosition throws JS error telling that 'style' is null or not an object on line 2583.

Have reproduced the bug on IE 7/Win and IE 8 running in IE 7 mode/Win with Prototype 1.6.1_rc3. IE 8/Win and Firefox 3.5.2/Win are ok.


Call .clonePosition.
Source element passed (and all its parents) must NOT have set position:*** style property.
Property object must be set, with arguments as in example code below.

Example code:


&lt;a href=&quot;#&quot; onclick=&quot;$('positioned').clonePosition($(this), {setWidth: false, setHeight: false, offsetTop: 200, offsetLeft: 200})&quot;&gt;CLICK ME!&lt;/a&gt;
&lt;div id=&quot;positioned&quot; style=&quot;background-color: red; position: absolute;&quot;&gt;.&lt;/div&gt;&lt;/body&gt;</code>

Put the example code into page and then click on a link. Expected is that DIV will be repositioned, however IE 7 raises JavaScript error.

Details about raised error (extracted from IE 8 Developer Tool):
Name: „'style' is null or not an object“ on line „var value = element.style[style];“ in method „Element.Methods.getStyle“.
element argument is actually reference to „document“, which has not set „style“ property.

Comments and changes to this ticket

  • shivprasad

    shivprasad August 21st, 2009 @ 07:08 AM

    In my case this error comes first time i click on it. IE6.
    I have modified following method, just added try catch and don't report
    Works perfectly for me

    clonePosition: function(element, source) {
     /* try catch below added by shiv */
              delta = Element.viewportOffset(parent);
  • Michal

    Michal August 21st, 2009 @ 04:27 PM

    • Tag set to ie6, ie7, needs:failing_testcase

    I did not understood the logic properly, but it is probably called recursively and ends it in the way that „parent“ in previous code is „document“ node itself and not an HTML node (it should stop on „HTML“ node I think…)

  • Tobie Langel

    Tobie Langel August 25th, 2009 @ 09:59 PM

    • Tag changed from ie6, ie7, needs:failing_testcase to needs:failing_testcase
  • Steve Lowery

    Steve Lowery August 27th, 2009 @ 11:00 PM

    • Tag changed from needs:failing_testcase to needs:failing_testcase

    We had the same issue. I found some an online post (http://dev.rubyonrails.org/ticket/11007) that pointed to making the following change in the getOffsetParent function.

    Original line:
    while ((element = element.parentNode) && element != document.body)

    New line:
    while ((element = element.parentNode) && element != document.body && element != document)

    Worked as advertised.

  • Tobie Langel

    Tobie Langel August 28th, 2009 @ 12:41 AM

    • State changed from “new” to “bug”
  • T.J. Crowder

    T.J. Crowder November 16th, 2009 @ 04:50 PM

    [responsible:none bulk edit command]

  • Tisho Georgiev

    Tisho Georgiev March 1st, 2010 @ 08:19 PM

    • Tag changed from needs:failing_testcase to needs:failing_testcase, section:dom

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