#354 ✓resolved
Hilberty

DOM node expandos should be accessed via typeof

Reported by Hilberty | September 23rd, 2008 @ 01:20 PM | in 1.6.1

This is a strange bug, because the code involved here has been working without failure almost one year. But I change my computer and I have now this problem.

But my colleagues do not encounter the problem.

I am under Windows Xp Pro Sp3 with all patches installed. The jre used is jre1.5.0_15. prototype version is 1.6.0.2. scriptaculous.js, effects.js and dragdrop.js are also included in my pages.

The error is only encountered in IE7 and IE6. It works fine on Firefox.

When calling $$ for searching applet objects in this function repaintGraphs, a java.lang.NosuchFieldException: _extendedByPrototype occurs in the function Element.extend from prototype.js :


function repaintGraphs()
{
    $$('applet[code="DynGraph.class"]').each(function(gg)
    {
       // some code here
    });

}

Element.extend = (function() {
  if (Prototype.BrowserFeatures.SpecificElementExtensions)
    return Prototype.K;

  var Methods = { }, ByTag = Element.Methods.ByTag;

  var extend = Object.extend(function(element) {
    if (!element || element._extendedByPrototype ||             <---- ERROR
OCCURS HERE
        element.nodeType != 1 || element == window) return element;

The error occurs only if at least an applet of class DynGraph.class is found in the page.

A try catch in the Element.extend does not solve the problem since the error occurs in another function for an other field.

Comments and changes to this ticket

  • Hilberty

    Hilberty September 23rd, 2008 @ 01:56 PM

    The installed jre is 1.6.0-10rc, but the applet are compiled for jre1.5.0_15. When java is not activated for IE (using javascript control panel), there is no javascript error. But no more applet too... ;)

  • John-David Dalton
  • Hilberty

    Hilberty September 23rd, 2008 @ 05:51 PM

    I tried and got this error :

    element.getAttribute('_extendedByPrototype')    Object doesn't support this property or method  Error
    
    
  • John-David Dalton
  • Hilberty

    Hilberty September 23rd, 2008 @ 06:44 PM

    Ok. I will try to investigate why this strange bug appears. Maybe it is because I am launching Tomcat and the servlet from Eclipse. I downagraded java to jre1.6.0_07 without results.

  • John-David Dalton
  • Juriy Zaytsev

    Juriy Zaytsev September 23rd, 2008 @ 09:54 PM

    It seems as if IE does not implement some of the internal methods for certain objects. Could you try if accessing property via typeof or in prevents an error?

    
    '_extendedByPrototype' in element
    // or
    typeof element._extendedByPrototype != 'undefined'
    
  • Hilberty

    Hilberty September 24th, 2008 @ 09:46 AM

    I bless you !

    
    '_extendedByPrototype' in element
    

    works fine.

  • Juriy Zaytsev

    Juriy Zaytsev September 24th, 2008 @ 01:41 PM

    • Assigned user set to “Juriy Zaytsev”
    • State changed from “new” to “bug”
    • Tag changed from ie6, ie7 to ie6, ie7, needs_patch, needs_tests, priority_low
    • Milestone set to 1.7

    @Hilberty Glad it helped ;)

    @All This could be marked as low-priority fix. Is there a way to set priority in Lighthouse or should we do it via tags?

  • John-David Dalton
  • Juriy Zaytsev

    Juriy Zaytsev September 24th, 2008 @ 08:25 PM

    @John

    I guess it depends on how "_extendedByPrototype" in element is resolved (i.e. true/false)

  • John-David Dalton
  • Hilberty

    Hilberty September 25th, 2008 @ 11:13 AM

    I have done this in the javascript file :

    
    var element = $('bulle');
    alert('_extendedByPrototype' in element);
    alert(element._extendedByPrototype);
    

    On IE 6 and IE 7 : true function(){}

    On IE 7 : true function(){}

    On FF3 : false undefined

    Hope this will help

  • Juriy Zaytsev

    Juriy Zaytsev September 25th, 2008 @ 02:01 PM

    @John

    Actually FF should never assign '_extendedByPrototype' to elements (making Element.extend an alias of Prototype.K)

  • John-David Dalton
  • Hilberty

    Hilberty September 26th, 2008 @ 05:18 PM

    I made the test with two different objects (div and applet). Obviously, the alert failed with the applet object.

    I will try the suggested alerts Monday morning.

  • Hilberty

    Hilberty September 29th, 2008 @ 10:06 AM

    Unfortunately (or not), I cannot reproduce the problem anymore. The code suddenly works again with the original prototype.js code, but I do not know what causes it.

  • Andrew Dupont

    Andrew Dupont September 29th, 2008 @ 02:07 PM

    • State changed from “bug” to “invalid”
  • Hilberty

    Hilberty September 29th, 2008 @ 05:52 PM

    I know how to reproduce the problem. This is due to the installation of jre 1.6.0-10rc. This was working fine until Chrome asked me to install the required component and installed this latest release. Now, the problem have appeared again in IE.

    With the latest release of prototype (1.6.0.3), the work around

    
    '_extendedByPrototype' in element
    

    is not enough since the access to the property _countedByPrototype also produce the same error in

    
    unique: function(nodes
    
  • Juriy Zaytsev
  • Prasad

    Prasad October 13th, 2008 @ 05:26 PM

    Hi,

    I've gone through this entire post hoping there would be some solution. Let me complicate the problem :).

    I'm too getting same error with applets embedded in tag. Funny part is I get this error only sometime. my browser JRE is 1.6.0_10rc, however, if I use JRE 1.6.0.7, I don't get this error & everything works fine. Sometime, it works fine with 1.6.0_10rc too.. Just too wiered. And yes the browser is IE7.

    It works fine with FF 3.0.

  • Prasad

    Prasad October 13th, 2008 @ 05:57 PM

    I observed something if that is of some help to you. I'm trying to access a tag which is indeed an applet having id as 'View'.

    When I access applet like this : var actualApplet = $('View'); //It gives me an error with JRE 1.6.0_10rc but works fine with 1.6.0_07.. but when I access like : var actualApplet = document.getElementById('View'); // Works fine with both versions.

    I can't understand why $('View') shouldn't work with 1.6.0_10rc but works with 1.6.0_10rc. What JRE has to do anything with it? If a browser (IE7) is giving error when accessing like $('View'), I expect it to be consistent with JRE versions :)

    accessing $('View') throws error at line no 2547 of prototype.js version 1.6.0.2 saying java.lang.NoSuchFieldException: _extendedByPrototype.

  • Juriy Zaytsev

    Juriy Zaytsev October 13th, 2008 @ 06:08 PM

    Apparently 1.6.0_10rc now throws error when an applet element property value resolves to undefined (during a property lookup) : )

    The question is whether this is a desired behavior or a regression issue (of JRE)

  • Matt McKeon

    Matt McKeon October 18th, 2008 @ 12:26 AM

    Yep, I'm seeing this too with 1.6.0_10

    Can we get this ticket revalidated please?

  • Juriy Zaytsev

    Juriy Zaytsev October 18th, 2008 @ 01:09 AM

    Matt,

    this looks like a regression on JRE side. Has anyone reported it to them yet?

  • Hilberty

    Hilberty November 3rd, 2008 @ 06:37 PM

    I think this ticket must be revalidated. 1.6.0_10 is no more a release candidate now and the current version of java can be automatically updated to that latest version.

    For our team, it is a very annoying problem. Our only known workaround is to disable the applet use.

  • Juriy Zaytsev

    Juriy Zaytsev November 3rd, 2008 @ 08:59 PM

    • Milestone changed from 1.7 to 1.6.1
    • State changed from “invalid” to “bug”
    • Assigned user set to “Juriy Zaytsev”

    I think we can "fix" it, as it would affect practically nothing.

  • Hilberty

    Hilberty November 6th, 2008 @ 10:11 AM

    The workarounds : element.extendedByPrototype --> typeof element.extendedByPrototype != 'undefined' and : !(n = nodes[i]).countedByPrototype) --> typeof (n = nodes[i]).countedByPrototype == 'undefined' seems to work successfully. I modified prototype.js that way and I have no more errors.

  • John-David Dalton
  • John-David Dalton
  • Juriy Zaytsev

    Juriy Zaytsev February 22nd, 2009 @ 09:11 PM

    @Hilberty

    Exactly in which place did you have to change _extendedByPrototype and _countedByPrototype checks?

  • Juriy Zaytsev

    Juriy Zaytsev February 22nd, 2009 @ 09:14 PM

    • Title changed from “A Runtime Error has occured : java.lang.NosuchFieldException: _extendedByPrototype” to “DOM node expandos should be accessed via typeof”
  • Hilberty

    Hilberty February 24th, 2009 @ 11:29 AM

    Well, I changed code like this ( version 1.6.0.3) :

    boldin line 2565 :bold

    
    Element.extend = (function() {
      if (Prototype.BrowserFeatures.SpecificElementExtensions)
        return Prototype.K;
    
      var Methods = { }, ByTag = Element.Methods.ByTag;
    
      var extend = Object.extend(function(element) {
        if (!element || typeof element._extendedByPrototype != 'undefined' /*element._extendedByPrototype*/ ||
            element.nodeType != 1 || element == window) return element;
    

    boldin line 3110 :bold

    
        // filters out duplicates and extends all nodes
        unique: function(nodes) {
          if (nodes.length == 0) return nodes;
          var results = [], n;
          for (var i = 0, l = nodes.length; i < l; i++)
     /*       if (!(n = nodes[i])._countedByPrototype) {*/
              if (typeof (n = nodes[i])._countedByPrototype == 'undefined') {
    
  • Juriy Zaytsev

    Juriy Zaytsev February 24th, 2009 @ 03:01 PM

    • Assigned user changed from “Juriy Zaytsev” to “Andrew Dupont”
    • Tag changed from ie6, ie7, needs_patch, needs_tests, priority_low to ie6, ie7, patched

    @Hilberty

    Thanks. I'm attaching a patch for this.

  • Juriy Zaytsev
  • Tobie Langel

    Tobie Langel February 24th, 2009 @ 05:02 PM

    • Tag changed from ie6, ie7, patched to ie6, ie7, needs_tests, patched

    That's an issue only with OBJECT elements, right? It might also affect the newly created storage interface.

    Could we include unit tests for this ?

    And could we also use triple equal for consistency.

  • Juriy Zaytsev

    Juriy Zaytsev February 24th, 2009 @ 05:30 PM

    Tobie,

    I can't make unit tests for this patch as the issue only happens with a certain version of JRE.

  • GitHub Robot

    GitHub Robot February 28th, 2009 @ 11:50 AM

    • State changed from “bug” to “resolved”

    (from [682a55c2d3c00053c098ca3483123c44fb6eee7f]) Make sure _extendedByPrototype, _countedByPrototype, and prototypeUID node expandos are accessed with typeof to prevent errors in some environments. [#354 state:resolved] (Hilberty, kangax, Andrew Dupont) http://github.com/sstephenson/pr...

  • Tobie Langel

    Tobie Langel July 24th, 2009 @ 02:26 AM

    • Tag changed from ie6, ie7, needs_tests, patched to ie6, ie7, missing:tests, patched

    [not-tagged:"needs_tests" tagged:"missing:tests" bulk edit command]

  • Tobie Langel

    Tobie Langel July 24th, 2009 @ 03:36 AM

    • Tag changed from ie6, ie7, missing:tests, patched to ie6, ie7, needs:tests, patched

    [not-tagged:"missing:tests" tagged:"needs:tests" bulk edit command]

  • Tobie Langel

    Tobie Langel July 24th, 2009 @ 12:46 PM

    • Tag changed from ie6, ie7, needs:tests, patched to needs:tests, patched

    [not-tagged:"ie6" not-tagged:"ie7" bulk edit command]

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

Attachments

Referenced by

Pages