postcss-focus-within 9.0.0 → 10.0.0
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 +4 -3
- package/README.md +5 -5
- package/dist/browser-global.js +1 -1
- package/dist/browser-global.js.map +1 -1
- package/dist/browser.cjs +1 -1
- package/dist/browser.cjs.map +1 -1
- package/dist/browser.mjs +1 -1
- package/dist/browser.mjs.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.mjs +1 -1
- package/package.json +5 -12
- package/dist/index.cjs +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
# Changes to PostCSS Focus Within
|
|
2
2
|
|
|
3
|
-
###
|
|
3
|
+
### 10.0.0
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
_January 14, 2026_
|
|
6
6
|
|
|
7
|
-
- Updated: Support for Node
|
|
7
|
+
- Updated: Support for Node `20.19.0` or later (major).
|
|
8
|
+
- Removed: `commonjs` API. In supported Node versions `require(esm)` will work without needing to make code changes.
|
|
8
9
|
|
|
9
10
|
[Full CHANGELOG](https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-focus-within/CHANGELOG.md)
|
package/README.md
CHANGED
|
@@ -9,7 +9,7 @@ To use this feature you need to do two things :
|
|
|
9
9
|
- add the [PostCSS plugin](#usage) that transforms the selector into a class or attribute
|
|
10
10
|
- add the [browser polyfill](#browser) that sets the attribute or class on elements in a browser
|
|
11
11
|
|
|
12
|
-
```
|
|
12
|
+
```css
|
|
13
13
|
.my-form-field:focus-within label {
|
|
14
14
|
background-color: yellow;
|
|
15
15
|
}
|
|
@@ -62,7 +62,7 @@ is preserved. By default, it is preserved.
|
|
|
62
62
|
postcssFocusWithin({ preserve: false })
|
|
63
63
|
```
|
|
64
64
|
|
|
65
|
-
```
|
|
65
|
+
```css
|
|
66
66
|
.my-form-field:focus-within label {
|
|
67
67
|
background-color: yellow;
|
|
68
68
|
}
|
|
@@ -86,7 +86,7 @@ to polyfill `classList` in those cases.
|
|
|
86
86
|
postcssFocusWithin({ replaceWith: '.focus-within' });
|
|
87
87
|
```
|
|
88
88
|
|
|
89
|
-
```
|
|
89
|
+
```css
|
|
90
90
|
.my-form-field:focus-within label {
|
|
91
91
|
background-color: yellow;
|
|
92
92
|
}
|
|
@@ -116,7 +116,7 @@ Set this to `true` to prevent the class from being added.
|
|
|
116
116
|
postcssFocusWithin({ disablePolyfillReadyClass: true })
|
|
117
117
|
```
|
|
118
118
|
|
|
119
|
-
```
|
|
119
|
+
```css
|
|
120
120
|
.my-form-field:focus-within label {
|
|
121
121
|
background-color: yellow;
|
|
122
122
|
}
|
|
@@ -143,7 +143,7 @@ or
|
|
|
143
143
|
|
|
144
144
|
```html
|
|
145
145
|
<!-- When using a CDN url you will have to manually update the version number -->
|
|
146
|
-
<script src="https://unpkg.com/postcss-focus-within@
|
|
146
|
+
<script src="https://unpkg.com/postcss-focus-within@10.0.0/dist/browser-global.js"></script>
|
|
147
147
|
<script>focusWithinInit()</script>
|
|
148
148
|
```
|
|
149
149
|
|
package/dist/browser-global.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
!function(){var e=[" ",">","~",":","+","@","#","(",")"];function isValidReplacement(t){for(var n=!0,i=0,c=e.length;i<c&&n;i++)t.indexOf(e[i])>-1&&(n=!1);return n}function focusWithin(e){var t={force:!1,replaceWith:"[focus-within]"};if(void 0!==e&&"force"in e&&(t.force=e.force),void 0!==e&&"replaceWith"in e&&(t.replaceWith=e.replaceWith),!isValidReplacement(t.replaceWith))throw new Error(t.replaceWith+" is not a valid replacement since it can't be applied to single elements.");try{if(document.querySelector(":focus-within"),!t.force)return}catch(d){}var n,i,c,o,r,a=(n=t.replaceWith,r=[],"."===n[0]?(i=n.slice(1),c=function remove(e){return e.classList.remove(i)},o=function add(e){return e.classList.add(i)}):(i=n.slice(1,-1),c=function remove(e){return e.removeAttribute(i,"")},o=function add(e){return e.setAttribute(i,"")}),function handleFocusChange(){r.forEach(
|
|
1
|
+
!function(){var e=[" ",">","~",":","+","@","#","(",")"];function isValidReplacement(t){for(var n=!0,i=0,c=e.length;i<c&&n;i++)t.indexOf(e[i])>-1&&(n=!1);return n}function focusWithin(e){var t={force:!1,replaceWith:"[focus-within]"};if(void 0!==e&&"force"in e&&(t.force=e.force),void 0!==e&&"replaceWith"in e&&(t.replaceWith=e.replaceWith),!isValidReplacement(t.replaceWith))throw new Error(t.replaceWith+" is not a valid replacement since it can't be applied to single elements.");try{if(document.querySelector(":focus-within"),!t.force)return}catch(d){}var n,i,c,o,r,a=(n=t.replaceWith,r=[],"."===n[0]?(i=n.slice(1),c=function remove(e){return e.classList.remove(i)},o=function add(e){return e.classList.add(i)}):(i=n.slice(1,-1),c=function remove(e){return e.removeAttribute(i,"")},o=function add(e){return e.setAttribute(i,"")}),function handleFocusChange(){r.forEach(function(e){return c(e)}),r.length=0;var e=document.activeElement;if(!/^(#document|HTML|BODY)$/.test(Object(e).nodeName))for(;e&&1===e.nodeType;)o(e),r.push(e),e=e.parentNode}),u=function initializeEventListeners(){document.documentElement.className.indexOf("js-focus-within")>-1||(document.documentElement.className=document.documentElement.className+" js-focus-within",document.addEventListener("focus",a,!0),document.addEventListener("blur",a,!0))};"complete"===document.readyState?u():document.addEventListener("DOMContentLoaded",u)}("object"==typeof window&&window||"object"==typeof self&&self||{}).focusWithinInit=focusWithin}();
|
|
2
2
|
//# sourceMappingURL=browser-global.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"browser-global.js","sources":["../src/is-valid-replacement.mjs","../src/browser.js","../src/browser-global.js"],"sourcesContent":["const INVALID_SELECTOR_CHAR = [\n\t' ', // Can't use child selector\n\t'>', // Can't use direct child selector\n\t'~', // Can't use sibling selector\n\t':', // Can't use pseudo selector\n\t'+', // Can't use adjacent selector\n\t'@', // Can't use at\n\t'#', // Can't use id selector\n\t'(', // Can't use parenthesis\n\t')', // Can't use parenthesis\n];\n\nexport default function isValidReplacement(selector) {\n\tlet isValid = true;\n\n\t// Purposely archaic so it's interoperable in old browsers\n\tfor (let i = 0, length = INVALID_SELECTOR_CHAR.length; i < length && isValid; i++) {\n\t\tif (selector.indexOf(INVALID_SELECTOR_CHAR[i]) > -1) {\n\t\t\tisValid = false;\n\t\t}\n\t}\n\n\treturn isValid;\n}\n","import isValidReplacement from './is-valid-replacement.mjs';\nfunction generateHandler(replaceWith) {\n\tlet selector;\n\tlet remove;\n\tlet add;\n\tconst lastElements = [];\n\n\tif (replaceWith[0] === '.') {\n\t\tselector = replaceWith.slice(1);\n\t\tremove = (el) => el.classList.remove(selector);\n\t\tadd = (el) => el.classList.add(selector);\n\t} else {\n\t\t// A bit naive\n\t\tselector = replaceWith.slice(1, -1);\n\t\tremove = (el) => el.removeAttribute(selector, '');\n\t\tadd = (el) => el.setAttribute(selector, '');\n\t}\n\n\treturn function handleFocusChange() {\n\t\tlastElements.forEach(lastElement => remove(lastElement));\n\t\tlastElements.length = 0;\n\n\t\tlet activeElement = document.activeElement;\n\n\t\t// only add focus if it has not been added and is not the document element\n\t\tif (!/^(#document|HTML|BODY)$/.test(Object(activeElement).nodeName)) {\n\t\t\twhile (activeElement && activeElement.nodeType === 1) {\n\t\t\t\tadd(activeElement);\n\t\t\t\tlastElements.push(activeElement);\n\n\t\t\t\tactiveElement = activeElement.parentNode;\n\t\t\t}\n\t\t}\n\t};\n}\n\nexport default function focusWithin(opts) {\n\t// configuration\n\tconst options = {\n\t\tforce: false,\n\t\treplaceWith: '[focus-within]',\n\t};\n\n\tif (typeof opts !== 'undefined' && 'force' in opts) {\n\t\toptions.force = opts.force;\n\t}\n\n\tif (typeof opts !== 'undefined' && 'replaceWith' in opts) {\n\t\toptions.replaceWith = opts.replaceWith;\n\t}\n\n\tif (!isValidReplacement(options.replaceWith)) {\n\t\tthrow new Error(`${options.replaceWith} is not a valid replacement since it can't be applied to single elements.`);\n\t}\n\n\ttry {\n\t\tdocument.querySelector(':focus-within');\n\n\t\tif (!options.force) {\n\t\t\treturn;\n\t\t}\n\t} catch (_) {}\n\n\tconst handleFocusChange = generateHandler(options.replaceWith);\n\n\tconst initialize = function initializeEventListeners() {\n\t\tif (document.documentElement.className.indexOf('js-focus-within') > -1) {\n\t\t\treturn;\n\t\t}\n\n\t\tdocument.documentElement.className = document.documentElement.className + ' js-focus-within';\n\t\tdocument.addEventListener('focus', handleFocusChange, true);\n\t\tdocument.addEventListener('blur', handleFocusChange, true);\n\t};\n\n\tif (document.readyState === 'complete') {\n\t\tinitialize();\n\t} else {\n\t\tdocument.addEventListener('DOMContentLoaded', initialize);\n\t}\n}\n","import { default as focusWithinInit } from './browser';\n\n(function (global) {\n\tglobal.focusWithinInit = focusWithinInit;\n}('object' === typeof window && window || 'object' === typeof self && self || {}));\n"],"names":["INVALID_SELECTOR_CHAR","isValidReplacement","selector","isValid","i","length","indexOf","focusWithin","opts","options","force","replaceWith","Error","document","querySelector","_","remove","add","lastElements","handleFocusChange","slice","el","classList","removeAttribute","setAttribute","forEach","lastElement","activeElement","test","Object","nodeName","nodeType","push","parentNode","initialize","initializeEventListeners","documentElement","className","addEventListener","readyState","window","self","focusWithinInit"],"mappings":"YAAA,IAAMA,EAAwB,CAC7B,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,KAGc,SAASC,mBAAmBC,GAI1C,IAHA,IAAIC,GAAU,EAGLC,EAAI,EAAGC,EAASL,EAAsBK,OAAQD,EAAIC,GAAUF,EAASC,IACzEF,EAASI,QAAQN,EAAsBI,
|
|
1
|
+
{"version":3,"file":"browser-global.js","sources":["../src/is-valid-replacement.mjs","../src/browser.js","../src/browser-global.js"],"sourcesContent":["const INVALID_SELECTOR_CHAR = [\n\t' ', // Can't use child selector\n\t'>', // Can't use direct child selector\n\t'~', // Can't use sibling selector\n\t':', // Can't use pseudo selector\n\t'+', // Can't use adjacent selector\n\t'@', // Can't use at\n\t'#', // Can't use id selector\n\t'(', // Can't use parenthesis\n\t')', // Can't use parenthesis\n];\n\nexport default function isValidReplacement(selector) {\n\tlet isValid = true;\n\n\t// Purposely archaic so it's interoperable in old browsers\n\tfor (let i = 0, length = INVALID_SELECTOR_CHAR.length; i < length && isValid; i++) {\n\t\tif (selector.indexOf(INVALID_SELECTOR_CHAR[i]) > -1) {\n\t\t\tisValid = false;\n\t\t}\n\t}\n\n\treturn isValid;\n}\n","import isValidReplacement from './is-valid-replacement.mjs';\nfunction generateHandler(replaceWith) {\n\tlet selector;\n\tlet remove;\n\tlet add;\n\tconst lastElements = [];\n\n\tif (replaceWith[0] === '.') {\n\t\tselector = replaceWith.slice(1);\n\t\tremove = (el) => el.classList.remove(selector);\n\t\tadd = (el) => el.classList.add(selector);\n\t} else {\n\t\t// A bit naive\n\t\tselector = replaceWith.slice(1, -1);\n\t\tremove = (el) => el.removeAttribute(selector, '');\n\t\tadd = (el) => el.setAttribute(selector, '');\n\t}\n\n\treturn function handleFocusChange() {\n\t\tlastElements.forEach(lastElement => remove(lastElement));\n\t\tlastElements.length = 0;\n\n\t\tlet activeElement = document.activeElement;\n\n\t\t// only add focus if it has not been added and is not the document element\n\t\tif (!/^(#document|HTML|BODY)$/.test(Object(activeElement).nodeName)) {\n\t\t\twhile (activeElement && activeElement.nodeType === 1) {\n\t\t\t\tadd(activeElement);\n\t\t\t\tlastElements.push(activeElement);\n\n\t\t\t\tactiveElement = activeElement.parentNode;\n\t\t\t}\n\t\t}\n\t};\n}\n\nexport default function focusWithin(opts) {\n\t// configuration\n\tconst options = {\n\t\tforce: false,\n\t\treplaceWith: '[focus-within]',\n\t};\n\n\tif (typeof opts !== 'undefined' && 'force' in opts) {\n\t\toptions.force = opts.force;\n\t}\n\n\tif (typeof opts !== 'undefined' && 'replaceWith' in opts) {\n\t\toptions.replaceWith = opts.replaceWith;\n\t}\n\n\tif (!isValidReplacement(options.replaceWith)) {\n\t\tthrow new Error(`${options.replaceWith} is not a valid replacement since it can't be applied to single elements.`);\n\t}\n\n\ttry {\n\t\tdocument.querySelector(':focus-within');\n\n\t\tif (!options.force) {\n\t\t\treturn;\n\t\t}\n\t} catch (_) {}\n\n\tconst handleFocusChange = generateHandler(options.replaceWith);\n\n\tconst initialize = function initializeEventListeners() {\n\t\tif (document.documentElement.className.indexOf('js-focus-within') > -1) {\n\t\t\treturn;\n\t\t}\n\n\t\tdocument.documentElement.className = document.documentElement.className + ' js-focus-within';\n\t\tdocument.addEventListener('focus', handleFocusChange, true);\n\t\tdocument.addEventListener('blur', handleFocusChange, true);\n\t};\n\n\tif (document.readyState === 'complete') {\n\t\tinitialize();\n\t} else {\n\t\tdocument.addEventListener('DOMContentLoaded', initialize);\n\t}\n}\n","import { default as focusWithinInit } from './browser';\n\n(function (global) {\n\tglobal.focusWithinInit = focusWithinInit;\n}('object' === typeof window && window || 'object' === typeof self && self || {}));\n"],"names":["INVALID_SELECTOR_CHAR","isValidReplacement","selector","isValid","i","length","indexOf","focusWithin","opts","options","force","replaceWith","Error","document","querySelector","_","remove","add","lastElements","handleFocusChange","slice","el","classList","removeAttribute","setAttribute","forEach","lastElement","activeElement","test","Object","nodeName","nodeType","push","parentNode","initialize","initializeEventListeners","documentElement","className","addEventListener","readyState","window","self","focusWithinInit"],"mappings":"YAAA,IAAMA,EAAwB,CAC7B,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,KAGc,SAASC,mBAAmBC,GAI1C,IAHA,IAAIC,GAAU,EAGLC,EAAI,EAAGC,EAASL,EAAsBK,OAAQD,EAAIC,GAAUF,EAASC,IACzEF,EAASI,QAAQN,EAAsBI,KAAM,IAChDD,GAAU,GAIZ,OAAOA,CACR,CCae,SAASI,YAAYC,GAEnC,IAAMC,EAAU,CACfC,OAAO,EACPC,YAAa,kBAWd,QARoB,IAATH,GAAwB,UAAWA,IAC7CC,EAAQC,MAAQF,EAAKE,YAGF,IAATF,GAAwB,gBAAiBA,IACnDC,EAAQE,YAAcH,EAAKG,cAGvBV,mBAAmBQ,EAAQE,aAC/B,MAAM,IAAIC,MAASH,EAAQE,y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];function isValidReplacement(t){for(var n=!0,c=0,i=e.length;c<i&&n;c++)t.indexOf(e[c])>-1&&(n=!1);return n}module.exports=function focusWithin(e){var t={force:!1,replaceWith:"[focus-within]"};if(void 0!==e&&"force"in e&&(t.force=e.force),void 0!==e&&"replaceWith"in e&&(t.replaceWith=e.replaceWith),!isValidReplacement(t.replaceWith))throw new Error(t.replaceWith+" is not a valid replacement since it can't be applied to single elements.");try{if(document.querySelector(":focus-within"),!t.force)return}catch(d){}var n,c,i,o,r,a=(n=t.replaceWith,r=[],"."===n[0]?(c=n.slice(1),i=function remove(e){return e.classList.remove(c)},o=function add(e){return e.classList.add(c)}):(c=n.slice(1,-1),i=function remove(e){return e.removeAttribute(c,"")},o=function add(e){return e.setAttribute(c,"")}),function handleFocusChange(){r.forEach(
|
|
1
|
+
var e=[" ",">","~",":","+","@","#","(",")"];function isValidReplacement(t){for(var n=!0,c=0,i=e.length;c<i&&n;c++)t.indexOf(e[c])>-1&&(n=!1);return n}module.exports=function focusWithin(e){var t={force:!1,replaceWith:"[focus-within]"};if(void 0!==e&&"force"in e&&(t.force=e.force),void 0!==e&&"replaceWith"in e&&(t.replaceWith=e.replaceWith),!isValidReplacement(t.replaceWith))throw new Error(t.replaceWith+" is not a valid replacement since it can't be applied to single elements.");try{if(document.querySelector(":focus-within"),!t.force)return}catch(d){}var n,c,i,o,r,a=(n=t.replaceWith,r=[],"."===n[0]?(c=n.slice(1),i=function remove(e){return e.classList.remove(c)},o=function add(e){return e.classList.add(c)}):(c=n.slice(1,-1),i=function remove(e){return e.removeAttribute(c,"")},o=function add(e){return e.setAttribute(c,"")}),function handleFocusChange(){r.forEach(function(e){return i(e)}),r.length=0;var e=document.activeElement;if(!/^(#document|HTML|BODY)$/.test(Object(e).nodeName))for(;e&&1===e.nodeType;)o(e),r.push(e),e=e.parentNode}),u=function initializeEventListeners(){document.documentElement.className.indexOf("js-focus-within")>-1||(document.documentElement.className=document.documentElement.className+" js-focus-within",document.addEventListener("focus",a,!0),document.addEventListener("blur",a,!0))};"complete"===document.readyState?u():document.addEventListener("DOMContentLoaded",u)};
|
|
2
2
|
//# sourceMappingURL=browser.cjs.map
|
package/dist/browser.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"browser.cjs","sources":["../src/is-valid-replacement.mjs","../src/browser.js"],"sourcesContent":["const INVALID_SELECTOR_CHAR = [\n\t' ', // Can't use child selector\n\t'>', // Can't use direct child selector\n\t'~', // Can't use sibling selector\n\t':', // Can't use pseudo selector\n\t'+', // Can't use adjacent selector\n\t'@', // Can't use at\n\t'#', // Can't use id selector\n\t'(', // Can't use parenthesis\n\t')', // Can't use parenthesis\n];\n\nexport default function isValidReplacement(selector) {\n\tlet isValid = true;\n\n\t// Purposely archaic so it's interoperable in old browsers\n\tfor (let i = 0, length = INVALID_SELECTOR_CHAR.length; i < length && isValid; i++) {\n\t\tif (selector.indexOf(INVALID_SELECTOR_CHAR[i]) > -1) {\n\t\t\tisValid = false;\n\t\t}\n\t}\n\n\treturn isValid;\n}\n","import isValidReplacement from './is-valid-replacement.mjs';\nfunction generateHandler(replaceWith) {\n\tlet selector;\n\tlet remove;\n\tlet add;\n\tconst lastElements = [];\n\n\tif (replaceWith[0] === '.') {\n\t\tselector = replaceWith.slice(1);\n\t\tremove = (el) => el.classList.remove(selector);\n\t\tadd = (el) => el.classList.add(selector);\n\t} else {\n\t\t// A bit naive\n\t\tselector = replaceWith.slice(1, -1);\n\t\tremove = (el) => el.removeAttribute(selector, '');\n\t\tadd = (el) => el.setAttribute(selector, '');\n\t}\n\n\treturn function handleFocusChange() {\n\t\tlastElements.forEach(lastElement => remove(lastElement));\n\t\tlastElements.length = 0;\n\n\t\tlet activeElement = document.activeElement;\n\n\t\t// only add focus if it has not been added and is not the document element\n\t\tif (!/^(#document|HTML|BODY)$/.test(Object(activeElement).nodeName)) {\n\t\t\twhile (activeElement && activeElement.nodeType === 1) {\n\t\t\t\tadd(activeElement);\n\t\t\t\tlastElements.push(activeElement);\n\n\t\t\t\tactiveElement = activeElement.parentNode;\n\t\t\t}\n\t\t}\n\t};\n}\n\nexport default function focusWithin(opts) {\n\t// configuration\n\tconst options = {\n\t\tforce: false,\n\t\treplaceWith: '[focus-within]',\n\t};\n\n\tif (typeof opts !== 'undefined' && 'force' in opts) {\n\t\toptions.force = opts.force;\n\t}\n\n\tif (typeof opts !== 'undefined' && 'replaceWith' in opts) {\n\t\toptions.replaceWith = opts.replaceWith;\n\t}\n\n\tif (!isValidReplacement(options.replaceWith)) {\n\t\tthrow new Error(`${options.replaceWith} is not a valid replacement since it can't be applied to single elements.`);\n\t}\n\n\ttry {\n\t\tdocument.querySelector(':focus-within');\n\n\t\tif (!options.force) {\n\t\t\treturn;\n\t\t}\n\t} catch (_) {}\n\n\tconst handleFocusChange = generateHandler(options.replaceWith);\n\n\tconst initialize = function initializeEventListeners() {\n\t\tif (document.documentElement.className.indexOf('js-focus-within') > -1) {\n\t\t\treturn;\n\t\t}\n\n\t\tdocument.documentElement.className = document.documentElement.className + ' js-focus-within';\n\t\tdocument.addEventListener('focus', handleFocusChange, true);\n\t\tdocument.addEventListener('blur', handleFocusChange, true);\n\t};\n\n\tif (document.readyState === 'complete') {\n\t\tinitialize();\n\t} else {\n\t\tdocument.addEventListener('DOMContentLoaded', initialize);\n\t}\n}\n"],"names":["INVALID_SELECTOR_CHAR","isValidReplacement","selector","isValid","i","length","indexOf","focusWithin","opts","options","force","replaceWith","Error","document","querySelector","_","remove","add","lastElements","handleFocusChange","slice","el","classList","removeAttribute","setAttribute","forEach","lastElement","activeElement","test","Object","nodeName","nodeType","push","parentNode","initialize","initializeEventListeners","documentElement","className","addEventListener","readyState"],"mappings":"AAAA,IAAMA,EAAwB,CAC7B,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,KAGc,SAASC,mBAAmBC,GAI1C,IAHA,IAAIC,GAAU,EAGLC,EAAI,EAAGC,EAASL,EAAsBK,OAAQD,EAAIC,GAAUF,EAASC,IACzEF,EAASI,QAAQN,EAAsBI,
|
|
1
|
+
{"version":3,"file":"browser.cjs","sources":["../src/is-valid-replacement.mjs","../src/browser.js"],"sourcesContent":["const INVALID_SELECTOR_CHAR = [\n\t' ', // Can't use child selector\n\t'>', // Can't use direct child selector\n\t'~', // Can't use sibling selector\n\t':', // Can't use pseudo selector\n\t'+', // Can't use adjacent selector\n\t'@', // Can't use at\n\t'#', // Can't use id selector\n\t'(', // Can't use parenthesis\n\t')', // Can't use parenthesis\n];\n\nexport default function isValidReplacement(selector) {\n\tlet isValid = true;\n\n\t// Purposely archaic so it's interoperable in old browsers\n\tfor (let i = 0, length = INVALID_SELECTOR_CHAR.length; i < length && isValid; i++) {\n\t\tif (selector.indexOf(INVALID_SELECTOR_CHAR[i]) > -1) {\n\t\t\tisValid = false;\n\t\t}\n\t}\n\n\treturn isValid;\n}\n","import isValidReplacement from './is-valid-replacement.mjs';\nfunction generateHandler(replaceWith) {\n\tlet selector;\n\tlet remove;\n\tlet add;\n\tconst lastElements = [];\n\n\tif (replaceWith[0] === '.') {\n\t\tselector = replaceWith.slice(1);\n\t\tremove = (el) => el.classList.remove(selector);\n\t\tadd = (el) => el.classList.add(selector);\n\t} else {\n\t\t// A bit naive\n\t\tselector = replaceWith.slice(1, -1);\n\t\tremove = (el) => el.removeAttribute(selector, '');\n\t\tadd = (el) => el.setAttribute(selector, '');\n\t}\n\n\treturn function handleFocusChange() {\n\t\tlastElements.forEach(lastElement => remove(lastElement));\n\t\tlastElements.length = 0;\n\n\t\tlet activeElement = document.activeElement;\n\n\t\t// only add focus if it has not been added and is not the document element\n\t\tif (!/^(#document|HTML|BODY)$/.test(Object(activeElement).nodeName)) {\n\t\t\twhile (activeElement && activeElement.nodeType === 1) {\n\t\t\t\tadd(activeElement);\n\t\t\t\tlastElements.push(activeElement);\n\n\t\t\t\tactiveElement = activeElement.parentNode;\n\t\t\t}\n\t\t}\n\t};\n}\n\nexport default function focusWithin(opts) {\n\t// configuration\n\tconst options = {\n\t\tforce: false,\n\t\treplaceWith: '[focus-within]',\n\t};\n\n\tif (typeof opts !== 'undefined' && 'force' in opts) {\n\t\toptions.force = opts.force;\n\t}\n\n\tif (typeof opts !== 'undefined' && 'replaceWith' in opts) {\n\t\toptions.replaceWith = opts.replaceWith;\n\t}\n\n\tif (!isValidReplacement(options.replaceWith)) {\n\t\tthrow new Error(`${options.replaceWith} is not a valid replacement since it can't be applied to single elements.`);\n\t}\n\n\ttry {\n\t\tdocument.querySelector(':focus-within');\n\n\t\tif (!options.force) {\n\t\t\treturn;\n\t\t}\n\t} catch (_) {}\n\n\tconst handleFocusChange = generateHandler(options.replaceWith);\n\n\tconst initialize = function initializeEventListeners() {\n\t\tif (document.documentElement.className.indexOf('js-focus-within') > -1) {\n\t\t\treturn;\n\t\t}\n\n\t\tdocument.documentElement.className = document.documentElement.className + ' js-focus-within';\n\t\tdocument.addEventListener('focus', handleFocusChange, true);\n\t\tdocument.addEventListener('blur', handleFocusChange, true);\n\t};\n\n\tif (document.readyState === 'complete') {\n\t\tinitialize();\n\t} else {\n\t\tdocument.addEventListener('DOMContentLoaded', initialize);\n\t}\n}\n"],"names":["INVALID_SELECTOR_CHAR","isValidReplacement","selector","isValid","i","length","indexOf","focusWithin","opts","options","force","replaceWith","Error","document","querySelector","_","remove","add","lastElements","handleFocusChange","slice","el","classList","removeAttribute","setAttribute","forEach","lastElement","activeElement","test","Object","nodeName","nodeType","push","parentNode","initialize","initializeEventListeners","documentElement","className","addEventListener","readyState"],"mappings":"AAAA,IAAMA,EAAwB,CAC7B,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,KAGc,SAASC,mBAAmBC,GAI1C,IAHA,IAAIC,GAAU,EAGLC,EAAI,EAAGC,EAASL,EAAsBK,OAAQD,EAAIC,GAAUF,EAASC,IACzEF,EAASI,QAAQN,EAAsBI,KAAM,IAChDD,GAAU,GAIZ,OAAOA,CACR,gBCae,SAASI,YAAYC,GAEnC,IAAMC,EAAU,CACfC,OAAO,EACPC,Y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iBAAiB,mBAAoBJ,EAEhD"}
|
package/dist/browser.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var e=[" ",">","~",":","+","@","#","(",")"];function isValidReplacement(t){for(var n=!0,i=0,c=e.length;i<c&&n;i++)t.indexOf(e[i])>-1&&(n=!1);return n}function focusWithin(e){var t={force:!1,replaceWith:"[focus-within]"};if(void 0!==e&&"force"in e&&(t.force=e.force),void 0!==e&&"replaceWith"in e&&(t.replaceWith=e.replaceWith),!isValidReplacement(t.replaceWith))throw new Error(t.replaceWith+" is not a valid replacement since it can't be applied to single elements.");try{if(document.querySelector(":focus-within"),!t.force)return}catch(d){}var n,i,c,o,r,a=(n=t.replaceWith,r=[],"."===n[0]?(i=n.slice(1),c=function remove(e){return e.classList.remove(i)},o=function add(e){return e.classList.add(i)}):(i=n.slice(1,-1),c=function remove(e){return e.removeAttribute(i,"")},o=function add(e){return e.setAttribute(i,"")}),function handleFocusChange(){r.forEach(
|
|
1
|
+
var e=[" ",">","~",":","+","@","#","(",")"];function isValidReplacement(t){for(var n=!0,i=0,c=e.length;i<c&&n;i++)t.indexOf(e[i])>-1&&(n=!1);return n}function focusWithin(e){var t={force:!1,replaceWith:"[focus-within]"};if(void 0!==e&&"force"in e&&(t.force=e.force),void 0!==e&&"replaceWith"in e&&(t.replaceWith=e.replaceWith),!isValidReplacement(t.replaceWith))throw new Error(t.replaceWith+" is not a valid replacement since it can't be applied to single elements.");try{if(document.querySelector(":focus-within"),!t.force)return}catch(d){}var n,i,c,o,r,a=(n=t.replaceWith,r=[],"."===n[0]?(i=n.slice(1),c=function remove(e){return e.classList.remove(i)},o=function add(e){return e.classList.add(i)}):(i=n.slice(1,-1),c=function remove(e){return e.removeAttribute(i,"")},o=function add(e){return e.setAttribute(i,"")}),function handleFocusChange(){r.forEach(function(e){return c(e)}),r.length=0;var e=document.activeElement;if(!/^(#document|HTML|BODY)$/.test(Object(e).nodeName))for(;e&&1===e.nodeType;)o(e),r.push(e),e=e.parentNode}),u=function initializeEventListeners(){document.documentElement.className.indexOf("js-focus-within")>-1||(document.documentElement.className=document.documentElement.className+" js-focus-within",document.addEventListener("focus",a,!0),document.addEventListener("blur",a,!0))};"complete"===document.readyState?u():document.addEventListener("DOMContentLoaded",u)}export{focusWithin as default};
|
|
2
2
|
//# sourceMappingURL=browser.mjs.map
|
package/dist/browser.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"browser.mjs","sources":["../src/is-valid-replacement.mjs","../src/browser.js"],"sourcesContent":["const INVALID_SELECTOR_CHAR = [\n\t' ', // Can't use child selector\n\t'>', // Can't use direct child selector\n\t'~', // Can't use sibling selector\n\t':', // Can't use pseudo selector\n\t'+', // Can't use adjacent selector\n\t'@', // Can't use at\n\t'#', // Can't use id selector\n\t'(', // Can't use parenthesis\n\t')', // Can't use parenthesis\n];\n\nexport default function isValidReplacement(selector) {\n\tlet isValid = true;\n\n\t// Purposely archaic so it's interoperable in old browsers\n\tfor (let i = 0, length = INVALID_SELECTOR_CHAR.length; i < length && isValid; i++) {\n\t\tif (selector.indexOf(INVALID_SELECTOR_CHAR[i]) > -1) {\n\t\t\tisValid = false;\n\t\t}\n\t}\n\n\treturn isValid;\n}\n","import isValidReplacement from './is-valid-replacement.mjs';\nfunction generateHandler(replaceWith) {\n\tlet selector;\n\tlet remove;\n\tlet add;\n\tconst lastElements = [];\n\n\tif (replaceWith[0] === '.') {\n\t\tselector = replaceWith.slice(1);\n\t\tremove = (el) => el.classList.remove(selector);\n\t\tadd = (el) => el.classList.add(selector);\n\t} else {\n\t\t// A bit naive\n\t\tselector = replaceWith.slice(1, -1);\n\t\tremove = (el) => el.removeAttribute(selector, '');\n\t\tadd = (el) => el.setAttribute(selector, '');\n\t}\n\n\treturn function handleFocusChange() {\n\t\tlastElements.forEach(lastElement => remove(lastElement));\n\t\tlastElements.length = 0;\n\n\t\tlet activeElement = document.activeElement;\n\n\t\t// only add focus if it has not been added and is not the document element\n\t\tif (!/^(#document|HTML|BODY)$/.test(Object(activeElement).nodeName)) {\n\t\t\twhile (activeElement && activeElement.nodeType === 1) {\n\t\t\t\tadd(activeElement);\n\t\t\t\tlastElements.push(activeElement);\n\n\t\t\t\tactiveElement = activeElement.parentNode;\n\t\t\t}\n\t\t}\n\t};\n}\n\nexport default function focusWithin(opts) {\n\t// configuration\n\tconst options = {\n\t\tforce: false,\n\t\treplaceWith: '[focus-within]',\n\t};\n\n\tif (typeof opts !== 'undefined' && 'force' in opts) {\n\t\toptions.force = opts.force;\n\t}\n\n\tif (typeof opts !== 'undefined' && 'replaceWith' in opts) {\n\t\toptions.replaceWith = opts.replaceWith;\n\t}\n\n\tif (!isValidReplacement(options.replaceWith)) {\n\t\tthrow new Error(`${options.replaceWith} is not a valid replacement since it can't be applied to single elements.`);\n\t}\n\n\ttry {\n\t\tdocument.querySelector(':focus-within');\n\n\t\tif (!options.force) {\n\t\t\treturn;\n\t\t}\n\t} catch (_) {}\n\n\tconst handleFocusChange = generateHandler(options.replaceWith);\n\n\tconst initialize = function initializeEventListeners() {\n\t\tif (document.documentElement.className.indexOf('js-focus-within') > -1) {\n\t\t\treturn;\n\t\t}\n\n\t\tdocument.documentElement.className = document.documentElement.className + ' js-focus-within';\n\t\tdocument.addEventListener('focus', handleFocusChange, true);\n\t\tdocument.addEventListener('blur', handleFocusChange, true);\n\t};\n\n\tif (document.readyState === 'complete') {\n\t\tinitialize();\n\t} else {\n\t\tdocument.addEventListener('DOMContentLoaded', initialize);\n\t}\n}\n"],"names":["INVALID_SELECTOR_CHAR","isValidReplacement","selector","isValid","i","length","indexOf","focusWithin","opts","options","force","replaceWith","Error","document","querySelector","_","remove","add","lastElements","handleFocusChange","slice","el","classList","removeAttribute","setAttribute","forEach","lastElement","activeElement","test","Object","nodeName","nodeType","push","parentNode","initialize","initializeEventListeners","documentElement","className","addEventListener","readyState"],"mappings":"AAAA,IAAMA,EAAwB,CAC7B,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,KAGc,SAASC,mBAAmBC,GAI1C,IAHA,IAAIC,GAAU,EAGLC,EAAI,EAAGC,EAASL,EAAsBK,OAAQD,EAAIC,GAAUF,EAASC,IACzEF,EAASI,QAAQN,EAAsBI,
|
|
1
|
+
{"version":3,"file":"browser.mjs","sources":["../src/is-valid-replacement.mjs","../src/browser.js"],"sourcesContent":["const INVALID_SELECTOR_CHAR = [\n\t' ', // Can't use child selector\n\t'>', // Can't use direct child selector\n\t'~', // Can't use sibling selector\n\t':', // Can't use pseudo selector\n\t'+', // Can't use adjacent selector\n\t'@', // Can't use at\n\t'#', // Can't use id selector\n\t'(', // Can't use parenthesis\n\t')', // Can't use parenthesis\n];\n\nexport default function isValidReplacement(selector) {\n\tlet isValid = true;\n\n\t// Purposely archaic so it's interoperable in old browsers\n\tfor (let i = 0, length = INVALID_SELECTOR_CHAR.length; i < length && isValid; i++) {\n\t\tif (selector.indexOf(INVALID_SELECTOR_CHAR[i]) > -1) {\n\t\t\tisValid = false;\n\t\t}\n\t}\n\n\treturn isValid;\n}\n","import isValidReplacement from './is-valid-replacement.mjs';\nfunction generateHandler(replaceWith) {\n\tlet selector;\n\tlet remove;\n\tlet add;\n\tconst lastElements = [];\n\n\tif (replaceWith[0] === '.') {\n\t\tselector = replaceWith.slice(1);\n\t\tremove = (el) => el.classList.remove(selector);\n\t\tadd = (el) => el.classList.add(selector);\n\t} else {\n\t\t// A bit naive\n\t\tselector = replaceWith.slice(1, -1);\n\t\tremove = (el) => el.removeAttribute(selector, '');\n\t\tadd = (el) => el.setAttribute(selector, '');\n\t}\n\n\treturn function handleFocusChange() {\n\t\tlastElements.forEach(lastElement => remove(lastElement));\n\t\tlastElements.length = 0;\n\n\t\tlet activeElement = document.activeElement;\n\n\t\t// only add focus if it has not been added and is not the document element\n\t\tif (!/^(#document|HTML|BODY)$/.test(Object(activeElement).nodeName)) {\n\t\t\twhile (activeElement && activeElement.nodeType === 1) {\n\t\t\t\tadd(activeElement);\n\t\t\t\tlastElements.push(activeElement);\n\n\t\t\t\tactiveElement = activeElement.parentNode;\n\t\t\t}\n\t\t}\n\t};\n}\n\nexport default function focusWithin(opts) {\n\t// configuration\n\tconst options = {\n\t\tforce: false,\n\t\treplaceWith: '[focus-within]',\n\t};\n\n\tif (typeof opts !== 'undefined' && 'force' in opts) {\n\t\toptions.force = opts.force;\n\t}\n\n\tif (typeof opts !== 'undefined' && 'replaceWith' in opts) {\n\t\toptions.replaceWith = opts.replaceWith;\n\t}\n\n\tif (!isValidReplacement(options.replaceWith)) {\n\t\tthrow new Error(`${options.replaceWith} is not a valid replacement since it can't be applied to single elements.`);\n\t}\n\n\ttry {\n\t\tdocument.querySelector(':focus-within');\n\n\t\tif (!options.force) {\n\t\t\treturn;\n\t\t}\n\t} catch (_) {}\n\n\tconst handleFocusChange = generateHandler(options.replaceWith);\n\n\tconst initialize = function initializeEventListeners() {\n\t\tif (document.documentElement.className.indexOf('js-focus-within') > -1) {\n\t\t\treturn;\n\t\t}\n\n\t\tdocument.documentElement.className = document.documentElement.className + ' js-focus-within';\n\t\tdocument.addEventListener('focus', handleFocusChange, true);\n\t\tdocument.addEventListener('blur', handleFocusChange, true);\n\t};\n\n\tif (document.readyState === 'complete') {\n\t\tinitialize();\n\t} else {\n\t\tdocument.addEventListener('DOMContentLoaded', initialize);\n\t}\n}\n"],"names":["INVALID_SELECTOR_CHAR","isValidReplacement","selector","isValid","i","length","indexOf","focusWithin","opts","options","force","replaceWith","Error","document","querySelector","_","remove","add","lastElements","handleFocusChange","slice","el","classList","removeAttribute","setAttribute","forEach","lastElement","activeElement","test","Object","nodeName","nodeType","push","parentNode","initialize","initializeEventListeners","documentElement","className","addEventListener","readyState"],"mappings":"AAAA,IAAMA,EAAwB,CAC7B,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,KAGc,SAASC,mBAAmBC,GAI1C,IAHA,IAAIC,GAAU,EAGLC,EAAI,EAAGC,EAASL,EAAsBK,OAAQD,EAAIC,GAAUF,EAASC,IACzEF,EA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yB,iBAAiB,QAASnB,GAAmB,GACtDN,SAASyB,iBAAiB,OAAQnB,GAAmB,GACtD,EAE4B,aAAxBN,SAAS0B,WACZL,IAEArB,SAASyB,iBAAiB,mBAAoBJ,EAEhD"}
|
package/dist/index.d.ts
CHANGED
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
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),r=e().astSync(o.replaceWith);return isValidReplacement(o.replaceWith)?{postcssPlugin:"postcss-focus-within",prepare(){const s=new WeakSet;return{postcssPlugin:"postcss-focus-within",Rule(l,{result:i}){if(s.has(l))return;if(!l.selector.toLowerCase().includes(n))return;const a=l.selectors.flatMap(
|
|
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),r=e().astSync(o.replaceWith);return isValidReplacement(o.replaceWith)?{postcssPlugin:"postcss-focus-within",prepare(){const s=new WeakSet;return{postcssPlugin:"postcss-focus-within",Rule(l,{result:i}){if(s.has(l))return;if(!l.selector.toLowerCase().includes(n))return;const a=l.selectors.flatMap(s=>{if(!s.toLowerCase().includes(n))return[s];let a;try{a=e().astSync(s)}catch(e){return l.warn(i,`Failed to parse selector : "${s}" with message: "${e instanceof Error?e.message:e}"`),s}if(void 0===a)return[s];let c=!1;if(a.walkPseudos(e=>{e.value.toLowerCase()===n&&(e.nodes&&e.nodes.length||(c=!0,e.replaceWith(r.clone({}))))}),!c)return[s];const d=a.clone();if(!o.disablePolyfillReadyClass){if(a.nodes?.[0]?.nodes?.length)for(let s=0;s<a.nodes[0].nodes.length;s++){const n=a.nodes[0].nodes[s];if("combinator"===n.type||e.isPseudoElement(n)){a.nodes[0].insertBefore(n,e.className({value:t}));break}if(s===a.nodes[0].nodes.length-1){a.nodes[0].append(e.className({value:t}));break}}return a.nodes?.[0]?.nodes&&(d.nodes[0].prepend(e.combinator({value:" "})),d.nodes[0].prepend(e.className({value:t}))),[a.toString(),d.toString()]}return[a.toString()]});a.join(",")!==l.selectors.join(",")&&(s.add(l),l.cloneBefore({selectors:a}),o.preserve||l.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,creator as"module.exports"};
|
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": "
|
|
4
|
+
"version": "10.0.0",
|
|
5
5
|
"contributors": [
|
|
6
6
|
{
|
|
7
7
|
"name": "Antonio Laguna",
|
|
@@ -29,20 +29,13 @@
|
|
|
29
29
|
}
|
|
30
30
|
],
|
|
31
31
|
"engines": {
|
|
32
|
-
"node": ">=
|
|
32
|
+
"node": ">=20.19.0"
|
|
33
33
|
},
|
|
34
34
|
"type": "module",
|
|
35
|
-
"main": "dist/index.cjs",
|
|
36
|
-
"module": "dist/index.mjs",
|
|
37
35
|
"exports": {
|
|
38
36
|
".": {
|
|
39
|
-
"
|
|
40
|
-
|
|
41
|
-
"default": "./dist/index.mjs"
|
|
42
|
-
},
|
|
43
|
-
"require": {
|
|
44
|
-
"default": "./dist/index.cjs"
|
|
45
|
-
}
|
|
37
|
+
"types": "./dist/index.d.ts",
|
|
38
|
+
"default": "./dist/index.mjs"
|
|
46
39
|
},
|
|
47
40
|
"./browser": {
|
|
48
41
|
"import": "./dist/browser.mjs",
|
|
@@ -60,7 +53,7 @@
|
|
|
60
53
|
"dist"
|
|
61
54
|
],
|
|
62
55
|
"dependencies": {
|
|
63
|
-
"postcss-selector-parser": "^
|
|
56
|
+
"postcss-selector-parser": "^7.1.1"
|
|
64
57
|
},
|
|
65
58
|
"peerDependencies": {
|
|
66
59
|
"postcss": "^8.4"
|
package/dist/index.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
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),r=e().astSync(o.replaceWith);return isValidReplacement(o.replaceWith)?{postcssPlugin:"postcss-focus-within",prepare(){const s=new WeakSet;return{postcssPlugin:"postcss-focus-within",Rule(l,{result:i}){if(s.has(l))return;if(!l.selector.toLowerCase().includes(n))return;const a=l.selectors.flatMap((s=>{if(!s.toLowerCase().includes(n))return[s];let a;try{a=e().astSync(s)}catch(e){return l.warn(i,`Failed to parse selector : "${s}" with message: "${e instanceof Error?e.message:e}"`),s}if(void 0===a)return[s];let c=!1;if(a.walkPseudos((e=>{e.value.toLowerCase()===n&&(e.nodes&&e.nodes.length||(c=!0,e.replaceWith(r.clone({}))))})),!c)return[s];const d=a.clone();if(!o.disablePolyfillReadyClass){if(a.nodes?.[0]?.nodes?.length)for(let s=0;s<a.nodes[0].nodes.length;s++){const n=a.nodes[0].nodes[s];if("combinator"===n.type||e.isPseudoElement(n)){a.nodes[0].insertBefore(n,e.className({value:t}));break}if(s===a.nodes[0].nodes.length-1){a.nodes[0].append(e.className({value:t}));break}}return a.nodes?.[0]?.nodes&&(d.nodes[0].prepend(e.combinator({value:" "})),d.nodes[0].prepend(e.className({value:t}))),[a.toString(),d.toString()]}return[a.toString()]}));a.join(",")!==l.selectors.join(",")&&(s.add(l),l.cloneBefore({selectors:a}),o.preserve||l.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;
|