Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Issue 5764: Change JSTerm's $ helper function from getElementById to …

…querySelector
  • Loading branch information...
commit f47c2225fd280cb31d3a6170956bab684758d75c 1 parent 24fd0ae
steve authored
Showing with 24 additions and 4 deletions.
  1. +24 −4 extension/content/firebug/console/commandLine.js
28 extension/content/firebug/console/commandLine.js
View
@@ -1043,14 +1043,34 @@ Firebug.CommandLine.CommandHandler = Obj.extend(Object,
function FirebugCommandLineAPI(context)
{
- this.$ = function(id) // returns unwrapped elements from the page
+ this.$ = function(selector, start) // returns unwrapped elements from the page
{
- return Wrapper.unwrapObject(context.baseWindow.document).getElementById(id);
+ var result;
+ if (start && start.querySelector && (start.nodeType == 1 || start.nodeType == 9 || start.nodeType == 11))
+ result = start.querySelector(selector);
+ else
+ {
+ result = Wrapper.unwrapObject(context.baseWindow.document).querySelector(selector);
+ if (result == null && (selector||"")[0] !== "#")
+ {
+ result = Wrapper.unwrapObject(context.baseWindow.document).querySelector("#" + selector);
+ if (result != null)
+ {
+ Firebug.Console.log("The console function $() has changed from $=getElementById(id) to $=querySelector(selector). You might try $(\"#" + selector + "\")", context, "warn");
+ result = null;
+ }
+ }
+ }
+ return result;
};
- this.$$ = function(selector) // returns unwrapped elements from the page
+ this.$$ = function(selector, start) // returns unwrapped elements from the page
{
- var result = Wrapper.unwrapObject(context.baseWindow.document).querySelectorAll(selector);
+ var result;
+ if (start && start.querySelectorAll && (start.nodeType == 1 || start.nodeType == 9 || start.nodeType == 11))
+ result = start.querySelectorAll(selector);
+ else
+ result = Wrapper.unwrapObject(context.baseWindow.document).querySelectorAll(selector);
return Arr.cloneArray(result);
};
Please sign in to comment.
Something went wrong with that request. Please try again.