dotnet / interactive

.NET Interactive combines the power of .NET with many other languages to create notebooks, REPLs, and embedded coding experiences. Share code, explore data, write, and learn across your apps in ways you couldn't before.
MIT License
2.88k stars 382 forks source link

Javascript void no longer works with VS Code error "unable to open void(0)" #2758

Closed marckruzik closed 1 year ago

marckruzik commented 1 year ago

Describe the bug

Javascript code often uses "void(0)" to have a blank link, with no special behaviour from the browser, usually with an associated onClick event. I just updated Polyglot Notebook (EDIT: and VS Code), and now all my "void(0)" link are producing errors.

Here is how to reproduce the bug. In a html cell, write the following:

<a href="javascript:void(0);" onClick="alert('hello')">Click on me</a>

Click on the link.

Visual Studio displays an error:

2023_02_21-18h44m49s-● folder_same dib - notebook - Visual Studio Code

Is that a bug? Or is "void(0)" a bad practice which should no longer be used? If so, how to get the intended behavior?

Please complete the following:

Which version of .NET Interactive are you using? (In a notebook, run the #!about magic command. ):

AssemblyVersion BuildDate AssemblyInformationalVersion AssemblyName
1.0.0.0 2023-02-21T14:04:30.5659994Z 1.0.410202+fce65bd557e21539f9eb0ba3f9c6a64300386c94 Microsoft.DotNet.Interactive.App

EDIT: VS Code v1.75.1

jonsequitur commented 1 year ago

The behavior change is in VS Code and is outside the scope of the Polyglot Notebooks extension.

marckruzik commented 1 year ago

As a workaround (at least for my own scripts), I can replace the links by buttons. Before:

<a href="javascript:void(0);" onClick="MyFunction();">text</a>

After:

<button onClick="MyFunction();">text</button>

The behavior change is in VS Code and is outside the scope of the Polyglot Notebooks extension.

Ok. I am closing the issue for now. We will see if the problem arises in some extension.