#118 ✓resolved
Zekid

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

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

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 set to 1.6.0.3
    • State changed from “invalid” to “bug”
    • Assigned user set 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 set 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.1
  • Juriy Zaytsev

    Juriy Zaytsev February 22nd, 2009 @ 10:39 PM

    • Assigned user changed from “Juriy Zaytsev” to “Andrew Dupont”
    • Tag changed from dom, element, ie, needs_patch, needs_tests to dom, element, ie, patched, tested
  • GitHub Robot

    GitHub Robot February 24th, 2009 @ 03:21 AM

    • State changed from “bug” to “resolved”

    (from [043653a28292a23838ada7618879e48ac5a5aadf]) Make sure getAttribute is used without flag when accessing the "type" attribute of an iframe (IE throws error otherwise). [#118 state:resolved] (Zekid, kangax) http://github.com/sstephenson/pr...

  • Andrew

    Andrew May 20th, 2009 @ 05:50 PM

    • Tag changed from dom, element, ie, patched, tested to dom, element, ie, iframe, patched, safari4, tested

    This patch causes Safari 4 to infinitely attempt to load "about:blank"

    This probably goes against the trend against browser sniffing, but frankly, I don't know enough about the issue to come up with a better fix.

    
       var iframeGetAttributeThrowsError = (function() {
          if(Prototype.Browser.Webkit) return false;
          var el = document.createElement('iframe'),
    
  • Tobie Langel

    Tobie Langel May 20th, 2009 @ 06:09 PM

    That should be fixed in trunk, or at least in kangax's branch. We're aware of the issue.

  • Andrew

    Andrew May 20th, 2009 @ 06:29 PM

    • Tag changed from dom, element, ie, iframe, patched, safari4, tested to dom, element, ie, iframe, patched, tested

    Oops, I didn't see #631

  • Tobie Langel

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

    • Tag changed from dom, element, ie, iframe, patched, tested to element, ie, iframe, patched, section:dom

    [not-tagged:"dom" tagged:"section:dom" bulk edit command]

  • Tobie Langel

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

    • Tag changed from element, ie, iframe, patched, section:dom to ie, iframe, patched, section:dom

    [not-tagged:"element" bulk edit command]

  • Tobie Langel

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

    • Tag changed from ie, iframe, patched, section:dom to patched, 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

Attachments

Referenced by

Pages