github: comment will be remaining even if reload browser, why?

前端 未结 1 948
温柔的废话
温柔的废话 2021-01-12 04:00

When I write a comment with github\'s issue page, I noticed that the comment body remains even if I reload the browser.

I have checked localStorage, session

1条回答
  •  太阳男子
    2021-01-12 04:39

    They are using SessionStorage to do this:

    On Page Leave:

    1. select all of the input fields with .js-session-resumable as selector
    2. put {id, value} pair of inputs in an array
    3. put it in SessionStorage as session-resume:/current/page/path

    On Page Load:

    1. check if there are any values with session-resume:/current/page/path key in SessionStorage
    2. if yes, update values of inputs and remove this record from SessionStorage

    Note: If you write a comment in a page (without submitting it) and go to another page, then you can see your comment saved in SessionStorage.

    0 讨论(0)
提交回复
热议问题