postcss-focus-within 7.0.0 → 7.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/CHANGELOG.md +8 -0
- package/README.md +2 -2
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +2 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# Changes to PostCSS Focus Within
|
|
2
2
|
|
|
3
|
+
### 7.0.2 (February 8, 2023)
|
|
4
|
+
|
|
5
|
+
- Reduce the amount of duplicate fallback CSS.
|
|
6
|
+
|
|
7
|
+
### 7.0.1 (January 28, 2023)
|
|
8
|
+
|
|
9
|
+
- Improve `types` declaration in `package.json`
|
|
10
|
+
|
|
3
11
|
### 7.0.0 (January 24, 2023)
|
|
4
12
|
|
|
5
13
|
- Updated: Support for Node v14+ (major).
|
package/README.md
CHANGED
|
@@ -128,7 +128,7 @@ postcssFocusWithin({ disablePolyfillReadyClass: true })
|
|
|
128
128
|
|
|
129
129
|
/* becomes */
|
|
130
130
|
|
|
131
|
-
.my-form-field[focus-within] label
|
|
131
|
+
.my-form-field[focus-within] label {
|
|
132
132
|
background-color: yellow;
|
|
133
133
|
}
|
|
134
134
|
.my-form-field:focus-within label {
|
|
@@ -148,7 +148,7 @@ or
|
|
|
148
148
|
|
|
149
149
|
```html
|
|
150
150
|
<!-- When using a CDN url you will have to manually update the version number -->
|
|
151
|
-
<script src="https://unpkg.com/postcss-focus-within@7.0.
|
|
151
|
+
<script src="https://unpkg.com/postcss-focus-within@7.0.2/dist/browser-global.js"></script>
|
|
152
152
|
<script>focusWithinInit()</script>
|
|
153
153
|
```
|
|
154
154
|
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=require("postcss-selector-parser");const s=[" ",">","~",":","+","@","#","(",")"];function isValidReplacement(e){let
|
|
1
|
+
"use strict";var e=require("postcss-selector-parser");const s=[" ",">","~",":","+","@","#","(",")"];function isValidReplacement(e){let t=!0;for(let n=0,o=s.length;n<o&&t;n++)e.indexOf(s[n])>-1&&(t=!1);return t}const t="js-focus-within",n=":focus-within",creator=s=>{const o=Object.assign({preserve:!0,replaceWith:"[focus-within]",disablePolyfillReadyClass:!1},s),l=e().astSync(o.replaceWith);return isValidReplacement(o.replaceWith)?{postcssPlugin:"postcss-focus-within",prepare(){const s=new WeakSet;return{Rule(r,{result:a}){if(s.has(r))return;if(!r.selector.toLowerCase().includes(n))return;const i=r.selectors.flatMap((s=>{if(!s.toLowerCase().includes(n))return[s];let i;try{i=e().astSync(s)}catch(e){return r.warn(a,`Failed to parse selector : "${s}" with message: "${e.message}"`),s}if(void 0===i)return[s];let c=!1;if(i.walkPseudos((e=>{e.value.toLowerCase()===n&&(e.nodes&&e.nodes.length||(c=!0,e.replaceWith(l.clone({}))))})),!c)return[s];const u=i.clone();if(!o.disablePolyfillReadyClass){var d,p,f,h,g;if(null!=(d=i.nodes)&&null!=(p=d[0])&&null!=(f=p.nodes)&&f.length)for(let s=0;s<i.nodes[0].nodes.length;s++){const n=i.nodes[0].nodes[s];if("combinator"===n.type||e.isPseudoElement(n)){i.nodes[0].insertBefore(n,e.className({value:t}));break}if(s===i.nodes[0].nodes.length-1){i.nodes[0].append(e.className({value:t}));break}}return null!=(h=i.nodes)&&null!=(g=h[0])&&g.nodes&&(u.nodes[0].prepend(e.combinator({value:" "})),u.nodes[0].prepend(e.className({value:t}))),[i.toString(),u.toString()]}return[i.toString()]}));i.join(",")!==r.selectors.join(",")&&(s.add(r),r.cloneBefore({selectors:i}),o.preserve||r.remove())}}}}:{postcssPlugin:"postcss-focus-within",Once:(e,{result:s})=>{e.warn(s,`${o.replaceWith} is not a valid replacement since it can't be applied to single elements.`)}}};creator.postcss=!0,module.exports=creator;
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"postcss-selector-parser";const s=[" ",">","~",":","+","@","#","(",")"];function isValidReplacement(e){let
|
|
1
|
+
import e from"postcss-selector-parser";const s=[" ",">","~",":","+","@","#","(",")"];function isValidReplacement(e){let t=!0;for(let n=0,o=s.length;n<o&&t;n++)e.indexOf(s[n])>-1&&(t=!1);return t}const t="js-focus-within",n=":focus-within",creator=s=>{const o=Object.assign({preserve:!0,replaceWith:"[focus-within]",disablePolyfillReadyClass:!1},s),l=e().astSync(o.replaceWith);return isValidReplacement(o.replaceWith)?{postcssPlugin:"postcss-focus-within",prepare(){const s=new WeakSet;return{Rule(r,{result:a}){if(s.has(r))return;if(!r.selector.toLowerCase().includes(n))return;const i=r.selectors.flatMap((s=>{if(!s.toLowerCase().includes(n))return[s];let i;try{i=e().astSync(s)}catch(e){return r.warn(a,`Failed to parse selector : "${s}" with message: "${e.message}"`),s}if(void 0===i)return[s];let c=!1;if(i.walkPseudos((e=>{e.value.toLowerCase()===n&&(e.nodes&&e.nodes.length||(c=!0,e.replaceWith(l.clone({}))))})),!c)return[s];const d=i.clone();if(!o.disablePolyfillReadyClass){var u,p,f,h,m;if(null!=(u=i.nodes)&&null!=(p=u[0])&&null!=(f=p.nodes)&&f.length)for(let s=0;s<i.nodes[0].nodes.length;s++){const n=i.nodes[0].nodes[s];if("combinator"===n.type||e.isPseudoElement(n)){i.nodes[0].insertBefore(n,e.className({value:t}));break}if(s===i.nodes[0].nodes.length-1){i.nodes[0].append(e.className({value:t}));break}}return null!=(h=i.nodes)&&null!=(m=h[0])&&m.nodes&&(d.nodes[0].prepend(e.combinator({value:" "})),d.nodes[0].prepend(e.className({value:t}))),[i.toString(),d.toString()]}return[i.toString()]}));i.join(",")!==r.selectors.join(",")&&(s.add(r),r.cloneBefore({selectors:i}),o.preserve||r.remove())}}}}:{postcssPlugin:"postcss-focus-within",Once:(e,{result:s})=>{e.warn(s,`${o.replaceWith} is not a valid replacement since it can't be applied to single elements.`)}}};creator.postcss=!0;export{creator as default};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "postcss-focus-within",
|
|
3
3
|
"description": "Use the :focus-within pseudo-selector in CSS",
|
|
4
|
-
"version": "7.0.
|
|
4
|
+
"version": "7.0.2",
|
|
5
5
|
"contributors": [
|
|
6
6
|
{
|
|
7
7
|
"name": "Antonio Laguna",
|
|
@@ -30,6 +30,7 @@
|
|
|
30
30
|
"types": "dist/index.d.ts",
|
|
31
31
|
"exports": {
|
|
32
32
|
".": {
|
|
33
|
+
"types": "./dist/index.d.ts",
|
|
33
34
|
"import": "./dist/index.mjs",
|
|
34
35
|
"require": "./dist/index.cjs",
|
|
35
36
|
"default": "./dist/index.mjs"
|