Skip to content

Commit f6778b9

Browse files
committed
Prevent null contRules in CssRulesView
1 parent 6d1527a commit f6778b9

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

src/css_composer/view/CssRulesView.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,13 @@ module.exports = require('backbone').View.extend({
8686
const container = fragment || this.el;
8787
let contRules;
8888

89-
// Try to find a specific container for the rule, if it
90-
// containes a media query
89+
// Try to find a specific container for the rule (if it
90+
// containes a media query), otherwise get the default one
9191
try {
9292
contRules = container.querySelector(`#${blockId}`);
93-
} catch (e) {
93+
} catch (e) {}
94+
95+
if (!contRules) {
9496
contRules = container.querySelector(`#${defaultBlockId}`);
9597
}
9698

test/specs/css_composer/view/CssRulesView.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,11 @@ module.exports = {
8585
mediaText: '(max-width: 1000px)'
8686
},
8787
{
88-
selectorsAdd: '#testid2',
88+
selectorsAdd: '#testid3',
89+
mediaText: '(min-width: 900px)'
90+
},
91+
{
92+
selectorsAdd: '#testid4',
8993
mediaText: 'screen and (max-width: 900px) and (min-width: 600px)'
9094
}
9195
];

0 commit comments

Comments
 (0)