Closed Bug 703342 Opened 13 years ago Closed 7 years ago

Make $0 available to Scratchpad

Categories

(DevTools Graveyard :: Scratchpad, defect, P3)

defect

Tracking

(Not tracked)

RESOLVED WONTFIX

People

(Reporter: dangoor, Assigned: cedricv)

Details

If you're trying out some DOM manipulation code in Scratchpad, it would be handy to have $0 available as you do in the console for accessing the currently selected element in the highlighter.
I have a hack for this. In a Browser scratchpad, run: this.__defineGetter__("$0", function() { return InspectorUI.selection; }); now $0 behaves as a getter. You can save this file and re-open and re-run it to achieve this. I've resisted adding shortcuts to the scratchpad itself because code written there should be copyable to your script files to run. $0 is a potential exception though so I won't close this, but I do think providing clues for people to implement what they need for their own workflows.
Perhaps a new option in the Environment menu that added the web console helpers (and more?) would make sense?
I think importing $0 by default in a content Scratchpad makes sense. Principle of least surprise applies (most if not all code snippets working in the web console should work in a scratchpad imho) Does Sandbox.importFunction works with getters? And the getter should also check that the InspectorUI.selection is from the current tab - since a content scratchpad runs on that tab.
OS: Mac OS X → All
Hardware: x86 → All
Assignee: nobody → cedricv
Component: Developer Tools → Developer Tools: Scratchpad
QA Contact: developer.tools → developer.tools.scratchpad
Mihai suggests implementing a separate environment. Filter on BLACKEAGLE!
Priority: -- → P3
Not touched in the past 5 years. No user complaints. Closing.
Status: NEW → RESOLVED
Closed: 7 years ago
Resolution: --- → WONTFIX
Product: Firefox → DevTools
Product: DevTools → DevTools Graveyard
You need to log in before you can comment on or make changes to this bug.