mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-10-08 04:06:08 +08:00
feat(babel6): Fix spread operator
This commit is contained in:
parent
92199587b3
commit
706f92bc9d
5 changed files with 127 additions and 119 deletions
|
@ -1,7 +1,8 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import {DraftStore, Actions, Utils} from 'nylas-exports';
|
import {DraftStore, Actions, Utils} from 'nylas-exports';
|
||||||
|
|
||||||
export default ComposedComponent => class extends React.Component {
|
function InflateDraftClientId(ComposedComponent) {
|
||||||
|
return class extends React.Component {
|
||||||
static displayName = ComposedComponent.displayName;
|
static displayName = ComposedComponent.displayName;
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
draftClientId: React.PropTypes.string,
|
draftClientId: React.PropTypes.string,
|
||||||
|
@ -95,4 +96,6 @@ export default ComposedComponent => class extends React.Component {
|
||||||
}
|
}
|
||||||
return <ComposedComponent ref="composed" {...this.props} {...this.state} />;
|
return <ComposedComponent ref="composed" {...this.props} {...this.state} />;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
export default InflateDraftClientId
|
||||||
|
|
|
@ -1,36 +0,0 @@
|
||||||
import React, {Component} from 'react';
|
|
||||||
|
|
||||||
export default (ComposedComponent, {stores, getStateFromStores}) => class extends Component {
|
|
||||||
static displayName = ComposedComponent.displayName;
|
|
||||||
|
|
||||||
static containerRequired = false;
|
|
||||||
|
|
||||||
constructor(props) {
|
|
||||||
super(props);
|
|
||||||
this._unlisteners = [];
|
|
||||||
this.state = getStateFromStores(props);
|
|
||||||
}
|
|
||||||
|
|
||||||
componentDidMount() {
|
|
||||||
stores.forEach((store) => {
|
|
||||||
this._unlisteners.push(store.listen(() => {
|
|
||||||
this.setState(getStateFromStores(this.props));
|
|
||||||
}));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
componentWillReceiveProps(nextProps) {
|
|
||||||
this.setState(getStateFromStores(nextProps));
|
|
||||||
}
|
|
||||||
|
|
||||||
componentWillUnmount() {
|
|
||||||
for (const unlisten of this._unlisteners) {
|
|
||||||
unlisten();
|
|
||||||
}
|
|
||||||
this._unlisteners = [];
|
|
||||||
}
|
|
||||||
|
|
||||||
render() {
|
|
||||||
return <ComposedComponent {...this.props} {...this.state} />;
|
|
||||||
}
|
|
||||||
};
|
|
40
src/components/decorators/listens-to-flux-store.jsx
Normal file
40
src/components/decorators/listens-to-flux-store.jsx
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
import React, {Component} from 'react';
|
||||||
|
|
||||||
|
function ListensToFluxStore(ComposedComponent, {stores, getStateFromStores}) {
|
||||||
|
return class extends Component {
|
||||||
|
static displayName = ComposedComponent.displayName;
|
||||||
|
|
||||||
|
static containerRequired = false;
|
||||||
|
|
||||||
|
constructor(props) {
|
||||||
|
super(props);
|
||||||
|
this._unlisteners = [];
|
||||||
|
this.state = getStateFromStores(props);
|
||||||
|
}
|
||||||
|
|
||||||
|
componentDidMount() {
|
||||||
|
stores.forEach((store) => {
|
||||||
|
this._unlisteners.push(store.listen(() => {
|
||||||
|
this.setState(getStateFromStores(this.props));
|
||||||
|
}));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
componentWillReceiveProps(nextProps) {
|
||||||
|
this.setState(getStateFromStores(nextProps));
|
||||||
|
}
|
||||||
|
|
||||||
|
componentWillUnmount() {
|
||||||
|
for (const unlisten of this._unlisteners) {
|
||||||
|
unlisten();
|
||||||
|
}
|
||||||
|
this._unlisteners = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
render() {
|
||||||
|
return <ComposedComponent {...this.props} {...this.state} />;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export default ListensToFluxStore
|
|
@ -2,6 +2,7 @@ import RegExpUtils from '../regexp-utils';
|
||||||
|
|
||||||
export function getFunctionArgs(func) {
|
export function getFunctionArgs(func) {
|
||||||
const match = func.toString().match(RegExpUtils.functionArgs());
|
const match = func.toString().match(RegExpUtils.functionArgs());
|
||||||
if (!match) return null;
|
if (!match) return [[]];
|
||||||
return match[1].split(/\s*,\s*/);
|
const matchStr = match[1] || match[2]
|
||||||
|
return matchStr.split(/\s*,\s*/);
|
||||||
}
|
}
|
||||||
|
|
|
@ -158,8 +158,8 @@ RegExpUtils =
|
||||||
looseStyleTag: -> /<style/gim
|
looseStyleTag: -> /<style/gim
|
||||||
|
|
||||||
# Regular expression matching javasript function arguments:
|
# Regular expression matching javasript function arguments:
|
||||||
# https://regex101.com/r/pZ6zF0/1
|
# https://regex101.com/r/pZ6zF0/2
|
||||||
functionArgs: -> /\(\s*([^)]+?)\s*\)/
|
functionArgs: -> /(?:\(\s*([^)]+?)\s*\)|(\w+)\s?=>)/
|
||||||
|
|
||||||
illegalPathCharactersRegexp: ->
|
illegalPathCharactersRegexp: ->
|
||||||
#https://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v=vs.85).aspx
|
#https://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v=vs.85).aspx
|
||||||
|
|
Loading…
Add table
Reference in a new issue