fix states
This commit is contained in:
parent
22b32f149d
commit
ff2db7a247
@ -25,8 +25,16 @@ export const sampleRules = [
|
|||||||
{
|
{
|
||||||
component: 'Button',
|
component: 'Button',
|
||||||
directives: {
|
directives: {
|
||||||
background: '#808080',
|
background: '#000000',
|
||||||
opacity: 0.5
|
opacity: 0.8
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
component: 'Button',
|
||||||
|
state: ['hover'],
|
||||||
|
directives: {
|
||||||
|
background: '#FF00FF',
|
||||||
|
opacity: 0.9
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
@ -81,7 +81,10 @@ export const init = (ruleset) => {
|
|||||||
|
|
||||||
if (Object.prototype.hasOwnProperty.call(rule, 'state')) {
|
if (Object.prototype.hasOwnProperty.call(rule, 'state')) {
|
||||||
const ruleStatesSet = new Set(['normal', ...(rule.state || [])])
|
const ruleStatesSet = new Set(['normal', ...(rule.state || [])])
|
||||||
return combination.state.every(state => ruleStatesSet.has(state))
|
const combinationSet = new Set(['normal', ...combination.state])
|
||||||
|
const setsAreEqual = combination.state.every(state => ruleStatesSet.has(state)) &&
|
||||||
|
[...ruleStatesSet].every(state => combinationSet.has(state))
|
||||||
|
return setsAreEqual
|
||||||
} else {
|
} else {
|
||||||
if (combination.state.length !== 1 || combination.state[0] !== 'normal') return false
|
if (combination.state.length !== 1 || combination.state[0] !== 'normal') return false
|
||||||
return true
|
return true
|
||||||
@ -93,6 +96,7 @@ export const init = (ruleset) => {
|
|||||||
let currentParent = parent
|
let currentParent = parent
|
||||||
while (currentParent) {
|
while (currentParent) {
|
||||||
const rulesParent = ruleset.filter(findRules(currentParent, true))
|
const rulesParent = ruleset.filter(findRules(currentParent, true))
|
||||||
|
rulesParent > 1 && console.log('OOPS')
|
||||||
lowerLevelComponent = rulesParent[rulesParent.length - 1]
|
lowerLevelComponent = rulesParent[rulesParent.length - 1]
|
||||||
currentParent = currentParent.parent
|
currentParent = currentParent.parent
|
||||||
if (lowerLevelComponent && filter(lowerLevelComponent)) currentParent = null
|
if (lowerLevelComponent && filter(lowerLevelComponent)) currentParent = null
|
||||||
|
Loading…
Reference in New Issue
Block a user