diff --git a/src/Blazored.SessionStorage/BrowserStorageProvider.cs b/src/Blazored.SessionStorage/BrowserStorageProvider.cs index 883c4bb..1576b36 100644 --- a/src/Blazored.SessionStorage/BrowserStorageProvider.cs +++ b/src/Blazored.SessionStorage/BrowserStorageProvider.cs @@ -24,7 +24,7 @@ public async ValueTask ClearAsync(CancellationToken cancellationToken = default) { try { - await _jSRuntime.InvokeVoidAsync("sessionStorage.clear", cancellationToken); + await _jSRuntime.InvokeVoidAsync("window.sessionStorage.clear", cancellationToken); } catch (Exception exception) { @@ -41,7 +41,7 @@ public async ValueTask GetItemAsync(string key, CancellationToken cancel { try { - return await _jSRuntime.InvokeAsync("sessionStorage.getItem", cancellationToken, key); + return await _jSRuntime.InvokeAsync("window.sessionStorage.getItem", cancellationToken, key); } catch (Exception exception) { @@ -58,7 +58,7 @@ public async ValueTask KeyAsync(int index, CancellationToken cancellatio { try { - return await _jSRuntime.InvokeAsync("sessionStorage.key", cancellationToken, index); + return await _jSRuntime.InvokeAsync("window.sessionStorage.key", cancellationToken, index); } catch (Exception exception) { @@ -92,7 +92,7 @@ public async ValueTask ContainKeyAsync(string key, CancellationToken cance { try { - return await _jSRuntime.InvokeAsync("sessionStorage.hasOwnProperty", cancellationToken, key); + return await _jSRuntime.InvokeAsync("window.sessionStorage.hasOwnProperty", cancellationToken, key); } catch (Exception exception) { @@ -109,7 +109,7 @@ public async ValueTask LengthAsync(CancellationToken cancellationToken = de { try { - return await _jSRuntime.InvokeAsync("eval", cancellationToken, "sessionStorage.length"); + return await _jSRuntime.InvokeAsync("eval", cancellationToken, "window.sessionStorage.length"); } catch (Exception exception) { @@ -126,7 +126,7 @@ public async ValueTask RemoveItemAsync(string key, CancellationToken cancellatio { try { - await _jSRuntime.InvokeVoidAsync("sessionStorage.removeItem", cancellationToken, key); + await _jSRuntime.InvokeVoidAsync("window.sessionStorage.removeItem", cancellationToken, key); } catch (Exception exception) { @@ -145,7 +145,7 @@ public async ValueTask RemoveItemsAsync(IEnumerable keys, CancellationTo { foreach (var key in keys) { - await _jSRuntime.InvokeVoidAsync("sessionStorage.removeItem", cancellationToken, key); + await _jSRuntime.InvokeVoidAsync("window.sessionStorage.removeItem", cancellationToken, key); } } catch (Exception exception) @@ -163,7 +163,7 @@ public async ValueTask SetItemAsync(string key, string data, CancellationToken c { try { - await _jSRuntime.InvokeVoidAsync("sessionStorage.setItem", cancellationToken, key, data); + await _jSRuntime.InvokeVoidAsync("window.sessionStorage.setItem", cancellationToken, key, data); } catch (Exception exception) { @@ -181,7 +181,7 @@ public void Clear() CheckForInProcessRuntime(); try { - _jSInProcessRuntime.InvokeVoid("sessionStorage.clear"); + _jSInProcessRuntime.InvokeVoid("window.sessionStorage.clear"); } catch (Exception exception) { @@ -199,7 +199,7 @@ public string GetItem(string key) CheckForInProcessRuntime(); try { - return _jSInProcessRuntime.Invoke("sessionStorage.getItem", key); + return _jSInProcessRuntime.Invoke("window.sessionStorage.getItem", key); } catch (Exception exception) { @@ -217,7 +217,7 @@ public string Key(int index) CheckForInProcessRuntime(); try { - return _jSInProcessRuntime.Invoke("sessionStorage.key", index); + return _jSInProcessRuntime.Invoke("window.sessionStorage.key", index); } catch (Exception exception) { @@ -253,7 +253,7 @@ public bool ContainKey(string key) CheckForInProcessRuntime(); try { - return _jSInProcessRuntime.Invoke("sessionStorage.hasOwnProperty", key); + return _jSInProcessRuntime.Invoke("window.sessionStorage.hasOwnProperty", key); } catch (Exception exception) { @@ -271,7 +271,7 @@ public int Length() CheckForInProcessRuntime(); try { - return _jSInProcessRuntime.Invoke("eval", "sessionStorage.length"); + return _jSInProcessRuntime.Invoke("eval", "window.sessionStorage.length"); } catch (Exception exception) { @@ -289,7 +289,7 @@ public void RemoveItem(string key) CheckForInProcessRuntime(); try { - _jSInProcessRuntime.InvokeVoid("sessionStorage.removeItem", key); + _jSInProcessRuntime.InvokeVoid("window.sessionStorage.removeItem", key); } catch (Exception exception) { @@ -309,7 +309,7 @@ public void RemoveItems(IEnumerable keys) { foreach (var key in keys) { - _jSInProcessRuntime.InvokeVoid("sessionStorage.removeItem", key); + _jSInProcessRuntime.InvokeVoid("window.sessionStorage.removeItem", key); } } catch (Exception exception) @@ -328,7 +328,7 @@ public void SetItem(string key, string data) CheckForInProcessRuntime(); try { - _jSInProcessRuntime.InvokeVoid("sessionStorage.setItem", key, data); + _jSInProcessRuntime.InvokeVoid("window.sessionStorage.setItem", key, data); } catch (Exception exception) {