8
0

isnode.js 602 B

1234567891011121314151617181920212223242526
  1. /**
  2. * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
  3. * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
  4. */
  5. /**
  6. * @module utils/dom/isnode
  7. */
  8. /**
  9. * Checks if the object is a native DOM Node.
  10. *
  11. * @param {*} obj
  12. * @returns {Boolean}
  13. */
  14. export default function isNode( obj ) {
  15. if ( obj ) {
  16. if ( obj.defaultView ) {
  17. return obj instanceof obj.defaultView.Document;
  18. } else if ( obj.ownerDocument && obj.ownerDocument.defaultView ) {
  19. return obj instanceof obj.ownerDocument.defaultView.Node;
  20. }
  21. }
  22. return false;
  23. }