Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Merge pull request #46 from sroussey/issue-5764

Issue 5764
  • Loading branch information...
commit 7579ab2475138688ebddab05653fb9073db9eef2 2 parents 62cfb15 + 0f8b98d
Jan Odvarko authored October 03, 2012
4  extension/content/firebug/chrome/reps.js
@@ -701,7 +701,6 @@ FirebugReps.Arr = domplate(Firebug.Rep,
701 701
     },
702 702
 
703 703
     // http://code.google.com/p/fbug/issues/detail?id=874
704  
-    // BEGIN Yahoo BSD Source (modified here)  YAHOO.lang.isArray, YUI 2.2.2 June 2007
705 704
     isArray: function(obj, win)
706 705
     {
707 706
         win = win || window;
@@ -746,8 +745,7 @@ FirebugReps.Arr = domplate(Firebug.Rep,
746 745
 
747 746
         return false;
748 747
     },
749  
-    // END Yahoo BSD SOURCE See license below.
750  
-
  748
+    
751 749
     getTitle: function(object, context)
752 750
     {
753 751
         return "[" + object.length + "]";
32  extension/content/firebug/console/commandLine.js
@@ -1049,14 +1049,38 @@ Firebug.CommandLine.CommandHandler = Obj.extend(Object,
1049 1049
 
1050 1050
 function FirebugCommandLineAPI(context)
1051 1051
 {
1052  
-    this.$ = function(id)  // returns unwrapped elements from the page
  1052
+    this.$ = function(selector, start)  // returns unwrapped elements from the page
1053 1053
     {
1054  
-        return Wrapper.unwrapObject(context.baseWindow.document).getElementById(id);
  1054
+        var result;
  1055
+        if (start && start.querySelector && (
  1056
+                start.nodeType == Node.ELEMENT_NODE ||
  1057
+                start.nodeType == Node.DOCUMENT_NODE ||
  1058
+                start.nodeType == Node.DOCUMENT_FRAGMENT_NODE)) {
  1059
+            return start.querySelector(selector);
  1060
+        }
  1061
+        
  1062
+        result = context.baseWindow.document.querySelector(selector);
  1063
+        if (result == null && (selector||"")[0] !== "#")
  1064
+        {
  1065
+            if (context.baseWindow.document.getElementById(selector))
  1066
+            {
  1067
+                // This should be removed in the next minor (non-bugfix) version
  1068
+                var msg = Locale.$STRF("warning.dollar_change", [selector]);
  1069
+                Firebug.Console.log(msg, context, "warn");
  1070
+                result = null;
  1071
+            }
  1072
+        }
  1073
+        return result;
1055 1074
     };
1056 1075
 
1057  
-    this.$$ = function(selector) // returns unwrapped elements from the page
  1076
+    this.$$ = function(selector, start) // returns unwrapped elements from the page
1058 1077
     {
1059  
-        var result = Wrapper.unwrapObject(context.baseWindow.document).querySelectorAll(selector);
  1078
+        var result;
  1079
+        if (start && start.querySelectorAll && (start.nodeType == Node.ELEMENT_NODE || start.nodeType == Node.DOCUMENT_NODE || start.nodeType == Node.DOCUMENT_FRAGMENT_NODE)) {
  1080
+            result = start.querySelectorAll(selector);
  1081
+        }
  1082
+        else
  1083
+            result = context.baseWindow.document.querySelectorAll(selector);
1060 1084
         return Arr.cloneArray(result);
1061 1085
     };
1062 1086
 
1  extension/locale/en-US/firebug.properties
@@ -1367,6 +1367,7 @@ confirmation.Edit_CSS_Source=Your existing CSS edits will be discarded.\nAre you
1367 1367
 # Console messages
1368 1368
 warning.Console_must_be_enabled=Console must be enabled
1369 1369
 warning.Command_line_blocked?=Command line blocked?
  1370
+warning.dollar_change=The console command line function $() has changed meaning from $=getElementById(id) to $=querySelector(selector). You might try $("#%S") instead.
1370 1371
 message.Reload_to_activate_window_console=Reload to activate window console
1371 1372
 
1372 1373
 # LOCALIZATION NOTE (message.sourceNotAvailableFor, message.The_resource_from_this_URL_is_not_text):
4  tests/content/commandLine/4391/issue4391.html
@@ -16,11 +16,11 @@
16 16
 
17 17
 <ol>
18 18
 <li>Open Firebug and enable the Console panel.</li>
19  
-<li>Type following in to the command line: <code style="color:green">$("testElement")</code></li>
  19
+<li>Type following in to the command line: <code style="color:green">$("#testElement")</code></li>
20 20
 <li>Press Enter</li>
21 21
 <li>The result should be:
22 22
 <pre>
23  
->>> $("testElement")
  23
+>>> $("#testElement")
24 24
 &ltdiv id="testElement"&gt
25 25
 </pre>
26 26
 <li>Load jQuery by clicking this button:
4  tests/content/commandLine/api/api.html
@@ -19,11 +19,11 @@
19 19
     <i>'expression' -> 'result'</i>
20 20
 </li>
21 21
 <ol>
22  
-    <li><code>$("test1") -> &lt;div id="test1"&gt;</code></li>
  22
+    <li><code>$("#test1") -> &lt;div id="test1"&gt;</code></li>
23 23
     <li><code>$$(".a.c") -> [div.a, div.a]</code></li>
24 24
     <li><code>$x("html/body/span/div[1]") -> [div.test]</code></li>
25 25
     <li><code>dir(a) -> a: 10</code></li>
26  
-    <li><code>dirxml($('test3')) -> &lt;div id="test3"&gt;&lt;div&gt;&lt;/div&gt;&lt;/div&gt;</code></li>
  26
+    <li><code>dirxml($('#test3')) -> &lt;div id="test3"&gt;&lt;div&gt;&lt;/div&gt;&lt;/div&gt;</code></li>
27 27
     <li><code>keys(b) -> ["a", "name"]</code></li>
28 28
     <li><code>values(b) -> [7, "a"]</code></li>
29 29
     <li><code>table(a) -> Object Properties: 10 (tabular output)</code></li>
4  tests/content/commandLine/api/api.js
@@ -15,7 +15,7 @@ function runTest()
15 15
             // parameters.
16 16
 
17 17
             // \u00A0 == &nbsp; == #160 -> used by nodeTag domplate.
18  
-            tasks.push(executeAndVerify, "$(\"test1\")", "<div\u00A0id=\"test1\">",
  18
+            tasks.push(executeAndVerify, "$(\"#test1\")", "<div\u00A0id=\"test1\">",
19 19
                 "a", "objectLink objectLink-element");
20 20
 
21 21
             tasks.push(executeAndVerify, "$$(\".a.c\")", "[div.a, div.a]",
@@ -27,7 +27,7 @@ function runTest()
27 27
             tasks.push(executeAndVerify, "dir(a)", /\s*a\s*10\s*/,
28 28
                 "table", "domTable");
29 29
 
30  
-            tasks.push(executeAndVerify, "dirxml($('test3'))",
  30
+            tasks.push(executeAndVerify, "dirxml($('#test3'))",
31 31
                 "<div\u00A0id=\"test3\"><div></div></div>",
32 32
                 "div", "logRow logRow-dirxml");
33 33
 
2  tests/content/commandLine/api/cd.html
@@ -20,7 +20,7 @@
20 20
 </li>
21 21
 <ol>
22 22
     <li><code>cd(frames[0]) -> "Current window:", Window cdFrame.html]</code></li>
23  
-    <li><code>$("test-iframe-1") -> &lt;div id="test-iframe-1"&gt;</code></li>
  23
+    <li><code>$("#test-iframe-1") -> &lt;div id="test-iframe-1"&gt;</code></li>
24 24
     <li><code>cd(top) -> ["Current window:", Window cd.html]</code></li>
25 25
 </ol>
26 26
 </ol>
2  tests/content/commandLine/api/cd.js
@@ -13,7 +13,7 @@ function runTest()
13 13
                 "[\"Current window:\", Window cdFrame.html]",
14 14
                 "pre", "objectBox objectBox-array");
15 15
 
16  
-            tasks.push(FBTest.executeCommandAndVerify, "$(\"test-iframe-1\")",
  16
+            tasks.push(FBTest.executeCommandAndVerify, "$(\"#test-iframe-1\")",
17 17
                 /<div\s*id=\"test-iframe-1\">/,
18 18
                 "a", "objectLink objectLink-element");
19 19
 
4  tests/content/dom/attributes/attributes.js
@@ -19,11 +19,11 @@ function runTest()
19 19
             tasks.push(testDomPanel);
20 20
 
21 21
             tasks.push(executeCommandAndVerify,
22  
-                "$('testId').attributes", expectedValue,
  22
+                "$('#testId').attributes", expectedValue,
23 23
                 "a", "objectLink objectLink-NamedNodeMap");
24 24
 
25 25
             tasks.push(executeCommandAndVerify,
26  
-                "$('testId').attributes[0]",
  26
+                "$('#testId').attributes[0]",
27 27
                 expectedValue2,
28 28
                 "a", "objectLink objectLink-Attr");
29 29
 

0 notes on commit 7579ab2

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