@@ -82,45 +82,31 @@ function buildElementRoleList(elementRolesMap) {
82
82
return `${ name } ${ attributes
83
83
. map ( ( { name : attributeName , value, constraints = [ ] } ) => {
84
84
const shouldNotExist = constraints . indexOf ( 'undefined' ) !== - 1
85
- const hasValue = typeof value !== 'undefined'
86
- if ( shouldNotExist ) {
87
- return `:not([ ${ attributeName } ])`
88
- } else if ( hasValue ) {
85
+ const shouldBeNonEmpty = constraints . indexOf ( 'set' ) !== - 1
86
+ const hasExplicitValue = typeof value !== 'undefined'
87
+
88
+ if ( hasExplicitValue ) {
89
89
return `[${ attributeName } ="${ value } "]`
90
- } else {
91
- return `[${ attributeName } ]`
90
+ } else if ( shouldNotExist ) {
91
+ return `:not([${ attributeName } ])`
92
+ } else if ( shouldBeNonEmpty ) {
93
+ return `[${ attributeName } ]:not([${ attributeName } =""])`
92
94
}
95
+
96
+ return `[${ attributeName } ]`
93
97
} )
94
98
. join ( '' ) } `
95
99
}
96
100
97
101
function getSelectorSpecificity ( { attributes = [ ] } ) {
98
- return {
99
- primaryKey : attributes . length ,
100
- secondaryKey : attributes . reduce ( ( acc , { value, constraints = [ ] } ) => {
101
- const shouldNotExist = constraints . indexOf ( 'undefined' ) !== - 1
102
- const hasValue = typeof value !== 'undefined'
103
-
104
- if ( shouldNotExist ) {
105
- return acc + 2
106
- } else if ( hasValue ) {
107
- return acc + 1
108
- }
109
-
110
- return acc
111
- } , 0 ) ,
112
- }
102
+ return attributes . length
113
103
}
114
104
115
105
function bySelectorSpecificity (
116
106
{ specificity : leftSpecificity } ,
117
107
{ specificity : rightSpecificity } ,
118
108
) {
119
- if ( rightSpecificity . primaryKey !== leftSpecificity . primaryKey ) {
120
- return rightSpecificity . primaryKey - leftSpecificity . primaryKey
121
- }
122
-
123
- return rightSpecificity . secondaryKey - leftSpecificity . secondaryKey
109
+ return rightSpecificity - leftSpecificity
124
110
}
125
111
126
112
function match ( element ) {
0 commit comments