#60 ✓invalid
Domini

Empty $$("tag") when there is tag#reserved_keyword in IE6/7, maybe Opera

Reported by Domini | April 28th, 2008 @ 05:11 PM

This code will alert 0 instead of 2 (and selects will be empty) in IE6/7, maybe in Opera (didn't check). Everything is OK in Firefox and Safari.

I think the problem is $("length"), whose id is similar to Array.prototype.length property.

Is there a workaround? Can you fix this?

Comments and changes to this ticket

  • Domini

    Domini April 28th, 2008 @ 05:11 PM

    • no changes were found...
  • John-David Dalton

    John-David Dalton April 28th, 2008 @ 07:12 PM

    Can you please restate your problem. I think I have an idea but please clarify your issue.

  • Domini

    Domini April 28th, 2008 @ 07:22 PM

    Use attachment. I've tried to post code in plain text, but it has become spoiled.

  • John-David Dalton
  • Domini

    Domini April 28th, 2008 @ 07:42 PM

    Site is not available now. Looked in Google Cache - "Milestone: 2.x". Does this mean that this error won't be corrected until 2.0 release?

  • John-David Dalton

    John-David Dalton April 28th, 2008 @ 07:47 PM

    The link I posted worked fine for me odd.

    I don't know about any 2.x milestone for that fix.

    This issue is related to how IE handles 'shortcuts' to its dom elements via its ID.

    document.getElementsByTagName('SELECT').length will reference the select element with the 'id' length. I do not see much of a way around this, avoid ID's that are the same as element properties.

  • Domini

    Domini April 28th, 2008 @ 07:53 PM

    I understand that this is an IE specific issue. :) I thought there is some workaround maybe.

    This issue is beyond prototype abilities and must be solved on a concrete document basis, not on prototype basis. Do I understand right?

  • John-David Dalton

    John-David Dalton April 28th, 2008 @ 08:11 PM

    There are ways to fix it in certain situations like with Element#readAttribute, but others like with that example I posted above I am unaware of how to solve it.

  • Tobie Langel

    Tobie Langel April 30th, 2008 @ 01:10 AM

    • State changed from “new” to “bug”
  • John-David Dalton

    John-David Dalton May 21st, 2008 @ 05:12 PM

    this is fixed by adding the following to the bottom of array.js

    (function( ){
      var div = document.createElement('div');
      div.appendChild(div.cloneNode(false)).id = 'length';
      if (typeof div.getElementsByTagName('div').length != 'object') return;
      $A = function(iterable) {
        if (!iterable) return [];
        if (iterable.toArray) return iterable.toArray();
        var length = iterable.length || 0;
        if (typeof length == 'object' && length.id == 'length') {
          var item = length;
          item.id  = null;
          length   = iterable.length;
          item.id  = 'length';
        }
        var results = new Array(length);
        while (length--) results[length] = iterable[length];
        return results;
      };
    })();
    

    and wrapping the return in $A for the Selector.handlers.tagName method (its not returning an array so it can't so things like $$('select').each(...)

          } else return $A(root.getElementsByTagName(tagName));
    
  • John-David Dalton

    John-David Dalton May 22nd, 2008 @ 10:55 PM

    • State changed from “bug” to “invalid”

    This is a problem in Opera 9.5 and 9.25 as well with no solution in site, just avoud naming elements the same as property names.

    That is the sure fire fix.

  • jeuxnewbanat

    jeuxnewbanat March 18th, 2016 @ 01:54 AM

    • Tag set to patched
    • Importance changed from “” to “”

    شكرا لكم اخي صراحة هده الاكواد تعلمتها من قبل وانا هنا لكي اشكرك على هدا العمل. لاتنسو زيارة موقعي الخاص بقسم العاب تلبيس جديدة للعام الجديد.

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

People watching this ticket

Attachments

Tags

Pages