css-has-pseudo 1.0.0 → 3.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/postcss.js DELETED
@@ -1,48 +0,0 @@
1
- 'use strict';
2
-
3
- function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
4
-
5
- var parser = _interopDefault(require('postcss-selector-parser'));
6
- var postcss$1 = _interopDefault(require('postcss'));
7
-
8
- const selectorRegExp = /:has/;
9
- var postcss = postcss$1.plugin('css-has-pseudo', opts => {
10
- const preserve = Boolean('preserve' in Object(opts) ? opts.preserve : true);
11
- return root => {
12
- root.walkRules(selectorRegExp, rule => {
13
- const modifiedSelector = parser(selectors => {
14
- selectors.walkPseudos(selector => {
15
- if (selector.value === ':has' && selector.nodes) {
16
- const isNotHas = checkIfParentIsNot(selector);
17
- selector.value = isNotHas ? ':not-has' : ':has';
18
- const attribute = parser.attribute({
19
- attribute: encodeURIComponent(String(selector)).replace(/%3A/g, ':').replace(/%5B/g, '[').replace(/%5D/g, ']').replace(/%2C/g, ',').replace(/[():%[\],]/g, '\\$&')
20
- });
21
-
22
- if (isNotHas) {
23
- selector.parent.parent.replaceWith(attribute);
24
- } else {
25
- selector.replaceWith(attribute);
26
- }
27
- }
28
- });
29
- }).processSync(rule.selector);
30
- const clone = rule.clone({
31
- selector: modifiedSelector
32
- });
33
-
34
- if (preserve) {
35
- rule.before(clone);
36
- } else {
37
- rule.replaceWith(clone);
38
- }
39
- });
40
- };
41
- });
42
-
43
- function checkIfParentIsNot(selector) {
44
- return Object(Object(selector.parent).parent).type === 'pseudo' && selector.parent.parent.value === ':not';
45
- }
46
-
47
- module.exports = postcss;
48
- //# sourceMappingURL=postcss.js.map
package/postcss.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"postcss.js","sources":["src/postcss.js"],"sourcesContent":["import parser from 'postcss-selector-parser';\nimport postcss from 'postcss';\n\nconst selectorRegExp = /:has/;\n\nexport default postcss.plugin('css-has-pseudo', opts => {\n\tconst preserve = Boolean('preserve' in Object(opts) ? opts.preserve : true);\n\n\treturn root => {\n\t\troot.walkRules(selectorRegExp, rule => {\n\t\t\tconst modifiedSelector = parser(selectors => {\n\t\t\t\tselectors.walkPseudos(selector => {\n\t\t\t\t\tif (selector.value === ':has' && selector.nodes) {\n\t\t\t\t\t\tconst isNotHas = checkIfParentIsNot(selector);\n\t\t\t\t\t\tselector.value = isNotHas ? ':not-has' : ':has';\n\n\t\t\t\t\t\tconst attribute = parser.attribute({\n\t\t\t\t\t\t\tattribute: encodeURIComponent(String(selector))\n\t\t\t\t\t\t\t.replace(/%3A/g, ':')\n\t\t\t\t\t\t\t.replace(/%5B/g, '[')\n\t\t\t\t\t\t\t.replace(/%5D/g, ']')\n\t\t\t\t\t\t\t.replace(/%2C/g, ',')\n\t\t\t\t\t\t\t.replace(/[():%[\\],]/g, '\\\\$&')\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\tif (isNotHas) {\n\t\t\t\t\t\t\tselector.parent.parent.replaceWith(attribute);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tselector.replaceWith(attribute);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}).processSync(rule.selector);\n\n\t\t\tconst clone = rule.clone({ selector: modifiedSelector });\n\n\t\t\tif (preserve) {\n\t\t\t\trule.before(clone);\n\t\t\t} else {\n\t\t\t\trule.replaceWith(clone);\n\t\t\t}\n\t\t});\n\t};\n});\n\nfunction checkIfParentIsNot (selector) {\n\treturn Object(Object(selector.parent).parent).type === 'pseudo' && selector.parent.parent.value === ':not';\n}\n"],"names":["selectorRegExp","postcss","plugin","opts","preserve","Boolean","Object","root","walkRules","rule","modifiedSelector","parser","selectors","walkPseudos","selector","value","nodes","isNotHas","checkIfParentIsNot","attribute","encodeURIComponent","String","replace","parent","replaceWith","processSync","clone","before","type"],"mappings":";;;;;;;AAGA,MAAMA,cAAc,GA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ADD,MAEO;QACNjB,IAAI,CAACe,WAAL,CAAiBE,KAAjB;;KA9BF;GADD;CAHc,CAAf;;AAwCA,SAASR,kBAAT,CAA6BJ,QAA7B,EAAuC;SAC/BR,MAAM,CAACA,MAAM,CAACQ,QAAQ,CAACS,MAAV,CAAN,CAAwBA,MAAzB,CAAN,CAAuCK,IAAvC,KAAgD,QAAhD,IAA4Dd,QAAQ,CAACS,MAAT,CAAgBA,MAAhB,CAAuBR,KAAvB,KAAiC,MAApG;;;;;"}
package/postcss.mjs DELETED
@@ -1,44 +0,0 @@
1
- import parser from 'postcss-selector-parser';
2
- import postcss$1 from 'postcss';
3
-
4
- const selectorRegExp = /:has/;
5
- var postcss = postcss$1.plugin('css-has-pseudo', opts => {
6
- const preserve = Boolean('preserve' in Object(opts) ? opts.preserve : true);
7
- return root => {
8
- root.walkRules(selectorRegExp, rule => {
9
- const modifiedSelector = parser(selectors => {
10
- selectors.walkPseudos(selector => {
11
- if (selector.value === ':has' && selector.nodes) {
12
- const isNotHas = checkIfParentIsNot(selector);
13
- selector.value = isNotHas ? ':not-has' : ':has';
14
- const attribute = parser.attribute({
15
- attribute: encodeURIComponent(String(selector)).replace(/%3A/g, ':').replace(/%5B/g, '[').replace(/%5D/g, ']').replace(/%2C/g, ',').replace(/[():%[\],]/g, '\\$&')
16
- });
17
-
18
- if (isNotHas) {
19
- selector.parent.parent.replaceWith(attribute);
20
- } else {
21
- selector.replaceWith(attribute);
22
- }
23
- }
24
- });
25
- }).processSync(rule.selector);
26
- const clone = rule.clone({
27
- selector: modifiedSelector
28
- });
29
-
30
- if (preserve) {
31
- rule.before(clone);
32
- } else {
33
- rule.replaceWith(clone);
34
- }
35
- });
36
- };
37
- });
38
-
39
- function checkIfParentIsNot(selector) {
40
- return Object(Object(selector.parent).parent).type === 'pseudo' && selector.parent.parent.value === ':not';
41
- }
42
-
43
- export default postcss;
44
- //# sourceMappingURL=postcss.mjs.map
package/postcss.mjs.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"postcss.mjs","sources":["src/postcss.js"],"sourcesContent":["import parser from 'postcss-selector-parser';\nimport postcss from 'postcss';\n\nconst selectorRegExp = /:has/;\n\nexport default postcss.plugin('css-has-pseudo', opts => {\n\tconst preserve = Boolean('preserve' in Object(opts) ? opts.preserve : true);\n\n\treturn root => {\n\t\troot.walkRules(selectorRegExp, rule => {\n\t\t\tconst modifiedSelector = parser(selectors => {\n\t\t\t\tselectors.walkPseudos(selector => {\n\t\t\t\t\tif (selector.value === ':has' && selector.nodes) {\n\t\t\t\t\t\tconst isNotHas = checkIfParentIsNot(selector);\n\t\t\t\t\t\tselector.value = isNotHas ? ':not-has' : ':has';\n\n\t\t\t\t\t\tconst attribute = parser.attribute({\n\t\t\t\t\t\t\tattribute: encodeURIComponent(String(selector))\n\t\t\t\t\t\t\t.replace(/%3A/g, ':')\n\t\t\t\t\t\t\t.replace(/%5B/g, '[')\n\t\t\t\t\t\t\t.replace(/%5D/g, ']')\n\t\t\t\t\t\t\t.replace(/%2C/g, ',')\n\t\t\t\t\t\t\t.replace(/[():%[\\],]/g, '\\\\$&')\n\t\t\t\t\t\t});\n\n\t\t\t\t\t\tif (isNotHas) {\n\t\t\t\t\t\t\tselector.parent.parent.replaceWith(attribute);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tselector.replaceWith(attribute);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}).processSync(rule.selector);\n\n\t\t\tconst clone = rule.clone({ selector: modifiedSelector });\n\n\t\t\tif (preserve) {\n\t\t\t\trule.before(clone);\n\t\t\t} else {\n\t\t\t\trule.replaceWith(clone);\n\t\t\t}\n\t\t});\n\t};\n});\n\nfunction checkIfParentIsNot (selector) {\n\treturn Object(Object(selector.parent).parent).type === 'pseudo' && selector.parent.parent.value === ':not';\n}\n"],"names":["selectorRegExp","postcss","plugin","opts","preserve","Boolean","Object","root","walkRules","rule","modifiedSelector","parser","selectors","walkPseudos","selector","value","nodes","isNotHas","checkIfParentIsNot","attribute","encodeURIComponent","String","replace","parent","replaceWith","processSync","clone","before","type"],"mappings":";;;AAGA,MAAMA,cAAc,GAAG,MAAvB;AAEA,cAAeC,SAAO,CAACC,MAAR,CAAe,gBAAf,EAAiCC,IAAI,IAAI;QACjDC,QAAQ,GAAGC,OAAO,CAAC,cAAcC,MAAM,CAACH,IAAD,CAApB,GAA6BA,IAAI,CAACC,QAAlC,GAA6C,IAA9C,CAAxB;SAEOG,IAAI,IAAI;IACdA,IAAI,CAACC,SAAL,CAAeR,cAAf,EAA+BS,IAAI,IAAI;YAChCC,gBAAgB,GAAGC,MAAM,CAACC,SAAS,IAAI;QAC5CA,SAAS,CAACC,WAAV,CAAsBC,QAAQ,IAAI;cAC7BA,QAAQ,CAACC,KAAT,KAAmB,MAAnB,IAA6BD,QAAQ,CAACE,KAA1C,EAAiD;kBAC1CC,QAAQ,GAAGC,kBAAkB,CAACJ,QAAD,CAAnC;YACAA,QAAQ,CAACC,KAAT,GAAiBE,QAAQ,GAAG,UAAH,GAAgB,MAAzC;kBAEME,SAAS,GAAGR,MAAM,CAACQ,SAAP,CAAiB;cAClCA,SAAS,EAAEC,kBAAkB,CAACC,MAAM,CAACP,QAAD,CAAP,CAAlB,CACVQ,OADU,CACF,MADE,EACM,GADN,EAEVA,OAFU,CAEF,MAFE,EAEM,GAFN,EAGVA,OAHU,CAGF,MAHE,EAGM,GAHN,EAIVA,OAJU,CAIF,MAJE,EAIM,GAJN,EAKVA,OALU,CAKF,aALE,EAKa,MALb;aADM,CAAlB;;gBASIL,QAAJ,EAAc;cACbH,QAAQ,CAACS,MAAT,CAAgBA,MAAhB,CAAuBC,WAAvB,CAAmCL,SAAnC;aADD,MAEO;cACNL,QAAQ,CAACU,WAAT,CAAqBL,SAArB;;;SAjBH;OAD8B,CAAN,CAsBtBM,WAtBsB,CAsBVhB,IAAI,CAACK,QAtBK,CAAzB;YAwBMY,KAAK,GAAGjB,IAAI,CAACiB,KAAL,CAAW;Q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