source: trip-planner-front/node_modules/postcss-normalize-charset/dist/index.js@ ceaed42

Last change on this file since ceaed42 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 1.2 KB
Line 
1"use strict";
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6exports.default = void 0;
7const charset = 'charset'; // eslint-disable-next-line no-control-regex
8
9const nonAscii = /[^\x00-\x7F]/;
10
11function pluginCreator(opts = {}) {
12 return {
13 postcssPlugin: 'postcss-normalize-' + charset,
14
15 OnceExit(css, {
16 AtRule
17 }) {
18 let charsetRule;
19 let nonAsciiNode;
20 css.walk(node => {
21 if (node.type === 'atrule' && node.name === charset) {
22 if (!charsetRule) {
23 charsetRule = node;
24 }
25
26 node.remove();
27 } else if (!nonAsciiNode && node.parent === css && nonAscii.test(node.toString())) {
28 nonAsciiNode = node;
29 }
30 });
31
32 if (nonAsciiNode) {
33 if (!charsetRule && opts.add !== false) {
34 charsetRule = new AtRule({
35 name: charset,
36 params: '"utf-8"'
37 });
38 }
39
40 if (charsetRule) {
41 charsetRule.source = nonAsciiNode.source;
42 css.prepend(charsetRule);
43 }
44 }
45 }
46
47 };
48}
49
50pluginCreator.postcss = true;
51var _default = pluginCreator;
52exports.default = _default;
53module.exports = exports.default;
Note: See TracBrowser for help on using the repository browser.