File tree Expand file tree Collapse file tree 2 files changed +9
-2
lines changed Expand file tree Collapse file tree 2 files changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -18,8 +18,8 @@ export function extendStyle(htmlNode, cssNode) {
18
18
export function sortCssNodesBySpecificity ( nodes ) {
19
19
// Sort CSS nodes by specificity (ascending): div - .foo - #bar
20
20
return nodes . sort ( ( a , b ) => {
21
- a = getSpecificity ( a . selector ) ;
22
- b = getSpecificity ( b . selector ) ;
21
+ a = typeof a . selector == 'string' ? getSpecificity ( a . selector ) : 0 ;
22
+ b = typeof b . selector == 'string' ? getSpecificity ( b . selector ) : 0 ;
23
23
24
24
if ( a > b ) {
25
25
return 1 ;
Original file line number Diff line number Diff line change @@ -36,6 +36,13 @@ describe('Plugin', () => {
36
36
expect ( html ) . toBe ( expectedHtmlWithStyle ) ;
37
37
} ) ;
38
38
} ) ;
39
+
40
+ it ( 'should properly process any other nodes' , ( ) => {
41
+ var css = '@media {}/* comment */.test {color: red;}' ;
42
+ var html = '<div class="test">olala</div>' ;
43
+ var expectedHtml = '<div class="test" style="color: red">olala</div>' ;
44
+ return initPlugin ( css , html ) . then ( html => expect ( html ) . toBe ( expectedHtml ) ) ;
45
+ } ) ;
39
46
} ) ;
40
47
41
48
You can’t perform that action at this time.
0 commit comments