#118 bug
Zekid

#readAttribute('type') fails when invoked on an iframe

Reported by Zekid | May 26th, 2008 @ 05:07 PM | in 1.6.0.4

Hello,

I just try this code :

alert($(document).select('iframe').length)

in a page that i have an iframe.

And it doesn't work on IE 6.0 but it's ok with Firefox.

I found a tip to make it work,that it's to use an attribute 'type' in the iframe tag.

I found that problem come from this line :

element.getAttribute(attribute, 2)

in Element._attributeTranslations.read method.

I hope i'm not wrong.

Regards.

Comments and changes to this ticket

  • Tobie Langel

    Tobie Langel May 27th, 2008 @ 12:40 AM

    • → State changed from “new” to “bug”
  • Juriy Zaytsev

    Juriy Zaytsev May 27th, 2008 @ 07:01 AM

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

    "document" is not really extended with "select" method, so you should be getting an error in any browser.

    I can't reproduce this error when "selecting" from "documentElement" or "body" nodes:

    $(document.documentElement).select('iframe'); // [<iframe/>]
    $(document.body).select('iframe'); // [<iframe/>]
    

    Please reopen if I you experience any problems.

  • Zekid

    Zekid May 27th, 2008 @ 04:02 PM

    Excuse me I think it was the same problem, but the real problem is :

    alert($(document.documentElement).select('input:not([type~=hidden])').length);

    if i want to have all inputs that are not of type hidden.

    It is use in modalbox.js, and it doesn't work on IE 6 when you have got an iframe in your document.

    This is real problem and it is due to :

    element.getAttribute(attribute, 2)

    Thanks for your previous quick response.

  • Juriy Zaytsev

    Juriy Zaytsev May 27th, 2008 @ 06:14 PM

    • → Milestone changed from “” to “1.6.0.3”
    • → State changed from “invalid” to “bug”
    • → Assigned user changed from “” to “Juriy Zaytsev”

    Ok, got it.

    iframe throws error when trying to call "getAttribute('type', flag)" when flag is 2

    Will attach patch as soon as I can.

  • Zekid

    Zekid May 27th, 2008 @ 06:25 PM

    Cool.

    Happy to help you !

  • Juriy Zaytsev

    Juriy Zaytsev May 27th, 2008 @ 07:12 PM

    • → Title changed from “$(document).select('iframe') doesn't work on IE” to “#readAttribute('type') fails when invoked on an iframe”
  • John-David Dalton

    John-David Dalton May 28th, 2008 @ 06:08 PM

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

    Cannot reproduce this,

    alert($(document.documentElement).select('input:not([type~=hidden])').length);
    

    would not even iterate over the iframe because of it is not an INPUT element.

    I have tried:

    new Element('iframe', {'src': 'javascript:void(0);'}).readAttribute('src');
    new Element('iframe', {'src': 'javascript:void(0);'}).getAttribute('src', 2);
    

    with no errors.

    Please reopen if I am mistaken.

  • Juriy Zaytsev

    Juriy Zaytsev May 28th, 2008 @ 07:02 PM

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

    John, #readAttribute fails only when attribute name is "type" and is invoked on an iframe

  • Zekid

    Zekid May 28th, 2008 @ 07:13 PM

    Like just saying Juriy, this is only on attribute 'type' and 'iframe', and in this code :

    attr: function(nodes, root, attr, value, operator) {

    if (!nodes) nodes = root.getElementsByTagName("*");

    var handler = Selector.operators[operator], results = [];

    for (var i = 0, node; node = nodes[i]; i++) {

    var nodeValue = Element.readAttribute(node, attr);

    if (nodeValue === null) continue;

    if (handler(nodeValue, value)) results.push(node);

    }

    return results;

    }

    You use all HTML elements root.getElementsByTagName("*");

    That's why when you use select('input:not([type~=hidden])'), it fail.

  • John-David Dalton
  • Zekid
  • Juriy Zaytsev

    Juriy Zaytsev June 11th, 2008 @ 03:16 PM

    • → State changed from “bug” to “resolved”
  • nate

    nate October 31st, 2008 @ 12:56 PM

    • → Tag changed from “” to “dom element ie needs_patch needs_tests”

    Did this bug make it into the 1.6.0.3 release? I ask because I know that not all of the bugs scheduled to be released in the 1.6.0.3 release actually made it in. Also I an still seeing the issue.

    It is now occurring on line 2317 of prototype.js return element.getAttribute(attribute, 2);

    element.tagName = "IFRAME" attribute = "type"

    Error message: Object doesn't support this property or method

  • Juriy Zaytsev

    Juriy Zaytsev October 31st, 2008 @ 03:32 PM

    • → State changed from “resolved” to “bug”

    It did not : /

  • Tobie Langel

    Tobie Langel November 8th, 2008 @ 02:01 PM

    • → Milestone changed from “1.6.0.3” to “1.6.0.4”

Please Login or create a free account to add a new comment.

You can update this ticket by sending an email to from your email client. (help)

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