has-selector
यह क्या करती है
यह स्किल ऐसा कोड खोजती है जो JavaScript से पैरेंट की स्टाइल बदलता है, उसके children की सामग्री के आधार पर। यह सरल, CSS-आधारित स्टाइलिंग चाहने वाले डेवलपर्स के लिए है।
कब इस्तेमाल करें
- ✓जब आपकी स्क्रिप्ट कंटेनर में इनपुट बदलने पर उसमें class जोड़ती है।
- ✓जब आप सिर्फ़ सामग्री के आधार पर पैरेंट को स्टाइल करने के लिए JavaScript लिखते हैं।
- ✓जब आप ऐसी स्टाइलिंग कोड कम करना चाहते हैं जिसे सिंक में रखना मुश्किल हो।
Skill का लिंक
https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/has-selector/SKILL.mdइसे कॉपी करके अपने AI (Claude, ChatGPT या Cursor) में पेस्ट करें और निर्देशों का पालन करने को कहें।
कैसे इस्तेमाल करें
सबसे आसान तरीका: मैसेज कॉपी करके अपने AI में पेस्ट करें। वह skill पढ़कर निर्देशों का पालन करेगा।
पेस्ट करने के लिए तैयार मैसेज
Claude Code, Codex या Cursor के लिए: प्रोजेक्ट फ़ोल्डर में चलाएँ और skill इंस्टॉल हो जाएगी।
SKILL.md डाउनलोड करें और अपने एजेंट के skills फ़ोल्डर में रखें।
AI से क्या माँगें: उदाहरण
“क्या मैं जब child बदले तब पैरेंट को स्टाइल करने के लिए JavaScript की जगह CSS इस्तेमाल कर सकता हूँ?”
हर हफ़्ते 5 नई skills, 1 मिनट में पढ़ें।
यह कैसे काम करती है
एजेंट पैरेंट classes बदलने वाला JavaScript खोजता है और :has selector सुझाता है जो child शर्त पूरी होने पर पैरेंट को लक्षित करे। वह यह भी समझाता है कि :has, :is और :not से कैसे अलग है।
तकनीकी सामग्री (मूल SKILL.md)
लेखक का मूल टेक्स्ट, अंग्रेज़ी में, सीधे GitHub से।
Use :has() to style parent elements based on their descendants
Before :has(), styling a parent based on its children required JavaScript: detecting state, toggling classes, and keeping DOM and styles in sync. This created coupling between styling logic and application logic. :has() moves that relationship back into CSS where it belongs, reducing JavaScript complexity, eliminating class-toggling boilerplate, and making styling intent readable in the stylesheet itself.
Quick Reference
- :has() selects an element when a matching descendant exists inside it
- It is the parent selector CSS has needed for decades
- Baseline support since late 2023 — all major browsers include it
- Avoid complex :has() selectors in hot reflow paths — they can affect layout performance
Check
Look for patterns in this code where JavaScript toggles a class on a parent element based on the state or content of a child element. These are candidates for replacement with :has().
Fix
Replace the JavaScript class-toggling logic with a CSS :has() selector. Show the selector that targets the parent element when the relevant child condition is met.
Explain
Explain how the :has() pseudo-class works, how it differs from :is() and :not(), what descendant vs child combinators mean inside :has(), and how browser support stands today.
Code Review
Review the stylesheets and component JavaScript in this file. Flag any locations where a parent element's style is controlled by toggling a class from JavaScript based on child state — and show the equivalent :has() rule.
For full implementation details, code examples, and framework-specific guidance,
see references/rule.md.
Rule page: https://frontendchecklist.io/rules/css/has-selector
अक्सर पूछे जाने वाले सवाल
:has क्या करता है?
यह एक एलिमेंट को तब चुनता है जब उसके भीतर कोई मेल खाने वाला child या descendant मौजूद हो, जो पहले CSS में संभव नहीं था।
क्या यह व्यापक रूप से समर्थित है?
स्किल कहती है कि 2023 के अंत से सभी प्रमुख ब्राउज़रों में :has का baseline समर्थन है।
क्या यह पेज को धीमा कर सकता है?
स्किल बार-बार पुनर्गणना होने वाले layout क्षेत्रों में जटिल :has selectors से चेतावनी देती है।
जानकारी
लेखक का मूल विवरण
Use when reviewing stylesheets or components that use JavaScript to toggle classes on parent elements based on child state, form input values, or content presence — :has() may replace the JavaScript entirely.
लोकप्रियता
- GitHub स्टार
- 75k
- रैंकिंग में स्थान
- #2865
- लाइसेंस
- MIT
- अपडेट की गई
- 31/10/2026
कमेंट
- …
इस repository की और skills
frontendchecklist
75kकमांड-लाइन टूल से फ़्रंटएंड कोड और लाइव पेजों को एक्सेसिबिलिटी, स्पीड, SEO और सिक्योरिटी के 380 से ज़्यादा नियमों से जाँचती है।
frontend-checklist-global
75kफ़्रंटएंड प्रोजेक्ट को Front-End Checklist के सभी 386 नियमों से ऑडिट करती है, और हर मिली समस्या का ठोस समाधान देती है।
404-page
75kजाँचती है कि आपका गुम पेज उपयोगी लिंक देता है और सही 404 स्टेटस लौटाता है, ताकि भटके हुए विज़िटर रास्ता ढूँढ सकें।
about-page
75kजाँचती है कि आपकी साइट पर एक साफ़ About पेज है जो बताता है कि उसे कौन चलाता है, ताकि विज़िटर और सर्च इंजन का भरोसा बढ़े।
मिलती-जुलती skills
angular-developer
280kआपके एजेंट को Angular code बनाने और प्रोजेक्ट स्ट्रक्चर पर सलाह देने में मदद करता है। नए प्रोजेक्ट शुरू करने, code के हिस्से बनाने, या performance और accessibility सुधारने में उपयोगी है।
frontend-a11y
280kआपके एजेंट को web interfaces को सबके लिए accessible बनाने में मदद करता है। यह सुनिश्चित करता है कि websites और apps screen readers और keyboard navigation के साथ अच्छे से काम करें।
frontend-patterns
280kआपके एजेंट को React और Next.js में frontend development के modern patterns लागू करने में मदद करता है। यह performance optimize करता है, state manage करता है और best practices फॉलो करवाता है।