Skip to content

Commit

Permalink
feat(react:can): adds an alias to on prop
Browse files Browse the repository at this point in the history
  • Loading branch information
stalniy committed Aug 31, 2018
1 parent 4c5c690 commit 748ea64
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
9 changes: 5 additions & 4 deletions packages/casl-react/src/Can.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,12 @@ function alias(names, validate) {
export default class Can extends PureComponent {
static propTypes = {
I: alias('do', PropTypes.string.isRequired),
a: alias('on this of', REQUIRED_OBJECT_OR_STRING),
of: alias('on a this', REQUIRED_OBJECT_OR_STRING),
this: alias('on a of', REQUIRED_OBJECT_OR_STRING),
a: alias('on this of an', REQUIRED_OBJECT_OR_STRING),
an: alias('on this of a', REQUIRED_OBJECT_OR_STRING),
of: alias('on a this an', REQUIRED_OBJECT_OR_STRING),
this: alias('on a of an', REQUIRED_OBJECT_OR_STRING),
do: alias('I', PropTypes.string.isRequired),
on: alias('this a of', REQUIRED_OBJECT_OR_STRING),
on: alias('this a of an', REQUIRED_OBJECT_OR_STRING),
not: PropTypes.bool,
children: PropTypes.any.isRequired,
ability: PropTypes.instanceOf(Ability).isRequired
Expand Down
2 changes: 1 addition & 1 deletion packages/casl-react/src/factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export function createContextualCan(Consumer) {
return createElement(Consumer, null, ability => createElement(Can, {
ability: props.ability || ability,
I: props.I || props.do,
a: props.a || props.of || props.this || props.on,
a: props.on || props.a || props.an || props.of || props.this,
not: props.not,
children: props.children
}));
Expand Down

0 comments on commit 748ea64

Please sign in to comment.