Skip to content
This repository
Browse code

Change console host command: $ → querySelector

This comes from a change to Firebug's Command Line API
<http://getfirebug.com/wiki/index.php/Command_Line_API>.
  • Loading branch information...
commit d52158c36f81480900b76c5d71fc1b5caf0cfeb4 1 parent cf46806
Thaddee Tyl authored August 23, 2012
2  src/repl/commandtransformer.js
@@ -254,7 +254,7 @@ cls.HostCommandTransformer = function() {
254 254
   {
255 255
     if (this.is_global_call(tokenlist, index))
256 256
       token[VALUE] = "(typeof $ == 'function' && $ || \
257  
-                       function(e) { return document.getElementById(e); })";
  257
+                       function(e) { return document.querySelector(e); })";
258 258
   };
259 259
 
260 260
   this._hostcommands.$$ = function(token, tokenlist, index)
10  tests/commandtransformer.qunit.html
@@ -76,11 +76,11 @@
76 76
 
77 77
 test("$", function() {
78 78
     equal(transform("$"), "$");
79  
-    equal(transform("$(foo)"), "document.getElementById(foo)");
80  
-    equal(transform("var x=$(foo)"), "var x=document.getElementById(foo)");
81  
-    equal(transform("var x= $(foo)"), "var x= document.getElementById(foo)");
82  
-    equal(transform("var x =$(foo)"), "var x =document.getElementById(foo)");
83  
-    equal(transform("var x = $(foo)"), "var x = document.getElementById(foo)");
  79
+    equal(transform("$(foo)"), "document.querySelector(foo)");
  80
+    equal(transform("var x=$(foo)"), "var x=document.querySelector(foo)");
  81
+    equal(transform("var x= $(foo)"), "var x= document.querySelector(foo)");
  82
+    equal(transform("var x =$(foo)"), "var x =document.querySelector(foo)");
  83
+    equal(transform("var x = $(foo)"), "var x = document.querySelector(foo)");
84 84
 
85 85
 });
86 86
 

0 notes on commit d52158c

Please sign in to comment.
Something went wrong with that request. Please try again.