Skip to content

Commit

Permalink
feat(wasm): Added GetHtmlAttribute for an Element on Wasm.
Browse files Browse the repository at this point in the history
  • Loading branch information
carldebilly committed Aug 3, 2020
1 parent bac4731 commit 92b0489
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,14 @@ public static void SetHtmlAttribute(this UIElement element, params (string name,
WindowManagerInterop.SetAttributes(element.HtmlId, attributes);
}

/// <summary>
/// Get the HTML attribute value of an element
/// </summary>
public static string GetHtmlAttribute(this UIElement element, string name)
{
return WindowManagerInterop.GetAttribute(element.HtmlId, name);
}

/// <summary>
/// Clear/remove a HTML attribute from an element.
/// </summary>
Expand Down
9 changes: 9 additions & 0 deletions src/Uno.UI/UI/Xaml/WindowManagerInterop.wasm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -658,6 +658,15 @@ private struct WindowManagerSetAttributeParams

#endregion

#region GetAttribute
internal static string GetAttribute(IntPtr htmlId, string name)
{
var command = "Uno.UI.WindowManager.current.setAttributes(\"" + htmlId + "\", \"" + name + "\");";

return WebAssemblyRuntime.InvokeJS(command);
}
#endregion

#region ClearAttribute
internal static void RemoveAttribute(IntPtr htmlId, string name)
{
Expand Down

0 comments on commit 92b0489

Please sign in to comment.