css-has-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/CHANGELOG.md ADDED
@@ -0,0 +1,84 @@
1
+ # Changes to CSS Has Pseudo
2
+
3
+ ### 3.0.0 (December 13, 2021)
4
+
5
+ - Breaking: require/import paths have changed
6
+ - Changed: new polyfill CDN urls.
7
+ - Updated: documentation
8
+
9
+ **Migrating to 3.0.0**
10
+
11
+ PostCSS plugin :
12
+
13
+ ```diff
14
+ - const postcssHasPseudo = require('css-has-pseudo/postcss');
15
+ + const postcssHasPseudo = require('css-has-pseudo');
16
+ ```
17
+
18
+ Browser Polyfill :
19
+
20
+ ```diff
21
+ - const cssHasPseudo = require('css-has-pseudo');
22
+ + const cssHasPseudo = require('css-has-pseudo/browser');
23
+ ```
24
+
25
+ _The old CND url is now deprecated and will be removed in a next major release._
26
+ _It will continue to work for now._
27
+
28
+ ```diff
29
+ - <script src="https://unpkg.com/css-has-pseudo/browser"></script>
30
+ + <script src="https://unpkg.com/css-has-pseudo/dist/browser-global.js"></script>
31
+ ```
32
+
33
+ ### 2.0.0 (September 16, 2021)
34
+
35
+ - Updated: Support for PostCS 8+ (major).
36
+ - Updated: Support for Node 12+ (major).
37
+
38
+ ### 1.0.0 (June 10, 2019)
39
+
40
+ - Updated: `postcss-selector-parser` to 6.0.2 (major)
41
+ - Updated: `postcss` to 7.0.16 (patch)
42
+ - Updated: Node 8+ compatibility (major)
43
+
44
+ ### 0.10.0 (December 11, 2018)
45
+
46
+ - Fixed an issue where inaccessible rules would crash the library
47
+
48
+ ### 0.9.0 (November 26, 2018)
49
+
50
+ - Improved CLI usage
51
+
52
+ ### 0.8.0 (November 26, 2018)
53
+
54
+ - Fixed an issue where attribute names were not being properly encoded
55
+
56
+ ### 0.7.0 (November 25, 2018)
57
+
58
+ - Replaced `setImmediate` with `requestAnimationFrame` for future compatibility
59
+
60
+ ### 0.6.0 (November 25, 2018)
61
+
62
+ - Fixed an issue where nested rules were not supported
63
+
64
+ ### 0.5.0 (November 21, 2018)
65
+
66
+ - Further optimize script; from 775 bytes to 757 bytes
67
+
68
+ ### 0.4.0 (November 21, 2018)
69
+
70
+ - Fixed an issue with the browser script not picking up added nodes
71
+
72
+ ### 0.3.0 (November 21, 2018)
73
+
74
+ - Fixed the misnamed function name for the browser-ready script
75
+
76
+ ### 0.2.0 (November 21, 2018)
77
+
78
+ - Improved browser compatibility with updated parsers, encoders, and decoders
79
+ - Improved performance by walking the DOM less
80
+ - Reduced script size by 9%; from 855 bytes to 775 bytes
81
+
82
+ ### 0.1.0 (November 20, 2018)
83
+
84
+ - Initial version
package/README.md CHANGED
@@ -1,7 +1,6 @@
1
1
  # CSS Has Pseudo [<img src="http://jonathantneal.github.io/js-logo.svg" alt="" width="90" height="90" align="right">][CSS Has Pseudo]
2
2
 
3
3
  [![NPM Version][npm-img]][npm-url]
4
- [![Build Status][cli-img]][cli-url]
5
4
  [![Support Chat][git-img]][git-url]
6
5
 
7
6
  [CSS Has Pseudo] lets you style elements relative to other elements in CSS,
@@ -32,21 +31,29 @@ body:has(:focus) {
32
31
  From the command line, transform CSS files that use `:has` selectors:
33
32
 
34
33
  ```bash
35
- npx css-has-pseudo SOURCE.css TRANSFORMED.css
34
+ npx css-has-pseudo SOURCE.css --output TRANSFORMED.css
36
35
  ```
37
36
 
38
37
  Next, use your transformed CSS with this script:
39
38
 
40
39
  ```html
41
40
  <link rel="stylesheet" href="TRANSFORMED.css">
42
- <script src="https://unpkg.com/css-has-pseudo/browser"></script>
41
+ <script src="https://unpkg.com/css-has-pseudo/dist/browser-global.js"></script>
43
42
  <script>cssHasPseudo(document)</script>
44
43
  ```
45
44
 
46
- That’s it. The script is 765 bytes and works in all browsers, including
45
+ ⚠️ Please use a versioned url, like this : `https://unpkg.com/css-has-pseudo@3.0.0/dist/browser-global.js`
46
+ Without the version, you might unexpectedly get a new major version of the library with breaking changes.
47
+
48
+ ⚠️ If you were using an older version via a CDN, please update the entire url.
49
+ The old URL will no longer work in a future release.
50
+
51
+ That’s it. The script is 765 bytes and works in most browser versions, including
47
52
  Internet Explorer 11. With a [Mutation Observer polyfill], the script will work
48
53
  down to Internet Explorer 9.
49
54
 
55
+ See [README BROWSER](README-BROWSER.md) for more information.
56
+
50
57
  ## How it works
51
58
 
52
59
  The [PostCSS plugin](README-POSTCSS.md) clones rules containing `:has`,
@@ -89,13 +96,11 @@ elements otherwise matching `:has` natively.
89
96
  </body>
90
97
  ```
91
98
 
92
- [cli-img]: https://img.shields.io/travis/csstools/css-has-pseudo/master.svg
93
- [cli-url]: https://travis-ci.org/csstools/css-has-pseudo
94
99
  [git-img]: https://img.shields.io/badge/support-chat-blue.svg
95
100
  [git-url]: https://gitter.im/postcss/postcss
96
101
  [npm-img]: https://img.shields.io/npm/v/css-has-pseudo.svg
97
102
  [npm-url]: https://www.npmjs.com/package/css-has-pseudo
98
103
 
99
- [CSS Has Pseudo]: https://github.com/csstools/css-has-pseudo
104
+ [CSS Has Pseudo]: https://github.com/csstools/postcss-plugins/tree/main/plugins/css-has-pseudo
100
105
  [Mutation Observer polyfill]: https://github.com/webmodules/mutation-observer
101
106
  [Selectors Level 4]: https://drafts.csswg.org/selectors-4/#has-pseudo
package/browser.js CHANGED
@@ -1,2 +1,117 @@
1
+ (function () {
1
2
 
2
- //# sourceMappingURL=browser.js.map
3
+ /* global MutationObserver,requestAnimationFrame */
4
+ function cssHasPseudo(document) {
5
+ var observedItems = []; // document.createAttribute() doesn't support `:` in the name. innerHTML does
6
+
7
+ var attributeElement = document.createElement('x'); // walk all stylesheets to collect observed css rules
8
+
9
+ [].forEach.call(document.styleSheets, walkStyleSheet);
10
+ transformObservedItems(); // observe DOM modifications that affect selectors
11
+
12
+ var mutationObserver = new MutationObserver(function (mutationsList) {
13
+ mutationsList.forEach(function (mutation) {
14
+ [].forEach.call(mutation.addedNodes || [], function (node) {
15
+ // walk stylesheets to collect observed css rules
16
+ if (node.nodeType === 1 && node.sheet) {
17
+ walkStyleSheet(node.sheet);
18
+ }
19
+ }); // transform observed css rules
20
+
21
+ cleanupObservedCssRules();
22
+ transformObservedItems();
23
+ });
24
+ });
25
+ mutationObserver.observe(document, {
26
+ childList: true,
27
+ subtree: true
28
+ }); // observe DOM events that affect pseudo-selectors
29
+
30
+ document.addEventListener('focus', transformObservedItems, true);
31
+ document.addEventListener('blur', transformObservedItems, true);
32
+ document.addEventListener('input', transformObservedItems); // transform observed css rules
33
+
34
+ function transformObservedItems() {
35
+ requestAnimationFrame(function () {
36
+ observedItems.forEach(function (item) {
37
+ var nodes = [];
38
+ [].forEach.call(document.querySelectorAll(item.scopeSelector), function (element) {
39
+ var nthChild = [].indexOf.call(element.parentNode.children, element) + 1;
40
+ var relativeSelectors = item.relativeSelectors.map(function (relativeSelector) {
41
+ return item.scopeSelector + ':nth-child(' + nthChild + ') ' + relativeSelector;
42
+ }).join(); // find any relative :has element from the :scope element
43
+
44
+ var relativeElement = element.parentNode.querySelector(relativeSelectors);
45
+ var shouldElementMatch = item.isNot ? !relativeElement : relativeElement;
46
+
47
+ if (shouldElementMatch) {
48
+ // memorize the node
49
+ nodes.push(element); // set an attribute with an irregular attribute name
50
+ // document.createAttribute() doesn't support special characters
51
+
52
+ attributeElement.innerHTML = '<x ' + item.attributeName + '>';
53
+ element.setAttributeNode(attributeElement.children[0].attributes[0].cloneNode()); // trigger a style refresh in IE and Edge
54
+
55
+ document.documentElement.style.zoom = 1;
56
+ document.documentElement.style.zoom = null;
57
+ }
58
+ }); // remove the encoded attribute from all nodes that no longer match them
59
+
60
+ item.nodes.forEach(function (node) {
61
+ if (nodes.indexOf(node) === -1) {
62
+ node.removeAttribute(item.attributeName); // trigger a style refresh in IE and Edge
63
+
64
+ document.documentElement.style.zoom = 1;
65
+ document.documentElement.style.zoom = null;
66
+ }
67
+ }); // update the
68
+
69
+ item.nodes = nodes;
70
+ });
71
+ });
72
+ } // remove any observed cssrules that no longer apply
73
+
74
+
75
+ function cleanupObservedCssRules() {
76
+ [].push.apply(observedItems, observedItems.splice(0).filter(function (item) {
77
+ return item.rule.parentStyleSheet && item.rule.parentStyleSheet.ownerNode && document.documentElement.contains(item.rule.parentStyleSheet.ownerNode);
78
+ }));
79
+ } // walk a stylesheet to collect observed css rules
80
+
81
+
82
+ function walkStyleSheet(styleSheet) {
83
+ try {
84
+ // walk a css rule to collect observed css rules
85
+ [].forEach.call(styleSheet.cssRules || [], function (rule) {
86
+ if (rule.selectorText) {
87
+ // decode the selector text in all browsers to:
88
+ // [1] = :scope, [2] = :not(:has), [3] = :has relative, [4] = :scope relative
89
+ var selectors = decodeURIComponent(rule.selectorText.replace(/\\(.)/g, '$1')).match(/^(.*?)\[:(not-)?has\((.+?)\)\](.*?)$/);
90
+
91
+ if (selectors) {
92
+ var attributeName = ':' + (selectors[2] ? 'not-' : '') + 'has(' + // encode a :has() pseudo selector as an attribute name
93
+ encodeURIComponent(selectors[3]).replace(/%3A/g, ':').replace(/%5B/g, '[').replace(/%5D/g, ']').replace(/%2C/g, ',') + ')';
94
+ observedItems.push({
95
+ rule: rule,
96
+ scopeSelector: selectors[1],
97
+ isNot: selectors[2],
98
+ relativeSelectors: selectors[3].split(/\s*,\s*/),
99
+ attributeName: attributeName,
100
+ nodes: []
101
+ });
102
+ }
103
+ } else {
104
+ walkStyleSheet(rule);
105
+ }
106
+ });
107
+ } catch (error) {
108
+ /* do nothing and continue */
109
+ }
110
+ }
111
+ }
112
+
113
+ /* global self */
114
+ self.cssHasPseudo = cssHasPseudo;
115
+
116
+ })();
117
+ //# sourceMappingURL=browser-global.js.map
@@ -0,0 +1,117 @@
1
+ (function () {
2
+
3
+ /* global MutationObserver,requestAnimationFrame */
4
+ function cssHasPseudo(document) {
5
+ var observedItems = []; // document.createAttribute() doesn't support `:` in the name. innerHTML does
6
+
7
+ var attributeElement = document.createElement('x'); // walk all stylesheets to collect observed css rules
8
+
9
+ [].forEach.call(document.styleSheets, walkStyleSheet);
10
+ transformObservedItems(); // observe DOM modifications that affect selectors
11
+
12
+ var mutationObserver = new MutationObserver(function (mutationsList) {
13
+ mutationsList.forEach(function (mutation) {
14
+ [].forEach.call(mutation.addedNodes || [], function (node) {
15
+ // walk stylesheets to collect observed css rules
16
+ if (node.nodeType === 1 && node.sheet) {
17
+ walkStyleSheet(node.sheet);
18
+ }
19
+ }); // transform observed css rules
20
+
21
+ cleanupObservedCssRules();
22
+ transformObservedItems();
23
+ });
24
+ });
25
+ mutationObserver.observe(document, {
26
+ childList: true,
27
+ subtree: true
28
+ }); // observe DOM events that affect pseudo-selectors
29
+
30
+ document.addEventListener('focus', transformObservedItems, true);
31
+ document.addEventListener('blur', transformObservedItems, true);
32
+ document.addEventListener('input', transformObservedItems); // transform observed css rules
33
+
34
+ function transformObservedItems() {
35
+ requestAnimationFrame(function () {
36
+ observedItems.forEach(function (item) {
37
+ var nodes = [];
38
+ [].forEach.call(document.querySelectorAll(item.scopeSelector), function (element) {
39
+ var nthChild = [].indexOf.call(element.parentNode.children, element) + 1;
40
+ var relativeSelectors = item.relativeSelectors.map(function (relativeSelector) {
41
+ return item.scopeSelector + ':nth-child(' + nthChild + ') ' + relativeSelector;
42
+ }).join(); // find any relative :has element from the :scope element
43
+
44
+ var relativeElement = element.parentNode.querySelector(relativeSelectors);
45
+ var shouldElementMatch = item.isNot ? !relativeElement : relativeElement;
46
+
47
+ if (shouldElementMatch) {
48
+ // memorize the node
49
+ nodes.push(element); // set an attribute with an irregular attribute name
50
+ // document.createAttribute() doesn't support special characters
51
+
52
+ attributeElement.innerHTML = '<x ' + item.attributeName + '>';
53
+ element.setAttributeNode(attributeElement.children[0].attributes[0].cloneNode()); // trigger a style refresh in IE and Edge
54
+
55
+ document.documentElement.style.zoom = 1;
56
+ document.documentElement.style.zoom = null;
57
+ }
58
+ }); // remove the encoded attribute from all nodes that no longer match them
59
+
60
+ item.nodes.forEach(function (node) {
61
+ if (nodes.indexOf(node) === -1) {
62
+ node.removeAttribute(item.attributeName); // trigger a style refresh in IE and Edge
63
+
64
+ document.documentElement.style.zoom = 1;
65
+ document.documentElement.style.zoom = null;
66
+ }
67
+ }); // update the
68
+
69
+ item.nodes = nodes;
70
+ });
71
+ });
72
+ } // remove any observed cssrules that no longer apply
73
+
74
+
75
+ function cleanupObservedCssRules() {
76
+ [].push.apply(observedItems, observedItems.splice(0).filter(function (item) {
77
+ return item.rule.parentStyleSheet && item.rule.parentStyleSheet.ownerNode && document.documentElement.contains(item.rule.parentStyleSheet.ownerNode);
78
+ }));
79
+ } // walk a stylesheet to collect observed css rules
80
+
81
+
82
+ function walkStyleSheet(styleSheet) {
83
+ try {
84
+ // walk a css rule to collect observed css rules
85
+ [].forEach.call(styleSheet.cssRules || [], function (rule) {
86
+ if (rule.selectorText) {
87
+ // decode the selector text in all browsers to:
88
+ // [1] = :scope, [2] = :not(:has), [3] = :has relative, [4] = :scope relative
89
+ var selectors = decodeURIComponent(rule.selectorText.replace(/\\(.)/g, '$1')).match(/^(.*?)\[:(not-)?has\((.+?)\)\](.*?)$/);
90
+
91
+ if (selectors) {
92
+ var attributeName = ':' + (selectors[2] ? 'not-' : '') + 'has(' + // encode a :has() pseudo selector as an attribute name
93
+ encodeURIComponent(selectors[3]).replace(/%3A/g, ':').replace(/%5B/g, '[').replace(/%5D/g, ']').replace(/%2C/g, ',') + ')';
94
+ observedItems.push({
95
+ rule: rule,
96
+ scopeSelector: selectors[1],
97
+ isNot: selectors[2],
98
+ relativeSelectors: selectors[3].split(/\s*,\s*/),
99
+ attributeName: attributeName,
100
+ nodes: []
101
+ });
102
+ }
103
+ } else {
104
+ walkStyleSheet(rule);
105
+ }
106
+ });
107
+ } catch (error) {
108
+ /* do nothing and continue */
109
+ }
110
+ }
111
+ }
112
+
113
+ /* global self */
114
+ self.cssHasPseudo = cssHasPseudo;
115
+
116
+ })();
117
+ //# sourceMappingURL=browser-global.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"browser-global.js","sources":["../src/browser.js","../src/browser-global.js"],"sourcesContent":["/* global MutationObserver,requestAnimationFrame */\nexport default function cssHasPseudo(document) {\n\tconst observedItems = [];\n\n\t// document.createAttribute() doesn't support `:` in the name. innerHTML does\n\tconst attributeElement = document.createElement('x');\n\n\t// walk all stylesheets to collect observed css rules\n\t[].forEach.call(document.styleSheets, walkStyleSheet);\n\ttransformObservedItems();\n\n\t// observe DOM modifications that affect selectors\n\tconst mutationObserver = new MutationObserver(mutationsList => {\n\t\tmutationsList.forEach(mutation => {\n\t\t\t[].forEach.call(mutation.addedNodes || [], node => {\n\t\t\t\t// walk stylesheets to collect observed css rules\n\t\t\t\tif (node.nodeType === 1 && node.sheet) {\n\t\t\t\t\twalkStyleSheet(node.sheet);\n\t\t\t\t}\n\t\t\t});\n\n\t\t\t// transform observed css rules\n\t\t\tcleanupObservedCssRules();\n\t\t\ttransformObservedItems();\n\t\t});\n\t});\n\n\tmutationObserver.observe(document, { childList: true, subtree: true });\n\n\t// observe DOM events that affect pseudo-selectors\n\tdocument.addEventListener('focus', transformObservedItems, true);\n\tdocument.addEventListener('blur', transformObservedItems, true);\n\tdocument.addEventListener('input', transformObservedItems);\n\n\t// transform observed css rules\n\tfunction transformObservedItems () {\n\t\trequestAnimationFrame(() => {\n\t\t\tobservedItems.forEach(\n\t\t\t\titem => {\n\t\t\t\t\tconst nodes = [];\n\n\t\t\t\t\t[].forEach.call(\n\t\t\t\t\t\tdocument.querySelectorAll(item.scopeSelector),\n\t\t\t\t\t\telement => {\n\t\t\t\t\t\t\tconst nthChild = [].indexOf.call(element.parentNode.children, element) + 1;\n\t\t\t\t\t\t\tconst relativeSelectors = item.relativeSelectors.map(\n\t\t\t\t\t\t\t\trelativeSelector => item.scopeSelector + ':nth-child(' + nthChild + ') ' + relativeSelector,\n\t\t\t\t\t\t\t).join();\n\n\t\t\t\t\t\t\t// find any relative :has element from the :scope element\n\t\t\t\t\t\t\tconst relativeElement = element.parentNode.querySelector(relativeSelectors);\n\n\t\t\t\t\t\t\tconst shouldElementMatch = item.isNot ? !relativeElement : relativeElement;\n\n\t\t\t\t\t\t\tif (shouldElementMatch) {\n\t\t\t\t\t\t\t\t// memorize the node\n\t\t\t\t\t\t\t\tnodes.push(element);\n\n\t\t\t\t\t\t\t\t// set an attribute with an irregular attribute name\n\t\t\t\t\t\t\t\t// document.createAttribute() doesn't support special characters\n\t\t\t\t\t\t\t\tattributeElement.innerHTML = '<x ' + item.attributeName + '>';\n\n\t\t\t\t\t\t\t\telement.setAttributeNode(attributeElement.children[0].attributes[0].cloneNode());\n\n\t\t\t\t\t\t\t\t// trigger a style refresh in IE and Edge\n\t\t\t\t\t\t\t\tdocument.documentElement.style.zoom = 1; document.documentElement.style.zoom = null;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t},\n\t\t\t\t\t);\n\n\t\t\t\t\t// remove the encoded attribute from all nodes that no longer match them\n\t\t\t\t\titem.nodes.forEach(node => {\n\t\t\t\t\t\tif (nodes.indexOf(node) === -1) {\n\t\t\t\t\t\t\tnode.removeAttribute(item.attributeName);\n\n\t\t\t\t\t\t\t// trigger a style refresh in IE and Edge\n\t\t\t\t\t\t\tdocument.documentElement.style.zoom = 1; document.documentElement.style.zoom = null;\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\n\t\t\t\t\t// update the\n\t\t\t\t\titem.nodes = nodes;\n\t\t\t\t},\n\t\t\t);\n\t\t});\n\t}\n\n\t// remove any observed cssrules that no longer apply\n\tfunction cleanupObservedCssRules () {\n\t\t[].push.apply(\n\t\t\tobservedItems,\n\t\t\tobservedItems.splice(0).filter(\n\t\t\t\titem => item.rule.parentStyleSheet &&\n\t\t\t\t\titem.rule.parentStyleSheet.ownerNode &&\n\t\t\t\t\tdocument.documentElement.contains(item.rule.parentStyleSheet.ownerNode),\n\t\t\t),\n\t\t);\n\t}\n\n\t// walk a stylesheet to collect observed css rules\n\tfunction walkStyleSheet (styleSheet) {\n\t\ttry {\n\t\t\t// walk a css rule to collect observed css rules\n\t\t\t[].forEach.call(styleSheet.cssRules || [], rule => {\n\t\t\t\tif (rule.selectorText) {\n\t\t\t\t\t// decode the selector text in all browsers to:\n\t\t\t\t\t// [1] = :scope, [2] = :not(:has), [3] = :has relative, [4] = :scope relative\n\t\t\t\t\tconst selectors = decodeURIComponent(rule.selectorText.replace(/\\\\(.)/g, '$1')).match(/^(.*?)\\[:(not-)?has\\((.+?)\\)\\](.*?)$/);\n\n\t\t\t\t\tif (selectors) {\n\t\t\t\t\t\tconst attributeName = ':' + (selectors[2] ? 'not-' : '') + 'has(' +\n\t\t\t\t\t\t\t// encode a :has() pseudo selector as an attribute name\n\t\t\t\t\t\t\tencodeURIComponent(selectors[3]).replace(/%3A/g, ':').replace(/%5B/g, '[').replace(/%5D/g, ']').replace(/%2C/g, ',') +\n\t\t\t\t\t\t')';\n\n\t\t\t\t\t\tobservedItems.push({\n\t\t\t\t\t\t\trule,\n\t\t\t\t\t\t\tscopeSelector: selectors[1],\n\t\t\t\t\t\t\tisNot: selectors[2],\n\t\t\t\t\t\t\trelativeSelectors: selectors[3].split(/\\s*,\\s*/),\n\t\t\t\t\t\t\tattributeName,\n\t\t\t\t\t\t\tnodes: [],\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\twalkStyleSheet(rule);\n\t\t\t\t}\n\t\t\t});\n\t\t} catch (error) {\n\t\t\t/* do nothing and continue */\n\t\t}\n\t}\n}\n","/* global self */\nimport { default as cssHasPseudo } from './browser';\nself.cssHasPseudo = cssHasPseudo;\n"],"names":["cssHasPseudo","document","observedItems","attributeElement","createElement","forEach","call","styleSheets","walkStyleSheet","transformObservedItems","mutationObserver","MutationObserver","mutationsList","mutation","addedNodes","node","nodeType","sheet","cleanupObservedCssRules","observe","childList","subtree","addEventListener","requestAnimationFrame","item","nodes","querySelectorAll","scopeSelector","element","nthChild","indexOf","parentNode","children","relativeSelectors","map","relativeSelector","join","relativeElement","querySelector","shouldElementMatch","isNot","push","innerHTML","attributeName","setAttributeNode","attributes","cloneNode","documentElement","style","zoom","removeAttribute","apply","splice","filter","rule","parentStyleSheet","ownerNode","contains","styleSheet","cssRules","selectorText","selectors","decodeURIComponent","replace","match","encodeURIComponent","split","error","self"],"mappings":";;CAAA;CACe,SAASA,YAAT,CAAsBC,QAAtB,EAAgC;CAC9C,MAAMC,aAAa,GAAG,EAAtB,CAD8C;;CAI9C,MAAMC,gBAAgB,GAAGF,QAAQ,CAACG,aAAT,CAAuB,GAAvB,CAAzB,CAJ8C;;CAO9C,KAAGC,OAAH,CAAWC,IAAX,CAAgBL,QAAQ,CAACM,WAAzB,EAAsCC,cAAtC;CACAC,EAAAA,sBAAsB,GARwB;;CAW9C,MAAMC,gBAAgB,GAAG,IAAIC,gBAAJ,CAAqB,UAAAC,aAAa,EAAI;CAC9DA,IAAAA,aAAa,CAACP,OAAd,CAAsB,UAAAQ,QAAQ,EAAI;CACjC,SAAGR,OAAH,CAAWC,IAAX,CAAgBO,QAAQ,CAACC,UAAT,IAAuB,EAAvC,EAA2C,UAAAC,IAAI,EAAI;CAClD;CACA,YAAIA,IAAI,CAACC,QAAL,KAAkB,CAAlB,IAAuBD,IAAI,CAACE,KAAhC,EAAuC;CACtCT,UAAAA,cAAc,CAACO,IAAI,CAACE,KAAN,CAAd;CACA;CACD,OALD,EADiC;;CASjCC,MAAAA,uBAAuB;CACvBT,MAAAA,sBAAsB;CACtB,KAXD;CAYA,GAbwB,CAAzB;CAeAC,EAAAA,gBAAgB,CAACS,OAAjB,CAAyBlB,QAAzB,EAAmC;CAAEmB,IAAAA,SAAS,EAAE,IAAb;CAAmBC,IAAAA,OAAO,EAAE;CAA5B,GAAnC,EA1B8C;;CA6B9CpB,EAAAA,QAAQ,CAACqB,gBAAT,CAA0B,OAA1B,EAAmCb,sBAAnC,EAA2D,IAA3D;CACAR,EAAAA,QAAQ,CAACqB,gBAAT,CAA0B,MAA1B,EAAkCb,sBAAlC,EAA0D,IAA1D;CACAR,EAAAA,QAAQ,CAACqB,gBAAT,CAA0B,OAA1B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MC,SAAS,GAAGC,kBAAkB,CAACR,IAAI,CAACM,YAAL,CAAkBG,OAAlB,CAA0B,QAA1B,EAAoC,IAApC,CAAD,CAAlB,CAA8DC,KAA9D,CAAoE,sCAApE,CAAlB;;CAEA,cAAIH,SAAJ,EAAe;CACd,gBAAMlB,aAAa,GAAG,OAAOkB,SAAS,CAAC,CAAD,CAAT,GAAe,MAAf,GAAwB,EAA/B,IAAqC,MAArC;CAErBI,YAAAA,kBAAkB,CAACJ,SAAS,CAAC,CAAD,CAAV,CAAlB,CAAiCE,OAAjC,CAAyC,MAAzC,EAAiD,GAAjD,EAAsDA,OAAtD,CAA8D,MAA9D,EAAsE,GAAtE,EAA2EA,OAA3E,CAAmF,MAAnF,EAA2F,GAA3F,EAAgGA,OAAhG,CAAwG,MAAxG,EAAgH,GAAhH,CAFqB,GAGtB,GAHA;CAKA7D,YAAAA,aAAa,CAACuC,IAAd,CAAmB;CAClBa,cAAAA,IAAI,EAAJA,IADkB;CAElB3B,cAAAA,aAAa,EAAEkC,SAAS,CAAC,CAAD,CAFN;CAGlBrB,cAAAA,KAAK,EAAEqB,SAAS,CAAC,CAAD,CAHE;CAIlB5B,cAAAA,iBAAiB,EAAE4B,SAAS,CAAC,CAAD,CAAT,CAAaK,KAAb,CAAmB,SAAnB,CAJD;CAKlBvB,cAAAA,aAAa,EAAbA,aALkB;CAMlBlB,cAAAA,KAAK,EAAE;CANW,aAAnB;CAQA;CACD,SApBD,MAoBO;CACNjB,UAAAA,cAAc,CAAC8C,IAAD,CAAd;CACA;CACD,OAxBD;CAyBA,KA3BD,CA2BE,OAAOa,KAAP,EAAc;CACf;CACA;CACD;CACD;;CCpID;CAEAC,IAAI,CAACpE,YAAL,GAAoBA,YAApB;;;;;;"}
@@ -1,16 +1,15 @@
1
- 'use strict';
2
-
1
+ /* global MutationObserver,requestAnimationFrame */
3
2
  function cssHasPseudo(document) {
4
- const observedItems = []; // document.createAttribute() doesn't support `:` in the name. innerHTML does
3
+ var observedItems = []; // document.createAttribute() doesn't support `:` in the name. innerHTML does
5
4
 
6
- const attributeElement = document.createElement('x'); // walk all stylesheets to collect observed css rules
5
+ var attributeElement = document.createElement('x'); // walk all stylesheets to collect observed css rules
7
6
 
8
7
  [].forEach.call(document.styleSheets, walkStyleSheet);
9
8
  transformObservedItems(); // observe DOM modifications that affect selectors
10
9
 
11
- const mutationObserver = new MutationObserver(mutationsList => {
12
- mutationsList.forEach(mutation => {
13
- [].forEach.call(mutation.addedNodes || [], node => {
10
+ var mutationObserver = new MutationObserver(function (mutationsList) {
11
+ mutationsList.forEach(function (mutation) {
12
+ [].forEach.call(mutation.addedNodes || [], function (node) {
14
13
  // walk stylesheets to collect observed css rules
15
14
  if (node.nodeType === 1 && node.sheet) {
16
15
  walkStyleSheet(node.sheet);
@@ -31,15 +30,17 @@ function cssHasPseudo(document) {
31
30
  document.addEventListener('input', transformObservedItems); // transform observed css rules
32
31
 
33
32
  function transformObservedItems() {
34
- requestAnimationFrame(() => {
35
- observedItems.forEach(item => {
36
- const nodes = [];
37
- [].forEach.call(document.querySelectorAll(item.scopeSelector), element => {
38
- const nthChild = [].indexOf.call(element.parentNode.children, element) + 1;
39
- const relativeSelectors = item.relativeSelectors.map(relativeSelector => item.scopeSelector + ':nth-child(' + nthChild + ') ' + relativeSelector).join(); // find any relative :has element from the :scope element
40
-
41
- const relativeElement = element.parentNode.querySelector(relativeSelectors);
42
- const shouldElementMatch = item.isNot ? !relativeElement : relativeElement;
33
+ requestAnimationFrame(function () {
34
+ observedItems.forEach(function (item) {
35
+ var nodes = [];
36
+ [].forEach.call(document.querySelectorAll(item.scopeSelector), function (element) {
37
+ var nthChild = [].indexOf.call(element.parentNode.children, element) + 1;
38
+ var relativeSelectors = item.relativeSelectors.map(function (relativeSelector) {
39
+ return item.scopeSelector + ':nth-child(' + nthChild + ') ' + relativeSelector;
40
+ }).join(); // find any relative :has element from the :scope element
41
+
42
+ var relativeElement = element.parentNode.querySelector(relativeSelectors);
43
+ var shouldElementMatch = item.isNot ? !relativeElement : relativeElement;
43
44
 
44
45
  if (shouldElementMatch) {
45
46
  // memorize the node
@@ -54,7 +55,7 @@ function cssHasPseudo(document) {
54
55
  }
55
56
  }); // remove the encoded attribute from all nodes that no longer match them
56
57
 
57
- item.nodes.forEach(node => {
58
+ item.nodes.forEach(function (node) {
58
59
  if (nodes.indexOf(node) === -1) {
59
60
  node.removeAttribute(item.attributeName); // trigger a style refresh in IE and Edge
60
61
 
@@ -70,28 +71,30 @@ function cssHasPseudo(document) {
70
71
 
71
72
 
72
73
  function cleanupObservedCssRules() {
73
- [].push.apply(observedItems, observedItems.splice(0).filter(item => item.rule.parentStyleSheet && item.rule.parentStyleSheet.ownerNode && document.documentElement.contains(item.rule.parentStyleSheet.ownerNode)));
74
+ [].push.apply(observedItems, observedItems.splice(0).filter(function (item) {
75
+ return item.rule.parentStyleSheet && item.rule.parentStyleSheet.ownerNode && document.documentElement.contains(item.rule.parentStyleSheet.ownerNode);
76
+ }));
74
77
  } // walk a stylesheet to collect observed css rules
75
78
 
76
79
 
77
80
  function walkStyleSheet(styleSheet) {
78
81
  try {
79
82
  // walk a css rule to collect observed css rules
80
- [].forEach.call(styleSheet.cssRules || [], rule => {
83
+ [].forEach.call(styleSheet.cssRules || [], function (rule) {
81
84
  if (rule.selectorText) {
82
85
  // decode the selector text in all browsers to:
83
86
  // [1] = :scope, [2] = :not(:has), [3] = :has relative, [4] = :scope relative
84
- const selectors = decodeURIComponent(rule.selectorText.replace(/\\(.)/g, '$1')).match(/^(.*?)\[:(not-)?has\((.+?)\)\](.*?)$/);
87
+ var selectors = decodeURIComponent(rule.selectorText.replace(/\\(.)/g, '$1')).match(/^(.*?)\[:(not-)?has\((.+?)\)\](.*?)$/);
85
88
 
86
89
  if (selectors) {
87
- const attributeName = ':' + (selectors[2] ? 'not-' : '') + 'has(' + // encode a :has() pseudo selector as an attribute name
90
+ var attributeName = ':' + (selectors[2] ? 'not-' : '') + 'has(' + // encode a :has() pseudo selector as an attribute name
88
91
  encodeURIComponent(selectors[3]).replace(/%3A/g, ':').replace(/%5B/g, '[').replace(/%5D/g, ']').replace(/%2C/g, ',') + ')';
89
92
  observedItems.push({
90
- rule,
93
+ rule: rule,
91
94
  scopeSelector: selectors[1],
92
95
  isNot: selectors[2],
93
96
  relativeSelectors: selectors[3].split(/\s*,\s*/),
94
- attributeName,
97
+ attributeName: attributeName,
95
98
  nodes: []
96
99
  });
97
100
  }
@@ -106,4 +109,4 @@ function cssHasPseudo(document) {
106
109
  }
107
110
 
108
111
  module.exports = cssHasPseudo;
109
- //# sourceMappingURL=index.js.map
112
+ //# sourceMappingURL=browser.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"browser.cjs","sources":["../src/browser.js"],"sourcesContent":["/* global MutationObserver,requestAnimationFrame */\nexport default function cssHasPseudo(document) {\n\tconst observedItems = [];\n\n\t// document.createAttribute() doesn't support `:` in the name. innerHTML does\n\tconst attributeElement = document.createElement('x');\n\n\t// walk all stylesheets to collect observed css rules\n\t[].forEach.call(document.styleSheets, walkStyleSheet);\n\ttransformObservedItems();\n\n\t// observe DOM modifications that affect selectors\n\tconst mutationObserver = new MutationObserver(mutationsList => {\n\t\tmutationsList.forEach(mutation => {\n\t\t\t[].forEach.call(mutation.addedNodes || [], node => {\n\t\t\t\t// walk stylesheets to collect observed css rules\n\t\t\t\tif (node.nodeType === 1 && node.sheet) {\n\t\t\t\t\twalkStyleSheet(node.sheet);\n\t\t\t\t}\n\t\t\t});\n\n\t\t\t// transform observed css rules\n\t\t\tcleanupObservedCssRules();\n\t\t\ttransformObservedItems();\n\t\t});\n\t});\n\n\tmutationObserver.observe(document, { childList: true, subtree: true });\n\n\t// observe DOM events that affect pseudo-selectors\n\tdocument.addEventListener('focus', transformObservedItems, true);\n\tdocument.addEventListener('blur', transformObservedItems, true);\n\tdocument.addEventListener('input', transformObservedItems);\n\n\t// transform observed css rules\n\tfunction transformObservedItems () {\n\t\trequestAnimationFrame(() => {\n\t\t\tobservedItems.forEach(\n\t\t\t\titem => {\n\t\t\t\t\tconst nodes = [];\n\n\t\t\t\t\t[].forEach.call(\n\t\t\t\t\t\tdocument.querySelectorAll(item.scopeSelector),\n\t\t\t\t\t\telement => {\n\t\t\t\t\t\t\tconst nthChild = [].indexOf.call(element.parentNode.children, element) + 1;\n\t\t\t\t\t\t\tconst relativeSelectors = item.relativeSelectors.map(\n\t\t\t\t\t\t\t\trelativeSelector => item.scopeSelector + ':nth-child(' + nthChild + ') ' + relativeSelector,\n\t\t\t\t\t\t\t).join();\n\n\t\t\t\t\t\t\t// find any relative :has element from the :scope element\n\t\t\t\t\t\t\tconst relativeElement = element.parentNode.querySelector(relativeSelectors);\n\n\t\t\t\t\t\t\tconst shouldElementMatch = item.isNot ? !relativeElement : relativeElement;\n\n\t\t\t\t\t\t\tif (shouldElementMatch) {\n\t\t\t\t\t\t\t\t// memorize the node\n\t\t\t\t\t\t\t\tnodes.push(element);\n\n\t\t\t\t\t\t\t\t// set an attribute with an irregular attribute name\n\t\t\t\t\t\t\t\t// document.createAttribute() doesn't support special characters\n\t\t\t\t\t\t\t\tattributeElement.innerHTML = '<x ' + item.attributeName + '>';\n\n\t\t\t\t\t\t\t\telement.setAttributeNode(attributeElement.children[0].attributes[0].cloneNode());\n\n\t\t\t\t\t\t\t\t// trigger a style refresh in IE and Edge\n\t\t\t\t\t\t\t\tdocument.documentElement.style.zoom = 1; document.documentElement.style.zoom = null;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t},\n\t\t\t\t\t);\n\n\t\t\t\t\t// remove the encoded attribute from all nodes that no longer match them\n\t\t\t\t\titem.nodes.forEach(node => {\n\t\t\t\t\t\tif (nodes.indexOf(node) === -1) {\n\t\t\t\t\t\t\tnode.removeAttribute(item.attributeName);\n\n\t\t\t\t\t\t\t// trigger a style refresh in IE and Edge\n\t\t\t\t\t\t\tdocument.documentElement.style.zoom = 1; document.documentElement.style.zoom = null;\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\n\t\t\t\t\t// update the\n\t\t\t\t\titem.nodes = nodes;\n\t\t\t\t},\n\t\t\t);\n\t\t});\n\t}\n\n\t// remove any observed cssrules that no longer apply\n\tfunction cleanupObservedCssRules () {\n\t\t[].push.apply(\n\t\t\tobservedItems,\n\t\t\tobservedItems.splice(0).filter(\n\t\t\t\titem => item.rule.parentStyleSheet &&\n\t\t\t\t\titem.rule.parentStyleSheet.ownerNode &&\n\t\t\t\t\tdocument.documentElement.contains(item.rule.parentStyleSheet.ownerNode),\n\t\t\t),\n\t\t);\n\t}\n\n\t// walk a stylesheet to collect observed css rules\n\tfunction walkStyleSheet (styleSheet) {\n\t\ttry {\n\t\t\t// walk a css rule to collect observed css rules\n\t\t\t[].forEach.call(styleSheet.cssRules || [], rule => {\n\t\t\t\tif (rule.selectorText) {\n\t\t\t\t\t// decode the selector text in all browsers to:\n\t\t\t\t\t// [1] = :scope, [2] = :not(:has), [3] = :has relative, [4] = :scope relative\n\t\t\t\t\tconst selectors = decodeURIComponent(rule.selectorText.replace(/\\\\(.)/g, '$1')).match(/^(.*?)\\[:(not-)?has\\((.+?)\\)\\](.*?)$/);\n\n\t\t\t\t\tif (selectors) {\n\t\t\t\t\t\tconst attributeName = ':' + (selectors[2] ? 'not-' : '') + 'has(' +\n\t\t\t\t\t\t\t// encode a :has() pseudo selector as an attribute name\n\t\t\t\t\t\t\tencodeURIComponent(selectors[3]).replace(/%3A/g, ':').replace(/%5B/g, '[').replace(/%5D/g, ']').replace(/%2C/g, ',') +\n\t\t\t\t\t\t')';\n\n\t\t\t\t\t\tobservedItems.push({\n\t\t\t\t\t\t\trule,\n\t\t\t\t\t\t\tscopeSelector: selectors[1],\n\t\t\t\t\t\t\tisNot: selectors[2],\n\t\t\t\t\t\t\trelativeSelectors: selectors[3].split(/\\s*,\\s*/),\n\t\t\t\t\t\t\tattributeName,\n\t\t\t\t\t\t\tnodes: [],\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\twalkStyleSheet(rule);\n\t\t\t\t}\n\t\t\t});\n\t\t} catch (error) {\n\t\t\t/* do nothing and continue */\n\t\t}\n\t}\n}\n"],"names":["cssHasPseudo","document","observedItems","attributeElement","createElement","forEach","call","styleSheets","walkStyleSheet","transformObservedItems","mutationObserver","MutationObserver","mutationsList","mutation","addedNodes","node","nodeType","sheet","cleanupObservedCssRules","observe","childList","subtree","addEventListener","requestAnimationFrame","item","nodes","querySelectorAll","scopeSelector","element","nthChild","indexOf","parentNode","children","relativeSelectors","map","relativeSelector","join","relativeElement","querySelector","shouldElementMatch","isNot","push","innerHTML","attributeName","setAttributeNode","attributes","cloneNode","documentElement","style","zoom","removeAttribute","apply","splice","filter","rule","parentStyleSheet","ownerNode","contains","styleSheet","cssRules","selectorText","selectors","decodeURIComponent","replace","match","encodeURIComponent","split","error"],"mappings":"AAAA;AACe,SAASA,YAAT,CAAsBC,QAAtB,EAAgC;AAC9C,MAAMC,aAAa,GAAG,EAAtB,CAD8C;;AAI9C,MAAMC,gBAAgB,GAAGF,QAAQ,CAACG,aAAT,CAAuB,GAAvB,CAAzB,CAJ8C;;AAO9C,KAAGC,OAAH,CAAWC,IAAX,CAAgBL,QAAQ,CAACM,WAAzB,EAAsCC,cAAtC;AACAC,EAAAA,sBAAsB,GARwB;;AAW9C,MAAMC,gBAAgB,GAAG,IAAIC,gBAAJ,CAAqB,UAAAC,aAAa,EAAI;AAC9DA,IAAAA,aAAa,CAACP,OAAd,CAAsB,UAAAQ,QAAQ,EAAI;AACjC,SAAGR,OAAH,CAAWC,IAAX,CAAgBO,QAAQ,CAACC,UAAT,IAAuB,EAAvC,EAA2C,UAAAC,IAAI,EAAI;AAClD;AACA,YAAIA,IAAI,CAACC,QAAL,KAAkB,CAAlB,IAAuBD,IAAI,CAACE,KAAhC,EAAuC;AACtCT,UAAAA,cAAc,CAACO,IAAI,CAACE,KAAN,CAAd;AACA;AACD,OALD,EADiC;;AASjCC,MAAAA,uBAAuB;AACvBT,MAAAA,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