File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -168,6 +168,21 @@ export default {
168
168
return mapped . map ( ( item ) => arr [ item . index ] ) ;
169
169
} ,
170
170
171
+ /**
172
+ * Normalize a selector string by parsing and reassembling.
173
+ * Removes extraneous whitespace, unencodes unnecessary unicode escapes,
174
+ * removes comments, normalizes nth formulas.
175
+ *
176
+ * This idea could be expanded upon to sort simple selectors and even
177
+ * standardize a preference between identical selectors, e.g. :first-child and :nth-child(1).
178
+ *
179
+ * @param {String } selector selector string
180
+ * @return {String } normalized selector string
181
+ */
182
+ normalize ( selector ) {
183
+ return this . parse ( selector ) . map ( ( s ) => s . toString ( ) ) . join ( ', ' ) ;
184
+ } ,
185
+
171
186
// escape methods
172
187
escape : CSS . escape ,
173
188
escapeString : CSS . escapeString ,
You can’t perform that action at this time.
0 commit comments