@ifed/component
Version:
@ifed/component
37 lines (36 loc) • 1.3 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.detectFlexGapSupported = exports.canUseDocElement = void 0;
Object.defineProperty(exports, "isStyleSupport", {
enumerable: true,
get: function () {
return _styleChecker.isStyleSupport;
}
});
var _canUseDom = _interopRequireDefault(require("rc-util/lib/Dom/canUseDom"));
var _styleChecker = require("rc-util/lib/Dom/styleChecker");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
const canUseDocElement = () => (0, _canUseDom.default)() && window.document.documentElement;
exports.canUseDocElement = canUseDocElement;
let flexGapSupported;
const detectFlexGapSupported = () => {
if (!canUseDocElement()) {
return false;
}
if (flexGapSupported !== undefined) {
return flexGapSupported;
}
const flex = document.createElement('div');
flex.style.display = 'flex';
flex.style.flexDirection = 'column';
flex.style.rowGap = '1px';
flex.appendChild(document.createElement('div'));
flex.appendChild(document.createElement('div'));
document.body.appendChild(flex);
flexGapSupported = flex.scrollHeight === 1;
document.body.removeChild(flex);
return flexGapSupported;
};
exports.detectFlexGapSupported = detectFlexGapSupported;