3 Star 54 Fork 14

Yaohaixiao / dom.js

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
getWindow.js 597 Bytes
一键复制 编辑 原始数据 按行查看 历史
import isWindow from './isWindow'
/**
* 获取 window 对象
* ========================================================================
* @method getWindow
* @since 1.6.0
* @see https://developer.mozilla.org/zh-CN/docs/Web/API/Node/ownerDocument
* @param {Node|Window} node
* @return {*|Window}
*/
const getWindow = (node) => {
if (node === null) {
return window
}
if (!isWindow(node)) {
const ownerDocument = node.ownerDocument
return ownerDocument ? ownerDocument.defaultView || window : window
}
return node
}
export default getWindow
JavaScript
1
https://gitee.com/yaohaixiao/dom.js.git
git@gitee.com:yaohaixiao/dom.js.git
yaohaixiao
dom.js
dom.js
main

搜索帮助