1 | "use strict";
|
2 |
|
3 | var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
4 |
|
5 | Object.defineProperty(exports, "__esModule", {
|
6 | value: true
|
7 | });
|
8 | exports.detectFlexGapSupported = exports.isStyleSupport = exports.canUseDocElement = void 0;
|
9 |
|
10 | var _canUseDom = _interopRequireDefault(require("rc-util/lib/Dom/canUseDom"));
|
11 |
|
12 | var canUseDocElement = function canUseDocElement() {
|
13 | return (0, _canUseDom["default"])() && window.document.documentElement;
|
14 | };
|
15 |
|
16 | exports.canUseDocElement = canUseDocElement;
|
17 |
|
18 | var isStyleSupport = function isStyleSupport(styleName) {
|
19 | if (canUseDocElement()) {
|
20 | var styleNameList = Array.isArray(styleName) ? styleName : [styleName];
|
21 | var documentElement = window.document.documentElement;
|
22 | return styleNameList.some(function (name) {
|
23 | return name in documentElement.style;
|
24 | });
|
25 | }
|
26 |
|
27 | return false;
|
28 | };
|
29 |
|
30 | exports.isStyleSupport = isStyleSupport;
|
31 | var flexGapSupported;
|
32 |
|
33 | var detectFlexGapSupported = function detectFlexGapSupported() {
|
34 | if (!canUseDocElement()) {
|
35 | return false;
|
36 | }
|
37 |
|
38 | if (flexGapSupported !== undefined) {
|
39 | return flexGapSupported;
|
40 | }
|
41 |
|
42 |
|
43 | var flex = document.createElement('div');
|
44 | flex.style.display = 'flex';
|
45 | flex.style.flexDirection = 'column';
|
46 | flex.style.rowGap = '1px';
|
47 |
|
48 | flex.appendChild(document.createElement('div'));
|
49 | flex.appendChild(document.createElement('div'));
|
50 |
|
51 | document.body.appendChild(flex);
|
52 | flexGapSupported = flex.scrollHeight === 1;
|
53 |
|
54 | document.body.removeChild(flex);
|
55 | return flexGapSupported;
|
56 | };
|
57 |
|
58 | exports.detectFlexGapSupported = detectFlexGapSupported; |
\ | No newline at end of file |