From 0d2cf7bdd6ee7b404f6e0f8eebfa9e8979ba7671 Mon Sep 17 00:00:00 2001 From: Malcolm Tredinnick Date: Sat, 11 Apr 2009 11:33:10 +0000 Subject: [PATCH] Fixed #10783 -- Fixed Javascript error when adding a new object in admin. git-svn-id: http://code.djangoproject.com/svn/django/trunk@10516 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/contrib/admin/media/js/getElementsBySelector.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/django/contrib/admin/media/js/getElementsBySelector.js b/django/contrib/admin/media/js/getElementsBySelector.js index ae6d387a91..15b57a1908 100644 --- a/django/contrib/admin/media/js/getElementsBySelector.js +++ b/django/contrib/admin/media/js/getElementsBySelector.js @@ -38,8 +38,8 @@ document.getElementsBySelector = function(selector) { var tagName = bits[0]; var id = bits[1]; var element = document.getElementById(id); - if (tagName && element.nodeName.toLowerCase() != tagName) { - // tag with that ID not found, return false + if (!element || (tagName && element.nodeName.toLowerCase() != tagName)) { + // ID not found or tag with that ID not found, return false. return new Array(); } // Set currentContext to contain just this element