Prototype: Make Selector correctly extend the first element it returns on IE. [Thomas Fuchs]

This commit is contained in:
Thomas Fuchs 2007-03-11 14:51:14 +00:00
parent a6984e692b
commit b2845e4557
3 changed files with 17 additions and 1 deletions

View File

@ -1,5 +1,7 @@
*SVN*
* Make Selector correctly extend the first element it returns on IE. [Thomas Fuchs]
* Prevent a crash in Safari when using $A() on NodeList objects that contain text nodes. [Thomas Fuchs]
* Fix Element.Methods.descendants() to properly extend elements on IE. [Thomas Fuchs]

View File

@ -249,7 +249,7 @@ Object.extend(Selector, {
unique: function(nodes) {
if (nodes.length == 0) return nodes;
var results = [nodes[0]], n;
nodes[0]._counted = true;
Element.extend(nodes[0])._counted = true;
for (var i = 0, l = nodes.length; i < l; i++) {
n = nodes[i];
if (!n._counted) {

View File

@ -359,6 +359,20 @@
assertEnumEqual($('list', 'p', 'link_1', 'item_1', 'item_3', 'troubleForm'), $$('#list, .first,', '*[xml:lang="es-us"] , #troubleForm'));
assertEnumEqual($('commaParent', 'commaChild'), $$('form[title*="commas,"], input[value="#commaOne,#commaTwo"]'));
assertEnumEqual($('commaParent', 'commaChild'), $$('form[title*="commas,"]', 'input[value="#commaOne,#commaTwo"]'));
}},
testSelectorExtendsAllNodes: function(){ with(this) {
var element = document.createElement('div');
(3).times(function(){
element.appendChild(document.createElement('div'));
});
element.setAttribute('id','scratch_element');
$$('body')[0].appendChild(element);
var results = $$('#scratch_element div');
assert(typeof results[0].show == 'function');
assert(typeof results[1].show == 'function');
assert(typeof results[2].show == 'function');
}}
}, 'testlog');
// ]]>