Added typeof method (#812)

* Add typeof method to check exact type of object #805

* Update changelog
This commit is contained in:
George Berezhnoy 2019-06-25 21:06:00 +03:00 committed by GitHub
commit 33cc273dda
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 5 deletions

8
dist/editor.js vendored

File diff suppressed because one or more lines are too long

View file

@ -4,6 +4,7 @@
- `Improvements` — Inline Toolbar now works on mobile devices [#706](https://github.com/codex-team/editor.js/issues/706)
- `Improvements` — Toolbar looks better on mobile devices [#706](https://github.com/codex-team/editor.js/issues/706)
- `Fix` — Added `typeof` util method to check exact object type [#805](https://github.com/codex-team/editor.js/issues/805)
### 2.14

View file

@ -316,7 +316,7 @@ export default class Util {
* @return {object}
*/
public static deepMerge(target, ...sources) {
const isObject = (item) => item && typeof item === 'object' && !Array.isArray(item);
const isObject = (item) => item && Util.typeof(item) === 'object';
if (!sources.length) { return target; }
const source = sources.shift();
@ -351,4 +351,12 @@ export default class Util {
return 'ontouchstart' in document.documentElement;
}
/**
* Return string representation of the object type
*
* @param {any} object
*/
public static typeof(object: any): string {
return Object.prototype.toString.call(object).match(/\s([a-zA-Z]+)/)[1].toLowerCase();
}
}