complete parseSelector
This commit is contained in:
Родитель
4529adf3a5
Коммит
8043cce472
|
@ -14,5 +14,11 @@ export function parseSelector(selector) {
|
|||
}
|
||||
}
|
||||
|
||||
return { classes, id: _.first(ids) };
|
||||
const result = { classes };
|
||||
if (!_.isEmpty(ids)) {
|
||||
result.id = _.first(ids);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
16
spec/util.js
16
spec/util.js
|
@ -10,4 +10,20 @@ describe('parseSelector', function () {
|
|||
|
||||
expect(parseSelector(selector)).to.deep.equal({ classes });
|
||||
});
|
||||
|
||||
it('should parse id correctly', function () {
|
||||
const selector = '#foo#foo-bar';
|
||||
const id = 'foo';
|
||||
|
||||
expect(parseSelector(selector)).to.deep.equal({ classes: [], id });
|
||||
});
|
||||
|
||||
it('shoul parse mixed selector correctly', function () {
|
||||
const selector = '.foo#bar.foo-bar';
|
||||
const classes = ['foo', 'foo-bar'];
|
||||
const id = 'bar';
|
||||
|
||||
expect(parseSelector(selector)).to.deep.equal({ classes, id });
|
||||
});
|
||||
});
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче