@@ -105,6 +105,94 @@ describe("Basic Suite", function() {
105
105
106
106
} ) ;
107
107
108
+ it ( 'can handle attribute selector value' , function ( ) {
109
+ const testComponent = createTestComponent ( parent , {
110
+ childClassName : 'header-1' ,
111
+ internalHTML : '<div data-test="Hello-World" class="header-2">Content</div>'
112
+ } ) ;
113
+ createTestComponent ( testComponent , {
114
+ childClassName : 'header-2'
115
+ } ) ;
116
+ testComponent . setAttribute ( 'data-test' , '123' )
117
+ testComponent . classList . add ( 'header-1' ) ;
118
+ const testComponents = querySelectorAllDeep ( `.header-1 [data-test="Hello-World"]` ) ;
119
+ expect ( testComponents . length ) . toEqual ( 1 ) ;
120
+ expect ( testComponents [ 0 ] . classList . contains ( 'header-2' ) ) . toBeTruthy ( ) ;
121
+ } ) ;
122
+
123
+
124
+ it ( 'can handle extra white space in attribute value' , function ( ) {
125
+ const testComponent = createTestComponent ( parent , {
126
+ childClassName : 'header-1' ,
127
+ internalHTML : '<div data-test="Hello World" class="header-2">Content</div>'
128
+ } ) ;
129
+ createTestComponent ( testComponent , {
130
+ childClassName : 'header-2'
131
+ } ) ;
132
+ // this should not match as matching children
133
+ testComponent . setAttribute ( 'data-test' , 'Hello World' )
134
+ testComponent . classList . add ( 'header-1' ) ;
135
+ const testComponents = querySelectorAllDeep ( `.header-1 [data-test="Hello World"]` ) ;
136
+ expect ( testComponents . length ) . toEqual ( 1 ) ;
137
+ } ) ;
138
+
139
+ it ( 'can handle escaped data in attributes' , function ( ) {
140
+ const testComponent = createTestComponent ( parent , {
141
+ childClassName : 'header-1' ,
142
+ internalHTML : '<div class="header-2">Content</div>'
143
+ } ) ;
144
+ const test2 = createTestComponent ( testComponent , {
145
+ childClassName : 'header-2'
146
+ } ) ;
147
+ test2 . setAttribute ( 'data-test' , 'Hello" World' )
148
+ testComponent . classList . add ( 'header-1' ) ;
149
+ const testComponents = querySelectorAllDeep ( `.header-1 [data-test="Hello\\" World"]` ) ;
150
+ expect ( testComponents . length ) . toEqual ( 1 ) ;
151
+ } ) ;
152
+
153
+ it ( 'can handle extra white space in single quoted attribute value' , function ( ) {
154
+ const testComponent = createTestComponent ( parent , {
155
+ childClassName : 'header-1' ,
156
+ internalHTML : '<div class="header-2">Content</div>'
157
+ } ) ;
158
+ createTestComponent ( testComponent , {
159
+ childClassName : 'header-2'
160
+ } ) ;
161
+ testComponent . setAttribute ( 'data-test' , 'Hello " \'World\'' )
162
+ testComponent . classList . add ( 'header-1' ) ;
163
+ const testComponents = querySelectorAllDeep ( `.header-1[data-test='Hello \\" \\'World\\'']` ) ;
164
+ expect ( testComponents . length ) . toEqual ( 1 ) ;
165
+ } ) ;
166
+
167
+ it ( 'split correctly on selector list' , function ( ) {
168
+ const testComponent = createTestComponent ( parent , {
169
+ internalHTML : '<span class="header-2"></span><div data-test="Hello" World" class="header-3">Content</div>'
170
+ } ) ;
171
+ createTestComponent ( testComponent , {
172
+ childClassName : 'header-4'
173
+ } ) ;
174
+ testComponent . setAttribute ( 'data-test' , '123' )
175
+ testComponent . classList . add ( 'header-1' ) ;
176
+ const testComponents = querySelectorAllDeep ( `.header-1,.header-2 + .header-3` ) ;
177
+ expect ( testComponents . length ) . toEqual ( 2 ) ;
178
+ expect ( testComponents [ 1 ] . classList . contains ( 'header-3' ) ) . toBeTruthy ( ) ;
179
+ } ) ;
180
+
181
+ it ( 'split correctly on selector list (ignore white space)' , function ( ) {
182
+ const testComponent = createTestComponent ( parent , {
183
+ internalHTML : '<span class="header-2"></span><div data-test="Hello World" class="header-3">Content</div>'
184
+ } ) ;
185
+ createTestComponent ( testComponent , {
186
+ childClassName : 'header-4'
187
+ } ) ;
188
+ testComponent . setAttribute ( 'data-test' , '123' )
189
+ testComponent . classList . add ( 'header-1' ) ;
190
+ const testComponents = querySelectorAllDeep ( ` .header-1, .header-2 + .header-3` ) ;
191
+ expect ( testComponents . length ) . toEqual ( 2 ) ;
192
+ expect ( testComponents [ 1 ] . classList . contains ( 'header-3' ) ) . toBeTruthy ( ) ;
193
+ } ) ;
194
+
195
+
108
196
109
197
// describe(".perf", function() {
110
198
0 commit comments