Skip to content

Releases: FThompson/FormPersistence.js

New options: include and exclude elements with filter functions

01 Feb 19:12
17327ca
Compare
Choose a tag to compare

Added includeFilter and excludeFilter options to all functions:

  • includeFilter Define a whitelist filter function that inputs an element and outputs a Boolean. The element is included if the function returns true. This option must be a function that accepts an element parameter. This filter does not apply to any elements specially handled in valueFunctions.
  • excludeFilter Define a blacklist filter function that inputs an element and outputs a Boolean. The element is excluded if the function returns true. This option must be a function that accepts an element parameter. This filter does not apply to any elements specially handled in valueFunctions. Exclusions take precedence over inclusions.

For example, the following option excludes hidden fields:

FormPersistence.persist(form, { excludeFilter: element => element.type === 'hidden' });

Alternatively, the following option includes all non-hidden fields:

FormPersistence.persist(form, { includeFilter: element => element.type !== 'hidden' });

Fixed checkbox array bug

16 Dec 07:36
Compare
Choose a tag to compare

Fixed an issue where checkbox arrays were not serialized correctly (#12).

Syntax fix for Babel 7 compilation

01 Aug 22:53
Compare
Choose a tag to compare

Minor fix for Babel 7 compilation, see #8.

Bugfix for setting nameless input values to undefined

13 Jul 06:10
Compare
Choose a tag to compare

Previously, a bug would occur when persisting a form with nameless input fields where upon load the field's value would be set to undefined. This release fixes that bug.

New options: include and exclude elements by name

13 Jul 01:39
Compare
Choose a tag to compare

Added include and exclude options to all functions:

  • include Define a whitelist of input names to be included during serialization. This option must be an array of strings.
  • exclude Define a blacklist of input names to be excluded during serialization. This option must be an array of strings.

Fixed a bug where non-data-persistence elements like <button> were serialized as a blank array.

Use form.elements instead of custom form element getter

06 Jul 05:41
Compare
Choose a tag to compare

Use form.elements instead of custom form element getter. This change simplifies the code and may improve performance by avoiding DOM queries.

Support id-less forms, IE, Edge<18, skipExternal and uuid options

04 Jul 05:39
Compare
Choose a tag to compare

This release is highlighted by new configuration options, bug fixes, and breaking changes for defining options.

  1. Use of an options object parameter to customize behavior, replacing the series of parameters on functions that had options. This change makes the library more future proof for adding additional options easily. This change breaks backwards compatibility.
  2. Support id-less forms. Specify uuid in options or an error will be thrown. The uuid can also be set for forms that have an id.
  3. Support for IE and Edge < 18. Library now uses custom form serialization instead of FormData which is not supported in these browsers.
  4. The skipExternal option can be set to true in order to skip form elements defined outside the form hierarchy with form='form-id' attributes. The entire document rather than just the form, must be searched for these external elements, so setting this option can improve performance on large pages.

Updated npm readme and removed extra React code

02 Jul 06:39
Compare
Choose a tag to compare

No functional changes in this release.

Created and published to npm

01 Jul 06:06
Compare
Choose a tag to compare

FormPersistence.js is now available on npm as form-persistence.

npm install form-persistence

Additionally added an example using React.

Fixed event detection bug on iOS Safari

25 Jun 07:44
Compare
Choose a tag to compare

Safari in iOS does not support the beforeunload event that FormPersistence previously relied on to know when to save form data to storage. In this release, the library additionally listens to unload events as a failsafe and removes the unload event listener if the beforeunload event successfully fires first.

If edge cases are discovered where neither beforeunload nor unload are fired, the pagehide event may be useful.