1 | 'use strict';
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 | exports.replaceAll = replaceAll;
|
7 | var matchConstName = /[$#]?[\w-\.]+/g;
|
8 |
|
9 | function replaceAll(replacements, text) {
|
10 | var matches = void 0;
|
11 | while (matches = matchConstName.exec(text)) {
|
12 | var replacement = replacements[matches[0]];
|
13 | if (replacement) {
|
14 | text = text.slice(0, matches.index) + replacement + text.slice(matchConstName.lastIndex);
|
15 | matchConstName.lastIndex -= matches[0].length - replacement.length;
|
16 | }
|
17 | }
|
18 | return text;
|
19 | }
|
20 |
|
21 | exports.default = function (css, translations) {
|
22 | css.walkDecls(function (decl) {
|
23 | return decl.value = replaceAll(translations, decl.value);
|
24 | });
|
25 | css.walkAtRules('media', function (atRule) {
|
26 | return atRule.params = replaceAll(translations, atRule.params);
|
27 | });
|
28 | }; |
\ | No newline at end of file |