Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

maping through nested rules #2935

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions src/code_manager/model/CssGenerator.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,15 @@ export default Backbone.Model.extend({
const selectorStrNoAdd = rule.selectorsToString({ skipAdd: 1 });
const selectorsAdd = rule.get('selectorsAdd');
const singleAtRule = rule.get('singleAtRule');
let isGjsRule = false;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is the point of this variable? Seems like you don't use it...

let found;

// This will not render a rule if there is no its component
rule.get('selectors').each(selector => {
const name = selector.getFullName();
if (name.startsWith('.gjs')) {
isGjsRule = true;
}
if (
this.compCls.indexOf(name) >= 0 ||
this.ids.indexOf(name) >= 0 ||
Expand All @@ -121,8 +125,10 @@ export default Backbone.Model.extend({
}
});

if ((selectorStrNoAdd && found) || selectorsAdd || singleAtRule) {
const block = rule.getDeclaration();
if ((selectorStrNoAdd && found) || selectorsAdd || singleAtRule || rule.attributes.style) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rule.attributes.style is an object, it's a truthy value, so the condition is pointless

const entries = Object.entries(rule.attributes.style);
const styleStr = entries.length > 0 ? entries.map(([k, v]) => `${k}:${v}`).join(';') + ';' : '';
const block = rule.getDeclaration().length > 0 ? rule.getDeclaration() : styleStr;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're calling rule.getDeclaration() twice and honestly, I don't understand the point of this change

block && (result += block);
} else {
dump.push(rule);
Expand Down Expand Up @@ -160,4 +166,4 @@ export default Backbone.Model.extend({
return this.getQueryLength(left) - this.getQueryLength(right);
});
}
});
});
2 changes: 1 addition & 1 deletion src/parser/model/BrowserParserCss.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const atRules = {
};
const atRuleKeys = keys(atRules);
const singleAtRules = ['5', '6', '11', '15'];
const singleAtRulesNames = ['font-face', 'page', 'counter-style', 'viewport'];
const singleAtRulesNames = ['font-face', 'counter-style', 'viewport'];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you remove the page?


/**
* Parse selector string to array.
Expand Down