Browse Source

Update ParserCSS, set some property conditionally

pull/803/head
Artur Arseniev 9 years ago
parent
commit
47987b9cbc
  1. 15
      src/parser/model/ParserCss.js
  2. 12
      test/specs/css_composer/model/CssModels.js
  3. 2
      test/specs/parser/model/ParserCss.js

15
src/parser/model/ParserCss.js

@ -133,7 +133,9 @@ module.exports = config => ({
// For each group of selectors
for (var k = 0, len3 = sels.length; k < len3; k++) {
var selArr = sels[k];
var model = { singleAtRule, atRuleType };
var model = {};
singleAtRule && (model.singleAtRule = singleAtRule);
atRuleType && (model.atRuleType = atRuleType);
//Isolate state from selector
var stateArr = selArr[selArr.length - 1].split(/:(.+)/);
@ -156,14 +158,15 @@ module.exports = config => ({
if (lastRule) {
lastRule.selectorsAdd = selsAddStr;
} else {
result.push({
singleAtRule,
atRuleType,
const model = {
selectors: [],
selectorsAdd: selsAddStr,
mediaText: condition,
style
});
};
singleAtRule && (model.singleAtRule = singleAtRule);
atRuleType && (model.atRuleType = atRuleType);
condition && (model.mediaText = condition);
result.push(model);
}
}
}

12
test/specs/css_composer/model/CssModels.js

@ -5,7 +5,7 @@ var Selector = require('selector_manager/model/Selector');
module.exports = {
run() {
describe.only('CssRule', () => {
describe('CssRule', () => {
let obj;
beforeEach(() => {
@ -89,6 +89,16 @@ module.exports = {
`@font-face{.test1{font-family:Open Sans;}}`
);
});
it('toCSS with a generic at-rule and condition', () => {
obj.set('atRuleType', 'font-face');
obj.set('mediaText', 'some-condition');
obj.get('selectors').add({ name: 'test1' });
obj.setStyle({ 'font-family': 'Open Sans' });
expect(obj.toCSS()).toEqual(
`@font-face some-condition{.test1{font-family:Open Sans;}}`
);
});
});
describe('CssRules', () => {

2
test/specs/parser/model/ParserCss.js

@ -2,7 +2,7 @@ const ParserCss = require('parser/model/ParserCss');
module.exports = {
run() {
describe('ParserCss', () => {
describe.only('ParserCss', () => {
var obj;
beforeEach(() => {

Loading…
Cancel
Save