Aspnetcore: [Preview 8] Blazor: @ref:suppressField leads to a JavaScript DOMException

Created on 14 Aug 2019  路  2Comments  路  Source: dotnet/aspnetcore

Describe the bug

A html element with a @ref:suppressField="btn" leads to a JavaScript exception:

Uncaught (in promise) DOMException: Failed to execute 'setAttribute' on 'Element': '@ref:suppressfield' is not a valid attribute name.

To Reproduce

@page "/counter"

<button @ref:suppressField="btn" @onclick="IncrementCount">Click me</button>

@code {
    ElementReference btn;
    void IncrementCount()
    {
        var test = btn.ToString();
    }
}

Screenshots

image

Additional context

Add any other context about the problem here.
Include the output of dotnet --info

.NET Core SDK (reflecting any global.json):
 Version:   3.0.100-preview8-013656
 Commit:    8bf06ffc8d

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.17134
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\3.0.100-preview8-013656\

Host (useful for support):
  Version: 3.0.0-preview8-28405-07
  Commit:  d01b2fb7bc

.NET Core SDKs installed:
  2.1.202 [C:\Program Files\dotnet\sdk]
  2.1.508 [C:\Program Files\dotnet\sdk]
  2.1.800 [C:\Program Files\dotnet\sdk]
  2.2.103 [C:\Program Files\dotnet\sdk]
  3.0.100-preview8-013656 [C:\Program Files\dotnet\sdk]

.NET Core runtimes installed:
  Microsoft.AspNetCore.All 2.1.12 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.2.1 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.1.12 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.2.1 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.0.0-preview8.19405.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 2.0.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.12 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.2.1 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.0.0-preview8-28405-07 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 3.0.0-preview8-28405-07 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Duplicate area-blazor bug

Most helpful comment

We expect ref and ref:suppressField separately. This should be a compiler error. Here's how we would expect users to write this:

```
@page "/counter"

@code {
ElementReference btn;
void IncrementCount()
{
var test = btn.ToString();
}
}

All 2 comments

We expect ref and ref:suppressField separately. This should be a compiler error. Here's how we would expect users to write this:

```
@page "/counter"

@code {
ElementReference btn;
void IncrementCount()
{
var test = btn.ToString();
}
}

Closing this as we have a separate issue tracking the work which is left here: #13137

Was this page helpful?
0 / 5 - 0 ratings