exponentiation operator (**) causes pretty print option in Dev Tools to fail.
Reported by
crj.wal...@gmail.com,
Nov 22 2016
|
|||||||
Issue description
UserAgent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.99 Safari/537.36
Steps to reproduce the problem:
1. Visit a website that uses the exponentiation operator (**) in a JS file.
2. Open Dev Tools.
3. Within Dev Tools, inspect the JS file that contains "**".
4. Press {} to "pretty print" the file.
What is the expected behavior?
A new tab in Dev Tools should show a reformatted version of the JS file.
What went wrong?
The new tab opens, but it does not show a reformatted version of the JS file.
I have seen two behaviors:
a) Sometimes the tab is empty.
b) Sometimes the tab show the entire file with no reformatting.
Neither behavior matches the expected results.
Did this work before? No
Chrome version: 54.0.2840.99 Channel: stable
OS Version: 6.1 (Windows 7, Windows Server 2008 R2)
Flash Version: Shockwave Flash 23.0 r0
,
Nov 22 2016
,
Nov 23 2016
The problem also manifests itself with inline javascript inside an HTML file. I am attempting to upload two html files. One file uses "Math.pow"; the other file uses "**". The file that uses "**" can not be reformatted using pretty print in Dev Tools.
,
Nov 23 2016
,
Nov 24 2016
Current source formatter supports ECMAScript 6 while exponentiation operator (**) is a ECMAScript 7 feature. @lushnikov, is there any plan to support es7 or I can just add this and start moving es7?
,
Dec 1 2016
,
Dec 2 2016
@Ahmet: we rely on acorn for js pretty-printing: https://github.com/ternjs/acorn As far as the project supports particular es7 feature, feel free to submit patch for pretty-print!
,
Dec 2 2016
It looks to me like support for the exponentiation operator was added to acorn back in January of this year.
,
Dec 5 2016
,
Dec 6 2016
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/1f78e2d88c8ad8d25e52176c4b76481b383625cb commit 1f78e2d88c8ad8d25e52176c4b76481b383625cb Author: allada <allada@chromium.org> Date: Tue Dec 06 00:54:22 2016 [Devtools] Update Acorn This patch simply updates acorn to 4.0.3. NOPRESUBMIT=true R=lushnikov BUG= 667894 Review-Url: https://codereview.chromium.org/2556503002 Cr-Commit-Position: refs/heads/master@{#436474} [modify] https://crrev.com/1f78e2d88c8ad8d25e52176c4b76481b383625cb/third_party/WebKit/Source/devtools/front_end/formatter_worker/acorn/acorn.js
,
Dec 7 2016
,
Dec 8 2016
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/818678e082ef6f4de7dd31eacc0b2502d7263682 commit 818678e082ef6f4de7dd31eacc0b2502d7263682 Author: allada <allada@chromium.org> Date: Thu Dec 08 02:22:01 2016 [Devtools] Upgrade acorn services to use ECMAScript7 Allows acorn to use ECMAScript7 for things like prettyprint. R=lushnikov BUG= 667894 Review-Url: https://codereview.chromium.org/2560963002 Cr-Commit-Position: refs/heads/master@{#437152} [modify] https://crrev.com/818678e082ef6f4de7dd31eacc0b2502d7263682/third_party/WebKit/LayoutTests/inspector/sources/pretty-print-javascript-7-expected.txt [modify] https://crrev.com/818678e082ef6f4de7dd31eacc0b2502d7263682/third_party/WebKit/LayoutTests/inspector/sources/pretty-print-javascript-7.html [modify] https://crrev.com/818678e082ef6f4de7dd31eacc0b2502d7263682/third_party/WebKit/Source/devtools/front_end/formatter_worker/AcornTokenizer.js [modify] https://crrev.com/818678e082ef6f4de7dd31eacc0b2502d7263682/third_party/WebKit/Source/devtools/front_end/formatter_worker/FormatterWorker.js [modify] https://crrev.com/818678e082ef6f4de7dd31eacc0b2502d7263682/third_party/WebKit/Source/devtools/front_end/formatter_worker/JavaScriptFormatter.js
,
Dec 11 2016
I just tested with Chrome Canary build 57.0.2948.0. Pretty Print now works as expected on files containing "**". Thank you.
,
Dec 12 2016
|
|||||||
►
Sign in to add a comment |
|||||||
Comment 1 by crj.wal...@gmail.com
, Nov 22 2016// e.g. consider this one line JS file: (function(){console.log("hello world 3x3="+3**2);})(); //It should get reformatted (via pretty print) to look something like this: (function() { console.log("hello world 3x3=" + 3 ** 2); })();