Last change
on this file was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
1.5 KB
|
Line | |
---|
1 | "use strict";
|
---|
2 |
|
---|
3 | Object.defineProperty(exports, "__esModule", {
|
---|
4 | value: true
|
---|
5 | });
|
---|
6 | exports.default = listStyleNormalizer;
|
---|
7 |
|
---|
8 | var _postcssValueParser = _interopRequireDefault(require("postcss-value-parser"));
|
---|
9 |
|
---|
10 | var _listStyleTypes = _interopRequireDefault(require("./listStyleTypes.json"));
|
---|
11 |
|
---|
12 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
---|
13 |
|
---|
14 | const definedTypes = _listStyleTypes.default['list-style-type'];
|
---|
15 | const definedPosition = ['inside', 'outside'];
|
---|
16 |
|
---|
17 | function listStyleNormalizer(listStyle) {
|
---|
18 | const order = {
|
---|
19 | type: '',
|
---|
20 | position: '',
|
---|
21 | image: ''
|
---|
22 | };
|
---|
23 | listStyle.walk(decl => {
|
---|
24 | if (decl.type === 'word') {
|
---|
25 | if (definedTypes.includes(decl.value)) {
|
---|
26 | // its a type field
|
---|
27 | order.type = `${order.type} ${decl.value}`;
|
---|
28 | } else if (definedPosition.includes(decl.value)) {
|
---|
29 | order.position = `${order.position} ${decl.value}`;
|
---|
30 | } else if (decl.value === 'none') {
|
---|
31 | if (order.type.split(' ').filter(e => e !== '' && e !== ' ').includes('none')) {
|
---|
32 | order.image = `${order.image} ${decl.value}`;
|
---|
33 | } else {
|
---|
34 | order.type = `${order.type} ${decl.value}`;
|
---|
35 | }
|
---|
36 | } else {
|
---|
37 | order.type = `${order.type} ${decl.value}`;
|
---|
38 | }
|
---|
39 | }
|
---|
40 |
|
---|
41 | if (decl.type === 'function') {
|
---|
42 | order.image = `${order.image} ${_postcssValueParser.default.stringify(decl)}`;
|
---|
43 | }
|
---|
44 | });
|
---|
45 | return `${order.type.trim()} ${order.position.trim()} ${order.image.trim()}`.trim();
|
---|
46 | }
|
---|
47 |
|
---|
48 | module.exports = exports.default; |
---|
Note:
See
TracBrowser
for help on using the repository browser.