From adacd63cfc5e6439a95c127fa6b48bdb4c1ac45a Mon Sep 17 00:00:00 2001 From: BrainFooLong Date: Mon, 6 Dec 2021 12:11:28 +0100 Subject: [PATCH] accept a `$` instance also as html element in `toJson/fromJson` --- CHANGELOG.md | 7 ++++++- dist/form-data-json.js | 7 ++++--- dist/form-data-json.min.js | 4 ++-- docs/scripts/form-data-json.js | 7 ++++--- docs/scripts/form-data-json.min.js | 4 ++-- package.json | 2 +- src/form-data-json.js | 5 +++-- 7 files changed, 22 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7f7047d..da75eaa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,9 @@ -### 2.1.0 - 24.October 2021 +### 2.1.1 - 06.December 2021 + +* accept a `$` instance also as html element in `toJson/fromJson`, which is used by many libraries that memic jquery behaviour - previously only explicitly `jQuery` was supported + + +* ### 2.1.0 - 24.October 2021 * added new toJson option `arrayify` to explicitely disable array return values when needed, default is `true` diff --git a/dist/form-data-json.js b/dist/form-data-json.js index b4b5689..4a95af0 100644 --- a/dist/form-data-json.js +++ b/dist/form-data-json.js @@ -1,5 +1,5 @@ 'use strict'; -// form-data-json-convert | version: 2.1.0 | url: https://github.com/brainfoolong/form-data-json +// form-data-json-convert | version: 2.1.1 | url: https://github.com/brainfoolong/form-data-json /** * Form Data Json Converter @@ -694,7 +694,7 @@ var FormDataJson = /*#__PURE__*/function () { } /** * Get html element out of given parameter - * @param {HTMLElement|JQuery|string} param + * @param {HTMLElement|JQuery|$|string} param * @return {HTMLElement|null} * @private */ @@ -704,7 +704,8 @@ var FormDataJson = /*#__PURE__*/function () { if (typeof param === 'string') return document.querySelector(param); if (param instanceof HTMLElement) return param; if (typeof jQuery !== 'undefined' && param instanceof jQuery) return param[0]; - console.warn('FormDataJson: Unsupported element passed. Supported is HTMLElement, a string query selector or JQuery object'); + if (typeof $ !== 'undefined' && param instanceof $) return param[0]; + console.warn('FormDataJson: Unsupported element passed. Supported is HTMLElement, a string query selector, JQuery or $ object'); return null; } /** diff --git a/dist/form-data-json.min.js b/dist/form-data-json.min.js index d6a8af0..98123a8 100644 --- a/dist/form-data-json.min.js +++ b/dist/form-data-json.min.js @@ -1,3 +1,3 @@ 'use strict'; -// form-data-json-convert | version: 2.1.0 | url: https://github.com/brainfoolong/form-data-json -var FormDataJson=function(){function a(){}return a.toJson=function toJson(b,c){function d(b){if("function"==typeof c.inputFilter&&!0!==c.inputFilter(b))return!1;if(!c.includeDisabled&&b.disabled)return!1;var d=(b.type||"text").toLowerCase();return!(!c.includeButtonValues&&(b instanceof HTMLButtonElement||-1