Skip to content

Commit

Permalink
accept a $ instance also as html element in toJson/fromJson
Browse files Browse the repository at this point in the history
  • Loading branch information
brainfoolong committed Dec 6, 2021
1 parent 464e336 commit adacd63
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 14 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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`

Expand Down
7 changes: 4 additions & 3 deletions dist/form-data-json.js
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
*/
Expand All @@ -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;
}
/**
Expand Down
4 changes: 2 additions & 2 deletions dist/form-data-json.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions docs/scripts/form-data-json.js
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
*/
Expand All @@ -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;
}
/**
Expand Down
Loading

0 comments on commit adacd63

Please sign in to comment.