session-resume
session-resume copied to clipboard
Support `fields:` option to skip selector query
By default, calls to persistResumableFields() will query the
document for elements with the (default or provided) selector:.
This commit adds support for specifying a fields: option, collecting
NodeList or Node[], to provide the function with a set of <input>
or <textarea> elements to persist. Providing fields: would make
selector: redundant, and vice-versa.
const myFields = document.querySelector("[data-persisted-field]")
// ...
// pass the `NodeList` directly
persistResumableFields(getPageID(), { fields: myFields })
// pass an array of `Node` instances
persistResumableFields(getPageID(), { fields: Array.from(myFields) })