Allow $0 in spippets
Reported by
ovkadu...@gmail.com,
Jan 11 2017
|
|||
Issue description
UserAgent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2978.0 Safari/537.36
Steps to reproduce the problem:
1. Go to Elements panel. Select any element
2. Create a snippet
3. Paste console.log($0);
4. Select the code.
5. Right click -> Evaluate in console
6. Console says "VM203:1 Uncaught ReferenceError: $0 is not defined"
What is the expected behavior?
So if it's possible to run script from inside console, I would love to have ability to use those $0 (and others) variables.
One of useful example:
$($0).click(function () {
console.log("button is clicked");
);
What went wrong?
It doesn't allow $0 in snippets.
Did this work before? N/A
Chrome version: 57.0.2978.0 Channel: canary
OS Version: 10.0
Flash Version: Shockwave Flash 24.0 r0
,
Jan 18 2017
Just wondering, why do you use select the code -> evaluate in console instead of "Ctrl + Enter" or just play button in bottom right corner of snippet source?
,
Jan 18 2017
,
Jan 18 2017
>>>Just wondering, why do you use select the code -> evaluate in console instead of "Ctrl + Enter" or just play button in bottom right corner of snippet source?
Running via "evaluate in console" gives access to the lexical scope variables.
So I might want to stop the code inside a function and run in the snippets something like this:
$("#btn").click(function () {
console.log("Current state of the internal internal is: " + internal1);
);
The function might look like this:
function () {
var internal1 = 45;
// here I can set stop the code execution in order to run "evaluate in console".
return {
setInternal: function (val) {
internal1 = val;
},
getComputedInternal: function () {
return internal1 * 2;
}
}
}
,
Jan 18 2017
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/57b9ce859ef097374f8ed46df3ffa66eefa0f243 commit 57b9ce859ef097374f8ed46df3ffa66eefa0f243 Author: kozyatinskiy <kozyatinskiy@chromium.org> Date: Wed Jan 18 23:30:30 2017 [DevTools] use command line API during selection evaluation in console BUG= chromium:680116 R=einbinder@chromium.org,dgozman@chromium.org Review-Url: https://codereview.chromium.org/2645723002 Cr-Commit-Position: refs/heads/master@{#444543} [modify] https://crrev.com/57b9ce859ef097374f8ed46df3ffa66eefa0f243/third_party/WebKit/Source/devtools/front_end/sdk/ConsoleModel.js [modify] https://crrev.com/57b9ce859ef097374f8ed46df3ffa66eefa0f243/third_party/WebKit/Source/devtools/front_end/sources/SourcesPanel.js
,
Jan 18 2017
I see, thanks for description!
,
Jan 20 2017
It works. Thank you!
,
Jan 26 2017
|
|||
►
Sign in to add a comment |
|||
Comment 1 by alph@chromium.org
, Jan 11 2017Owner: kozyatinskiy@chromium.org
Status: Assigned (was: Unconfirmed)