diff --git a/extension/content/firebug/console/commandLine.js b/extension/content/firebug/console/commandLine.js index ce96a43ccc..8707d675ab 100644 --- a/extension/content/firebug/console/commandLine.js +++ b/extension/content/firebug/console/commandLine.js @@ -1052,20 +1052,23 @@ function FirebugCommandLineAPI(context) this.$ = function(selector, start) // returns unwrapped elements from the page { var result; - if (start && start.querySelector && (start.nodeType == Node.ELEMENT_NODE || start.nodeType == Node.DOCUMENT_NODE || start.nodeType == Node.DOCUMENT_FRAGMENT_NODE)) - result = start.querySelector(selector); - else + if (start && start.querySelector && ( + start.nodeType == Node.ELEMENT_NODE || + start.nodeType == Node.DOCUMENT_NODE || + start.nodeType == Node.DOCUMENT_FRAGMENT_NODE)) { + return start.querySelector(selector); + } + + result = Wrapper.unwrapObject(context.baseWindow.document).querySelector(selector); + if (result == null && (selector||"")[0] !== "#") { - result = Wrapper.unwrapObject(context.baseWindow.document).querySelector(selector); - if (result == null && (selector||"")[0] !== "#") + result = Wrapper.unwrapObject(context.baseWindow.document).querySelector("#" + selector); + if (result != null) { - result = Wrapper.unwrapObject(context.baseWindow.document).querySelector("#" + selector); - if (result != null) - { - // This should be removed in the next minor (non-bugfix) version - Firebug.Console.log("The console function $() has changed from $=getElementById(id) to $=querySelector(selector). You might try $(\"#" + selector + "\")", context, "warn"); - result = null; - } + // This should be removed in the next minor (non-bugfix) version + var msg = Locale.$STRF("warning.dollar_change", [selector]); + Firebug.Console.log(msg, context, "warn"); + result = null; } } return result; @@ -1074,8 +1077,9 @@ function FirebugCommandLineAPI(context) this.$$ = function(selector, start) // returns unwrapped elements from the page { var result; - if (start && start.querySelectorAll && (start.nodeType == Node.ELEMENT_NODE || start.nodeType == Node.DOCUMENT_NODE || start.nodeType == Node.DOCUMENT_FRAGMENT_NODE)) + if (start && start.querySelectorAll && (start.nodeType == Node.ELEMENT_NODE || start.nodeType == Node.DOCUMENT_NODE || start.nodeType == Node.DOCUMENT_FRAGMENT_NODE)) { result = start.querySelectorAll(selector); + } else result = Wrapper.unwrapObject(context.baseWindow.document).querySelectorAll(selector); return Arr.cloneArray(result); diff --git a/extension/locale/en-US/firebug.properties b/extension/locale/en-US/firebug.properties index 192211fe49..0c40791e83 100644 --- a/extension/locale/en-US/firebug.properties +++ b/extension/locale/en-US/firebug.properties @@ -1367,6 +1367,7 @@ confirmation.Edit_CSS_Source=Your existing CSS edits will be discarded.\nAre you # Console messages warning.Console_must_be_enabled=Console must be enabled warning.Command_line_blocked?=Command line blocked? +warning.dollar_change=The console command line function $() has changed meaning from $=getElementById(id) to $=querySelector(selector). You might try $("#%S") instead. message.Reload_to_activate_window_console=Reload to activate window console # LOCALIZATION NOTE (message.sourceNotAvailableFor, message.The_resource_from_this_URL_is_not_text):