shineout 1.12.4-beta.2 → 1.12.4-beta.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -43,6 +43,8 @@ var _config = require("../config");
43
43
 
44
44
  var _zoom = require("../utils/zoom");
45
45
 
46
+ var _isInDocument = require("../utils/dom/isInDocument");
47
+
46
48
  var PICKER_V_MARGIN = 4;
47
49
  var root;
48
50
 
@@ -52,6 +54,11 @@ function initRoot() {
52
54
  document.body.appendChild(root);
53
55
  }
54
56
 
57
+ function getRoot() {
58
+ if (!root || (0, _isInDocument.isInDocument)(root) === false) initRoot();
59
+ return root;
60
+ }
61
+
55
62
  var getOverDocStyle = function getOverDocStyle(right) {
56
63
  return right ? {
57
64
  left: 0,
@@ -83,7 +90,7 @@ function _default(List) {
83
90
  if (!props.absolute) return (0, _assertThisInitialized2.default)(_this);
84
91
  _this.lastStyle = {};
85
92
  if (!root) initRoot();
86
- _this.container = typeof _this.props.absolute === 'function' ? _this.props.absolute() : root;
93
+ _this.container = typeof _this.props.absolute === 'function' ? _this.props.absolute() : getRoot();
87
94
  _this.element = document.createElement('div');
88
95
  if (_this.container) _this.container.appendChild(_this.element);
89
96
 
@@ -99,7 +106,7 @@ function _default(List) {
99
106
 
100
107
  _proto.componentDidMount = function componentDidMount() {
101
108
  if (this.props.absolute && !this.container) {
102
- this.container = typeof this.props.absolute === 'function' ? this.props.absolute() : root;
109
+ this.container = typeof this.props.absolute === 'function' ? this.props.absolute() : getRoot();
103
110
  this.container.appendChild(this.element);
104
111
 
105
112
  if (this.props.focus) {
@@ -155,7 +162,7 @@ function _default(List) {
155
162
  }
156
163
 
157
164
  var container = this.container;
158
- var rootContainer = container === root || !container ? document.body : container;
165
+ var rootContainer = container === getRoot() || !container ? document.body : container;
159
166
  var containerRect = rootContainer.getBoundingClientRect();
160
167
  var containerScroll = {
161
168
  left: rootContainer.scrollLeft,
@@ -52,7 +52,7 @@ function _default(type) {
52
52
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)((0, _assertThisInitialized2.default)(_this)), "onClick", function (e) {
53
53
  e.stopPropagation();
54
54
  var onClick = _this.props.onClick;
55
- if ((0, _is.isFunc)(onClick)) onClick();
55
+ if ((0, _is.isFunc)(onClick)) onClick(e);
56
56
  });
57
57
  _this.state = {
58
58
  checked: props.checked
@@ -37,6 +37,8 @@ var _context2 = require("./context");
37
37
 
38
38
  var _uid = require("../utils/uid");
39
39
 
40
+ var _isInDocument = require("../utils/dom/isInDocument");
41
+
40
42
  var _popContainer = _interopRequireDefault(require("../utils/dom/popContainer"));
41
43
 
42
44
  // import { getRTLPosition } from '../utils/strings'
@@ -215,7 +217,7 @@ function (_Component) {
215
217
  _proto.createContainer = function createContainer() {
216
218
  var zIndex = this.props.zIndex;
217
219
 
218
- if (!this.container) {
220
+ if (!this.container || !(0, _isInDocument.isInDocument)(this.container)) {
219
221
  this.container = this.getContainer();
220
222
  this.element.style.zIndex = zIndex;
221
223
  this.container.appendChild(this.element);
@@ -44,12 +44,19 @@ function show(props, id, innerStyle) {
44
44
  tip = props.tip,
45
45
  trigger = props.trigger,
46
46
  animation = props.animation,
47
- cn = props.className; // create
47
+ cn = props.className;
48
+ var container = (0, _popContainer.default)(); // create
49
+
50
+ if (!container.contains(div)) {
51
+ div = null;
52
+ arrow = null;
53
+ inner = null;
54
+ }
48
55
 
49
56
  if (!div) {
50
57
  div = document.createElement('div');
51
58
  div.style.display = 'none';
52
- (0, _popContainer.default)().appendChild(div);
59
+ container.appendChild(div);
53
60
  }
54
61
 
55
62
  if (!arrow) {
package/css/index.d.ts CHANGED
@@ -3,7 +3,7 @@ import * as utils from './utils'
3
3
 
4
4
  declare const __default: {
5
5
  utils: typeof utils,
6
- version: '1.12.4-beta.2'
6
+ version: '1.12.4-beta.4'
7
7
  }
8
8
 
9
9
  export default __default
package/css/index.js CHANGED
@@ -224,6 +224,6 @@ exports.Upload = _Upload.default;
224
224
  // Created by scripts/src-index.js.
225
225
  var _default = {
226
226
  utils: utils,
227
- version: '1.12.4-beta.2'
227
+ version: '1.12.4-beta.4'
228
228
  };
229
229
  exports.default = _default;
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+
3
+ exports.__esModule = true;
4
+ exports.isInDocument = isInDocument;
5
+
6
+ function isInDocument(element) {
7
+ if (element && 'isConnected' in element) {
8
+ return element.isConnected;
9
+ }
10
+
11
+ return document.documentElement.contains(element);
12
+ }
@@ -7,13 +7,18 @@ exports.default = void 0;
7
7
 
8
8
  var _ready = _interopRequireDefault(require("./ready"));
9
9
 
10
+ var _isInDocument = require("./isInDocument");
11
+
10
12
  /**
11
13
  * 最外层容器
12
14
  */
13
15
  var Container = null;
14
16
 
15
17
  var getContainer = function getContainer() {
16
- if (Container) return Container;
18
+ if (Container && (0, _isInDocument.isInDocument)(Container)) {
19
+ return Container;
20
+ }
21
+
17
22
  Container = document.createElement('div');
18
23
  Container.setAttribute('style', 'position: absolute; top: 0; left: 0; width: 100%; contain: size');
19
24
  (0, _ready.default)(function () {