mirror of
https://github.com/liabru/matter-js.git
synced 2025-01-13 16:18:50 -05:00
refactored Common.isElement
This commit is contained in:
parent
d63b0c25c8
commit
295cffeacf
1 changed files with 0 additions and 8 deletions
|
@ -177,15 +177,7 @@ module.exports = Common;
|
||||||
* @return {boolean} True if the object is a HTMLElement, otherwise false
|
* @return {boolean} True if the object is a HTMLElement, otherwise false
|
||||||
*/
|
*/
|
||||||
Common.isElement = function(obj) {
|
Common.isElement = function(obj) {
|
||||||
// http://stackoverflow.com/questions/384286/javascript-isdom-how-do-you-check-if-a-javascript-object-is-a-dom-object
|
|
||||||
try {
|
|
||||||
return obj instanceof HTMLElement;
|
return obj instanceof HTMLElement;
|
||||||
}
|
|
||||||
catch(e){
|
|
||||||
return (typeof obj==="object") &&
|
|
||||||
(obj.nodeType===1) && (typeof obj.style === "object") &&
|
|
||||||
(typeof obj.ownerDocument ==="object");
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue