akhodakivskiy / VimFx

Vim keyboard shortcuts for Firefox
https://addons.mozilla.org/firefox/addon/vimfx
Other
1.42k stars 174 forks source link

Uncaught TypeError: Array.map is not a function #991

Closed Ace-Who closed 1 year ago

Ace-Who commented 1 year ago

Firefox Nightly 110.0a1, Windows 10 1903 x64

Trying to learn custom commands. When I run the following code:

Array.map(document.querySelectorAll('command'), command => `${command.id}: ${command.getAttribute('oncommand')}`).join('\n')

in the Browser Console, it reports:

Uncaught TypeError: Array.map is not a function
    <anonymous> debugger eval code:1
    getEvalResult resource://devtools/server/actors/webconsole/eval-with-debugger.js:242
    evalWithDebugger resource://devtools/server/actors/webconsole/eval-with-debugger.js:166
    evaluateJS resource://devtools/server/actors/webconsole.js:983
    evaluateJSAsync resource://devtools/server/actors/webconsole.js:874
    makeInfallible resource://devtools/shared/ThreadSafeDevToolsUtils.js:103
debugger eval code:1:7
girst commented 1 year ago

On Fri, Jan 06, 2023 at 01:22:42PM -0800, Ace-Who wrote:

Array.map(document.querySelectorAll('command'), command => ${command.id}: ${command.getAttribute('oncommand')}).join('\n')

it would have been great if you had mentioned that this is snippet from the vimfx wiki. because this looked like a general javascript question, and the vimfx bug tracker is not really the right place for that.

but since it's in our wiki, it is relevant. :)

a while ago, Array.map was deprecated and then removed, in favour of Array.prototype.map(). if that works, please fix it in the wiki, thanks!

lydell commented 1 year ago

It should be possible to just replace Array.map with Array.from.

Ace-Who commented 1 year ago

@girst Got it, thank you!

Ace-Who commented 1 year ago

It should be possible to just replace Array.map with Array.from.

That works, thank you!