Skip to content

Commit

Permalink
feat: handle localstorage-set attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
frankpagan committed Jan 13, 2024
1 parent 2da2bcd commit 663ce65
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,13 @@ const CoCreateEvents = {
let values
if (prefix === 'localstorage') {
let key = element.getAttribute('localstorage-get')
if (key)
if (key) {
values = localStorage.getItem(key)
} else if (key = element.getAttribute('localstorage-set')) {
values = await element.getValue()
if (values)
localStorage.setItem(key, values)
}
if (!key || !values)
return
} else
Expand Down

0 comments on commit 663ce65

Please sign in to comment.