css-blank-pseudo 2.0.0 → 3.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/index.mjs DELETED
@@ -1,92 +0,0 @@
1
- function cssBlankPseudo(document, opts) {
2
- // configuration
3
- const className = Object(opts).className;
4
- const attr = Object(opts).attr || 'blank';
5
- const force = Object(opts).force;
6
-
7
- try {
8
- document.querySelector(':blank');
9
-
10
- if (!force) {
11
- return;
12
- }
13
- } catch (ignoredError) {
14
- /* do nothing and continue */
15
- } // observe value changes on <input>, <select>, and <textarea>
16
-
17
-
18
- const window = (document.ownerDocument || document).defaultView;
19
- observeValueOfHTMLElement(window.HTMLInputElement);
20
- observeValueOfHTMLElement(window.HTMLSelectElement);
21
- observeValueOfHTMLElement(window.HTMLTextAreaElement); // form control elements selector
22
-
23
- const selector = 'input,select,textarea'; // conditionally update all form control elements
24
-
25
- Array.prototype.forEach.call(document.querySelectorAll(selector), node => {
26
- node.addEventListener('input', configureCssBlankAttribute);
27
- configureCssBlankAttribute.call(node);
28
- }); // conditionally observe added or unobserve removed form control elements
29
-
30
- new MutationObserver(mutationsList => {
31
- mutationsList.forEach(mutation => {
32
- if (mutation.addedNodes) {
33
- mutation.addedNodes.forEach(node => {
34
- if (node.nodeType === 1 && node.matches(selector)) {
35
- node.addEventListener('input', configureCssBlankAttribute);
36
- configureCssBlankAttribute.call(node);
37
- }
38
- });
39
- }
40
-
41
- if (mutation.removedNodes) {
42
- mutation.removedNodes.forEach(node => {
43
- if (node.nodeType === 1 && node.matches(selector)) {
44
- node.removeEventListener('input', configureCssBlankAttribute);
45
- }
46
- });
47
- }
48
- });
49
- }).observe(document, {
50
- childList: true,
51
- subtree: true
52
- }); // update a form control element’s css-blank attribute
53
-
54
- function configureCssBlankAttribute() {
55
- if (this.value) {
56
- if (attr) {
57
- this.removeAttribute(attr);
58
- }
59
-
60
- if (className) {
61
- this.classList.remove(className);
62
- }
63
-
64
- this.removeAttribute('blank');
65
- } else {
66
- if (attr) {
67
- this.setAttribute('blank', attr);
68
- }
69
-
70
- if (className) {
71
- this.classList.add(className);
72
- }
73
- }
74
- } // observe changes to the "value" property on an HTML Element
75
-
76
-
77
- function observeValueOfHTMLElement(HTMLElement) {
78
- const descriptor = Object.getOwnPropertyDescriptor(HTMLElement.prototype, 'value');
79
- const nativeSet = descriptor.set;
80
-
81
- descriptor.set = function set(value) {
82
- // eslint-disable-line no-unused-vars
83
- nativeSet.apply(this, arguments);
84
- configureCssBlankAttribute.apply(this);
85
- };
86
-
87
- Object.defineProperty(HTMLElement.prototype, 'value', descriptor);
88
- }
89
- }
90
-
91
- export { cssBlankPseudo as default };
92
- //# sourceMappingURL=index.mjs.map
package/index.mjs.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.mjs","sources":["src/browser.js"],"sourcesContent":["export 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\n\t// form control elements selector\n\tconst selector = '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\tnode.addEventListener('input', configureCssBlankAttribute);\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\tif (mutation.addedNodes) {\n\t\t\t\tmutation.addedNodes.forEach(\n\t\t\t\t\tnode => {\n\t\t\t\t\t\tif (node.nodeType === 1 && node.matches(selector)) {\n\t\t\t\t\t\t\tnode.addEventListener('input', configureCssBlankAttribute);\n\t\t\t\t\t\t\tconfigureCssBlankAttribute.call(node);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tif (mutation.removedNodes) {\n\t\t\t\tmutation.removedNodes.forEach(\n\t\t\t\t\tnode => {\n\t\t\t\t\t\tif (node.nodeType === 1 && node.matches(selector)) {\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) {\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"],"names":["cssBlankPseudo","document","opts","className","Object","attr","force","querySelector","ignoredError","window","ownerDocument","defaultView","observeValueOfHTMLElement","HTMLInputElement","HTMLSelectElement","HTMLTextAreaElement","selector","Array","prototype","forEach","call","querySelectorAll","node","addEventListener","configureCssBlankAttribute","MutationObserver","mutationsList","mutation","addedNodes","nodeType","matches","removedNodes","removeEventListener","observe","childList","subtree","value","removeAttribute","classList","remove","setAttribute","add","HTMLElement","descriptor","getOwnPropertyDescriptor","nativeSet","set","apply","arguments","defineProperty"],"mappings":"AAAe,SAASA,cAAT,CAAyBC,QAAzB,EAAmCC,IAAnC,EAAyC;AACvD;AACA,QAAMC,SAAS,GAAGC,MAAM,CAACF,IAAD,CAAN,CAAaC,SAA/B;AACA,QAAME,IAAI,GAAGD,MAAM,CAACF,IAAD,CAAN,CAAaG,IAAb,IAAqB,OAAlC;AACA,QAAMC,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,GAZD;;;AAevD,QAAMC,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,CAnBuD;;AAsBvD,QAAMC,QAAQ,GAAG,uBAAjB,CAtBuD;;AAyBvDC,EAAAA,KAAK,CAACC,SAAN,CAAgBC,OAAhB,CAAwBC,IAAxB,CACCnB,QAAQ,CAACoB,gBAAT,CAA0BL,QAA1B,CADD,EAECM,IAAI,IAAI;AACPA,IAAAA,IAAI,CAACC,gBAAL,CAAsB,OAAtB,EAA+BC,0BAA/B;AACAA,IAAAA,0BAA0B,CAACJ,IAA3B,CAAgCE,IAAhC;AACA,GALF,EAzBuD;;AAkCv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F,SAAJ,EAAe;AACd,aAAKmC,SAAL,CAAeG,GAAf,CAAmBtC,SAAnB;AACA;AACD;AACD,GA/EsD;;;AAkFvD,WAASS,yBAAT,CAAoC8B,WAApC,EAAiD;AAChD,UAAMC,UAAU,GAAGvC,MAAM,CAACwC,wBAAP,CAAgCF,WAAW,CAACxB,SAA5C,EAAuD,OAAvD,CAAnB;AACA,UAAM2B,SAAS,GAAGF,UAAU,CAACG,GAA7B;;AAEAH,IAAAA,UAAU,CAACG,GAAX,GAAiB,SAASA,GAAT,CAAcV,KAAd,EAAqB;AAAE;AACvCS,MAAAA,SAAS,CAACE,KAAV,CAAgB,IAAhB,EAAsBC,SAAtB;AAEAxB,MAAAA,0BAA0B,CAACuB,KAA3B,CAAiC,IAAjC;AACA,KAJD;;AAMA3C,IAAAA,MAAM,CAAC6C,cAAP,CAAsBP,WAAW,CAACxB,SAAlC,EAA6C,OAA7C,EAAsDyB,UAAtD;AACA;AACD;;;;"}
package/legacy.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"legacy.js","sources":["src/browser-legacy.js"],"sourcesContent":["export 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","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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,YAAME,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;;;;"}
package/legacy.mjs DELETED
@@ -1,119 +0,0 @@
1
- function cssBlankPseudo(document, opts) {
2
- // configuration
3
- const className = Object(opts).className;
4
- const attr = Object(opts).attr || 'blank';
5
- const force = Object(opts).force;
6
-
7
- try {
8
- document.querySelector(':blank');
9
-
10
- if (!force) {
11
- return;
12
- }
13
- } catch (ignoredError) {
14
- /* do nothing and continue */
15
- } // observe value changes on <input>, <select>, and <textarea>
16
-
17
-
18
- const window = (document.ownerDocument || document).defaultView;
19
- observeValueOfHTMLElement(window.HTMLInputElement);
20
- observeValueOfHTMLElement(window.HTMLSelectElement);
21
- observeValueOfHTMLElement(window.HTMLTextAreaElement);
22
- observeSelectedOfHTMLElement(window.HTMLOptionElement); // form control elements selector
23
-
24
- const selector = 'INPUT,SELECT,TEXTAREA';
25
- const selectorRegExp = /^(INPUT|SELECT|TEXTAREA)$/; // conditionally update all form control elements
26
-
27
- Array.prototype.forEach.call(document.querySelectorAll(selector), node => {
28
- if (node.nodeName === 'SELECT') {
29
- node.addEventListener('change', configureCssBlankAttribute);
30
- } else {
31
- node.addEventListener('input', configureCssBlankAttribute);
32
- }
33
-
34
- configureCssBlankAttribute.call(node);
35
- }); // conditionally observe added or unobserve removed form control elements
36
-
37
- new MutationObserver(mutationsList => {
38
- mutationsList.forEach(mutation => {
39
- Array.prototype.forEach.call(mutation.addedNodes || [], node => {
40
- if (node.nodeType === 1 && selectorRegExp.test(node.nodeName)) {
41
- if (node.nodeName === 'SELECT') {
42
- node.addEventListener('change', configureCssBlankAttribute);
43
- } else {
44
- node.addEventListener('input', configureCssBlankAttribute);
45
- }
46
-
47
- configureCssBlankAttribute.call(node);
48
- }
49
- });
50
- Array.prototype.forEach.call(mutation.removedNodes || [], node => {
51
- if (node.nodeType === 1 && selectorRegExp.test(node.nodeName)) {
52
- if (node.nodeName === 'SELECT') {
53
- node.removeEventListener('change', configureCssBlankAttribute);
54
- } else {
55
- node.removeEventListener('input', configureCssBlankAttribute);
56
- }
57
- }
58
- });
59
- });
60
- }).observe(document, {
61
- childList: true,
62
- subtree: true
63
- }); // update a form control element’s css-blank attribute
64
-
65
- function configureCssBlankAttribute() {
66
- if (this.value || this.nodeName === 'SELECT' && this.options[this.selectedIndex].value) {
67
- if (attr) {
68
- this.removeAttribute(attr);
69
- }
70
-
71
- if (className) {
72
- this.classList.remove(className);
73
- }
74
-
75
- this.removeAttribute('blank');
76
- } else {
77
- if (attr) {
78
- this.setAttribute('blank', attr);
79
- }
80
-
81
- if (className) {
82
- this.classList.add(className);
83
- }
84
- }
85
- } // observe changes to the "value" property on an HTML Element
86
-
87
-
88
- function observeValueOfHTMLElement(HTMLElement) {
89
- const descriptor = Object.getOwnPropertyDescriptor(HTMLElement.prototype, 'value');
90
- const nativeSet = descriptor.set;
91
-
92
- descriptor.set = function set(value) {
93
- // eslint-disable-line no-unused-vars
94
- nativeSet.apply(this, arguments);
95
- configureCssBlankAttribute.apply(this);
96
- };
97
-
98
- Object.defineProperty(HTMLElement.prototype, 'value', descriptor);
99
- } // observe changes to the "selected" property on an HTML Element
100
-
101
-
102
- function observeSelectedOfHTMLElement(HTMLElement) {
103
- const descriptor = Object.getOwnPropertyDescriptor(HTMLElement.prototype, 'selected');
104
- const nativeSet = descriptor.set;
105
-
106
- descriptor.set = function set(value) {
107
- // eslint-disable-line no-unused-vars
108
- nativeSet.apply(this, arguments);
109
- const event = document.createEvent('Event');
110
- event.initEvent('change', true, true);
111
- this.dispatchEvent(event);
112
- };
113
-
114
- Object.defineProperty(HTMLElement.prototype, 'selected', descriptor);
115
- }
116
- }
117
-
118
- export { cssBlankPseudo as default };
119
- //# sourceMappingURL=legacy.mjs.map
package/legacy.mjs.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"legacy.mjs","sources":["src/browser-legacy.js"],"sourcesContent":["export 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":"AAAe,SAASA,cAAT,CAAyBC,QAAzB,EAAmCC,IAAnC,EAAyC;AACvD;AACA,QAAMC,SAAS,GAAGC,MAAM,CAACF,IAAD,CAAN,CAAaC,SAA/B;AACA,QAAME,IAAI,GAAGD,MAAM,CAACF,IAAD,CAAN,CAAaG,IAAb,IAAqB,OAAlC;AACA,QAAMC,KAAK,GAAGF,MAAM,CAACF,IAAD,CAAN,CAAaI,KAA3B;;AAEA,MAAI;AACHL,IAAAA,QAAQ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A,KAND;;AAQApD,IAAAA,MAAM,CAACmD,cAAP,CAAsBP,WAAW,CAAC3B,SAAlC,EAA6C,UAA7C,EAAyD4B,UAAzD;AACA;AACD;;;;"}
package/postcss.js DELETED
@@ -1,32 +0,0 @@
1
- 'use strict';
2
-
3
- const selectorRegExp = /:blank([^\w-]|$)/gi;
4
-
5
- const creator = opts => {
6
- const replaceWith = String(Object(opts).replaceWith || '[blank]');
7
- const preserve = Boolean('preserve' in Object(opts) ? opts.preserve : true);
8
- return {
9
- postcssPlugin: 'css-blank-pseudo',
10
- Once: root => {
11
- root.walkRules(selectorRegExp, rule => {
12
- const selector = rule.selector.replace(selectorRegExp, ($0, $1) => {
13
- return `${replaceWith}${$1}`;
14
- });
15
- const clone = rule.clone({
16
- selector
17
- });
18
-
19
- if (preserve) {
20
- rule.before(clone);
21
- } else {
22
- rule.replaceWith(clone);
23
- }
24
- });
25
- }
26
- };
27
- };
28
-
29
- creator.postcss = true;
30
-
31
- module.exports = creator;
32
- //# sourceMappingURL=postcss.js.map
package/postcss.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"postcss.js","sources":["src/postcss.js"],"sourcesContent":["const selectorRegExp = /:blank([^\\w-]|$)/gi;\n\nconst creator = opts => {\n\tconst replaceWith = String(Object(opts).replaceWith || '[blank]');\n\tconst preserve = Boolean('preserve' in Object(opts) ? opts.preserve : true);\n\n\treturn {\n\t\tpostcssPlugin: 'css-blank-pseudo',\n\t\tOnce: root => {\n\t\t\troot.walkRules(selectorRegExp, rule => {\n\t\t\t\tconst selector = rule.selector.replace(selectorRegExp, ($0, $1) => {\n\t\t\t\t\treturn `${replaceWith}${$1}`;\n\t\t\t\t});\n\n\t\t\t\tconst clone = rule.clone({ selector });\n\n\t\t\t\tif (preserve) {\n\t\t\t\t\trule.before(clone);\n\t\t\t\t} else {\n\t\t\t\t\trule.replaceWith(clone);\n\t\t\t\t}\n\t\t\t});\n\t\t},\n\t};\n};\n\ncreator.postcss = true\n\nexport default creator\n"],"names":["selectorRegExp","creator","opts","replaceWith","String","Object","preserve","Boolean","postcssPlugin","Once","root","walkRules","rule","selector","replace","$0","$1","clone","before","postcss"],"mappings":";;AAAA,MAAMA,cAAc,GAAG,oBAAvB;;MAEMC,OAAO,GAAGC,IAAI,IAAI;AACvB,QAAMC,WAAW,GAAGC,MAAM,CAACC,MAAM,CAACH,IAAD,CAAN,CAAaC,WAAb,IAA4B,SAA7B,CAA1B;AACA,QAAMG,QAAQ,GAAGC,OAAO,CAAC,cAAcF,MAAM,CAACH,IAAD,CAApB,GAA6BA,IAAI,CAACI,QAAlC,GAA6C,IAA9C,CAAxB;AAEA,SAAO;AACNE,IAAAA,aAAa,EAAE,kBADT;AAENC,IAAAA,IAAI,EAAEC,IAAI,IAAI;AACbA,MAAAA,IAAI,CAACC,SAAL,CAAeX,cAAf,EAA+BY,IAAI,IAAI;AACtC,cAAMC,QAAQ,GAAGD,IAAI,CAACC,QAAL,CAAcC,OAAd,CAAsBd,cAAtB,EAAsC,CAACe,EAAD,EAAKC,EAAL,KAAY;AAClE,iBAAQ,GAAEb,WAAY,GAAEa,EAAG,EAA3B;AACA,SAFgB,CAAjB;AAIA,cAAMC,KAAK,GAAGL,IAAI,CAACK,KAAL,CAAW;AAAEJ,UAAAA;AAAF,SAAX,CAAd;;AAEA,YAAIP,QAAJ,EAAc;AACbM,UAAAA,IAAI,CAACM,MAAL,CAAYD,KAAZ;AACA,SAFD,MAEO;AACNL,UAAAA,IAAI,CAACT,WAAL,CAAiBc,KAAjB;AACA;AACD,OAZD;AAaA;AAhBK,GAAP;AAkBA;;AAEDhB,OAAO,CAACkB,OAAR,GAAkB,IAAlB;;;;"}
package/postcss.mjs DELETED
@@ -1,30 +0,0 @@
1
- const selectorRegExp = /:blank([^\w-]|$)/gi;
2
-
3
- const creator = opts => {
4
- const replaceWith = String(Object(opts).replaceWith || '[blank]');
5
- const preserve = Boolean('preserve' in Object(opts) ? opts.preserve : true);
6
- return {
7
- postcssPlugin: 'css-blank-pseudo',
8
- Once: root => {
9
- root.walkRules(selectorRegExp, rule => {
10
- const selector = rule.selector.replace(selectorRegExp, ($0, $1) => {
11
- return `${replaceWith}${$1}`;
12
- });
13
- const clone = rule.clone({
14
- selector
15
- });
16
-
17
- if (preserve) {
18
- rule.before(clone);
19
- } else {
20
- rule.replaceWith(clone);
21
- }
22
- });
23
- }
24
- };
25
- };
26
-
27
- creator.postcss = true;
28
-
29
- export { creator as default };
30
- //# sourceMappingURL=postcss.mjs.map
package/postcss.mjs.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"postcss.mjs","sources":["src/postcss.js"],"sourcesContent":["const selectorRegExp = /:blank([^\\w-]|$)/gi;\n\nconst creator = opts => {\n\tconst replaceWith = String(Object(opts).replaceWith || '[blank]');\n\tconst preserve = Boolean('preserve' in Object(opts) ? opts.preserve : true);\n\n\treturn {\n\t\tpostcssPlugin: 'css-blank-pseudo',\n\t\tOnce: root => {\n\t\t\troot.walkRules(selectorRegExp, rule => {\n\t\t\t\tconst selector = rule.selector.replace(selectorRegExp, ($0, $1) => {\n\t\t\t\t\treturn `${replaceWith}${$1}`;\n\t\t\t\t});\n\n\t\t\t\tconst clone = rule.clone({ selector });\n\n\t\t\t\tif (preserve) {\n\t\t\t\t\trule.before(clone);\n\t\t\t\t} else {\n\t\t\t\t\trule.replaceWith(clone);\n\t\t\t\t}\n\t\t\t});\n\t\t},\n\t};\n};\n\ncreator.postcss = true\n\nexport default creator\n"],"names":["selectorRegExp","creator","opts","replaceWith","String","Object","preserve","Boolean","postcssPlugin","Once","root","walkRules","rule","selector","replace","$0","$1","clone","before","postcss"],"mappings":"AAAA,MAAMA,cAAc,GAAG,oBAAvB;;MAEMC,OAAO,GAAGC,IAAI,IAAI;AACvB,QAAMC,WAAW,GAAGC,MAAM,CAACC,MAAM,CAACH,IAAD,CAAN,CAAaC,WAAb,IAA4B,SAA7B,CAA1B;AACA,QAAMG,QAAQ,GAAGC,OAAO,CAAC,cAAcF,MAAM,CAACH,IAAD,CAApB,GAA6BA,IAAI,CAACI,QAAlC,GAA6C,IAA9C,CAAxB;AAEA,SAAO;AACNE,IAAAA,aAAa,EAAE,kBADT;AAENC,IAAAA,IAAI,EAAEC,IAAI,IAAI;AACbA,MAAAA,IAAI,CAACC,SAAL,CAAeX,cAAf,EAA+BY,IAAI,IAAI;AACtC,cAAMC,QAAQ,GAAGD,IAAI,CAACC,QAAL,CAAcC,OAAd,CAAsBd,cAAtB,EAAsC,CAACe,EAAD,EAAKC,EAAL,KAAY;AAClE,iBAAQ,GAAEb,WAAY,GAAEa,EAAG,EAA3B;AACA,SAFgB,CAAjB;AAIA,cAAMC,KAAK,GAAGL,IAAI,CAACK,KAAL,CAAW;AAAEJ,UAAAA;AAAF,SAAX,CAAd;;AAEA,YAAIP,QAAJ,EAAc;AACbM,UAAAA,IAAI,CAACM,MAAL,CAAYD,KAAZ;AACA,SAFD,MAEO;AACNL,UAAAA,IAAI,CAACT,WAAL,CAAiBc,KAAjB;AACA;AACD,OAZD;AAaA;AAhBK,GAAP;AAkBA;;AAEDhB,OAAO,CAACkB,OAAR,GAAkB,IAAlB;;;;"}