select element by id from disconnected cloned node
Reported by osmo | August 8th, 2008 @ 04:15 PM
using $().select on a disconnected cloned node to find an element by id, does not work in internet explorer 6. the same code does work in firefox 2 and firefox 3.
you can recreate the error using the following code: http://pastie.org/249959
Mislav asked me to reference ticket #198
Comments and changes to this ticket
-
John-David Dalton August 8th, 2008 @ 04:59 PM
- → State changed from new to invalid
This should be fixed in the current trunk of Prototype.
-
-
John-David Dalton August 8th, 2008 @ 05:08 PM
- → Milestone changed from to 1.6.0.3
- → State changed from invalid to bug
- → Assigned user changed from Mislav to John-David Dalton
-
Mislav August 8th, 2008 @ 05:15 PM
osmo tested with latest master. this still persists. can you tell why it's happening?
-
John-David Dalton August 8th, 2008 @ 05:19 PM
Yes, I can see why. Its checking $(id) first to see if it finds one. If it doesnt then it checks to see if its a disconnected node. Well in this case since its a cloned node the ID exists in 2 places, one in the document, the other diconnected. So it matches the one in the dom and later when it does a check to see if its a descendant of the cloned node it will fail and return an empty array.
-
John-David Dalton August 8th, 2008 @ 05:20 PM
I don't know if we should fix this because technically ID's are supposed to be unique. I wonder what the others think about this
-
John-David Dalton August 8th, 2008 @ 05:31 PM
I could see a patch using somehting like: Element#isOrphaned()
-
Mislav August 8th, 2008 @ 05:33 PM
I say wontfix because of non-unique IDs. That's what I first said to osmo on IRC.
-
John-David Dalton August 8th, 2008 @ 06:08 PM
- → State changed from bug to not_for_core
Andrew says won'tfix as well
-

osmo August 8th, 2008 @ 06:37 PM
I agree that IDs have to be unique, but I disagree that IDs have to be unique beyond the Document (for example in different DocumentFragments, etc ..).
e.g. I have a template in my Document. I use IDs in this template to mark important elements (elements that need to be updated or observed for example).
var template = $('template_id').cloneNode(true); template.id = 'new_unique_id1'; var template_content = template.select('#template_content_id'); template_content.id = 'new_unique_id2'; template_content.innerHTML = 'hello world!'; // repeat x times document.body.appendChild(template);In what way is this bad practice or not conform with HTML standards?
-
John-David Dalton August 8th, 2008 @ 06:36 PM
- → Milestone cleared.
- → State changed from not_for_core to bug
Ya I see what you are talking about (I will leave the ticket open so it will invite further discussion :)
-
-
Juriy Zaytsev August 8th, 2008 @ 06:39 PM
- → Milestone changed from to 1.6.0.3
This has nothing to do with "id" if I'm not mistaken. Here's an original issue: http://dev.rubyonrails.org/ticke...
-

osmo August 8th, 2008 @ 06:47 PM
Thanks for re-opening the ticket!
IDs are the more logical choice imo. I use classes for markup, and try to avoid using custom attributes (I do not want to go dojo style - the w3c validator does not recognise the custom attributes and invalidates the document).
-
John-David Dalton August 11th, 2008 @ 05:05 PM
- no changes were found...
-
John-David Dalton August 11th, 2008 @ 05:06 PM
Juriy I think you are mistaken I explain whats happening in the comments above :)
We can fix this by doing something like the attached patched/unit test.
-
John-David Dalton August 11th, 2008 @ 05:08 PM
- → Assigned user changed from John-David Dalton to Andrew Dupont
Also git trunk version didn't extend the resolved "targetNode"
-
Tobie Langel October 1st, 2008 @ 01:21 PM
- → Tag changed from element ie ie6 needs_patch needs_tests selector to element ie patched selector tested
- → Milestone cleared.
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.
