diff --git a/CHANGELOG b/CHANGELOG index ee22d37..0c8ebd6 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -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] diff --git a/src/selector.js b/src/selector.js index 56cdeb6..a185613 100644 --- a/src/selector.js +++ b/src/selector.js @@ -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) { diff --git a/test/unit/selector.html b/test/unit/selector.html index 35612aa..125870c 100644 --- a/test/unit/selector.html +++ b/test/unit/selector.html @@ -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'); // ]]>