Родитель
6b58739538
Коммит
97fb6ddde4
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
14
package.json
14
package.json
|
@ -26,22 +26,22 @@
|
|||
"parser": "@typescript-eslint/parser",
|
||||
"extends": [
|
||||
"plugin:github/browser",
|
||||
"plugin:github/es6",
|
||||
"plugin:github/recommended",
|
||||
"plugin:github/typescript"
|
||||
]
|
||||
},
|
||||
"devDependencies": {
|
||||
"@github/prettier-config": "0.0.4",
|
||||
"chai": "^4.2.0",
|
||||
"eslint": "^6.8.0",
|
||||
"eslint-plugin-github": "^3.4.1",
|
||||
"karma": "^5.0.1",
|
||||
"eslint": "^7.9.0",
|
||||
"eslint-plugin-github": "^4.1.1",
|
||||
"karma": "^5.2.2",
|
||||
"karma-chai": "^0.1.0",
|
||||
"karma-chrome-launcher": "^3.1.0",
|
||||
"karma-mocha": "^1.3.0",
|
||||
"karma-mocha": "^2.0.1",
|
||||
"karma-mocha-reporter": "^2.2.5",
|
||||
"mocha": "^7.1.1",
|
||||
"typescript": "^3.8.3"
|
||||
"mocha": "^8.1.3",
|
||||
"typescript": "^4.0.2"
|
||||
},
|
||||
"dependencies": {},
|
||||
"eslintIgnore": [
|
||||
|
|
10
src/index.ts
10
src/index.ts
|
@ -1,14 +1,14 @@
|
|||
// Last submitted HTMLFormElement that will cause a browser navigation.
|
||||
let submittedForm: HTMLFormElement | null = null
|
||||
|
||||
function shouldResumeField(field: HTMLInputElement | HTMLTextAreaElement) {
|
||||
return field.id && field.value !== field.defaultValue && field.form !== submittedForm
|
||||
function shouldResumeField(field: HTMLInputElement | HTMLTextAreaElement): boolean {
|
||||
return !!field.id && field.value !== field.defaultValue && field.form !== submittedForm
|
||||
}
|
||||
|
||||
type PersistOptions = {selector?: string; keyPrefix?: string}
|
||||
|
||||
// Write all ids and values of the selected fields on the page into sessionStorage.
|
||||
export function persistResumableFields(id: string, options?: PersistOptions) {
|
||||
export function persistResumableFields(id: string, options?: PersistOptions): void {
|
||||
const selector = options?.selector ?? '.js-session-resumable'
|
||||
const keyPrefix = options?.keyPrefix ?? 'session-resume:'
|
||||
const key = `${keyPrefix}${id}`
|
||||
|
@ -33,7 +33,7 @@ export function persistResumableFields(id: string, options?: PersistOptions) {
|
|||
|
||||
type RestoreOptions = {keyPrefix?: string}
|
||||
|
||||
export function restoreResumableFields(id: string, options?: RestoreOptions) {
|
||||
export function restoreResumableFields(id: string, options?: RestoreOptions): void {
|
||||
const keyPrefix = options?.keyPrefix ?? 'session-resume:'
|
||||
const key = `${keyPrefix}${id}`
|
||||
let fields
|
||||
|
@ -81,7 +81,7 @@ export function restoreResumableFields(id: string, options?: RestoreOptions) {
|
|||
}, 0)
|
||||
}
|
||||
|
||||
export function setForm(event: Event) {
|
||||
export function setForm(event: Event): void {
|
||||
submittedForm = event.target as HTMLFormElement
|
||||
|
||||
setTimeout(function () {
|
||||
|
|
Загрузка…
Ссылка в новой задаче