css-blank-pseudo 3.0.2 → 4.1.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.
@@ -1 +1 @@
1
- {"version":3,"file":"browser.cjs","sources":["../src/browser.js"],"sourcesContent":["/* global MutationObserver */\nexport default function cssBlankPseudo(document, opts) {\n\t// configuration\n\tconst className = Object(opts).className;\n\tconst attr = Object(opts).attr || 'blank';\n\tconst force = Object(opts).force;\n\n\ttry {\n\t\tdocument.querySelector(':blank');\n\n\t\tif (!force) {\n\t\t\treturn;\n\t\t}\n\t} catch (ignoredError) { /* do nothing and continue */ }\n\n\t// observe value changes on <input>, <select>, and <textarea>\n\tconst window = (document.ownerDocument || document).defaultView;\n\n\tobserveValueOfHTMLElement(window.HTMLInputElement);\n\tobserveValueOfHTMLElement(window.HTMLSelectElement);\n\tobserveValueOfHTMLElement(window.HTMLTextAreaElement);\n\tobserveSelectedOfHTMLElement(window.HTMLOptionElement);\n\n\t// form control elements selector\n\tconst selector = 'INPUT,SELECT,TEXTAREA';\n\tconst selectorRegExp = /^(INPUT|SELECT|TEXTAREA)$/;\n\n\t// conditionally update all form control elements\n\tArray.prototype.forEach.call(\n\t\tdocument.querySelectorAll(selector),\n\t\tnode => {\n\t\t\tif (node.nodeName === 'SELECT') {\n\t\t\t\tnode.addEventListener('change', configureCssBlankAttribute);\n\t\t\t} else {\n\t\t\t\tnode.addEventListener('input', configureCssBlankAttribute);\n\t\t\t}\n\n\t\t\tconfigureCssBlankAttribute.call(node);\n\t\t},\n\t);\n\n\t// conditionally observe added or unobserve removed form control elements\n\tnew MutationObserver(mutationsList => {\n\t\tmutationsList.forEach(mutation => {\n\t\t\tArray.prototype.forEach.call(\n\t\t\t\tmutation.addedNodes || [],\n\t\t\t\tnode => {\n\t\t\t\t\tif (node.nodeType === 1 && selectorRegExp.test(node.nodeName)) {\n\t\t\t\t\t\tif (node.nodeName === 'SELECT') {\n\t\t\t\t\t\t\tnode.addEventListener('change', configureCssBlankAttribute);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tnode.addEventListener('input', configureCssBlankAttribute);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconfigureCssBlankAttribute.call(node);\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t);\n\n\t\t\tArray.prototype.forEach.call(\n\t\t\t\tmutation.removedNodes || [],\n\t\t\t\tnode => {\n\t\t\t\t\tif (node.nodeType === 1 && selectorRegExp.test(node.nodeName)) {\n\t\t\t\t\t\tif (node.nodeName === 'SELECT') {\n\t\t\t\t\t\t\tnode.removeEventListener('change', configureCssBlankAttribute);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tnode.removeEventListener('input', configureCssBlankAttribute);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t);\n\t\t});\n\t}).observe(document, { childList: true, subtree: true });\n\n\t// update a form control element’s css-blank attribute\n\tfunction configureCssBlankAttribute () {\n\t\tif (this.value || this.nodeName === 'SELECT' && this.options[this.selectedIndex].value) {\n\t\t\tif (attr) {\n\t\t\t\tthis.removeAttribute(attr);\n\t\t\t}\n\n\t\t\tif (className) {\n\t\t\t\tthis.classList.remove(className);\n\t\t\t}\n\t\t\tthis.removeAttribute('blank');\n\t\t} else {\n\t\t\tif (attr) {\n\t\t\t\tthis.setAttribute('blank', attr);\n\t\t\t}\n\n\t\t\tif (className) {\n\t\t\t\tthis.classList.add(className);\n\t\t\t}\n\t\t}\n\t}\n\n\t// observe changes to the \"value\" property on an HTML Element\n\tfunction observeValueOfHTMLElement (HTMLElement) {\n\t\tconst descriptor = Object.getOwnPropertyDescriptor(HTMLElement.prototype, 'value');\n\t\tconst nativeSet = descriptor.set;\n\n\t\tdescriptor.set = function set (value) { // eslint-disable-line no-unused-vars\n\t\t\tnativeSet.apply(this, arguments);\n\n\t\t\tconfigureCssBlankAttribute.apply(this);\n\t\t};\n\n\t\tObject.defineProperty(HTMLElement.prototype, 'value', descriptor);\n\t}\n\n\t// observe changes to the \"selected\" property on an HTML Element\n\tfunction observeSelectedOfHTMLElement (HTMLElement) {\n\t\tconst descriptor = Object.getOwnPropertyDescriptor(HTMLElement.prototype, 'selected');\n\t\tconst nativeSet = descriptor.set;\n\n\t\tdescriptor.set = function set (value) { // eslint-disable-line no-unused-vars\n\t\t\tnativeSet.apply(this, arguments);\n\n\t\t\tconst event = document.createEvent('Event');\n\t\t\tevent.initEvent('change', true, true);\n\t\t\tthis.dispatchEvent(event);\n\t\t};\n\n\t\tObject.defineProperty(HTMLElement.prototype, 'selected', descriptor);\n\t}\n}\n"],"names":["cssBlankPseudo","document","opts","className","Object","attr","force","querySelector","ignoredError","window","ownerDocument","defaultView","observeValueOfHTMLElement","HTMLInputElement","HTMLSelectElement","HTMLTextAreaElement","observeSelectedOfHTMLElement","HTMLOptionElement","selector","selectorRegExp","Array","prototype","forEach","call","querySelectorAll","node","nodeName","addEventListener","configureCssBlankAttribute","MutationObserver","mutationsList","mutation","addedNodes","nodeType","test","removedNodes","removeEventListener","observe","childList","subtree","value","options","selectedIndex","removeAttribute","classList","remove","setAttribute","add","HTMLElement","descriptor","getOwnPropertyDescriptor","nativeSet","set","apply","arguments","defineProperty","event","createEvent","initEvent","dispatchEvent"],"mappings":"AAAA;AACe,SAASA,cAAT,CAAwBC,QAAxB,EAAkCC,IAAlC,EAAwC;AACtD;AACA,MAAMC,SAAS,GAAGC,MAAM,CAACF,IAAD,CAAN,CAAaC,SAA/B;AACA,MAAME,IAAI,GAAGD,MAAM,CAACF,IAAD,CAAN,CAAaG,IAAb,IAAqB,OAAlC;AACA,MAAMC,KAAK,GAAGF,MAAM,CAACF,IAAD,CAAN,CAAaI,KAA3B;;AAEA,MAAI;AACHL,IAAAA,QAAQ,CAACM,aAAT,CAAuB,QAAvB;;AAEA,QAAI,CAACD,KAAL,EAAY;AACX;AACA;AACD,GAND,CAME,OAAOE,YAAP,EAAqB;AAAE;AAA+B,GAZF;;;AAetD,MAAMC,MAA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ACD;;;;"}
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","/* global document,window,self,MutationObserver */\nimport isValidReplacement from './is-valid-replacement.mjs';\n\nconst CSS_CLASS_LOADED = 'js-blank-pseudo';\n\n// form control elements selector\nfunction isFormControlElement(element) {\n\tif (element.nodeName === 'INPUT' || element.nodeName === 'SELECT' || element.nodeName === 'TEXTAREA') {\n\t\treturn true;\n\t}\n\n\treturn false;\n}\n\nfunction createNewEvent(eventName) {\n\tlet event;\n\n\tif (typeof(Event) === 'function') {\n\t\tevent = new Event(eventName, { bubbles: true });\n\t} else {\n\t\tevent = document.createEvent('Event');\n\t\tevent.initEvent(eventName, true, false);\n\t}\n\n\treturn event;\n}\n\nfunction generateHandler(replaceWith) {\n\tlet selector;\n\tlet remove;\n\tlet add;\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 handleInputOrChangeEvent(event) {\n\t\tconst element = event.target;\n\t\tif (!isFormControlElement(element)) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst isSelect = element.nodeName === 'SELECT';\n\t\tconst hasValue = isSelect\n\t\t\t? !!element.options[element.selectedIndex].value\n\t\t\t: !!element.value;\n\n\t\tif (hasValue) {\n\t\t\tremove(element);\n\t\t} else {\n\t\t\tadd(element);\n\t\t}\n\t};\n}\n\n// observe changes to the \"selected\" property on an HTML Element\nfunction observeSelectedOfHTMLElement(HTMLElement) {\n\tconst descriptor = Object.getOwnPropertyDescriptor(HTMLElement.prototype, 'selected');\n\tconst nativeSet = descriptor.set;\n\n\tdescriptor.set = function set(value) { // eslint-disable-line no-unused-vars\n\t\tnativeSet.apply(this, arguments);\n\n\t\tconst event = createNewEvent('change');\n\t\tthis.parentElement.dispatchEvent(event);\n\t};\n\n\tObject.defineProperty(HTMLElement.prototype, 'selected', descriptor);\n}\n\n// observe changes to the \"value\" property on an HTML Element\nfunction observeValueOfHTMLElement(HTMLElement, handler) {\n\tconst descriptor = Object.getOwnPropertyDescriptor(HTMLElement.prototype, 'value');\n\tconst nativeSet = descriptor.set;\n\n\tdescriptor.set = function set() {\n\t\tnativeSet.apply(this, arguments);\n\t\thandler({ target: this });\n\t};\n\n\tObject.defineProperty(HTMLElement.prototype, 'value', descriptor);\n}\n\nexport default function cssBlankPseudoInit(opts) {\n\t// configuration\n\tconst options = {\n\t\tforce: false,\n\t\treplaceWith: '[blank]',\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(':blank');\n\n\t\tif (!options.force) {\n\t\t\treturn;\n\t\t}\n\t} catch (ignoredError) { /* do nothing and continue */ }\n\n\tconst handler = generateHandler(options.replaceWith);\n\tconst bindEvents = () => {\n\t\tif (document.body) {\n\t\t\tdocument.body.addEventListener('change', handler);\n\t\t\tdocument.body.addEventListener('input', handler);\n\t\t}\n\t};\n\tconst updateAllCandidates = () => {\n\t\tArray.prototype.forEach.call(\n\t\t\tdocument.querySelectorAll('input, select, textarea'),\n\t\t\tnode => {\n\t\t\t\thandler({ target: node });\n\t\t\t},\n\t\t);\n\t};\n\n\tif (document.body) {\n\t\tbindEvents();\n\t} else {\n\t\twindow.addEventListener('load', bindEvents);\n\t}\n\n\tif (document.documentElement.className.indexOf(CSS_CLASS_LOADED) === -1) {\n\t\tdocument.documentElement.className += ` ${CSS_CLASS_LOADED}`;\n\t}\n\n\tobserveValueOfHTMLElement(self.HTMLInputElement, handler);\n\tobserveValueOfHTMLElement(self.HTMLSelectElement, handler);\n\tobserveValueOfHTMLElement(self.HTMLTextAreaElement, handler);\n\tobserveSelectedOfHTMLElement(self.HTMLOptionElement, handler);\n\n\t// conditionally update all form control elements\n\tupdateAllCandidates();\n\n\tif (typeof self.MutationObserver !== 'undefined') {\n\t\t// conditionally observe added or unobserve removed form control elements\n\t\tnew MutationObserver(mutationsList => {\n\t\t\tmutationsList.forEach(mutation => {\n\t\t\t\tArray.prototype.forEach.call(\n\t\t\t\t\tmutation.addedNodes || [],\n\t\t\t\t\tnode => {\n\t\t\t\t\t\tif (node.nodeType === 1 && isFormControlElement(node)) {\n\t\t\t\t\t\t\thandler({ target: node });\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t});\n\t\t}).observe(document, { childList: true, subtree: true });\n\t} else {\n\t\tconst handleOnLoad = () => updateAllCandidates();\n\n\t\twindow.addEventListener('load', handleOnLoad);\n\t\twindow.addEventListener('DOMContentLoaded', handleOnLoad);\n\t}\n}\n"],"names":["INVALID_SELECTOR_CHAR","isFormControlElement","element","nodeName","createNewEvent","eventName","event","Event","bubbles","document","createEvent","initEvent","observeValueOfHTMLElement","HTMLElement","handler","descriptor","Object","getOwnPropertyDescriptor","prototype","nativeSet","set","apply","this","arguments","target","defineProperty","opts","options","force","replaceWith","selector","isValid","i","length","indexOf","isValidReplacement","Error","querySelector","ignoredError","remove","add","slice","el","classList","removeAttribute","setAttribute","selectedIndex","value","bindEvents","body","addEventListener","updateAllCandidates","Array","forEach","call","querySelectorAll","node","window","documentElement","className","self","HTMLInputElement","HTMLSelectElement","HTMLTextAreaElement","HTMLOptionElement","parentElement","dispatchEvent","MutationObserver","mutationsList","mutation","addedNodes","nodeType","observe","childList","subtree","handleOnLoad"],"mappings":"AAAA,IAAMA,EAAwB,CAC7B,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,KCHD,SAASC,EAAqBC,GAC7B,MAAyB,UAArBA,EAAQC,UAA6C,WAArBD,EAAQC,UAA8C,aAArBD,EAAQC,QAK7E,CAED,SAASC,EAAeC,GACvB,IAAIC,EASJ,MAPsB,mBAAXC,MACVD,EAAQ,IAAIC,MAAMF,EAAW,CAAEG,SAAS,KAExCF,EAAQG,SAASC,YAAY,UACvBC,UAAUN,GAAW,GAAM,GAG3BC,CACP,CAqDD,SAASM,EAA0BC,EAAaC,GAC/C,IAAMC,EAAaC,OAAOC,yBAAyBJ,EAAYK,UAAW,SACpEC,EAAYJ,EAAWK,IAE7BL,EAAWK,IAAM,WAChBD,EAAUE,MAAMC,KAAMC,WACtBT,EAAQ,CAAEU,OAAQF,QAGnBN,OAAOS,eAAeZ,EAAYK,UAAW,QAASH,EACtD,gBAEc,SAA4BW,GAE1C,IAAMC,EAAU,CACfC,OAAO,EACPC,YAAa,WAWd,QARoB,IAATH,GAAwB,UAAWA,IAC7CC,EAAQC,MAAQF,EAAKE,YAGF,IAATF,GAAwB,gBAAiBA,IACnDC,EAAQE,YAAcH,EAAKG,cD1Fd,SAA4BC,GAI1C,IAHA,IAAIC,GAAU,EAGLC,EAAI,EAAGC,EAASjC,EAAsBiC,OAAQD,EAAIC,GAAUF,EAASC,IACzEF,EAASI,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BAAqBjD,GAlFfD,EAmFR+C,KAAKI,kBAlF5BjD,EAAaC,OAAOC,yBAAyBJ,EAAYK,UAAW,YACpEC,EAAYJ,EAAWK,IAE7BL,EAAWK,IAAM,SAAa2B,GAC7B5B,EAAUE,MAAMC,KAAMC,WAEtB,IAAMjB,EAAQF,EAAe,UAC7BkB,KAAK2C,cAAcC,cAAc5D,IAGlCU,OAAOS,eAAeZ,EAAYK,UAAW,WAAYH,GA2EzDoC,SAEqC,IAA1BS,KAAKO,iBAEf,IAAIA,kBAAiB,SAAAC,GACpBA,EAAcf,SAAQ,SAAAgB,GACrBjB,MAAMlC,UAAUmC,QAAQC,KACvBe,EAASC,YAAc,IACvB,SAAAd,GACuB,IAAlBA,EAAKe,UAAkBtE,EAAqBuD,IAC/C1C,EAAQ,CAAEU,OAAQgC,SAKtB,IAAEgB,QAAQ/D,SAAU,CAAEgE,WAAW,EAAMC,SAAS,QAC3C,CACN,IAAMC,EAAe,WAAA,OAAMxB,KAE3BM,OAAOP,iBAAiB,OAAQyB,GAChClB,OAAOP,iBAAiB,mBAAoByB,EAC5C,CACD"}
package/dist/browser.mjs CHANGED
@@ -1,120 +1,2 @@
1
- /* global MutationObserver */
2
- function cssBlankPseudo(document, opts) {
3
- // configuration
4
- var className = Object(opts).className;
5
- var attr = Object(opts).attr || 'blank';
6
- var force = Object(opts).force;
7
-
8
- try {
9
- document.querySelector(':blank');
10
-
11
- if (!force) {
12
- return;
13
- }
14
- } catch (ignoredError) {
15
- /* do nothing and continue */
16
- } // observe value changes on <input>, <select>, and <textarea>
17
-
18
-
19
- var window = (document.ownerDocument || document).defaultView;
20
- observeValueOfHTMLElement(window.HTMLInputElement);
21
- observeValueOfHTMLElement(window.HTMLSelectElement);
22
- observeValueOfHTMLElement(window.HTMLTextAreaElement);
23
- observeSelectedOfHTMLElement(window.HTMLOptionElement); // form control elements selector
24
-
25
- var selector = 'INPUT,SELECT,TEXTAREA';
26
- var selectorRegExp = /^(INPUT|SELECT|TEXTAREA)$/; // conditionally update all form control elements
27
-
28
- Array.prototype.forEach.call(document.querySelectorAll(selector), function (node) {
29
- if (node.nodeName === 'SELECT') {
30
- node.addEventListener('change', configureCssBlankAttribute);
31
- } else {
32
- node.addEventListener('input', configureCssBlankAttribute);
33
- }
34
-
35
- configureCssBlankAttribute.call(node);
36
- }); // conditionally observe added or unobserve removed form control elements
37
-
38
- new MutationObserver(function (mutationsList) {
39
- mutationsList.forEach(function (mutation) {
40
- Array.prototype.forEach.call(mutation.addedNodes || [], function (node) {
41
- if (node.nodeType === 1 && selectorRegExp.test(node.nodeName)) {
42
- if (node.nodeName === 'SELECT') {
43
- node.addEventListener('change', configureCssBlankAttribute);
44
- } else {
45
- node.addEventListener('input', configureCssBlankAttribute);
46
- }
47
-
48
- configureCssBlankAttribute.call(node);
49
- }
50
- });
51
- Array.prototype.forEach.call(mutation.removedNodes || [], function (node) {
52
- if (node.nodeType === 1 && selectorRegExp.test(node.nodeName)) {
53
- if (node.nodeName === 'SELECT') {
54
- node.removeEventListener('change', configureCssBlankAttribute);
55
- } else {
56
- node.removeEventListener('input', configureCssBlankAttribute);
57
- }
58
- }
59
- });
60
- });
61
- }).observe(document, {
62
- childList: true,
63
- subtree: true
64
- }); // update a form control element’s css-blank attribute
65
-
66
- function configureCssBlankAttribute() {
67
- if (this.value || this.nodeName === 'SELECT' && this.options[this.selectedIndex].value) {
68
- if (attr) {
69
- this.removeAttribute(attr);
70
- }
71
-
72
- if (className) {
73
- this.classList.remove(className);
74
- }
75
-
76
- this.removeAttribute('blank');
77
- } else {
78
- if (attr) {
79
- this.setAttribute('blank', attr);
80
- }
81
-
82
- if (className) {
83
- this.classList.add(className);
84
- }
85
- }
86
- } // observe changes to the "value" property on an HTML Element
87
-
88
-
89
- function observeValueOfHTMLElement(HTMLElement) {
90
- var descriptor = Object.getOwnPropertyDescriptor(HTMLElement.prototype, 'value');
91
- var nativeSet = descriptor.set;
92
-
93
- descriptor.set = function set(value) {
94
- // eslint-disable-line no-unused-vars
95
- nativeSet.apply(this, arguments);
96
- configureCssBlankAttribute.apply(this);
97
- };
98
-
99
- Object.defineProperty(HTMLElement.prototype, 'value', descriptor);
100
- } // observe changes to the "selected" property on an HTML Element
101
-
102
-
103
- function observeSelectedOfHTMLElement(HTMLElement) {
104
- var descriptor = Object.getOwnPropertyDescriptor(HTMLElement.prototype, 'selected');
105
- var nativeSet = descriptor.set;
106
-
107
- descriptor.set = function set(value) {
108
- // eslint-disable-line no-unused-vars
109
- nativeSet.apply(this, arguments);
110
- var event = document.createEvent('Event');
111
- event.initEvent('change', true, true);
112
- this.dispatchEvent(event);
113
- };
114
-
115
- Object.defineProperty(HTMLElement.prototype, 'selected', descriptor);
116
- }
117
- }
118
-
119
- export { cssBlankPseudo as default };
1
+ var e=[" ",">","~",":","+","@","#","(",")"];function t(e){return"INPUT"===e.nodeName||"SELECT"===e.nodeName||"TEXTAREA"===e.nodeName}function n(e){var t;return"function"==typeof Event?t=new Event(e,{bubbles:!0}):(t=document.createEvent("Event")).initEvent(e,!0,!1),t}function r(e,t){var n=Object.getOwnPropertyDescriptor(e.prototype,"value"),r=n.set;n.set=function(){r.apply(this,arguments),t({target:this})},Object.defineProperty(e.prototype,"value",n)}function o(o){var c={force:!1,replaceWith:"[blank]"};if(void 0!==o&&"force"in o&&(c.force=o.force),void 0!==o&&"replaceWith"in o&&(c.replaceWith=o.replaceWith),!function(t){for(var n=!0,r=0,o=e.length;r<o&&n;r++)t.indexOf(e[r])>-1&&(n=!1);return n}(c.replaceWith))throw new Error(c.replaceWith+" is not a valid replacement since it can't be applied to single elements.");try{if(document.querySelector(":blank"),!c.force)return}catch(e){}var i,a,d,l,u,s,p,f=("."===(i=c.replaceWith)[0]?(a=i.slice(1),d=function(e){return e.classList.remove(a)},l=function(e){return e.classList.add(a)}):(a=i.slice(1,-1),d=function(e){return e.removeAttribute(a,"")},l=function(e){return e.setAttribute(a,"")}),function(e){var n=e.target;t(n)&&(("SELECT"===n.nodeName?n.options[n.selectedIndex].value:n.value)?d(n):l(n))}),v=function(){document.body&&(document.body.addEventListener("change",f),document.body.addEventListener("input",f))},m=function(){Array.prototype.forEach.call(document.querySelectorAll("input, select, textarea"),(function(e){f({target:e})}))};if(document.body?v():window.addEventListener("load",v),-1===document.documentElement.className.indexOf("js-blank-pseudo")&&(document.documentElement.className+=" js-blank-pseudo"),r(self.HTMLInputElement,f),r(self.HTMLSelectElement,f),r(self.HTMLTextAreaElement,f),u=self.HTMLOptionElement,s=Object.getOwnPropertyDescriptor(u.prototype,"selected"),p=s.set,s.set=function(e){p.apply(this,arguments);var t=n("change");this.parentElement.dispatchEvent(t)},Object.defineProperty(u.prototype,"selected",s),m(),void 0!==self.MutationObserver)new MutationObserver((function(e){e.forEach((function(e){Array.prototype.forEach.call(e.addedNodes||[],(function(e){1===e.nodeType&&t(e)&&f({target:e})}))}))})).observe(document,{childList:!0,subtree:!0});else{var E=function(){return m()};window.addEventListener("load",E),window.addEventListener("DOMContentLoaded",E)}}export{o as default};
120
2
  //# sourceMappingURL=browser.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"browser.mjs","sources":["../src/browser.js"],"sourcesContent":["/* global MutationObserver */\nexport default function cssBlankPseudo(document, opts) {\n\t// configuration\n\tconst className = Object(opts).className;\n\tconst attr = Object(opts).attr || 'blank';\n\tconst force = Object(opts).force;\n\n\ttry {\n\t\tdocument.querySelector(':blank');\n\n\t\tif (!force) {\n\t\t\treturn;\n\t\t}\n\t} catch (ignoredError) { /* do nothing and continue */ }\n\n\t// observe value changes on <input>, <select>, and <textarea>\n\tconst window = (document.ownerDocument || document).defaultView;\n\n\tobserveValueOfHTMLElement(window.HTMLInputElement);\n\tobserveValueOfHTMLElement(window.HTMLSelectElement);\n\tobserveValueOfHTMLElement(window.HTMLTextAreaElement);\n\tobserveSelectedOfHTMLElement(window.HTMLOptionElement);\n\n\t// form control elements selector\n\tconst selector = 'INPUT,SELECT,TEXTAREA';\n\tconst selectorRegExp = /^(INPUT|SELECT|TEXTAREA)$/;\n\n\t// conditionally update all form control elements\n\tArray.prototype.forEach.call(\n\t\tdocument.querySelectorAll(selector),\n\t\tnode => {\n\t\t\tif (node.nodeName === 'SELECT') {\n\t\t\t\tnode.addEventListener('change', configureCssBlankAttribute);\n\t\t\t} else {\n\t\t\t\tnode.addEventListener('input', configureCssBlankAttribute);\n\t\t\t}\n\n\t\t\tconfigureCssBlankAttribute.call(node);\n\t\t},\n\t);\n\n\t// conditionally observe added or unobserve removed form control elements\n\tnew MutationObserver(mutationsList => {\n\t\tmutationsList.forEach(mutation => {\n\t\t\tArray.prototype.forEach.call(\n\t\t\t\tmutation.addedNodes || [],\n\t\t\t\tnode => {\n\t\t\t\t\tif (node.nodeType === 1 && selectorRegExp.test(node.nodeName)) {\n\t\t\t\t\t\tif (node.nodeName === 'SELECT') {\n\t\t\t\t\t\t\tnode.addEventListener('change', configureCssBlankAttribute);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tnode.addEventListener('input', configureCssBlankAttribute);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconfigureCssBlankAttribute.call(node);\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t);\n\n\t\t\tArray.prototype.forEach.call(\n\t\t\t\tmutation.removedNodes || [],\n\t\t\t\tnode => {\n\t\t\t\t\tif (node.nodeType === 1 && selectorRegExp.test(node.nodeName)) {\n\t\t\t\t\t\tif (node.nodeName === 'SELECT') {\n\t\t\t\t\t\t\tnode.removeEventListener('change', configureCssBlankAttribute);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tnode.removeEventListener('input', configureCssBlankAttribute);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t);\n\t\t});\n\t}).observe(document, { childList: true, subtree: true });\n\n\t// update a form control element’s css-blank attribute\n\tfunction configureCssBlankAttribute () {\n\t\tif (this.value || this.nodeName === 'SELECT' && this.options[this.selectedIndex].value) {\n\t\t\tif (attr) {\n\t\t\t\tthis.removeAttribute(attr);\n\t\t\t}\n\n\t\t\tif (className) {\n\t\t\t\tthis.classList.remove(className);\n\t\t\t}\n\t\t\tthis.removeAttribute('blank');\n\t\t} else {\n\t\t\tif (attr) {\n\t\t\t\tthis.setAttribute('blank', attr);\n\t\t\t}\n\n\t\t\tif (className) {\n\t\t\t\tthis.classList.add(className);\n\t\t\t}\n\t\t}\n\t}\n\n\t// observe changes to the \"value\" property on an HTML Element\n\tfunction observeValueOfHTMLElement (HTMLElement) {\n\t\tconst descriptor = Object.getOwnPropertyDescriptor(HTMLElement.prototype, 'value');\n\t\tconst nativeSet = descriptor.set;\n\n\t\tdescriptor.set = function set (value) { // eslint-disable-line no-unused-vars\n\t\t\tnativeSet.apply(this, arguments);\n\n\t\t\tconfigureCssBlankAttribute.apply(this);\n\t\t};\n\n\t\tObject.defineProperty(HTMLElement.prototype, 'value', descriptor);\n\t}\n\n\t// observe changes to the \"selected\" property on an HTML Element\n\tfunction observeSelectedOfHTMLElement (HTMLElement) {\n\t\tconst descriptor = Object.getOwnPropertyDescriptor(HTMLElement.prototype, 'selected');\n\t\tconst nativeSet = descriptor.set;\n\n\t\tdescriptor.set = function set (value) { // eslint-disable-line no-unused-vars\n\t\t\tnativeSet.apply(this, arguments);\n\n\t\t\tconst event = document.createEvent('Event');\n\t\t\tevent.initEvent('change', true, true);\n\t\t\tthis.dispatchEvent(event);\n\t\t};\n\n\t\tObject.defineProperty(HTMLElement.prototype, 'selected', descriptor);\n\t}\n}\n"],"names":["cssBlankPseudo","document","opts","className","Object","attr","force","querySelector","ignoredError","window","ownerDocument","defaultView","observeValueOfHTMLElement","HTMLInputElement","HTMLSelectElement","HTMLTextAreaElement","observeSelectedOfHTMLElement","HTMLOptionElement","selector","selectorRegExp","Array","prototype","forEach","call","querySelectorAll","node","nodeName","addEventListener","configureCssBlankAttribute","MutationObserver","mutationsList","mutation","addedNodes","nodeType","test","removedNodes","removeEventListener","observe","childList","subtree","value","options","selectedIndex","removeAttribute","classList","remove","setAttribute","add","HTMLElement","descriptor","getOwnPropertyDescriptor","nativeSet","set","apply","arguments","defineProperty","event","createEvent","initEvent","dispatchEvent"],"mappings":"AAAA;AACe,SAASA,cAAT,CAAwBC,QAAxB,EAAkCC,IAAlC,EAAwC;AACtD;AACA,MAAMC,SAAS,GAAGC,MAAM,CAACF,IAAD,CAAN,CAAaC,SAA/B;AACA,MAAME,IAAI,GAAGD,MAAM,CAACF,IAAD,CAAN,CAAaG,IAAb,IAAqB,OAAlC;AACA,MAAMC,KAAK,GAAGF,MAAM,CAACF,IAAD,CAAN,CAAaI,KAA3B;;AAEA,MAAI;AACHL,IAAAA,QAAQ,CAACM,aAAT,CAAuB,QAAvB;;AAEA,QAAI,CAACD,KAAL,EAAY;AACX;AACA;AACD,GAND,CAME,OAAOE,YAAP,EAAqB;AAAE;AAA+B,GAZF;;;AAetD,MAAMC,MAAM,GAAG,CAACR,QAAQ,CAACS,aAAT,IAA0BT,QAA3B,EAAqCU,WAApD;AAEAC,EAAAA,yBAAyB,CAACH,MAAM,CAACI,gBAAR,CAAzB;AACAD,EAAAA,yBAAyB,CAACH,MAAM,CAACK,iBAAR,CAAzB;AACAF,EAAAA,yBAAyB,CAACH,MAAM,CAACM,mBAAR,CAAzB;AACAC,EAAAA,4BAA4B,CAACP,MAAM,CAACQ,iBAAR,CAA5B,CApBsD;;AAuBtD,MAAMC,QAAQ,GAAG,uBAAjB;AACA,MAAMC,cAAc,GAAG,2BAAvB,CAxBsD;;AA2BtDC,EAAAA,KAAK,CAACC,SAAN,CAAgBC,OAAhB,CAAwBC,IAAxB,CACCtB,QAAQ,CAACuB,gBAAT,CAA0BN,QAA1B,CADD,EAEC,UAAAO,IAAI,EAAI;AACP,QAAIA,IAAI,CAACC,QAAL,KAAkB,QAAtB,EAAgC;AAC/BD,MAAAA,IAAI,CAACE,gBAAL,CAAsB,QAAtB,EAAgCC,0BAAhC;AACA,KAFD,MAEO;AACNH,MAAAA,IAAI,CAACE,gBAAL,CAAsB,OAAtB,E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8C,wBAAP,CAAgCF,WAAW,CAAC3B,SAA5C,EAAuD,UAAvD,CAAnB;AACA,QAAM8B,SAAS,GAAGF,UAAU,CAACG,GAA7B;;AAEAH,IAAAA,UAAU,CAACG,GAAX,GAAiB,SAASA,GAAT,CAAcZ,KAAd,EAAqB;AAAE;AACvCW,MAAAA,SAAS,CAACE,KAAV,CAAgB,IAAhB,EAAsBC,SAAtB;AAEA,UAAME,KAAK,GAAGvD,QAAQ,CAACwD,WAAT,CAAqB,OAArB,CAAd;AACAD,MAAAA,KAAK,CAACE,SAAN,CAAgB,QAAhB,EAA0B,IAA1B,EAAgC,IAAhC;AACA,WAAKC,aAAL,CAAmBH,KAAnB;AACA,KAND;;AAQApD,IAAAA,MAAM,CAACmD,cAAP,CAAsBP,WAAW,CAAC3B,SAAlC,EAA6C,UAA7C,EAAyD4B,UAAzD;AACA;AACD;;;;"}
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","/* global document,window,self,MutationObserver */\nimport isValidReplacement from './is-valid-replacement.mjs';\n\nconst CSS_CLASS_LOADED = 'js-blank-pseudo';\n\n// form control elements selector\nfunction isFormControlElement(element) {\n\tif (element.nodeName === 'INPUT' || element.nodeName === 'SELECT' || element.nodeName === 'TEXTAREA') {\n\t\treturn true;\n\t}\n\n\treturn false;\n}\n\nfunction createNewEvent(eventName) {\n\tlet event;\n\n\tif (typeof(Event) === 'function') {\n\t\tevent = new Event(eventName, { bubbles: true });\n\t} else {\n\t\tevent = document.createEvent('Event');\n\t\tevent.initEvent(eventName, true, false);\n\t}\n\n\treturn event;\n}\n\nfunction generateHandler(replaceWith) {\n\tlet selector;\n\tlet remove;\n\tlet add;\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 handleInputOrChangeEvent(event) {\n\t\tconst element = event.target;\n\t\tif (!isFormControlElement(element)) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst isSelect = element.nodeName === 'SELECT';\n\t\tconst hasValue = isSelect\n\t\t\t? !!element.options[element.selectedIndex].value\n\t\t\t: !!element.value;\n\n\t\tif (hasValue) {\n\t\t\tremove(element);\n\t\t} else {\n\t\t\tadd(element);\n\t\t}\n\t};\n}\n\n// observe changes to the \"selected\" property on an HTML Element\nfunction observeSelectedOfHTMLElement(HTMLElement) {\n\tconst descriptor = Object.getOwnPropertyDescriptor(HTMLElement.prototype, 'selected');\n\tconst nativeSet = descriptor.set;\n\n\tdescriptor.set = function set(value) { // eslint-disable-line no-unused-vars\n\t\tnativeSet.apply(this, arguments);\n\n\t\tconst event = createNewEvent('change');\n\t\tthis.parentElement.dispatchEvent(event);\n\t};\n\n\tObject.defineProperty(HTMLElement.prototype, 'selected', descriptor);\n}\n\n// observe changes to the \"value\" property on an HTML Element\nfunction observeValueOfHTMLElement(HTMLElement, handler) {\n\tconst descriptor = Object.getOwnPropertyDescriptor(HTMLElement.prototype, 'value');\n\tconst nativeSet = descriptor.set;\n\n\tdescriptor.set = function set() {\n\t\tnativeSet.apply(this, arguments);\n\t\thandler({ target: this });\n\t};\n\n\tObject.defineProperty(HTMLElement.prototype, 'value', descriptor);\n}\n\nexport default function cssBlankPseudoInit(opts) {\n\t// configuration\n\tconst options = {\n\t\tforce: false,\n\t\treplaceWith: '[blank]',\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(':blank');\n\n\t\tif (!options.force) {\n\t\t\treturn;\n\t\t}\n\t} catch (ignoredError) { /* do nothing and continue */ }\n\n\tconst handler = generateHandler(options.replaceWith);\n\tconst bindEvents = () => {\n\t\tif (document.body) {\n\t\t\tdocument.body.addEventListener('change', handler);\n\t\t\tdocument.body.addEventListener('input', handler);\n\t\t}\n\t};\n\tconst updateAllCandidates = () => {\n\t\tArray.prototype.forEach.call(\n\t\t\tdocument.querySelectorAll('input, select, textarea'),\n\t\t\tnode => {\n\t\t\t\thandler({ target: node });\n\t\t\t},\n\t\t);\n\t};\n\n\tif (document.body) {\n\t\tbindEvents();\n\t} else {\n\t\twindow.addEventListener('load', bindEvents);\n\t}\n\n\tif (document.documentElement.className.indexOf(CSS_CLASS_LOADED) === -1) {\n\t\tdocument.documentElement.className += ` ${CSS_CLASS_LOADED}`;\n\t}\n\n\tobserveValueOfHTMLElement(self.HTMLInputElement, handler);\n\tobserveValueOfHTMLElement(self.HTMLSelectElement, handler);\n\tobserveValueOfHTMLElement(self.HTMLTextAreaElement, handler);\n\tobserveSelectedOfHTMLElement(self.HTMLOptionElement, handler);\n\n\t// conditionally update all form control elements\n\tupdateAllCandidates();\n\n\tif (typeof self.MutationObserver !== 'undefined') {\n\t\t// conditionally observe added or unobserve removed form control elements\n\t\tnew MutationObserver(mutationsList => {\n\t\t\tmutationsList.forEach(mutation => {\n\t\t\t\tArray.prototype.forEach.call(\n\t\t\t\t\tmutation.addedNodes || [],\n\t\t\t\t\tnode => {\n\t\t\t\t\t\tif (node.nodeType === 1 && isFormControlElement(node)) {\n\t\t\t\t\t\t\thandler({ target: node });\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t});\n\t\t}).observe(document, { childList: true, subtree: true });\n\t} else {\n\t\tconst handleOnLoad = () => updateAllCandidates();\n\n\t\twindow.addEventListener('load', handleOnLoad);\n\t\twindow.addEventListener('DOMContentLoaded', handleOnLoad);\n\t}\n}\n"],"names":["INVALID_SELECTOR_CHAR","isFormControlElement","element","nodeName","createNewEvent","eventName","event","Event","bubbles","document","createEvent","initEvent","observeValueOfHTMLElement","HTMLElement","handler","descriptor","Object","getOwnPropertyDescriptor","prototype","nativeSet","set","apply","this","arguments","target","defineProperty","cssBlankPseudoInit","opts","options","force","replaceWith","selector","isValid","i","length","indexOf","isValidReplacement","Error","querySelector","ignoredError","remove","add","slice","el","classList","removeAttribute","setAttribute","selectedIndex","value","bindEvents","body","addEventListener","updateAllCandidates","Array","forEach","call","querySelectorAll","node","window","documentElement","className","self","HTMLInputElement","HTMLSelectElement","HTMLTextAreaElement","HTMLOptionElement","parentElement","dispatchEvent","MutationObserver","mutationsList","mutation","addedNodes","nodeType","observe","childList","subtree","handleOnLoad"],"mappings":"AAAA,IAAMA,EAAwB,CAC7B,IACA,IACA,IACA,IACA,IACA,IACA,IACA,IACA,KCHD,SAASC,EAAqBC,GAC7B,MAAyB,UAArBA,EAAQC,UAA6C,WAArBD,EAAQC,UAA8C,aAArBD,EAAQC,QAK7E,CAED,SAASC,EAAeC,GACvB,IAAIC,EASJ,MAPsB,mBAAXC,MACVD,EAAQ,IAAIC,MAAMF,EAAW,CAAEG,SAAS,KAExCF,EAAQG,SAASC,YAAY,UACvBC,UAAUN,GAAW,GA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EAC5C,CACD"}
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var t=e(require("postcss-selector-parser"));const r=e=>{const r=String(Object(e).replaceWith||"[blank]"),s=t.default().astSync(r),o=Boolean(!("preserve"in Object(e))||e.preserve);return{postcssPlugin:"css-blank-pseudo",Rule:(e,{result:r})=>{if(-1===e.selector.indexOf(":blank"))return;let n;try{const r=t.default((e=>{e.walkPseudos((e=>{":blank"===e.value&&(e.nodes&&e.nodes.length||e.replaceWith(s.clone()))}))})).processSync(e.selector);n=String(r)}catch(t){return void e.warn(r,`Failed to parse selector : ${e.selector}`)}if(void 0===n)return;if(n===e.selector)return;const c=e.clone({selector:n});o?e.before(c):e.replaceWith(c)}}};r.postcss=!0,module.exports=r;
1
+ "use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var s=e(require("postcss-selector-parser"));const l=[" ",">","~",":","+","@","#","(",")"];const n=e=>{const n=Object.assign({preserve:!0,replaceWith:"[blank]",disablePolyfillReadyClass:!1},e),t=s.default().astSync(n.replaceWith);return function(e){let s=!0;for(let n=0,t=l.length;n<t&&s;n++)e.indexOf(l[n])>-1&&(s=!1);return s}(n.replaceWith)?{postcssPlugin:"css-blank-pseudo",Rule(e,{result:l}){if(!e.selector.toLowerCase().includes(":blank"))return;const o=e.selectors.flatMap((o=>{if(!o.toLowerCase().includes(":blank"))return[o];let a;try{a=s.default().astSync(o)}catch(s){return e.warn(l,`Failed to parse selector : ${o}`),o}if(void 0===a)return[o];let r=!1;if(a.walkPseudos((e=>{":blank"===e.value.toLowerCase()&&(e.nodes&&e.nodes.length||(r=!0,e.replaceWith(t.clone({}))))})),!r)return[o];const d=a.clone();if(!n.disablePolyfillReadyClass){var u,c,i,p,f;if(null!=(u=a.nodes)&&null!=(c=u[0])&&null!=(i=c.nodes)&&i.length)for(let e=0;e<a.nodes[0].nodes.length;e++){const l=a.nodes[0].nodes[e];if("combinator"===l.type||s.default.isPseudoElement(l)){a.nodes[0].insertBefore(l,s.default.className({value:"js-blank-pseudo"}));break}if(e===a.nodes[0].nodes.length-1){a.nodes[0].append(s.default.className({value:"js-blank-pseudo"}));break}}null!=(p=a.nodes)&&null!=(f=p[0])&&f.nodes&&(d.nodes[0].prepend(s.default.combinator({value:" "})),d.nodes[0].prepend(s.default.className({value:"js-blank-pseudo"})))}return[a.toString(),d.toString()]}));o.join(",")!==e.selectors.join(",")&&(e.cloneBefore({selectors:o}),n.preserve||e.remove())}}:{postcssPlugin:"css-blank-pseudo",Once:(e,{result:s})=>{e.warn(s,`${n.replaceWith} is not a valid replacement since it can't be applied to single elements.`)}}};n.postcss=!0,module.exports=n;
@@ -0,0 +1,8 @@
1
+ import type { PluginCreator } from 'postcss';
2
+ declare type pluginOptions = {
3
+ preserve?: boolean;
4
+ replaceWith?: string;
5
+ disablePolyfillReadyClass?: boolean;
6
+ };
7
+ declare const creator: PluginCreator<pluginOptions>;
8
+ export default creator;
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- import e from"postcss-selector-parser";const r=r=>{const s=String(Object(r).replaceWith||"[blank]"),t=e().astSync(s),o=Boolean(!("preserve"in Object(r))||r.preserve);return{postcssPlugin:"css-blank-pseudo",Rule:(r,{result:s})=>{if(-1===r.selector.indexOf(":blank"))return;let c;try{const s=e((e=>{e.walkPseudos((e=>{":blank"===e.value&&(e.nodes&&e.nodes.length||e.replaceWith(t.clone()))}))})).processSync(r.selector);c=String(s)}catch(e){return void r.warn(s,`Failed to parse selector : ${r.selector}`)}if(void 0===c)return;if(c===r.selector)return;const n=r.clone({selector:c});o?r.before(n):r.replaceWith(n)}}};r.postcss=!0;export{r as default};
1
+ import e from"postcss-selector-parser";const s=[" ",">","~",":","+","@","#","(",")"];const n=n=>{const l=Object.assign({preserve:!0,replaceWith:"[blank]",disablePolyfillReadyClass:!1},n),o=e().astSync(l.replaceWith);return function(e){let n=!0;for(let l=0,o=s.length;l<o&&n;l++)e.indexOf(s[l])>-1&&(n=!1);return n}(l.replaceWith)?{postcssPlugin:"css-blank-pseudo",Rule(s,{result:n}){if(!s.selector.toLowerCase().includes(":blank"))return;const t=s.selectors.flatMap((t=>{if(!t.toLowerCase().includes(":blank"))return[t];let r;try{r=e().astSync(t)}catch(e){return s.warn(n,`Failed to parse selector : ${t}`),t}if(void 0===r)return[t];let a=!1;if(r.walkPseudos((e=>{":blank"===e.value.toLowerCase()&&(e.nodes&&e.nodes.length||(a=!0,e.replaceWith(o.clone({}))))})),!a)return[t];const c=r.clone();if(!l.disablePolyfillReadyClass){var i,d,u,p,f;if(null!=(i=r.nodes)&&null!=(d=i[0])&&null!=(u=d.nodes)&&u.length)for(let s=0;s<r.nodes[0].nodes.length;s++){const n=r.nodes[0].nodes[s];if("combinator"===n.type||e.isPseudoElement(n)){r.nodes[0].insertBefore(n,e.className({value:"js-blank-pseudo"}));break}if(s===r.nodes[0].nodes.length-1){r.nodes[0].append(e.className({value:"js-blank-pseudo"}));break}}null!=(p=r.nodes)&&null!=(f=p[0])&&f.nodes&&(c.nodes[0].prepend(e.combinator({value:" "})),c.nodes[0].prepend(e.className({value:"js-blank-pseudo"})))}return[r.toString(),c.toString()]}));t.join(",")!==s.selectors.join(",")&&(s.cloneBefore({selectors:t}),l.preserve||s.remove())}}:{postcssPlugin:"css-blank-pseudo",Once:(e,{result:s})=>{e.warn(s,`${l.replaceWith} is not a valid replacement since it can't be applied to single elements.`)}}};n.postcss=!0;export{n as default};
package/package.json CHANGED
@@ -1,85 +1,108 @@
1
1
  {
2
- "name": "css-blank-pseudo",
3
- "version": "3.0.2",
4
- "description": "Style form elements when they are empty",
5
- "author": "Jonathan Neal <jonathantneal@hotmail.com>",
6
- "license": "CC0-1.0",
7
- "homepage": "https://github.com/csstools/postcss-plugins/tree/main/plugins/css-blank-pseudo#readme",
8
- "bugs": "https://github.com/csstools/postcss-plugins/issues",
9
- "main": "dist/index.cjs",
10
- "module": "dist/index.mjs",
11
- "exports": {
12
- ".": {
13
- "import": "./dist/index.mjs",
14
- "require": "./dist/index.cjs",
15
- "default": "./dist/index.mjs"
16
- },
17
- "./browser": {
18
- "import": "./dist/browser.mjs",
19
- "require": "./dist/browser.cjs",
20
- "default": "./dist/browser.mjs"
21
- },
22
- "./browser-global": {
23
- "default": "./dist/browser-global.js"
24
- }
25
- },
26
- "files": [
27
- "CHANGELOG.md",
28
- "LICENSE.md",
29
- "README.md",
30
- "dist",
31
- "browser.js"
32
- ],
33
- "bin": {
34
- "css-blank-pseudo": "dist/cli.cjs"
35
- },
36
- "scripts": {
37
- "build": "rollup -c ../../rollup/default.js && npm run copy-browser-scripts-to-old-location",
38
- "clean": "node -e \"fs.rmSync('./dist', { recursive: true, force: true });\"",
39
- "copy-browser-scripts-to-old-location": "node -e \"fs.copyFileSync('./dist/browser-global.js', './browser.js'); fs.copyFileSync('./dist/browser-global.js', './browser-legacy.js')\"",
40
- "lint": "eslint ./src --ext .js --ext .ts --ext .mjs --no-error-on-unmatched-pattern",
41
- "prepublishOnly": "npm run clean && npm run build && npm run test",
42
- "stryker": "stryker run --logLevel error",
43
- "test": "postcss-tape --ci && npm run test:exports",
44
- "cli": "css-blank-pseudo",
45
- "test:exports": "node ./test/_import.mjs && node ./test/_require.cjs"
46
- },
47
- "engines": {
48
- "node": "^12 || ^14 || >=16"
49
- },
50
- "dependencies": {
51
- "postcss-selector-parser": "^6.0.8"
52
- },
53
- "devDependencies": {
54
- "postcss": "^8.3.6",
55
- "postcss-tape": "^6.0.1"
56
- },
57
- "peerDependencies": {
58
- "postcss": "^8.3"
59
- },
60
- "keywords": [
61
- "postcss",
62
- "css",
63
- "postcss-plugin",
64
- "javascript",
65
- "js",
66
- "polyfill",
67
- "blank",
68
- "empty",
69
- "pseudo",
70
- "selectors",
71
- "accessibility",
72
- "a11y",
73
- "input",
74
- "select",
75
- "textarea"
76
- ],
77
- "repository": {
78
- "type": "git",
79
- "url": "https://github.com/csstools/postcss-plugins.git",
80
- "directory": "plugins/css-blank-pseudo"
81
- },
82
- "volta": {
83
- "extends": "../../package.json"
84
- }
2
+ "name": "css-blank-pseudo",
3
+ "description": "Style form elements when they are empty",
4
+ "version": "4.1.0",
5
+ "contributors": [
6
+ {
7
+ "name": "Antonio Laguna",
8
+ "email": "antonio@laguna.es",
9
+ "url": "https://antonio.laguna.es"
10
+ },
11
+ {
12
+ "name": "Romain Menke",
13
+ "email": "romainmenke@gmail.com"
14
+ },
15
+ {
16
+ "name": "Jonathan Neal",
17
+ "email": "jonathantneal@hotmail.com"
18
+ }
19
+ ],
20
+ "license": "CC0-1.0",
21
+ "funding": {
22
+ "type": "opencollective",
23
+ "url": "https://opencollective.com/csstools"
24
+ },
25
+ "engines": {
26
+ "node": "^12 || ^14 || >=16"
27
+ },
28
+ "main": "dist/index.cjs",
29
+ "module": "dist/index.mjs",
30
+ "types": "dist/index.d.ts",
31
+ "exports": {
32
+ ".": {
33
+ "import": "./dist/index.mjs",
34
+ "require": "./dist/index.cjs",
35
+ "default": "./dist/index.mjs"
36
+ },
37
+ "./browser": {
38
+ "import": "./dist/browser.mjs",
39
+ "require": "./dist/browser.cjs",
40
+ "default": "./dist/browser.mjs"
41
+ },
42
+ "./browser-global": {
43
+ "default": "./dist/browser-global.js"
44
+ }
45
+ },
46
+ "files": [
47
+ "CHANGELOG.md",
48
+ "LICENSE.md",
49
+ "README.md",
50
+ "dist"
51
+ ],
52
+ "dependencies": {
53
+ "postcss-selector-parser": "^6.0.10"
54
+ },
55
+ "peerDependencies": {
56
+ "postcss": "^8.2"
57
+ },
58
+ "devDependencies": {
59
+ "puppeteer": "^15.5.0"
60
+ },
61
+ "scripts": {
62
+ "build": "rollup -c ../../rollup/default.js",
63
+ "clean": "node -e \"fs.rmSync('./dist', { recursive: true, force: true });\"",
64
+ "docs": "node ../../.github/bin/generate-docs/install.mjs && node ../../.github/bin/generate-docs/readme.mjs",
65
+ "lint": "npm run lint:eslint && npm run lint:package-json",
66
+ "lint:eslint": "eslint ./src --ext .js --ext .ts --ext .mjs --no-error-on-unmatched-pattern",
67
+ "lint:package-json": "node ../../.github/bin/format-package-json.mjs",
68
+ "prepublishOnly": "npm run clean && npm run build && npm run test",
69
+ "test": "node .tape.mjs && npm run test:exports && npm run test:invalid-replacement",
70
+ "test:browser": "node ./test/_browser.mjs",
71
+ "test:exports": "node ./test/_import.mjs && node ./test/_require.cjs",
72
+ "test:invalid-replacement": "node ./test/_valid-replacements.mjs",
73
+ "test:rewrite-expects": "REWRITE_EXPECTS=true node .tape.mjs"
74
+ },
75
+ "homepage": "https://github.com/csstools/postcss-plugins/tree/main/plugins/css-blank-pseudo#readme",
76
+ "repository": {
77
+ "type": "git",
78
+ "url": "https://github.com/csstools/postcss-plugins.git",
79
+ "directory": "plugins/css-blank-pseudo"
80
+ },
81
+ "bugs": "https://github.com/csstools/postcss-plugins/issues",
82
+ "keywords": [
83
+ "a11y",
84
+ "accessibility",
85
+ "blank",
86
+ "css",
87
+ "empty",
88
+ "input",
89
+ "javascript",
90
+ "js",
91
+ "polyfill",
92
+ "postcss",
93
+ "postcss-plugin",
94
+ "pseudo",
95
+ "select",
96
+ "selectors",
97
+ "textarea"
98
+ ],
99
+ "csstools": {
100
+ "cssdbId": "blank-pseudo-class",
101
+ "exportName": "postcssBlankPseudo",
102
+ "humanReadableName": "PostCSS Blank Pseudo",
103
+ "specUrl": "https://www.w3.org/TR/selectors-4/#blank"
104
+ },
105
+ "volta": {
106
+ "extends": "../../package.json"
107
+ }
85
108
  }