Skip to content
This repository has been archived by the owner on Feb 14, 2018. It is now read-only.

Pages Named "Clear" Cause Weird Behavior #438

Closed
michaelarthurcaulfield opened this issue Dec 7, 2014 · 5 comments
Closed

Pages Named "Clear" Cause Weird Behavior #438

michaelarthurcaulfield opened this issue Dec 7, 2014 · 5 comments

Comments

@michaelarthurcaulfield
Copy link

To duplicate, create a page named "Clear". It will freeze in this position:

screenshot 2014-12-06 at 10 03 02 pm

Not hard to work around, but mentioning in case strings are being evaluated in ways they shouldn't be.

DIscovered by student in my class writing page on the app Clear.

@paul90
Copy link
Contributor

paul90 commented Dec 7, 2014

will also freeze with other localStorage keywords

@WardCunningham
Copy link
Owner

Good catch. But @paul90, how did you even think to suspect this? I've not seen this behavior mentioned in any localStorage documentation.

Many thanks to @michaelarthurcaulfield and his students.

@paul90
Copy link
Contributor

paul90 commented Dec 7, 2014

Not seen it mentioned anywhere either, but there are some hints. At least one question points to DOM Storage guide

Note: Although the values can be set and read using the standard JavaScript property access method, using the getItem and setItem methods is recommended.

I also noticed that trying to follow the link to 'clear' also empties localstorage, which is a bit of a give away. Although the error in the Firefox console points to JSON.parse.

@WardCunningham
Copy link
Owner

I'm reminded of little Bobby Tables. http://xkcd.com/327/

@paul90
Copy link
Contributor

paul90 commented Dec 7, 2014

Of course localStorage["clear"] is the same as localStorage.clear which clears localStorage, which is a wee bit of a problem.

Other than the recommendation quoted above, most of the JavaScript texts seem to freely mix the use of setItem/getItem, square brackets, and the dot notation with not a word of warning of the trap that is awaiting.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants