css-blank-pseudo 0.1.0 → 0.1.4
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 +17 -1
- package/README.md +16 -12
- package/browser-legacy.js +1 -0
- package/browser.js +1 -1
- package/cli.js +3 -3
- package/index.js +4 -3
- package/index.js.map +1 -1
- package/index.mjs +4 -3
- package/index.mjs.map +1 -1
- package/legacy.js +121 -0
- package/legacy.js.map +1 -0
- package/legacy.mjs +119 -0
- package/legacy.mjs.map +1 -0
- package/package.json +15 -9
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# Changes to CSS Blank Pseudo
|
|
2
2
|
|
|
3
|
-
### 1.
|
|
3
|
+
### 0.1.4 (November 17, 2018)
|
|
4
|
+
|
|
5
|
+
- Update documentation
|
|
6
|
+
|
|
7
|
+
### 0.1.3 (November 17, 2018)
|
|
8
|
+
|
|
9
|
+
- Improve CLI usage
|
|
10
|
+
|
|
11
|
+
### 0.1.2 (November 17, 2018)
|
|
12
|
+
|
|
13
|
+
- Provide a version specifically for Internet Explorer 11
|
|
14
|
+
|
|
15
|
+
### 0.1.1 (November 17, 2018)
|
|
16
|
+
|
|
17
|
+
- Update documentation
|
|
18
|
+
|
|
19
|
+
### 0.1.0 (November 17, 2018)
|
|
4
20
|
|
|
5
21
|
- Initial version
|
package/README.md
CHANGED
|
@@ -33,8 +33,18 @@ Next, use your transformed CSS with this script:
|
|
|
33
33
|
<script>cssBlankPseudo(document)</script>
|
|
34
34
|
```
|
|
35
35
|
|
|
36
|
-
That’s it. The script is
|
|
37
|
-
|
|
36
|
+
That’s it. The script is 509 bytes and works in all browsers.
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
If you support Internet Explorer 11, use the **browser legacy** script, which
|
|
41
|
+
is 671 bytes:
|
|
42
|
+
|
|
43
|
+
```html
|
|
44
|
+
<link rel="stylesheet" href="TRANSFORMED.css">
|
|
45
|
+
<script src="https://unpkg.com/css-blank-pseudo/browser-legacy"></script>
|
|
46
|
+
<script>cssBlankPseudo(document)</script>
|
|
47
|
+
```
|
|
38
48
|
|
|
39
49
|
## How it works
|
|
40
50
|
|
|
@@ -48,11 +58,11 @@ input:blank {
|
|
|
48
58
|
|
|
49
59
|
/* becomes */
|
|
50
60
|
|
|
51
|
-
|
|
61
|
+
input[blank] {
|
|
52
62
|
background-color: yellow;
|
|
53
63
|
}
|
|
54
64
|
|
|
55
|
-
|
|
65
|
+
input:blank {
|
|
56
66
|
background-color: yellow;
|
|
57
67
|
}
|
|
58
68
|
```
|
|
@@ -61,14 +71,8 @@ Next, the [JavaScript library](README-BROWSER.md) adds a `blank` attribute to
|
|
|
61
71
|
elements otherwise matching `:blank` natively.
|
|
62
72
|
|
|
63
73
|
```html
|
|
64
|
-
<
|
|
65
|
-
|
|
66
|
-
<input id="a" value="" blank>
|
|
67
|
-
</div>
|
|
68
|
-
<div class="field">
|
|
69
|
-
<label for="b">Field</label>
|
|
70
|
-
<input id="b" value="This element has a value">
|
|
71
|
-
</div>
|
|
74
|
+
<input value="" blank>
|
|
75
|
+
<input value="This element has a value">
|
|
72
76
|
```
|
|
73
77
|
|
|
74
78
|
[cli-img]: https://img.shields.io/travis/csstools/css-blank-pseudo/master.svg
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function cssBlankPseudo(e,t){var n=Object(t).className,r=Object(t).attr||"blank",o=Object(t).force;try{if(e.querySelector(":blank"),!o)return}catch(e){}var a,i,s,c=(e.ownerDocument||e).defaultView;d(c.HTMLInputElement),d(c.HTMLSelectElement),d(c.HTMLTextAreaElement),a=c.HTMLOptionElement,i=Object.getOwnPropertyDescriptor(a.prototype,"selected"),s=i.set,i.set=function(t){s.apply(this,arguments);var n=e.createEvent("Event");n.initEvent("change",!0,!0),this.dispatchEvent(n)},Object.defineProperty(a.prototype,"selected",i);var l=/^(INPUT|SELECT|TEXTAREA)$/;function p(){this.value||"SELECT"===this.nodeName&&this.options[this.selectedIndex].value?(r&&this.removeAttribute(r),n&&this.classList.remove(n),this.removeAttribute("blank")):(r&&this.setAttribute("blank",r),n&&this.classList.add(n))}function d(e){var t=Object.getOwnPropertyDescriptor(e.prototype,"value"),n=t.set;t.set=function(e){n.apply(this,arguments),p.apply(this)},Object.defineProperty(e.prototype,"value",t)}Array.prototype.forEach.call(e.querySelectorAll("INPUT,SELECT,TEXTAREA"),function(e){"SELECT"===e.nodeName?e.addEventListener("change",p):e.addEventListener("input",p),p.call(e)}),new MutationObserver(function(e){e.forEach(function(e){Array.prototype.forEach.call(e.addedNodes||[],function(e){1===e.nodeType&&l.test(e.nodeName)&&("SELECT"===e.nodeName?e.addEventListener("change",p):e.addEventListener("input",p),p.call(e))}),Array.prototype.forEach.call(e.removedNodes||[],function(e){1===e.nodeType&&l.test(e.nodeName)&&("SELECT"===e.nodeName?e.removeEventListener("change",p):e.removeEventListener("input",p))})})}).observe(e,{childList:!0,subtree:!0})}
|
package/browser.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function cssBlankPseudo(e,t){var r=Object(t).className,n=Object(t).attr||"blank",o=Object(t).force;try{if(e.querySelector(":blank"),!o)return}catch(e){}
|
|
1
|
+
function cssBlankPseudo(e,t){var r=Object(t).className,n=Object(t).attr||"blank",o=Object(t).force;try{if(e.querySelector(":blank"),!o)return}catch(e){}var a=(e.ownerDocument||e).defaultView;i(a.HTMLInputElement),i(a.HTMLSelectElement),i(a.HTMLTextAreaElement);var c="input,select,textarea";function s(){this.value?(n&&this.removeAttribute(n),r&&this.classList.remove(r),this.removeAttribute("blank")):(n&&this.setAttribute("blank",n),r&&this.classList.add(r))}function i(e){var t=Object.getOwnPropertyDescriptor(e.prototype,"value"),r=t.set;t.set=function(e){r.apply(this,arguments),s.apply(this)},Object.defineProperty(e.prototype,"value",t)}Array.prototype.forEach.call(e.querySelectorAll(c),function(e){e.addEventListener("input",s),s.call(e)}),new MutationObserver(function(e){e.forEach(function(e){e.addedNodes&&e.addedNodes.forEach(function(e){1===e.nodeType&&e.matches(c)&&(e.addEventListener("input",s),s.call(e))}),e.removedNodes&&e.removedNodes.forEach(function(e){1===e.nodeType&&e.matches(c)&&e.removeEventListener("input",s)})})}).observe(e,{childList:!0,subtree:!0})}
|
package/cli.js
CHANGED
|
@@ -28,7 +28,7 @@ var plugin = postcss.plugin('css-blank-pseudo', opts => {
|
|
|
28
28
|
});
|
|
29
29
|
|
|
30
30
|
if (process.argv.length < 3) {
|
|
31
|
-
console.log(['CSS Blank Pseudo\n', ' Transforms CSS with :blank {}\n', 'Usage:\n', ' css-blank-pseudo source.css transformed.css', ' css-blank-pseudo --in=source.css --out=transformed.css --opts={}', ' echo "@media (prefers-color-scheme: dark) {}" | css
|
|
31
|
+
console.log(['CSS Blank Pseudo\n', ' Transforms CSS with :blank {}\n', 'Usage:\n', ' css-blank-pseudo source.css transformed.css', ' css-blank-pseudo --in=source.css --out=transformed.css --opts={}', ' echo "@media (prefers-color-scheme: dark) {}" | css-blank-pseudo\n'].join('\n'));
|
|
32
32
|
process.exit(0);
|
|
33
33
|
} // get process and plugin options from the command line
|
|
34
34
|
|
|
@@ -36,7 +36,7 @@ if (process.argv.length < 3) {
|
|
|
36
36
|
const fileRegExp = /^[\w\/.]+$/;
|
|
37
37
|
const argRegExp = /^--(\w+)=("|')?(.+)\2$/;
|
|
38
38
|
const relaxedJsonPropRegExp = /(['"])?([a-z0-9A-Z_]+)(['"])?:/g;
|
|
39
|
-
const relaxedJsonValueRegExp = /("[a-z0-9A-Z_]+":\s*)'([
|
|
39
|
+
const relaxedJsonValueRegExp = /("[a-z0-9A-Z_]+":\s*)'?([A-z0-9]+)'?([,}])/g;
|
|
40
40
|
const argo = process.argv.slice(2).reduce((object, arg) => {
|
|
41
41
|
const argMatch = arg.match(argRegExp);
|
|
42
42
|
const fileMatch = arg.match(fileRegExp);
|
|
@@ -59,7 +59,7 @@ const argo = process.argv.slice(2).reduce((object, arg) => {
|
|
|
59
59
|
}); // get css from command line arguments or stdin
|
|
60
60
|
|
|
61
61
|
(argo.from === '<stdin>' ? getStdin() : readFile(argo.from)).then(css => {
|
|
62
|
-
const pluginOpts = JSON.parse(argo.opts.replace(relaxedJsonPropRegExp, '"$2": ').replace(relaxedJsonValueRegExp, '$1"$2"'));
|
|
62
|
+
const pluginOpts = JSON.parse(argo.opts.replace(relaxedJsonPropRegExp, '"$2": ').replace(relaxedJsonValueRegExp, '$1"$2"$3'));
|
|
63
63
|
const processOptions = Object.assign({
|
|
64
64
|
from: argo.from,
|
|
65
65
|
to: argo.to || argo.from
|
package/index.js
CHANGED
|
@@ -17,9 +17,10 @@ function cssBlankPseudo(document, opts) {
|
|
|
17
17
|
// observe value changes on <input>, <select>, and <textarea>
|
|
18
18
|
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
observeValueOfHTMLElement(
|
|
22
|
-
observeValueOfHTMLElement(
|
|
20
|
+
const window = (document.ownerDocument || document).defaultView;
|
|
21
|
+
observeValueOfHTMLElement(window.HTMLInputElement);
|
|
22
|
+
observeValueOfHTMLElement(window.HTMLSelectElement);
|
|
23
|
+
observeValueOfHTMLElement(window.HTMLTextAreaElement); // form control elements selector
|
|
23
24
|
|
|
24
25
|
const selector = 'input,select,textarea'; // conditionally update all form control elements
|
|
25
26
|
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","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\tobserveValueOfHTMLElement(HTMLInputElement);\n\tobserveValueOfHTMLElement(HTMLSelectElement);\n\tobserveValueOfHTMLElement(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","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,CAAwBC,QAAxB,EAAkCC,IAAlC,EAAwC;;QAEhDC,SAAS,GAAGC,MAAM,CAACF,IAAD,CAAN,CAAaC,SAA/B;QACME,IAAI,GAAGD,MAAM,CAACF,IAAD,CAAN,CAAaG,IAAb,IAAqB,OAAlC;QACMC,KAAK,GAAGF,MAAM,CAACF,IAAD,CAAN,CAAaI,KAA3B;;MAEI;IACHL,QAAQ,CAACM,aAAT,CAAuB,QAAvB;;QAEI,CAACD,KAAL,EAAY;;;GAHb,CAME,OAAOE,YAAP,EAAqB;;;;;
|
|
1
|
+
{"version":3,"file":"index.js","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,CAAwBC,QAAxB,EAAkCC,IAAlC,EAAwC;;QAEhDC,SAAS,GAAGC,MAAM,CAACF,IAAD,CAAN,CAAaC,SAA/B;QACME,IAAI,GAAGD,MAAM,CAACF,IAAD,CAAN,CAAaG,IAAb,IAAqB,OAAlC;QACMC,KAAK,GAAGF,MAAM,CAACF,IAAD,CAAN,CAAaI,KAA3B;;MAEI;IACHL,QAAQ,CAACM,aAAT,CAAuB,QAAvB;;QAEI,CAACD,KAAL,EAAY;;;GAHb,CAME,OAAOE,YAAP,EAAqB;;;;;QAGjBC,MAAM,GAAG,CAACR,QAAQ,CAACS,aAAT,IAA0BT,QAA3B,EAAqCU,WAApD;EAEAC,yBAAyB,CAACH,MAAM,CAACI,gBAAR,CAAzB;EACAD,yBAAyB,CAACH,MAAM,CAACK,iBAAR,CAAzB;EACAF,yBAAyB,CAACH,MAAM,CAACM,mBAAR,CAA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AAL,CAAqB,OAArB;KARD,MASO;UACFhC,IAAJ,EAAU;aACJmC,YAAL,CAAkB,OAAlB,EAA2BnC,IAA3B;;;UAGGF,SAAJ,EAAe;aACTmC,SAAL,CAAeG,GAAf,CAAmBtC,SAAnB;;;GA5EmD;;;WAkF7CS,yBAAT,CAAmC8B,WAAnC,EAAgD;UACzCC,UAAU,GAAGvC,MAAM,CAACwC,wBAAP,CAAgCF,WAAW,CAACxB,SAA5C,EAAuD,OAAvD,CAAnB;UACM2B,SAAS,GAAGF,UAAU,CAACG,GAA7B;;IAEAH,UAAU,CAACG,GAAX,GAAiB,SAASA,GAAT,CAAaV,KAAb,EAAoB;;MACpCS,SAAS,CAACE,KAAV,CAAgB,IAAhB,EAAsBC,SAAtB;MAEAxB,0BAA0B,CAACuB,KAA3B,CAAiC,IAAjC;KAHD;;IAMA3C,MAAM,CAAC6C,cAAP,CAAsBP,WAAW,CAACxB,SAAlC,EAA6C,OAA7C,EAAsDyB,UAAtD;;;;;;"}
|
package/index.mjs
CHANGED
|
@@ -15,9 +15,10 @@ function cssBlankPseudo(document, opts) {
|
|
|
15
15
|
// observe value changes on <input>, <select>, and <textarea>
|
|
16
16
|
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
observeValueOfHTMLElement(
|
|
20
|
-
observeValueOfHTMLElement(
|
|
18
|
+
const window = (document.ownerDocument || document).defaultView;
|
|
19
|
+
observeValueOfHTMLElement(window.HTMLInputElement);
|
|
20
|
+
observeValueOfHTMLElement(window.HTMLSelectElement);
|
|
21
|
+
observeValueOfHTMLElement(window.HTMLTextAreaElement); // form control elements selector
|
|
21
22
|
|
|
22
23
|
const selector = 'input,select,textarea'; // conditionally update all form control elements
|
|
23
24
|
|
package/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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\tobserveValueOfHTMLElement(HTMLInputElement);\n\tobserveValueOfHTMLElement(HTMLSelectElement);\n\tobserveValueOfHTMLElement(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","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,CAAwBC,QAAxB,EAAkCC,IAAlC,EAAwC;;QAEhDC,SAAS,GAAGC,MAAM,CAACF,IAAD,CAAN,CAAaC,SAA/B;QACME,IAAI,GAAGD,MAAM,CAACF,IAAD,CAAN,CAAaG,IAAb,IAAqB,OAAlC;QACMC,KAAK,GAAGF,MAAM,CAACF,IAAD,CAAN,CAAaI,KAA3B;;MAEI;IACHL,QAAQ,CAACM,aAAT,CAAuB,QAAvB;;QAEI,CAACD,KAAL,EAAY;;;GAHb,CAME,OAAOE,YAAP,EAAqB;;;;;
|
|
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,CAAwBC,QAAxB,EAAkCC,IAAlC,EAAwC;;QAEhDC,SAAS,GAAGC,MAAM,CAACF,IAAD,CAAN,CAAaC,SAA/B;QACME,IAAI,GAAGD,MAAM,CAACF,IAAD,CAAN,CAAaG,IAAb,IAAqB,OAAlC;QACMC,KAAK,GAAGF,MAAM,CAACF,IAAD,CAAN,CAAaI,KAA3B;;MAEI;IACHL,QAAQ,CAACM,aAAT,CAAuB,QAAvB;;QAEI,CAACD,KAA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C,QAvBX,EAuBqB;IAAEiC,SAAS,EAAE,IAAb;IAAmBC,OAAO,EAAE;GAvBjD,EAlCsD;;WA4D7CX,0BAAT,GAAsC;QACjC,KAAKY,KAAT,EAAgB;UACX/B,IAAJ,EAAU;aACJgC,eAAL,CAAqBhC,IAArB;;;UAGGF,SAAJ,EAAe;aACTmC,SAAL,CAAeC,MAAf,CAAsBpC,SAAtB;;;WAEIkC,eAAL,CAAqB,OAArB;KARD,MASO;UACFhC,IAAJ,EAAU;aACJmC,YAAL,CAAkB,OAAlB,EAA2BnC,IAA3B;;;UAGGF,SAAJ,EAAe;aACTmC,SAAL,CAAeG,GAAf,CAAmBtC,SAAnB;;;GA5EmD;;;WAkF7CS,yBAAT,CAAmC8B,WAAnC,EAAgD;UACzCC,UAAU,GAAGvC,MAAM,CAACwC,wBAAP,CAAgCF,WAAW,CAACxB,SAA5C,EAAuD,OAAvD,CAAnB;UACM2B,SAAS,GAAGF,UAAU,CAACG,GAA7B;;IAEAH,UAAU,CAACG,GAAX,GAAiB,SAASA,GAAT,CAAaV,KAAb,EAAoB;;MACpCS,SAAS,CAACE,KAAV,CAAgB,IAAhB,EAAsBC,SAAtB;MAEAxB,0BAA0B,CAACuB,KAA3B,CAAiC,IAAjC;KAHD;;IAMA3C,MAAM,CAAC6C,cAAP,CAAsBP,WAAW,CAACxB,SAAlC,EAA6C,OAA7C,EAAsDyB,UAAtD;;;;;;"}
|
package/legacy.js
ADDED
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
function cssBlankPseudo(document, opts) {
|
|
4
|
+
// configuration
|
|
5
|
+
const className = Object(opts).className;
|
|
6
|
+
const attr = Object(opts).attr || 'blank';
|
|
7
|
+
const force = Object(opts).force;
|
|
8
|
+
|
|
9
|
+
try {
|
|
10
|
+
document.querySelector(':blank');
|
|
11
|
+
|
|
12
|
+
if (!force) {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
} catch (ignoredError) {}
|
|
16
|
+
/* do nothing and continue */
|
|
17
|
+
// observe value changes on <input>, <select>, and <textarea>
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
const window = (document.ownerDocument || document).defaultView;
|
|
21
|
+
observeValueOfHTMLElement(window.HTMLInputElement);
|
|
22
|
+
observeValueOfHTMLElement(window.HTMLSelectElement);
|
|
23
|
+
observeValueOfHTMLElement(window.HTMLTextAreaElement);
|
|
24
|
+
observeSelectedOfHTMLElement(window.HTMLOptionElement); // form control elements selector
|
|
25
|
+
|
|
26
|
+
const selector = 'INPUT,SELECT,TEXTAREA';
|
|
27
|
+
const selectorRegExp = /^(INPUT|SELECT|TEXTAREA)$/; // conditionally update all form control elements
|
|
28
|
+
|
|
29
|
+
Array.prototype.forEach.call(document.querySelectorAll(selector), node => {
|
|
30
|
+
if (node.nodeName === 'SELECT') {
|
|
31
|
+
node.addEventListener('change', configureCssBlankAttribute);
|
|
32
|
+
} else {
|
|
33
|
+
node.addEventListener('input', configureCssBlankAttribute);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
configureCssBlankAttribute.call(node);
|
|
37
|
+
}); // conditionally observe added or unobserve removed form control elements
|
|
38
|
+
|
|
39
|
+
new MutationObserver(mutationsList => {
|
|
40
|
+
mutationsList.forEach(mutation => {
|
|
41
|
+
Array.prototype.forEach.call(mutation.addedNodes || [], node => {
|
|
42
|
+
if (node.nodeType === 1 && selectorRegExp.test(node.nodeName)) {
|
|
43
|
+
if (node.nodeName === 'SELECT') {
|
|
44
|
+
node.addEventListener('change', configureCssBlankAttribute);
|
|
45
|
+
} else {
|
|
46
|
+
node.addEventListener('input', configureCssBlankAttribute);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
configureCssBlankAttribute.call(node);
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
Array.prototype.forEach.call(mutation.removedNodes || [], node => {
|
|
53
|
+
if (node.nodeType === 1 && selectorRegExp.test(node.nodeName)) {
|
|
54
|
+
if (node.nodeName === 'SELECT') {
|
|
55
|
+
node.removeEventListener('change', configureCssBlankAttribute);
|
|
56
|
+
} else {
|
|
57
|
+
node.removeEventListener('input', configureCssBlankAttribute);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
}).observe(document, {
|
|
63
|
+
childList: true,
|
|
64
|
+
subtree: true
|
|
65
|
+
}); // update a form control element’s css-blank attribute
|
|
66
|
+
|
|
67
|
+
function configureCssBlankAttribute() {
|
|
68
|
+
if (this.value || this.nodeName === 'SELECT' && this.options[this.selectedIndex].value) {
|
|
69
|
+
if (attr) {
|
|
70
|
+
this.removeAttribute(attr);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
if (className) {
|
|
74
|
+
this.classList.remove(className);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
this.removeAttribute('blank');
|
|
78
|
+
} else {
|
|
79
|
+
if (attr) {
|
|
80
|
+
this.setAttribute('blank', attr);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
if (className) {
|
|
84
|
+
this.classList.add(className);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
} // observe changes to the "value" property on an HTML Element
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
function observeValueOfHTMLElement(HTMLElement) {
|
|
91
|
+
const descriptor = Object.getOwnPropertyDescriptor(HTMLElement.prototype, 'value');
|
|
92
|
+
const nativeSet = descriptor.set;
|
|
93
|
+
|
|
94
|
+
descriptor.set = function set(value) {
|
|
95
|
+
// eslint-disable-line no-unused-vars
|
|
96
|
+
nativeSet.apply(this, arguments);
|
|
97
|
+
configureCssBlankAttribute.apply(this);
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
Object.defineProperty(HTMLElement.prototype, 'value', descriptor);
|
|
101
|
+
} // observe changes to the "selected" property on an HTML Element
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
function observeSelectedOfHTMLElement(HTMLElement) {
|
|
105
|
+
const descriptor = Object.getOwnPropertyDescriptor(HTMLElement.prototype, 'selected');
|
|
106
|
+
const nativeSet = descriptor.set;
|
|
107
|
+
|
|
108
|
+
descriptor.set = function set(value) {
|
|
109
|
+
// eslint-disable-line no-unused-vars
|
|
110
|
+
nativeSet.apply(this, arguments);
|
|
111
|
+
const event = document.createEvent('Event');
|
|
112
|
+
event.initEvent('change', true, true);
|
|
113
|
+
this.dispatchEvent(event);
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
Object.defineProperty(HTMLElement.prototype, 'selected', descriptor);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
module.exports = cssBlankPseudo;
|
|
121
|
+
//# sourceMappingURL=legacy.js.map
|
package/legacy.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
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","apply","arguments","defineProperty","event","createEvent","initEvent","dispatchEvent"],"mappings":";;AAAe,SAASA,cAAT,CAAwBC,QAAxB,EAAkCC,IAAlC,EAAwC;;QAEhDC,SAAS,GAAGC,MAAM,CAACF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mD;;;WAgG7CS,yBAAT,CAAmCoC,WAAnC,EAAgD;UACzCC,UAAU,GAAG7C,MAAM,CAAC8C,wBAAP,CAAgCF,WAAW,CAAC3B,SAA5C,EAAuD,OAAvD,CAAnB;UACM8B,SAAS,GAAGF,UAAU,CAACG,GAA7B;;IAEAH,UAAU,CAACG,GAAX,GAAiB,SAASA,GAAT,CAAaZ,KAAb,EAAoB;;MACpCW,SAAS,CAACE,KAAV,CAAgB,IAAhB,EAAsBC,SAAtB;MAEA1B,0BAA0B,CAACyB,KAA3B,CAAiC,IAAjC;KAHD;;IAMAjD,MAAM,CAACmD,cAAP,CAAsBP,WAAW,CAAC3B,SAAlC,EAA6C,OAA7C,EAAsD4B,UAAtD;GA1GqD;;;WA8G7CjC,4BAAT,CAAsCgC,WAAtC,EAAmD;UAC5CC,UAAU,GAAG7C,MAAM,CAAC8C,wBAAP,CAAgCF,WAAW,CAAC3B,SAA5C,EAAuD,UAAvD,CAAnB;UACM8B,SAAS,GAAGF,UAAU,CAACG,GAA7B;;IAEAH,UAAU,CAACG,GAAX,GAAiB,SAASA,GAAT,CAAaZ,KAAb,EAAoB;;MACpCW,SAAS,CAACE,KAAV,CAAgB,IAAhB,EAAsBC,SAAtB;YAEME,KAAK,GAAGvD,QAAQ,CAACwD,WAAT,CAAqB,OAArB,CAAd;MACAD,KAAK,CAACE,SAAN,CAAgB,QAAhB,EAA0B,IAA1B,EAAgC,IAAhC;WACKC,aAAL,CAAmBH,KAAnB;KALD;;IAQApD,MAAM,CAACmD,cAAP,CAAsBP,WAAW,CAAC3B,SAAlC,EAA6C,UAA7C,EAAyD4B,UAAzD;;;;;;"}
|
package/legacy.mjs
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
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 default cssBlankPseudo;
|
|
119
|
+
//# sourceMappingURL=legacy.mjs.map
|
package/legacy.mjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
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","initE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"0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"description": "Style form elements when they are empty",
|
|
5
5
|
"author": "Jonathan Neal <jonathantneal@hotmail.com>",
|
|
6
6
|
"license": "CC0-1.0",
|
|
@@ -14,11 +14,16 @@
|
|
|
14
14
|
},
|
|
15
15
|
"files": [
|
|
16
16
|
"browser.js",
|
|
17
|
+
"browser-legacy.js",
|
|
17
18
|
"cli.js",
|
|
18
19
|
"index.js",
|
|
19
20
|
"index.js.map",
|
|
20
21
|
"index.mjs",
|
|
21
22
|
"index.mjs.map",
|
|
23
|
+
"legacy.js",
|
|
24
|
+
"legacy.js.map",
|
|
25
|
+
"legacy.mjs",
|
|
26
|
+
"legacy.mjs.map",
|
|
22
27
|
"postcss.js",
|
|
23
28
|
"postcss.js.map",
|
|
24
29
|
"postcss.mjs",
|
|
@@ -26,11 +31,11 @@
|
|
|
26
31
|
],
|
|
27
32
|
"scripts": {
|
|
28
33
|
"build": "npm run build:browser && npm run build:cli && npm run build:node && npm run build:postcss",
|
|
29
|
-
"build:browser": "cross-env NODE_ENV=browser rollup -c .rollup.js --silent",
|
|
34
|
+
"build:browser": "cross-env NODE_ENV=browser rollup -c .rollup.js --silent && cross-env NODE_ENV=browser:legacy rollup -c .rollup.js --silent",
|
|
30
35
|
"build:cli": "cross-env NODE_ENV=cli rollup -c .rollup.js --silent",
|
|
31
36
|
"build:postcss": "cross-env NODE_ENV=postcss rollup -c .rollup.js --silent",
|
|
32
|
-
"build:node": "rollup -c .rollup.js --silent",
|
|
33
|
-
"prepublishOnly": "npm build && npm test",
|
|
37
|
+
"build:node": "rollup -c .rollup.js --silent && cross-env NODE_ENV=legacy rollup -c .rollup.js --silent",
|
|
38
|
+
"prepublishOnly": "npm run build && npm test",
|
|
34
39
|
"pretest": "npm run build:postcss",
|
|
35
40
|
"pretest:postcss": "npm run build:postcss",
|
|
36
41
|
"test": "npm run test:js && npm run test:postcss",
|
|
@@ -67,13 +72,14 @@
|
|
|
67
72
|
"javascript",
|
|
68
73
|
"js",
|
|
69
74
|
"polyfill",
|
|
70
|
-
"
|
|
71
|
-
"
|
|
72
|
-
"
|
|
75
|
+
"blank",
|
|
76
|
+
"empty",
|
|
77
|
+
"pseudo",
|
|
73
78
|
"selectors",
|
|
74
79
|
"accessibility",
|
|
75
80
|
"a11y",
|
|
76
|
-
"
|
|
77
|
-
"
|
|
81
|
+
"input",
|
|
82
|
+
"select",
|
|
83
|
+
"textarea"
|
|
78
84
|
]
|
|
79
85
|
}
|