UNPKG

@mdui/jq

Version:

拥有和 jQuery 相似 API 的轻量级 JavaScript 工具库

18 lines (17 loc) 521 B
import { getDocument } from 'ssr-window'; import { $ } from '../$.js'; import './css.js'; import './map.js'; /** * 返回最近的用于定位的父元素 */ $.fn.offsetParent = function () { const document = getDocument(); return this.map(function () { let offsetParent = this.offsetParent; while (offsetParent && $(offsetParent).css('position') === 'static') { offsetParent = offsetParent.offsetParent; } return offsetParent || document.documentElement; }); };