-
Notifications
You must be signed in to change notification settings - Fork 10
core-localstorage defaulting logic has bad null
test
#5
Comments
null
testnull
test
fwiw, I think if (this.value != null) { is equivalent to if (this.value !== null && this.value !== undefined) { ... I tend to use the former as it's a bit more concise. |
(wanted to double check this, so found the relevant spec for == https://people.mozilla.org/~jorendorff/es6-draft.html#sec-abstract-equality-comparison) |
You are right about that, and it's definitely more concise. OTOH, it's one of the most confusing bits of Javascript: This is the main reason we prefer |
Depending on my mood, I'm waffling between brevity and clarity. We could make a |
Thanks guys! You're fixing bugs faster than I'm able to isolate them from my app ;) |
If there no value is in localstorage, core-localstorage tries not to create one unless it looks like the user has set a real value. However, the conditional is written such that a value of
undefined
does get saved.https://github.com/Polymer/core-localstorage/blob/master/core-localstorage.html#L100
Should probably be:
if (this.value !== null && this.value !== undefined) {
The text was updated successfully, but these errors were encountered: