css-has-pseudo 0.9.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 CHANGED
@@ -1,5 +1,50 @@
1
1
  # Changes to CSS Has Pseudo
2
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
+
3
48
  ### 0.9.0 (November 26, 2018)
4
49
 
5
50
  - Improved CLI usage
package/README.md CHANGED
@@ -1,12 +1,13 @@
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,
8
7
  following the [Selectors Level 4] specification.
9
8
 
9
+ [!['Can I use' table](https://caniuse.bitsofco.de/image/css-has.png)](https://caniuse.com/#feat=css-has)
10
+
10
11
  ```css
11
12
  a:has(> img) {
12
13
  /* style links that contain an image */
@@ -30,21 +31,29 @@ body:has(:focus) {
30
31
  From the command line, transform CSS files that use `:has` selectors:
31
32
 
32
33
  ```bash
33
- npx css-has-pseudo SOURCE.css TRANSFORMED.css
34
+ npx css-has-pseudo SOURCE.css --output TRANSFORMED.css
34
35
  ```
35
36
 
36
37
  Next, use your transformed CSS with this script:
37
38
 
38
39
  ```html
39
40
  <link rel="stylesheet" href="TRANSFORMED.css">
40
- <script src="https://unpkg.com/css-has-pseudo/browser"></script>
41
+ <script src="https://unpkg.com/css-has-pseudo/dist/browser-global.js"></script>
41
42
  <script>cssHasPseudo(document)</script>
42
43
  ```
43
44
 
44
- That’s it. The script is 768 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
45
52
  Internet Explorer 11. With a [Mutation Observer polyfill], the script will work
46
53
  down to Internet Explorer 9.
47
54
 
55
+ See [README BROWSER](README-BROWSER.md) for more information.
56
+
48
57
  ## How it works
49
58
 
50
59
  The [PostCSS plugin](README-POSTCSS.md) clones rules containing `:has`,
@@ -87,13 +96,11 @@ elements otherwise matching `:has` natively.
87
96
  </body>
88
97
  ```
89
98
 
90
- [cli-img]: https://img.shields.io/travis/csstools/css-has-pseudo/master.svg
91
- [cli-url]: https://travis-ci.org/csstools/css-has-pseudo
92
99
  [git-img]: https://img.shields.io/badge/support-chat-blue.svg
93
100
  [git-url]: https://gitter.im/postcss/postcss
94
101
  [npm-img]: https://img.shields.io/npm/v/css-has-pseudo.svg
95
102
  [npm-url]: https://www.npmjs.com/package/css-has-pseudo
96
103
 
97
- [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
98
105
  [Mutation Observer polyfill]: https://github.com/webmodules/mutation-observer
99
106
  [Selectors Level 4]: https://drafts.csswg.org/selectors-4/#has-pseudo
package/browser.js CHANGED
@@ -1 +1,117 @@
1
- function cssHasPseudo(n){var t=[],r=n.createElement("x");function e(){requestAnimationFrame(function(){t.forEach(function(t){var e=[];Array.prototype.forEach.call(n.querySelectorAll(t.n),function(o){var u=Array.prototype.indexOf.call(o.parentNode.children,o)+1,i=t.t.map(function(n){return t.n+":nth-child("+u+") "+n}).join(),c=o.parentNode.querySelector(i);(t.r?!c:c)&&(e.push(o),r.innerHTML="<x "+t.e+">",o.setAttributeNode(r.children[0].attributes[0].cloneNode()),n.documentElement.style.zoom=1,n.documentElement.style.zoom=null)}),t.o.forEach(function(r){-1===e.indexOf(r)&&(r.removeAttribute(t.e),n.documentElement.style.zoom=1,n.documentElement.style.zoom=null)}),t.o=e})})}function o(n){Array.prototype.forEach.call(n.cssRules||[],function(n){if(n.selectorText){var r=decodeURIComponent(n.selectorText.replace(/\\(.)/g,"$1")).match(/^(.*?)\[:(not-)?has\((.+?)\)\](.*?)$/);if(r){var e=":"+(r[2]?"not-":"")+"has("+encodeURIComponent(r[3]).replace(/%3A/g,":").replace(/%5B/g,"[").replace(/%5D/g,"]").replace(/%2C/g,",")+")";t.push({u:n,n:r[1],r:r[2],t:r[3].split(/\s*,\s*/),e:e,o:[]})}}else o(n)})}Array.prototype.forEach.call(n.styleSheets,o),e(),new MutationObserver(function(r){r.forEach(function(r){Array.prototype.forEach.call(r.addedNodes||[],function(n){1===n.nodeType&&n.sheet&&o(n.sheet)}),Array.prototype.push.apply(t,t.splice(0).filter(function(t){return t.u.parentStyleSheet&&t.u.parentStyleSheet.ownerNode&&n.documentElement.contains(t.u.parentStyleSheet.ownerNode)})),e()})}).observe(n,{childList:!0,subtree:!0}),n.addEventListener("focus",e,!0),n.addEventListener("blur",e,!0),n.addEventListener("input",e)}
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,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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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;;;;;;"}
@@ -0,0 +1,112 @@
1
+ /* global MutationObserver,requestAnimationFrame */
2
+ function cssHasPseudo(document) {
3
+ var observedItems = []; // document.createAttribute() doesn't support `:` in the name. innerHTML does
4
+
5
+ var attributeElement = document.createElement('x'); // walk all stylesheets to collect observed css rules
6
+
7
+ [].forEach.call(document.styleSheets, walkStyleSheet);
8
+ transformObservedItems(); // observe DOM modifications that affect selectors
9
+
10
+ var mutationObserver = new MutationObserver(function (mutationsList) {
11
+ mutationsList.forEach(function (mutation) {
12
+ [].forEach.call(mutation.addedNodes || [], function (node) {
13
+ // walk stylesheets to collect observed css rules
14
+ if (node.nodeType === 1 && node.sheet) {
15
+ walkStyleSheet(node.sheet);
16
+ }
17
+ }); // transform observed css rules
18
+
19
+ cleanupObservedCssRules();
20
+ transformObservedItems();
21
+ });
22
+ });
23
+ mutationObserver.observe(document, {
24
+ childList: true,
25
+ subtree: true
26
+ }); // observe DOM events that affect pseudo-selectors
27
+
28
+ document.addEventListener('focus', transformObservedItems, true);
29
+ document.addEventListener('blur', transformObservedItems, true);
30
+ document.addEventListener('input', transformObservedItems); // transform observed css rules
31
+
32
+ function transformObservedItems() {
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;
44
+
45
+ if (shouldElementMatch) {
46
+ // memorize the node
47
+ nodes.push(element); // set an attribute with an irregular attribute name
48
+ // document.createAttribute() doesn't support special characters
49
+
50
+ attributeElement.innerHTML = '<x ' + item.attributeName + '>';
51
+ element.setAttributeNode(attributeElement.children[0].attributes[0].cloneNode()); // trigger a style refresh in IE and Edge
52
+
53
+ document.documentElement.style.zoom = 1;
54
+ document.documentElement.style.zoom = null;
55
+ }
56
+ }); // remove the encoded attribute from all nodes that no longer match them
57
+
58
+ item.nodes.forEach(function (node) {
59
+ if (nodes.indexOf(node) === -1) {
60
+ node.removeAttribute(item.attributeName); // trigger a style refresh in IE and Edge
61
+
62
+ document.documentElement.style.zoom = 1;
63
+ document.documentElement.style.zoom = null;
64
+ }
65
+ }); // update the
66
+
67
+ item.nodes = nodes;
68
+ });
69
+ });
70
+ } // remove any observed cssrules that no longer apply
71
+
72
+
73
+ function cleanupObservedCssRules() {
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
+ }));
77
+ } // walk a stylesheet to collect observed css rules
78
+
79
+
80
+ function walkStyleSheet(styleSheet) {
81
+ try {
82
+ // walk a css rule to collect observed css rules
83
+ [].forEach.call(styleSheet.cssRules || [], function (rule) {
84
+ if (rule.selectorText) {
85
+ // decode the selector text in all browsers to:
86
+ // [1] = :scope, [2] = :not(:has), [3] = :has relative, [4] = :scope relative
87
+ var selectors = decodeURIComponent(rule.selectorText.replace(/\\(.)/g, '$1')).match(/^(.*?)\[:(not-)?has\((.+?)\)\](.*?)$/);
88
+
89
+ if (selectors) {
90
+ var attributeName = ':' + (selectors[2] ? 'not-' : '') + 'has(' + // encode a :has() pseudo selector as an attribute name
91
+ encodeURIComponent(selectors[3]).replace(/%3A/g, ':').replace(/%5B/g, '[').replace(/%5D/g, ']').replace(/%2C/g, ',') + ')';
92
+ observedItems.push({
93
+ rule: rule,
94
+ scopeSelector: selectors[1],
95
+ isNot: selectors[2],
96
+ relativeSelectors: selectors[3].split(/\s*,\s*/),
97
+ attributeName: attributeName,
98
+ nodes: []
99
+ });
100
+ }
101
+ } else {
102
+ walkStyleSheet(rule);
103
+ }
104
+ });
105
+ } catch (error) {
106
+ /* do nothing and continue */
107
+ }
108
+ }
109
+ }
110
+
111
+ module.exports = cssHasPseudo;
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,KAA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