ant-design-blazor/components/core/Extensions/ElementReferenceExtensions.cs
James Yeung d2f95b2a07
fix(module: Core): Remove the event listener when the event listener service is disposed (#2738)
* fix(module: Core): Remove the event listener when the component is disaposed

* fix DomEventKey
2022-09-26 10:11:04 +08:00

33 lines
912 B
C#

// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.AspNetCore.Components;
namespace AntDesign.Core.Extensions
{
public static class ElementReferenceExtensions
{
public static string GetSelector(this ElementReference? elementReference)
{
return elementReference?.GetSelector();
}
public static string GetSelector(this ElementReference elementReference)
{
#if NET5_0_OR_GREATER
if (elementReference.Context is null)
{
return null;
}
return $"[_bl_{elementReference.Id}]";
#endif
return $"[_bl_{elementReference.Id}]";
}
}
}