diff options
author | Samy Pesse <samypesse@gmail.com> | 2016-09-20 19:41:25 +0200 |
---|---|---|
committer | Samy Pesse <samypesse@gmail.com> | 2016-09-20 19:41:25 +0200 |
commit | 3b3f43a35d5b2c795f05bb5271bd775c1b8271c6 (patch) | |
tree | 79f36a086a9de9a4201d49b4e06e9badce5916fe /packages/gitbook-core/src | |
parent | ced0be930dd86bc204cab5b4e3a1cd83aed68ccf (diff) | |
download | gitbook-3b3f43a35d5b2c795f05bb5271bd775c1b8271c6.zip gitbook-3b3f43a35d5b2c795f05bb5271bd775c1b8271c6.tar.gz gitbook-3b3f43a35d5b2c795f05bb5271bd775c1b8271c6.tar.bz2 |
Fix rendering of unsafe injected components
Diffstat (limited to 'packages/gitbook-core/src')
-rw-r--r-- | packages/gitbook-core/src/actions/components.js | 2 | ||||
-rw-r--r-- | packages/gitbook-core/src/components/InjectedComponent.js | 15 |
2 files changed, 11 insertions, 6 deletions
diff --git a/packages/gitbook-core/src/actions/components.js b/packages/gitbook-core/src/actions/components.js index 89b0c9e..f21c382 100644 --- a/packages/gitbook-core/src/actions/components.js +++ b/packages/gitbook-core/src/actions/components.js @@ -8,7 +8,7 @@ const ACTION_TYPES = require('./TYPES'); function findMatchingComponents(state, matching) { return state .filter(({descriptor}) => { - if (matching.role && matching.role === descriptor.role) { + if (matching.role && matching.role !== descriptor.role) { return false; } diff --git a/packages/gitbook-core/src/components/InjectedComponent.js b/packages/gitbook-core/src/components/InjectedComponent.js index df2c1c7..40fc923 100644 --- a/packages/gitbook-core/src/components/InjectedComponent.js +++ b/packages/gitbook-core/src/components/InjectedComponent.js @@ -1,5 +1,6 @@ const React = require('react'); const ReactRedux = require('react-redux'); +const { List } = require('immutable'); const UnsafeComponent = require('./UnsafeComponent'); const { findMatchingComponents } = require('../actions/components'); @@ -28,7 +29,10 @@ const { findMatchingComponents } = require('../actions/components'); const InjectedComponentSet = React.createClass({ propTypes: { - components: React.PropTypes.arrayOf(React.PropTypes.func).isRequired, + components: React.PropTypes.oneOfType([ + React.PropTypes.arrayOf(React.PropTypes.func), + React.PropTypes.instanceOf(List) + ]).isRequired, props: React.PropTypes.object, withContainer: React.PropTypes.bool }, @@ -36,11 +40,12 @@ const InjectedComponentSet = React.createClass({ render() { const { components, props, ...divProps } = this.props; - const inner = components.map(Component => { - if (Component.sandbox === false) { - return <Component key={Component.displayName} {...props} />; + const inner = components.map(Comp => { + // TODO fix sandboxing + if (Comp.sandbox === false || 1) { + return <Comp key={Comp.displayName} {...props} />; } else { - return <UnsafeComponent key={Component.displayName} Component={Component} props={props} />; + return <UnsafeComponent key={Comp.displayName} Component={Comp} props={props} />; } }); |