Skip to content

Commit

Permalink
chore: rm polyfill
Browse files Browse the repository at this point in the history
  • Loading branch information
picodoth committed May 31, 2018
1 parent 53c826b commit 96d78b4
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 18 deletions.
3 changes: 1 addition & 2 deletions package.json
Expand Up @@ -80,8 +80,7 @@
"prop-types": "^15.5.6",
"rc-animate": "2.x",
"rc-trigger": "^2.3.0",
"rc-util": "^4.1.0",
"react-lifecycles-compat": "^3.0.2"
"rc-util": "^4.1.0"
},
"pre-commit": [
"lint"
Expand Down
3 changes: 0 additions & 3 deletions src/Menu.jsx
Expand Up @@ -3,7 +3,6 @@ import PropTypes from 'prop-types';
import { Provider, create } from 'mini-store';
import { default as SubPopupMenu, getActiveKey } from './SubPopupMenu';
import { noop } from './util';
import { polyfill } from 'react-lifecycles-compat';

class Menu extends React.Component {
static propTypes = {
Expand Down Expand Up @@ -212,6 +211,4 @@ class Menu extends React.Component {
}
}

polyfill(Menu);

export default Menu;
23 changes: 10 additions & 13 deletions src/SubPopupMenu.js
Expand Up @@ -4,7 +4,6 @@ import { connect } from 'mini-store';
import KeyCode from 'rc-util/lib/KeyCode';
import createChainedFunction from 'rc-util/lib/createChainedFunction';
import classNames from 'classnames';
import { polyfill } from 'react-lifecycles-compat';
import { getKeyFromChildrenIndex, loopMenuItem, noop, menuAllProps } from './util';
import DOMWrap from './DOMWrap';

Expand Down Expand Up @@ -140,6 +139,16 @@ export class SubPopupMenu extends React.Component {
return this.props.visible || nextProps.visible;
}

componentDidUpdate() {
const props = this.props;
const originalActiveKey = 'activeKey' in props ? props.activeKey :
props.store.getState().activeKey[getEventKey(props)];
const activeKey = getActiveKey(props, originalActiveKey);
if (activeKey !== originalActiveKey) {
updateActiveKey(props.store, getEventKey(props), activeKey);
}
}

// all keyboard events callbacks run from here at first
onKeyDown = (e, callback) => {
const keyCode = e.keyCode;
Expand Down Expand Up @@ -194,16 +203,6 @@ export class SubPopupMenu extends React.Component {
this.props.onDestroy(key);
};

componentDidUpdate() {
const props = this.props;
const originalActiveKey = 'activeKey' in props ? props.activeKey :
props.store.getState().activeKey[getEventKey(props)];
const activeKey = getActiveKey(props, originalActiveKey);
if (activeKey !== originalActiveKey) {
updateActiveKey(props.store, getEventKey(props), activeKey);
}
}

getFlatInstanceArray = () => {
return this.instanceArray;
};
Expand Down Expand Up @@ -354,6 +353,4 @@ export class SubPopupMenu extends React.Component {
}
}

polyfill(SubPopupMenu);

export default connect()(SubPopupMenu);

0 comments on commit 96d78b4

Please sign in to comment.