mavo
mavo copied to clipboard
Add support for boolean storage params
This would allow authors to specify, e.g., mv-storage-private
instead of more verbose mv-storage-private="true"
when working with the GitHub backend. AFAIK, instead of true
we can use any truthy value in this case.
To be honest, when trying the new feature of the GitHub backend (to document it), my first attempt was to specify the boolean mv-storage-private
attribute to make it work. But I failed. I had to crawl through the source code to remind myself how the storage params work under the hood.
If I'm not mistaken, to make it work, we can replace this.element.getAttribute(n)
in this line
https://github.com/mavoweb/mavo/blob/d6b7b3b2c39fa6bef832031e73d15e5b1b0e73cd/src/mavo.js#L453
with this.element.getAttribute(n) || true
.
Why not this.element.getAttribute(n) ?? true
? Because in some DOM implementations, if the specified attribute does not exist on the specified element, getAttribute()
will return an empty string instead of null
.
Might we want to consider eg mv-storage-options="private, encrypted, other-boolean-attributes"
On Oct 7, 2022, 12:47 PM, at 12:47 PM, Dmitry Sharabin @.***> wrote:
This would allow authors to specify, e.g.,
mv-storage-private
instead of more verbosemv-storage-private="true"
when working with the GitHub backend. AFAIK, instead oftrue
we can use any truthy value in this case.To be honest, when trying the new feature of the GitHub backend (to document it), my first attempt was to specify the boolean
mv-storage-private
attribute to make it work. But I failed. I had to crawl through the source code to remind myself how the storage params work under the hood.If I'm not mistaken, to make it work, we can replace
this.element.getAttribute(n)
in this line https://github.com/mavoweb/mavo/blob/d6b7b3b2c39fa6bef832031e73d15e5b1b0e73cd/src/mavo.js#L453with
this.element.getAttribute(n) || true
.Why not
this.element.getAttribute(n) ?? true
? Because in some DOM implementations, if the specified attribute does not exist on the specified element,getAttribute()
will return an empty string instead ofnull
.-- Reply to this email directly or view it on GitHub: https://github.com/mavoweb/mavo/issues/928 You are receiving this because you are subscribed to this thread.
Message ID: @.***>
Might we want to consider eg mv-storage-options="private, encrypted, other-boolean-attributes"
I'm afraid in that case, we might lose the options
storage param. Btw, it’s already in use in the Firebase Firestore plugin.
I'd rather leave them independent, for a number of reasons.