CASL v5.1.0-next.10 Release Notes
Release Date: 2020-10-17 // over 3 years ago-
5.1.0-next.10 (2020-10-17)
๐จ Code Refactoring
- ruleIndex: removes possibility to pass subject to
rulesFor
andpossibleRulesFor
[skip release] (b8c324d)
๐ Performance Improvements
- ruleIndex: removes subject type detection from
_buildIndexFor
(13fe934)
๐ฅ BREAKING CHANGES
ruleIndex:
rulesFor
,possibleRulesFor
,rulesToQuery
,ruleToAST
,rulesToFields
accepts only subject type now!Before
import { Ability } from '@casl/ability';const ability = new Ability([{ action: 'read', subject: 'Post' }]);class Post {}console.log(ability.rulesFor('read', new Post())); // [Rule]console.log(ability.rulesFor('read', 'Post')); // [Rule]
After
import { Ability } from '@casl/ability';const ability = new Ability([{ action: 'read', subject: 'Post' }]);class Post {}console.log(ability.rulesFor('read', new Post())); // throws exceptionconsole.log(ability.rulesFor('read', 'Post')); // [Rule]
Other functions and methods have the same behavior
- ruleIndex: removes possibility to pass subject to