css-has-pseudo 5.0.1 → 6.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,24 +1,47 @@
1
1
  # Changes to CSS Has Pseudo
2
2
 
3
- ### 5.0.1 (January 28, 2023)
3
+ ### 6.0.0
4
+
5
+ _July 3, 2023_
6
+
7
+ - Change license to `MIT-0` ([read more about this change in the blog post](https://preset-env.cssdb.org/blog/license-change/))
8
+ - Updated [`@csstools/selector-specificity`](/packages/selector-specificity) to [`3.0.0`](/packages/selector-specificity/CHANGELOG.md#300) (major)
9
+
10
+ ### 5.0.2
11
+
12
+ _February 6, 2023_
13
+
14
+ - Reduce the amount of duplicate fallback CSS.
15
+
16
+ ### 5.0.1
17
+
18
+ _January 28, 2023_
4
19
 
5
20
  - Improve `types` declaration in `package.json`
6
21
 
7
- ### 5.0.0 (January 24, 2023)
22
+ ### 5.0.0
23
+
24
+ _January 24, 2023_
8
25
 
9
26
  - Updated: Support for Node v14+ (major).
10
27
  - Fix: Do not throw when a selector is invalid, show a warning instead.
11
28
  - Fix: make `:has()` unforgiving. `:has(.foo, :some-invalid-selector)` will no longer match elements that have children with `.foo`.
12
29
 
13
- ### 4.0.2 (December 12, 2022)
30
+ ### 4.0.2
31
+
32
+ _December 12, 2022_
14
33
 
15
34
  - Fix: correctly cleanup style rules when a browser has native support. [backported](https://github.com/csstools/postcss-plugins/pull/752)
16
35
 
17
- ### 4.0.1 (August 23, 2022)
36
+ ### 4.0.1
37
+
38
+ _August 23, 2022_
18
39
 
19
40
  - Fix: assign global browser polyfill to `window`, `self` or a blank object.
20
41
 
21
- ### 4.0.0 (July 8, 2022)
42
+ ### 4.0.0
43
+
44
+ _July 8, 2022_
22
45
 
23
46
  [Read the full changelog](https://github.com/csstools/postcss-plugins/wiki/PostCSS-Preset-Env-8)
24
47
 
@@ -46,27 +69,37 @@
46
69
  + <script src="https://unpkg.com/css-has-pseudo/dist/browser-global.js"></script>
47
70
  ```
48
71
 
49
- ### 3.0.4 (February 5, 2022)
72
+ ### 3.0.4
73
+
74
+ _February 5, 2022_
50
75
 
51
76
  - Rebuild of browser polyfills
52
77
 
53
- ### 3.0.3 (January 12, 2022)
78
+ ### 3.0.3
79
+
80
+ _January 12, 2022_
54
81
 
55
82
  - Fix compatibility with PostCSS `v8.2.x` [#147](https://github.com/csstools/postcss-plugins/issues/147)
56
83
 
57
84
  This version is not officially supported but some tool providers pinned PostCSS to `v8.2.x`,
58
85
  making it impossible for end users to have a working setup.
59
86
 
60
- ### 3.0.2 (January 2, 2022)
87
+ ### 3.0.2
88
+
89
+ _January 2, 2022_
61
90
 
62
91
  - Removed Sourcemaps from package tarball.
63
92
  - Moved CLI to CLI Package. See [announcement](https://github.com/csstools/postcss-plugins/discussions/121).
64
93
 
65
- ### 3.0.1 (December 27, 2021)
94
+ ### 3.0.1
95
+
96
+ _December 27, 2021_
66
97
 
67
98
  - Fixed: require/import paths for browser script
68
99
 
69
- ### 3.0.0 (December 13, 2021)
100
+ ### 3.0.0
101
+
102
+ _December 13, 2021_
70
103
 
71
104
  - Breaking: require/import paths have changed
72
105
  - Changed: new polyfill CDN urls.
@@ -96,55 +129,79 @@ _It will continue to work for now._
96
129
  + <script src="https://unpkg.com/css-has-pseudo/dist/browser-global.js"></script>
97
130
  ```
98
131
 
99
- ### 2.0.0 (September 16, 2021)
132
+ ### 2.0.0
133
+
134
+ _September 16, 2021_
100
135
 
101
136
  - Updated: Support for PostCS 8+ (major).
102
137
  - Updated: Support for Node 12+ (major).
103
138
 
104
- ### 1.0.0 (June 10, 2019)
139
+ ### 1.0.0
140
+
141
+ _June 10, 2019_
105
142
 
106
143
  - Updated: `postcss-selector-parser` to 6.0.2 (major)
107
144
  - Updated: `postcss` to 7.0.16 (patch)
108
145
  - Updated: Node 8+ compatibility (major)
109
146
 
110
- ### 0.10.0 (December 11, 2018)
147
+ ### 0.10.0
148
+
149
+ _December 11, 2018_
111
150
 
112
151
  - Fixed an issue where inaccessible rules would crash the library
113
152
 
114
- ### 0.9.0 (November 26, 2018)
153
+ ### 0.9.0
154
+
155
+ _November 26, 2018_
115
156
 
116
157
  - Improved CLI usage
117
158
 
118
- ### 0.8.0 (November 26, 2018)
159
+ ### 0.8.0
160
+
161
+ _November 26, 2018_
119
162
 
120
163
  - Fixed an issue where attribute names were not being properly encoded
121
164
 
122
- ### 0.7.0 (November 25, 2018)
165
+ ### 0.7.0
166
+
167
+ _November 25, 2018_
123
168
 
124
169
  - Replaced `setImmediate` with `requestAnimationFrame` for future compatibility
125
170
 
126
- ### 0.6.0 (November 25, 2018)
171
+ ### 0.6.0
172
+
173
+ _November 25, 2018_
127
174
 
128
175
  - Fixed an issue where nested rules were not supported
129
176
 
130
- ### 0.5.0 (November 21, 2018)
177
+ ### 0.5.0
178
+
179
+ _November 21, 2018_
131
180
 
132
181
  - Further optimize script; from 775 bytes to 757 bytes
133
182
 
134
- ### 0.4.0 (November 21, 2018)
183
+ ### 0.4.0
184
+
185
+ _November 21, 2018_
135
186
 
136
187
  - Fixed an issue with the browser script not picking up added nodes
137
188
 
138
- ### 0.3.0 (November 21, 2018)
189
+ ### 0.3.0
190
+
191
+ _November 21, 2018_
139
192
 
140
193
  - Fixed the misnamed function name for the browser-ready script
141
194
 
142
- ### 0.2.0 (November 21, 2018)
195
+ ### 0.2.0
196
+
197
+ _November 21, 2018_
143
198
 
144
199
  - Improved browser compatibility with updated parsers, encoders, and decoders
145
200
  - Improved performance by walking the DOM less
146
201
  - Reduced script size by 9%; from 855 bytes to 775 bytes
147
202
 
148
- ### 0.1.0 (November 20, 2018)
203
+ ### 0.1.0
204
+
205
+ _November 20, 2018_
149
206
 
150
207
  - Initial version
package/LICENSE.md CHANGED
@@ -1,108 +1,18 @@
1
- # CC0 1.0 Universal
2
-
3
- ## Statement of Purpose
4
-
5
- The laws of most jurisdictions throughout the world automatically confer
6
- exclusive Copyright and Related Rights (defined below) upon the creator and
7
- subsequent owner(s) (each and all, an “owner”) of an original work of
8
- authorship and/or a database (each, a “Work”).
9
-
10
- Certain owners wish to permanently relinquish those rights to a Work for the
11
- purpose of contributing to a commons of creative, cultural and scientific works
12
- (“Commons”) that the public can reliably and without fear of later claims of
13
- infringement build upon, modify, incorporate in other works, reuse and
14
- redistribute as freely as possible in any form whatsoever and for any purposes,
15
- including without limitation commercial purposes. These owners may contribute
16
- to the Commons to promote the ideal of a free culture and the further
17
- production of creative, cultural and scientific works, or to gain reputation or
18
- greater distribution for their Work in part through the use and efforts of
19
- others.
20
-
21
- For these and/or other purposes and motivations, and without any expectation of
22
- additional consideration or compensation, the person associating CC0 with a
23
- Work (the “Affirmer”), to the extent that he or she is an owner of Copyright
24
- and Related Rights in the Work, voluntarily elects to apply CC0 to the Work and
25
- publicly distribute the Work under its terms, with knowledge of his or her
26
- Copyright and Related Rights in the Work and the meaning and intended legal
27
- effect of CC0 on those rights.
28
-
29
- 1. Copyright and Related Rights. A Work made available under CC0 may be
30
- protected by copyright and related or neighboring rights (“Copyright and
31
- Related Rights”). Copyright and Related Rights include, but are not limited
32
- to, the following:
33
- 1. the right to reproduce, adapt, distribute, perform, display, communicate,
34
- and translate a Work;
35
- 2. moral rights retained by the original author(s) and/or performer(s);
36
- 3. publicity and privacy rights pertaining to a person’s image or likeness
37
- depicted in a Work;
38
- 4. rights protecting against unfair competition in regards to a Work,
39
- subject to the limitations in paragraph 4(i), below;
40
- 5. rights protecting the extraction, dissemination, use and reuse of data in
41
- a Work;
42
- 6. database rights (such as those arising under Directive 96/9/EC of the
43
- European Parliament and of the Council of 11 March 1996 on the legal
44
- protection of databases, and under any national implementation thereof,
45
- including any amended or successor version of such directive); and
46
- 7. other similar, equivalent or corresponding rights throughout the world
47
- based on applicable law or treaty, and any national implementations
48
- thereof.
49
-
50
- 2. Waiver. To the greatest extent permitted by, but not in contravention of,
51
- applicable law, Affirmer hereby overtly, fully, permanently, irrevocably and
52
- unconditionally waives, abandons, and surrenders all of Affirmer’s Copyright
53
- and Related Rights and associated claims and causes of action, whether now
54
- known or unknown (including existing as well as future claims and causes of
55
- action), in the Work (i) in all territories worldwide, (ii) for the maximum
56
- duration provided by applicable law or treaty (including future time
57
- extensions), (iii) in any current or future medium and for any number of
58
- copies, and (iv) for any purpose whatsoever, including without limitation
59
- commercial, advertising or promotional purposes (the “Waiver”). Affirmer
60
- makes the Waiver for the benefit of each member of the public at large and
61
- to the detriment of Affirmer’s heirs and successors, fully intending that
62
- such Waiver shall not be subject to revocation, rescission, cancellation,
63
- termination, or any other legal or equitable action to disrupt the quiet
64
- enjoyment of the Work by the public as contemplated by Affirmer’s express
65
- Statement of Purpose.
66
-
67
- 3. Public License Fallback. Should any part of the Waiver for any reason be
68
- judged legally invalid or ineffective under applicable law, then the Waiver
69
- shall be preserved to the maximum extent permitted taking into account
70
- Affirmer’s express Statement of Purpose. In addition, to the extent the
71
- Waiver is so judged Affirmer hereby grants to each affected person a
72
- royalty-free, non transferable, non sublicensable, non exclusive,
73
- irrevocable and unconditional license to exercise Affirmer’s Copyright and
74
- Related Rights in the Work (i) in all territories worldwide, (ii) for the
75
- maximum duration provided by applicable law or treaty (including future time
76
- extensions), (iii) in any current or future medium and for any number of
77
- copies, and (iv) for any purpose whatsoever, including without limitation
78
- commercial, advertising or promotional purposes (the “License”). The License
79
- shall be deemed effective as of the date CC0 was applied by Affirmer to the
80
- Work. Should any part of the License for any reason be judged legally
81
- invalid or ineffective under applicable law, such partial invalidity or
82
- ineffectiveness shall not invalidate the remainder of the License, and in
83
- such case Affirmer hereby affirms that he or she will not (i) exercise any
84
- of his or her remaining Copyright and Related Rights in the Work or (ii)
85
- assert any associated claims and causes of action with respect to the Work,
86
- in either case contrary to Affirmer’s express Statement of Purpose.
87
-
88
- 4. Limitations and Disclaimers.
89
- 1. No trademark or patent rights held by Affirmer are waived, abandoned,
90
- surrendered, licensed or otherwise affected by this document.
91
- 2. Affirmer offers the Work as-is and makes no representations or warranties
92
- of any kind concerning the Work, express, implied, statutory or
93
- otherwise, including without limitation warranties of title,
94
- merchantability, fitness for a particular purpose, non infringement, or
95
- the absence of latent or other defects, accuracy, or the present or
96
- absence of errors, whether or not discoverable, all to the greatest
97
- extent permissible under applicable law.
98
- 3. Affirmer disclaims responsibility for clearing rights of other persons
99
- that may apply to the Work or any use thereof, including without
100
- limitation any person’s Copyright and Related Rights in the Work.
101
- Further, Affirmer disclaims responsibility for obtaining any necessary
102
- consents, permissions or other rights required for any use of the Work.
103
- 4. Affirmer understands and acknowledges that Creative Commons is not a
104
- party to this document and has no duty or obligation with respect to this
105
- CC0 or use of the Work.
106
-
107
- For more information, please see
108
- http://creativecommons.org/publicdomain/zero/1.0/.
1
+ MIT No Attribution (MIT-0)
2
+
3
+ Copyright © CSSTools Contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the “Software”), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
9
+ of the Software, and to permit persons to whom the Software is furnished to do
10
+ so.
11
+
12
+ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
13
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
14
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
15
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
16
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
17
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
18
+ SOFTWARE.
package/README.md CHANGED
@@ -4,6 +4,10 @@
4
4
 
5
5
  [PostCSS Has Pseudo] lets you style elements relative to other elements in CSS, following the [Selectors Level 4] specification.
6
6
 
7
+ To use this feature you need to do two things :
8
+ - add the [PostCSS plugin](#usage) that transforms the selector into a class or attribute
9
+ - add the [browser polyfill](#browser) that sets the attribute or class on elements in a browser
10
+
7
11
  ```pcss
8
12
  .title:has(+ p) {
9
13
  margin-bottom: 1.5rem;
@@ -106,6 +110,16 @@ After :
106
110
 
107
111
  ## ⚠️ Known shortcomings
108
112
 
113
+ ### Performance
114
+
115
+ Determining which elements match a `:has` selector is relatively slow through a polyfill compared to the native feature.
116
+
117
+ A very large DOM or many and complex `:has` selectors can cause performance issues.
118
+ JavaScript frameworks that rewrite the DOM will be particularly affected by this.
119
+
120
+ _Any contributions to speedup matching are welcome.
121
+ Please open an issue to discuss proposed changes if you are interested in contributing._
122
+
109
123
  ### Specificity
110
124
 
111
125
  `:has` transforms will result in at least one attribute selector with specificity `0, 1, 0`.<br>
@@ -139,7 +153,7 @@ Then we can investigate and maybe fix these.
139
153
  ## Browser
140
154
 
141
155
  ```js
142
- // initialize prefersColorScheme (applies the current OS color scheme, if available)
156
+ // initialize cssHasPseudo
143
157
  import cssHasPseudo from 'css-has-pseudo/browser';
144
158
  cssHasPseudo(document);
145
159
  ```
@@ -148,11 +162,11 @@ or
148
162
 
149
163
  ```html
150
164
  <!-- When using a CDN url you will have to manually update the version number -->
151
- <script src="https://unpkg.com/css-has-pseudo@5.0.1/dist/browser-global.js"></script>
165
+ <script src="https://unpkg.com/css-has-pseudo@6.0.0/dist/browser-global.js"></script>
152
166
  <script>cssHasPseudo(document)</script>
153
167
  ```
154
168
 
155
- ⚠️ Please use a versioned url, like this : `https://unpkg.com/css-has-pseudo@5.0.1/dist/browser-global.js`
169
+ ⚠️ Please use a versioned url, like this : `https://unpkg.com/css-has-pseudo@6.0.0/dist/browser-global.js`
156
170
  Without the version, you might unexpectedly get a new major version of the library with breaking changes.
157
171
 
158
172
  [PostCSS Has Pseudo] works in all major browsers, including
@@ -1,2 +1,2 @@
1
- !function(){function decodeCSS(e){if("csstools-has-"!==e.slice(0,13))return"";for(var t=(e=e.slice(13)).split("-"),r="",o=0;o<t.length;o++)r+=String.fromCharCode(parseInt(t[o],36));return r}function extractEncodedSelectors(e){for(var t,r,o=[],n=0,s=!1,l=!1,i=0;i<e.length;i++){var c=e[i];switch(c){case"[":if(s){t+=c;continue}0===n?t="":t+=c,n++;continue;case"]":if(s){t+=c;continue}if(0===--n){var a=decodeCSS(t);l&&o.push(a)}else t+=c;continue;case"\\":t+=e[i],t+=e[i+1],i++;continue;case'"':case"'":if(s&&c===r){s=!1;continue}if(s){t+=c;continue}s=!0,r=c;continue;default:""===t&&1===n&&"csstools-has-"===e.slice(i,i+13)&&(l=!0),t+=c;continue}}for(var u=[],p=0;p<o.length;p++)-1===u.indexOf(o[p])&&u.push(o[p]);return u}function encodeCSS(e){if(""===e)return"";for(var t,r="",o=0;o<e.length;o++)t=e.charCodeAt(o).toString(36),r+=0===o?t:"-"+t;return"csstools-has-"+r}function hasNativeSupport(){try{if(!("CSS"in self)||!("supports"in self.CSS)||!self.CSS.supports("selector(:has(div))"))return!1}catch(e){return!1}return!0}function cssHasPseudo(e,t){t||(t={}),(t={hover:!!t.hover||!1,debug:!!t.debug||!1,observedAttributes:t.observedAttributes||[],forcePolyfill:!!t.forcePolyfill||!1}).mustPolyfill=t.forcePolyfill||!hasNativeSupport(),Array.isArray(t.observedAttributes)||(t.observedAttributes=[]),t.observedAttributes=t.observedAttributes.filter((function(e){return"string"==typeof e})),t.observedAttributes=t.observedAttributes.concat(["accept","accept-charset","accesskey","action","align","allow","alt","async","autocapitalize","autocomplete","autofocus","autoplay","buffered","capture","challenge","charset","checked","cite","class","code","codebase","cols","colspan","content","contenteditable","contextmenu","controls","coords","crossorigin","csp","data","datetime","decoding","default","defer","dir","dirname","disabled","download","draggable","enctype","enterkeyhint","for","form","formaction","formenctype","formmethod","formnovalidate","formtarget","headers","hidden","high","href","hreflang","http-equiv","icon","id","importance","integrity","intrinsicsize","inputmode","ismap","itemprop","keytype","kind","label","lang","language","list","loop","low","manifest","max","maxlength","minlength","media","method","min","multiple","muted","name","novalidate","open","optimum","pattern","ping","placeholder","poster","preload","radiogroup","readonly","referrerpolicy","rel","required","reversed","rows","rowspan","sandbox","scope","scoped","selected","shape","size","sizes","slot","span","spellcheck","src","srcdoc","srclang","srcset","start","step","summary","tabindex","target","title","translate","type","usemap","value","width","wrap"]);var r=[],o=e.createElement("x");if([].forEach.call(e.styleSheets,walkStyleSheet),t.mustPolyfill){if(transformObservedItemsThrottled(),"MutationObserver"in self)new MutationObserver((function(t){t.forEach((function(t){[].forEach.call(t.addedNodes||[],(function(e){1===e.nodeType&&e.sheet&&walkStyleSheet(e.sheet)})),[].push.apply(r,r.splice(0).filter((function(t){return t.rule.parentStyleSheet&&t.rule.parentStyleSheet.ownerNode&&e.documentElement.contains(t.rule.parentStyleSheet.ownerNode)}))),transformObservedItemsThrottled()}))})).observe(e,{childList:!0,subtree:!0,attributes:!0,attributeFilter:t.observedAttributes});if(e.addEventListener("focus",transformObservedItemsThrottled,!0),e.addEventListener("blur",transformObservedItemsThrottled,!0),e.addEventListener("input",transformObservedItemsThrottled),e.addEventListener("change",transformObservedItemsThrottled,!0),t.hover&&("onpointerenter"in e?(e.addEventListener("pointerenter",transformObservedItemsThrottled,!0),e.addEventListener("pointerleave",transformObservedItemsThrottled,!0)):(e.addEventListener("mouseover",transformObservedItemsThrottled,!0),e.addEventListener("mouseout",transformObservedItemsThrottled,!0))),"defineProperty"in Object&&"getOwnPropertyDescriptor"in Object&&"hasOwnProperty"in Object)try{var n=function observeProperty(e,t){if(e.hasOwnProperty(t)){var r=Object.getOwnPropertyDescriptor(e,t);r&&r.configurable&&"set"in r&&Object.defineProperty(e,t,{configurable:r.configurable,enumerable:r.enumerable,get:function get(){return r.get.apply(this,arguments)},set:function set(){r.set.apply(this,arguments);try{transformObservedItemsThrottled()}catch(e){}}})}};"HTMLElement"in self&&HTMLElement.prototype&&n(HTMLElement.prototype,"disabled"),["checked","selected","readOnly","required"].forEach((function(e){["HTMLButtonElement","HTMLFieldSetElement","HTMLInputElement","HTMLMeterElement","HTMLOptGroupElement","HTMLOptionElement","HTMLOutputElement","HTMLProgressElement","HTMLSelectElement","HTMLTextAreaElement"].forEach((function(t){t in self&&self[t].prototype&&n(self[t].prototype,e)}))}))}catch(l){t.debug&&console.error(l)}var s=!1}function transformObservedItemsThrottled(){s&&cancelAnimationFrame(s),s=requestAnimationFrame((function(){r.forEach((function(r){var n=[],s=[];try{s=e.querySelectorAll(r.selector)}catch(l){return void(t.debug&&console.error(l))}[].forEach.call(s,(function(t){n.push(t),o.innerHTML="<x "+r.attributeName+">",t.setAttributeNode(o.children[0].attributes[0].cloneNode()),e.documentElement.style.zoom=1,e.documentElement.style.zoom=null})),r.nodes.forEach((function(t){-1===n.indexOf(t)&&(t.removeAttribute(r.attributeName),e.documentElement.style.zoom=1,e.documentElement.style.zoom=null)})),r.nodes=n}))}))}function walkStyleSheet(e){try{[].forEach.call(e.cssRules||[],(function(o,n){if(o.selectorText){o.selectorText=o.selectorText.replace(/\.js-has-pseudo\s/g,"");try{var s=extractEncodedSelectors(o.selectorText.toString());if(0===s.length)return;if(!t.mustPolyfill)return void e.deleteRule(n);for(var i=0;i<s.length;i++){var c=s[i];r.push({rule:o,selector:c,attributeName:encodeCSS(c),nodes:[]})}}catch(l){t.debug&&console.error(l)}}else walkStyleSheet(o)}))}catch(l){t.debug&&console.error(l)}}}!function(e){try{if(e.document.querySelector(":has(*, :does-not-exist, > *)"),!e.document.querySelector(":has(:scope *)")&&CSS.supports("selector(:has(div))"))return}catch(a){}var t=polyfill(e.Element.prototype.querySelector);e.Element.prototype.querySelector=function querySelector(e){return t.apply(this,arguments)};var r=polyfill(e.Element.prototype.querySelectorAll);if(e.Element.prototype.querySelectorAll=function querySelectorAll(e){return r.apply(this,arguments)},e.Element.prototype.matches){var o=polyfill(e.Element.prototype.matches);e.Element.prototype.matches=function matches(e){return o.apply(this,arguments)}}if(e.Element.prototype.closest){var n=polyfill(e.Element.prototype.closest);e.Element.prototype.closest=function closest(e){return n.apply(this,arguments)}}if("Document"in e&&"prototype"in e.Document){var s=polyfill(e.Document.prototype.querySelector);e.Document.prototype.querySelector=function querySelector(e){return s.apply(this,arguments)};var l=polyfill(e.Document.prototype.querySelectorAll);if(e.Document.prototype.querySelectorAll=function querySelectorAll(e){return l.apply(this,arguments)},e.Document.prototype.matches){var i=polyfill(e.Document.prototype.matches);e.Document.prototype.matches=function matches(e){return i.apply(this,arguments)}}if(e.Document.prototype.closest){var c=polyfill(e.Document.prototype.closest);e.Document.prototype.closest=function closest(e){return c.apply(this,arguments)}}}function pseudoClassHasInnerQuery(e){for(var t="",r=0,o=0,n=!1,s=!1,l=!1,i=!1,c=0;c<e.length;c++){var a=e[c];if(n)t+=a,n=!1;else if(s)a===l&&(s=!1),t+=a;else switch(":has("!==t.toLowerCase()||i||(i=!0,r=c,t=""),a){case":":i||(t=""),t+=a;continue;case"(":i&&o++,t+=a;continue;case")":if(i){if(0===o)return{innerQuery:t,start:r,end:c-1};o--}t+=a;continue;case"\\":t+=a,n=!0;continue;case'"':case"'":t+=a,s=!0,l=a;continue;default:t+=a;continue}}return!1}function replaceScopeWithAttr(e,t){for(var r=[],o="",n=!1,s=!1,l=!1,i=0,c=0;c<e.length;c++){var a=e[c];if(n)o+=a,n=!1;else if(s)a===l&&(s=!1),o+=a;else switch(":scope"===o.toLowerCase()&&!i&&/^[\[\.\:\\"\s|+>~#&,)]/.test(a||"")&&(r.push(o.slice(0,o.length-6)),r.push("["+t+"]"),o=""),a){case":":r.push(o),o="",o+=a;continue;case"\\":o+=a,n=!0;continue;case'"':case"'":o+=a,s=!0,l=a;continue;case"[":o+=a,i++;continue;case"]":o+=a,i>0&&i--;continue;default:o+=a;continue}}return":scope"===o.toLowerCase()&&(r.push(o.slice(0,o.length-6)),r.push("["+t+"]"),o=""),0===r.length?e:r.join("")+o}function splitSelector(e){for(var t,r,o=[],n="",s=!1,l=!1,i=!1,c=!1,a=0,u=0;u<e.length;u++){var p=e[u];if(s)n+=p,s=!1;else switch(p){case",":if(l){n+=p;continue}if(a>0){n+=p;continue}o.push(n),n="";continue;case"\\":n+=p,s=!0;continue;case'"':case"'":if(l&&p===i){n+=p,l=!1;continue}n+=p,l=!0,i=p;continue;case"(":case")":case"[":case"]":if(l){n+=p;continue}if(t=p,"("===(r=c)&&")"===t||"["===r&&"]"===t){n+=p,0===--a&&(c=!1);continue}if(p===c){n+=p,a++;continue}n+=p,a++,c=p;continue;default:n+=p;continue}}return o.push(n),o}function replaceAllWithTempAttr(e,t,r){var o=pseudoClassHasInnerQuery(e);if(!o)return e;if(t)return!1;var n=o.innerQuery,s="q-has"+(Math.floor(9e6*Math.random())+1e6),l="["+s+"]",i=e;if(o.innerQuery.toLowerCase().indexOf(":has(")>-1){for(var c=splitSelector(o.innerQuery),a=[],u=0;u<c.length;u++){var p=c[u];if(!replaceAllWithTempAttr(p,!0,(function(){})))throw new Error("Nested :has() is not supported");a.push(p)}var f=i.substring(0,o.start-5),d=i.substring(o.end+2);return f+a.join(", ")+d}f=i.substring(0,o.start-5),d=i.substring(o.end+2);if(i=f+l+d,r(n,s),i.toLowerCase().indexOf(":has(")>-1){var h=replaceAllWithTempAttr(i,!1,r);if(h)return h}return i}function walkNode(e,t){if("setAttribute"in e&&"querySelector"in e&&t(e),e.hasChildNodes())for(var r=e.childNodes,o=0;o<r.length;++o)walkNode(r[o],t)}function polyfill(t){return function(r){if(-1===r.toLowerCase().indexOf(":has(")||!pseudoClassHasInnerQuery(r))return t.apply(this,arguments);var o;if("getRootNode"in this)o=this.getRootNode();else for(var n=this;n;)o=n,n=n.parentNode;var s=this;s===e.document&&(s=e.document.documentElement);var l="q-has-scope"+(Math.floor(9e6*Math.random())+1e6);s.setAttribute(l,"");try{r=replaceScopeWithAttr(r,l);var i=[l],c=replaceAllWithTempAttr(r,!1,(function(e,t){i.push(t);for(var r=splitSelector(e),n=0;n<r.length;n++){var s=r[n].trim(),l=s;l=">"===s[0]||"+"===s[0]||"~"===s[0]?s.slice(1).trim():":scope "+s,walkNode(o,(function(e){if(e.querySelector(l))switch(s[0]){case"~":case"+":for(var r=e.childNodes,o=0;o<r.length;o++){var n=r[o];if("setAttribute"in n){var i="q-has-id"+(Math.floor(9e6*Math.random())+1e6);n.setAttribute(i,""),e.querySelector(":scope ["+i+"] "+s)&&n.setAttribute(t,""),n.removeAttribute(i)}}break;case">":i="q-has-id"+(Math.floor(9e6*Math.random())+1e6);e.setAttribute(i,""),e.querySelector(":scope["+i+"] "+s)&&e.setAttribute(t,""),e.removeAttribute(i);break;default:e.setAttribute(t,"")}}))}}));arguments[0]=c;var u=t.apply(this,arguments);if(s.removeAttribute(l),i.length>0){for(var p=[],f=0;f<i.length;f++)p.push("["+i[f]+"]");for(var d=e.document.querySelectorAll(p.join(",")),h=0;h<d.length;h++)for(var m=d[h],y=0;y<i.length;y++)m.removeAttribute(i[y])}return u}catch(b){if(s.removeAttribute(l),i.length>0){for(p=[],f=0;f<i.length;f++)p.push("["+i[f]+"]");for(d=e.document.querySelectorAll(p.join(",")),h=0;h<d.length;h++)for(m=d[h],y=0;y<i.length;y++)m.removeAttribute(i[y])}var v="";try{t.apply(this,[":core-web-does-not-exist"])}catch(g){v=g.message,v&&(v=v.replace(":core-web-does-not-exist",r))}v||(v="Failed to execute 'querySelector' on 'Document': '"+r+"' is not a valid selector.");try{throw new DOMException(v)}catch(a){throw new Error(v)}}}}}(self),("object"==typeof window&&window||"object"==typeof self&&self||{}).cssHasPseudo=cssHasPseudo}();
1
+ !function(){function decodeCSS(e){if("csstools-has-"!==e.slice(0,13))return"";for(var t=(e=e.slice(13)).split("-"),r="",o=0;o<t.length;o++)r+=String.fromCharCode(parseInt(t[o],36));return r}function extractEncodedSelectors(e){for(var t,r,o=[],n=0,s=!1,l=!1,i=0;i<e.length;i++){var c=e[i];switch(c){case"[":if(s){t+=c;continue}0===n?t="":t+=c,n++;continue;case"]":if(s){t+=c;continue}if(0===--n){var a=decodeCSS(t);l&&o.push(a)}else t+=c;continue;case"\\":t+=e[i],t+=e[i+1],i++;continue;case'"':case"'":if(s&&c===r){s=!1;continue}if(s){t+=c;continue}s=!0,r=c;continue;default:""===t&&1===n&&"csstools-has-"===e.slice(i,i+13)&&(l=!0),t+=c;continue}}for(var u=[],p=0;p<o.length;p++)-1===u.indexOf(o[p])&&u.push(o[p]);return u}function encodeCSS(e){if(""===e)return"";for(var t,r="",o=0;o<e.length;o++)t=e.charCodeAt(o).toString(36),r+=0===o?t:"-"+t;return"csstools-has-"+r}function hasNativeSupport(){try{if(!("CSS"in self)||!("supports"in self.CSS)||!self.CSS.supports("selector(:has(div))"))return!1}catch(e){return!1}return!0}function cssHasPseudo(e,t){t||(t={}),(t={hover:!!t.hover||!1,debug:!!t.debug||!1,observedAttributes:t.observedAttributes||[],forcePolyfill:!!t.forcePolyfill||!1}).mustPolyfill=t.forcePolyfill||!hasNativeSupport(),Array.isArray(t.observedAttributes)||(t.observedAttributes=[]),t.observedAttributes=t.observedAttributes.filter((function(e){return"string"==typeof e})),t.observedAttributes=t.observedAttributes.concat(["accept","accept-charset","accesskey","action","align","allow","alt","async","autocapitalize","autocomplete","autofocus","autoplay","buffered","capture","challenge","charset","checked","cite","class","code","codebase","cols","colspan","content","contenteditable","contextmenu","controls","coords","crossorigin","csp","data","datetime","decoding","default","defer","dir","dirname","disabled","download","draggable","enctype","enterkeyhint","for","form","formaction","formenctype","formmethod","formnovalidate","formtarget","headers","hidden","high","href","hreflang","http-equiv","icon","id","importance","integrity","intrinsicsize","inputmode","ismap","itemprop","keytype","kind","label","lang","language","list","loop","low","manifest","max","maxlength","minlength","media","method","min","multiple","muted","name","novalidate","open","optimum","pattern","ping","placeholder","poster","preload","radiogroup","readonly","referrerpolicy","rel","required","reversed","rows","rowspan","sandbox","scope","scoped","selected","shape","size","sizes","slot","span","spellcheck","src","srcdoc","srclang","srcset","start","step","summary","tabindex","target","title","translate","type","usemap","value","width","wrap"]);var r=[],o=e.createElement("x");if([].forEach.call(e.styleSheets,walkStyleSheet),t.mustPolyfill){if(transformObservedItemsThrottled(),"MutationObserver"in self)new MutationObserver((function(t){t.forEach((function(t){[].forEach.call(t.addedNodes||[],(function(e){1===e.nodeType&&e.sheet&&walkStyleSheet(e.sheet)})),[].push.apply(r,r.splice(0).filter((function(t){return t.rule.parentStyleSheet&&t.rule.parentStyleSheet.ownerNode&&e.documentElement.contains(t.rule.parentStyleSheet.ownerNode)}))),transformObservedItemsThrottled()}))})).observe(e,{childList:!0,subtree:!0,attributes:!0,attributeFilter:t.observedAttributes});if(e.addEventListener("focus",transformObservedItemsThrottled,!0),e.addEventListener("blur",transformObservedItemsThrottled,!0),e.addEventListener("input",transformObservedItemsThrottled),e.addEventListener("change",transformObservedItemsThrottled,!0),t.hover&&("onpointerenter"in e?(e.addEventListener("pointerenter",transformObservedItemsThrottled,!0),e.addEventListener("pointerleave",transformObservedItemsThrottled,!0)):(e.addEventListener("mouseover",transformObservedItemsThrottled,!0),e.addEventListener("mouseout",transformObservedItemsThrottled,!0))),"defineProperty"in Object&&"getOwnPropertyDescriptor"in Object&&"hasOwnProperty"in Object)try{var n=function observeProperty(e,t){if(e.hasOwnProperty(t)){var r=Object.getOwnPropertyDescriptor(e,t);r&&r.configurable&&"set"in r&&Object.defineProperty(e,t,{configurable:r.configurable,enumerable:r.enumerable,get:function get(){return r.get.apply(this,arguments)},set:function set(){r.set.apply(this,arguments);try{transformObservedItemsThrottled()}catch(e){}}})}};"HTMLElement"in self&&HTMLElement.prototype&&n(HTMLElement.prototype,"disabled"),["checked","selected","readOnly","required"].forEach((function(e){["HTMLButtonElement","HTMLFieldSetElement","HTMLInputElement","HTMLMeterElement","HTMLOptGroupElement","HTMLOptionElement","HTMLOutputElement","HTMLProgressElement","HTMLSelectElement","HTMLTextAreaElement"].forEach((function(t){t in self&&self[t].prototype&&n(self[t].prototype,e)}))}))}catch(l){t.debug&&console.error(l)}var s=!1}function transformObservedItemsThrottled(){s&&cancelAnimationFrame(s),s=requestAnimationFrame((function(){r.forEach((function(r){var n=[],s=[];try{s=e.querySelectorAll(r.selector)}catch(l){return void(t.debug&&console.error(l))}[].forEach.call(s,(function(t){n.push(t),o.innerHTML="<x "+r.attributeName+">",t.setAttributeNode(o.children[0].attributes[0].cloneNode()),e.documentElement.style.zoom=1,e.documentElement.style.zoom=null})),r.nodes.forEach((function(t){-1===n.indexOf(t)&&(t.removeAttribute(r.attributeName),e.documentElement.style.zoom=1,e.documentElement.style.zoom=null)})),r.nodes=n}))}))}function walkStyleSheet(e){try{[].forEach.call(e.cssRules||[],(function(o,n){if(o.selectorText){o.selectorText=o.selectorText.replace(/\.js-has-pseudo\s/g,"");try{var s=extractEncodedSelectors(o.selectorText.toString());if(0===s.length)return;if(!t.mustPolyfill)return void e.deleteRule(n);for(var i=0;i<s.length;i++){var c=s[i];r.push({rule:o,selector:c,attributeName:encodeCSS(c),nodes:[]})}}catch(l){t.debug&&console.error(l)}}else walkStyleSheet(o)}))}catch(l){t.debug&&console.error(l)}}}!function(e){try{if(e.document.querySelector(":has(*, :does-not-exist, > *)"),!e.document.querySelector(":has(:scope *)")&&CSS.supports("selector(:has(div))"))return}catch(a){}var t=polyfill(e.Element.prototype.querySelector);e.Element.prototype.querySelector=function querySelector(e){return t.apply(this,arguments)};var r=polyfill(e.Element.prototype.querySelectorAll);if(e.Element.prototype.querySelectorAll=function querySelectorAll(e){return r.apply(this,arguments)},e.Element.prototype.matches){var o=polyfill(e.Element.prototype.matches);e.Element.prototype.matches=function matches(e){return o.apply(this,arguments)}}if(e.Element.prototype.closest){var n=polyfill(e.Element.prototype.closest);e.Element.prototype.closest=function closest(e){return n.apply(this,arguments)}}if("Document"in e&&"prototype"in e.Document){var s=polyfill(e.Document.prototype.querySelector);e.Document.prototype.querySelector=function querySelector(e){return s.apply(this,arguments)};var l=polyfill(e.Document.prototype.querySelectorAll);if(e.Document.prototype.querySelectorAll=function querySelectorAll(e){return l.apply(this,arguments)},e.Document.prototype.matches){var i=polyfill(e.Document.prototype.matches);e.Document.prototype.matches=function matches(e){return i.apply(this,arguments)}}if(e.Document.prototype.closest){var c=polyfill(e.Document.prototype.closest);e.Document.prototype.closest=function closest(e){return c.apply(this,arguments)}}}function pseudoClassHasInnerQuery(e){for(var t="",r=0,o=0,n=!1,s=!1,l=!1,i=!1,c=0;c<e.length;c++){var a=e[c];if(n)t+=a,n=!1;else if(s)a===l&&(s=!1),t+=a;else switch(":has("!==t.toLowerCase()||i||(i=!0,r=c,t=""),a){case":":i||(t=""),t+=a;continue;case"(":i&&o++,t+=a;continue;case")":if(i){if(0===o)return{innerQuery:t,start:r,end:c-1};o--}t+=a;continue;case"\\":t+=a,n=!0;continue;case'"':case"'":t+=a,s=!0,l=a;continue;default:t+=a;continue}}return!1}function replaceScopeWithAttr(e,t){for(var r=[],o="",n=!1,s=!1,l=!1,i=0,c=0;c<e.length;c++){var a=e[c];if(n)o+=a,n=!1;else if(s)a===l&&(s=!1),o+=a;else switch(":scope"===o.toLowerCase()&&!i&&/^[\[\.\:\\"\s|+>~#&,)]/.test(a||"")&&(r.push(o.slice(0,o.length-6)),r.push("["+t+"]"),o=""),a){case":":r.push(o),o="",o+=a;continue;case"\\":o+=a,n=!0;continue;case'"':case"'":o+=a,s=!0,l=a;continue;case"[":o+=a,i++;continue;case"]":o+=a,i>0&&i--;continue;default:o+=a;continue}}return":scope"===o.toLowerCase()&&(r.push(o.slice(0,o.length-6)),r.push("["+t+"]"),o=""),0===r.length?e:r.join("")+o}function splitSelector(e){for(var t,r,o=[],n="",s=!1,l=!1,i=!1,c=!1,a=0,u=0;u<e.length;u++){var p=e[u];if(s)n+=p,s=!1;else switch(p){case",":if(l){n+=p;continue}if(a>0){n+=p;continue}o.push(n),n="";continue;case"\\":n+=p,s=!0;continue;case'"':case"'":if(l&&p===i){n+=p,l=!1;continue}n+=p,l=!0,i=p;continue;case"(":case")":case"[":case"]":if(l){n+=p;continue}if(t=p,"("===(r=c)&&")"===t||"["===r&&"]"===t){n+=p,0===--a&&(c=!1);continue}if(p===c){n+=p,a++;continue}n+=p,a++,c=p;continue;default:n+=p;continue}}return o.push(n),o}function replaceAllWithTempAttr(e,t,r){var o=pseudoClassHasInnerQuery(e);if(!o)return e;if(t)return!1;var n=o.innerQuery,s="q-has"+(Math.floor(9e6*Math.random())+1e6),l="["+s+"]",i=e;if(o.innerQuery.toLowerCase().indexOf(":has(")>-1){for(var c=splitSelector(o.innerQuery),a=[],u=0;u<c.length;u++){var p=c[u];if(!replaceAllWithTempAttr(p,!0,(function(){})))throw new Error("Nested :has() is not supported");a.push(p)}var f=i.substring(0,o.start-5),d=i.substring(o.end+2);return f+a.join(", ")+d}f=i.substring(0,o.start-5),d=i.substring(o.end+2);if(i=f+l+d,r(n,s),i.toLowerCase().indexOf(":has(")>-1){var h=replaceAllWithTempAttr(i,!1,r);if(h)return h}return i}function walkNode(e,t){if("setAttribute"in e&&"querySelector"in e&&t(e),e.hasChildNodes())for(var r=e.childNodes,o=0;o<r.length;++o)walkNode(r[o],t)}function polyfill(t){return function(r){if(!r)return t.apply(this,arguments);var o,n=String(r);if(!n||-1===n.toLowerCase().indexOf(":has(")||!pseudoClassHasInnerQuery(n))return t.apply(this,arguments);if("getRootNode"in this)o=this.getRootNode();else for(var s=this;s;)o=s,s=s.parentNode;var l=this;l===e.document&&(l=e.document.documentElement);var i="q-has-scope"+(Math.floor(9e6*Math.random())+1e6);l.setAttribute(i,"");try{n=replaceScopeWithAttr(n,i);var c=[i],u=replaceAllWithTempAttr(n,!1,(function(e,t){c.push(t);for(var r=splitSelector(e),n=0;n<r.length;n++){var s=r[n].trim(),l=s;l=">"===s[0]||"+"===s[0]||"~"===s[0]?s.slice(1).trim():":scope "+s,walkNode(o,(function(e){if(e.querySelector(l))switch(s[0]){case"~":case"+":for(var r=e.childNodes,o=0;o<r.length;o++){var n=r[o];if("setAttribute"in n){var i="q-has-id"+(Math.floor(9e6*Math.random())+1e6);n.setAttribute(i,""),e.querySelector(":scope ["+i+"] "+s)&&n.setAttribute(t,""),n.removeAttribute(i)}}break;case">":i="q-has-id"+(Math.floor(9e6*Math.random())+1e6);e.setAttribute(i,""),e.querySelector(":scope["+i+"] "+s)&&e.setAttribute(t,""),e.removeAttribute(i);break;default:e.setAttribute(t,"")}}))}}));arguments[0]=u;var p=t.apply(this,arguments);if(l.removeAttribute(i),c.length>0){for(var f=[],d=0;d<c.length;d++)f.push("["+c[d]+"]");for(var h=e.document.querySelectorAll(f.join(",")),m=0;m<h.length;m++)for(var y=h[m],v=0;v<c.length;v++)y.removeAttribute(c[v])}return p}catch(g){if(l.removeAttribute(i),c.length>0){for(f=[],d=0;d<c.length;d++)f.push("["+c[d]+"]");for(h=e.document.querySelectorAll(f.join(",")),m=0;m<h.length;m++)for(y=h[m],v=0;v<c.length;v++)y.removeAttribute(c[v])}var b="";try{t.apply(this,[":core-web-does-not-exist"])}catch(S){b=S.message,b&&(b=b.replace(":core-web-does-not-exist",n))}b||(b="Failed to execute 'querySelector' on 'Document': '"+n+"' is not a valid selector.");try{throw new DOMException(b)}catch(a){throw new Error(b)}}}}}(self),("object"==typeof window&&window||"object"==typeof self&&self||{}).cssHasPseudo=cssHasPseudo}();
2
2
  //# sourceMappingURL=browser-global.js.map