session-resume icon indicating copy to clipboard operation
session-resume copied to clipboard

Support `fields:` option to skip selector query

Open seanpdoyle opened this issue 4 years ago • 0 comments

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) })

seanpdoyle avatar Dec 12 '21 01:12 seanpdoyle