prototype: Prevent an error being thrown by $$ when #id does not exist in $$("div #id"). Closes #8325.

This commit is contained in:
Sam Stephenson 2007-05-18 00:51:34 +00:00
parent a7a0edd830
commit beeb12e7dd
3 changed files with 5 additions and 1 deletions

View File

@ -1,5 +1,7 @@
*SVN*
* Prevent an error being thrown by $$ when #id does not exist in $$("div #id"). Closes #8325. [Tobie Langel, ecke]
* Make Prototype.ScriptFragment behave when including Prototype inline. [Christophe Porteneuve]
* Deprecate Position (kept for backwards compatibility). Add Element#cumulativeOffset, Element#positionedOffset, Element#absolutize, Element#relativize, Element#cumulativeScrollOffset, Element#getOffsetParent, Element#viewportOffset and Element#clonePosition. [Christophe Porteneuve]

View File

@ -339,7 +339,8 @@ Object.extend(Selector, {
id: function(nodes, root, id, combinator) {
var targetNode = $(id), h = Selector.handlers;
if (!nodes && root == document) return targetNode ? [targetNode] : [];
if (!targetNode) return [];
if (!nodes && root == document) return [targetNode];
if (nodes) {
if (combinator) {
if (combinator == 'child') {

View File

@ -219,6 +219,7 @@
assertEnumEqual($('level2_1', 'level2_2'), $$('#level1>span'));
assertEnumEqual($('level2_1', 'level2_2'), $$('#level1 > span'));
assertEnumEqual($('level3_1', 'level3_2'), $$('#level2_1 > *'));
assertEnumEqual([], $$('div > #nonexistent'));
$RunBenchmarks && wait(500, function() {
benchmark(function() { $$('#level1 > span') }, 1000);
});