├── .gitattributes ├── .mailmap ├── AUTHORS ├── .gitignore ├── .npmignore ├── .editorconfig ├── .github ├── ISSUE_TEMPLATE │ ├── feature_request.md │ └── bug_report.md ├── dependabot.yml ├── workflows │ ├── npm-publish.yml │ └── codeql.yml └── FUNDING.yml ├── SECURITY.md ├── package.json ├── LICENSE ├── CODE_OF_CONDUCT.md ├── CHANGELOG.md ├── CONTRIBUTING.md ├── README.md └── dist └── quanter.js /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto -------------------------------------------------------------------------------- /.mailmap: -------------------------------------------------------------------------------- 1 | Indian Modassir -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | Indian Modassir -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | vendor 3 | .DS_STORE 4 | .vscode 5 | .fleet 6 | .zed 7 | .idea 8 | *.iml 9 | *.swp 10 | *.swo 11 | *.log* 12 | .env* -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | vendor 3 | test 4 | package-lock.json 5 | CODE_OF_CONDUCT.md 6 | CONTRIBUTING.md 7 | CHANGELOG.md 8 | .DS_STORE 9 | .editorconfig 10 | .vscode 11 | .fleet 12 | .zed 13 | .idea 14 | .github 15 | .gitignore 16 | .gitattributes 17 | .CHANGELOG.md 18 | .mailmap 19 | *.iml 20 | *.swp 21 | *.swo 22 | *.log* 23 | .env* -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | charset = utf-8 5 | end_of_line = lf 6 | indent_size = 2 7 | indent_style = space 8 | insert_final_newline = true 9 | trim_trailing_whitespace = true 10 | 11 | [*.md] 12 | trim_trailing_whitespace = false 13 | 14 | [*.{yml,yaml}] 15 | indent_size = 2 16 | 17 | [docker-compose.yml] 18 | indent_size = 2 -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Additional context** 20 | Add any other context or screenshots about the feature request here. 21 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | # To get started with Dependabot version updates, you'll need to specify which 2 | # package ecosystems to update and where the package manifests are located. 3 | # Please see the documentation for all configuration options: 4 | # https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates 5 | 6 | version: 2 7 | updates: 8 | - package-ecosystem: "github-actions" # See documentation for possible values 9 | directory: "/" # Location of package manifests 10 | schedule: 11 | interval: "weekly" 12 | # Maintain dependencies for npm 13 | - package-ecosystem: "npm" 14 | directory: "/" 15 | schedule: 16 | interval: "weekly" 17 | -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | # Security Policy 2 | 3 | ## Supported Versions 4 | 5 | Use this section to tell people about which versions of your project are 6 | currently being supported with security updates. 7 | 8 | | Version | Supported | 9 | | ------- | ------------------ | 10 | | 5.1.x | :white_check_mark: | 11 | | 5.0.x | :x: | 12 | | 4.0.x | :white_check_mark: | 13 | | < 4.0 | :x: | 14 | 15 | ## Reporting a Vulnerability 16 | 17 | Use this section to tell people how to report a vulnerability. 18 | 19 | Tell them where to go, how often they can expect to get an update on a 20 | reported vulnerability, what to expect if the vulnerability is accepted or 21 | declined, etc. 22 | -------------------------------------------------------------------------------- /.github/workflows/npm-publish.yml: -------------------------------------------------------------------------------- 1 | name: Publish Package to npm 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | 8 | permissions: 9 | contents: read 10 | id-token: write 11 | 12 | jobs: 13 | publish: 14 | runs-on: ubuntu-latest 15 | 16 | steps: 17 | - name: Checkout repository 18 | uses: actions/checkout@v5 19 | 20 | - name: Setup Node.js 21 | uses: actions/setup-node@v4 22 | with: 23 | node-version: '20.x' 24 | registry-url: 'https://registry.npmjs.org' 25 | 26 | - name: Install dependencies 27 | run: npm ci 28 | 29 | - name: Build package 30 | run: npm run build 31 | 32 | - name: Publish to npm 33 | run: npm publish --provenance --access public 34 | env: 35 | NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] 4 | patreon: # Replace with a single Patreon username 5 | open_collective: # Replace with a single Open Collective username 6 | ko_fi: # Replace with a single Ko-fi username 7 | tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel 8 | community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry 9 | liberapay: # Replace with a single Liberapay username 10 | issuehunt: # Replace with a single IssueHunt username 11 | otechie: # Replace with a single Otechie username 12 | lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry 13 | custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] 14 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | **To Reproduce** 14 | Steps to reproduce the behavior: 15 | 1. Go to '...' 16 | 2. Click on '....' 17 | 3. Scroll down to '....' 18 | 4. See error 19 | 20 | **Expected behavior** 21 | A clear and concise description of what you expected to happen. 22 | 23 | **Screenshots** 24 | If applicable, add screenshots to help explain your problem. 25 | 26 | **Desktop (please complete the following information):** 27 | - OS: [e.g. iOS] 28 | - Browser [e.g. chrome, safari] 29 | - Version [e.g. 22] 30 | 31 | **Smartphone (please complete the following information):** 32 | - Device: [e.g. iPhone6] 33 | - OS: [e.g. iOS8.1] 34 | - Browser [e.g. stock browser, safari] 35 | - Version [e.g. 22] 36 | 37 | **Additional context** 38 | Add any other context about the problem here. 39 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "Quanter", 3 | "name": "quanter", 4 | "version": "4.4.6", 5 | "description": "A Pure-JavaScript, CSS selector engine designed to be easily select DOM-Elements.", 6 | "main": "dist/quanter.js", 7 | "scripts": { 8 | "test": "echo \"Error: no test specified\" && exit 1", 9 | "build": "echo \"No build required\"" 10 | }, 11 | "repository": { 12 | "type": "git", 13 | "url": "git+https://github.com/jsvibe/quanter.git" 14 | }, 15 | "keywords": [ 16 | "quanter", 17 | "javascript", 18 | "CSS", 19 | "selector", 20 | "pseudo", 21 | "jsvibe", 22 | "xpath", 23 | "selector engine" 24 | ], 25 | "homepage": "https://github.com/jsvibe/quanter#readme", 26 | "author": { 27 | "name": "Indian Modassir", 28 | "url": "https://github.com/indianmodassir" 29 | }, 30 | "license": "MIT", 31 | "files": [ 32 | "AUTHORS", 33 | "LICENSE", 34 | "dist/quanter.js", 35 | "dist/quanter.min.js" 36 | ], 37 | "bugs": { 38 | "url": "https://github.com/jsvibe/quanter/issues" 39 | } 40 | } -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 jsvibe 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /.github/workflows/codeql.yml: -------------------------------------------------------------------------------- 1 | # For most projects, this workflow file will not need changing; you simply need 2 | # to commit it to your repository. 3 | # 4 | # You may wish to alter this file to override the set of languages analyzed, 5 | # or to provide custom queries or build logic. 6 | # 7 | # ******** NOTE ******** 8 | # We have attempted to detect the languages in your repository. Please check 9 | # the `language` matrix defined below to confirm you have the correct set of 10 | # supported CodeQL languages. 11 | # 12 | name: "CodeQL" 13 | 14 | on: 15 | push: 16 | branches: [ "main" ] 17 | pull_request: 18 | branches: [ "main" ] 19 | schedule: 20 | - cron: '33 18 * * 2' 21 | 22 | jobs: 23 | analyze: 24 | name: Analyze 25 | # Runner size impacts CodeQL analysis time. To learn more, please see: 26 | # - https://gh.io/recommended-hardware-resources-for-running-codeql 27 | # - https://gh.io/supported-runners-and-hardware-resources 28 | # - https://gh.io/using-larger-runners 29 | # Consider using larger runners for possible analysis time improvements. 30 | runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }} 31 | timeout-minutes: ${{ (matrix.language == 'swift' && 120) || 360 }} 32 | permissions: 33 | actions: read 34 | contents: read 35 | security-events: write 36 | 37 | strategy: 38 | fail-fast: false 39 | matrix: 40 | language: [ 'javascript-typescript' ] 41 | # CodeQL supports [ 'c-cpp', 'csharp', 'go', 'java-kotlin', 'javascript-typescript', 'python', 'ruby', 'swift' ] 42 | # Use only 'java-kotlin' to analyze code written in Java, Kotlin or both 43 | # Use only 'javascript-typescript' to analyze code written in JavaScript, TypeScript or both 44 | # Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support 45 | 46 | steps: 47 | - name: Checkout repository 48 | uses: actions/checkout@v5 49 | 50 | # Initializes the CodeQL tools for scanning. 51 | - name: Initialize CodeQL 52 | uses: github/codeql-action/init@v3 53 | with: 54 | languages: ${{ matrix.language }} 55 | # If you wish to specify custom queries, you can do so here or in a config file. 56 | # By default, queries listed here will override any specified in a config file. 57 | # Prefix the list here with "+" to use these queries and those in the config file. 58 | 59 | # For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs 60 | # queries: security-extended,security-and-quality 61 | 62 | 63 | # Autobuild attempts to build any compiled languages (C/C++, C#, Go, Java, or Swift). 64 | # If this step fails, then you should remove it and run the build manually (see below) 65 | - name: Autobuild 66 | uses: github/codeql-action/autobuild@v3 67 | 68 | # ℹ️ Command-line programs to run using the OS shell. 69 | # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun 70 | 71 | # If the Autobuild fails above, remove it and uncomment the following three lines. 72 | # modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance. 73 | 74 | # - run: | 75 | # echo "Run, Build Application using script" 76 | # ./location_of_script_within_repo/buildscript.sh 77 | 78 | - name: Perform CodeQL Analysis 79 | uses: github/codeql-action/analyze@v3 80 | with: 81 | category: "/language:${{matrix.language}}" 82 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | We as members, contributors, and leaders pledge to make participation in our 6 | community a harassment-free experience for everyone, regardless of age, body 7 | size, visible or invisible disability, ethnicity, sex characteristics, gender 8 | identity and expression, level of experience, education, socio-economic status, 9 | nationality, personal appearance, race, religion, or sexual identity 10 | and orientation. 11 | 12 | We pledge to act and interact in ways that contribute to an open, welcoming, 13 | diverse, inclusive, and healthy community. 14 | 15 | ## Our Standards 16 | 17 | Examples of behavior that contributes to a positive environment for our 18 | community include: 19 | 20 | * Demonstrating empathy and kindness toward other people 21 | * Being respectful of differing opinions, viewpoints, and experiences 22 | * Giving and gracefully accepting constructive feedback 23 | * Accepting responsibility and apologizing to those affected by our mistakes, 24 | and learning from the experience 25 | * Focusing on what is best not just for us as individuals, but for the 26 | overall community 27 | 28 | Examples of unacceptable behavior include: 29 | 30 | * The use of sexualized language or imagery, and sexual attention or 31 | advances of any kind 32 | * Trolling, insulting or derogatory comments, and personal or political attacks 33 | * Public or private harassment 34 | * Publishing others' private information, such as a physical or email 35 | address, without their explicit permission 36 | * Other conduct which could reasonably be considered inappropriate in a 37 | professional setting 38 | 39 | ## Enforcement Responsibilities 40 | 41 | Community leaders are responsible for clarifying and enforcing our standards of 42 | acceptable behavior and will take appropriate and fair corrective action in 43 | response to any behavior that they deem inappropriate, threatening, offensive, 44 | or harmful. 45 | 46 | Community leaders have the right and responsibility to remove, edit, or reject 47 | comments, commits, code, wiki edits, issues, and other contributions that are 48 | not aligned to this Code of Conduct, and will communicate reasons for moderation 49 | decisions when appropriate. 50 | 51 | ## Scope 52 | 53 | This Code of Conduct applies within all community spaces, and also applies when 54 | an individual is officially representing the community in public spaces. 55 | Examples of representing our community include using an official e-mail address, 56 | posting via an official social media account, or acting as an appointed 57 | representative at an online or offline event. 58 | 59 | ## Enforcement 60 | 61 | Instances of abusive, harassing, or otherwise unacceptable behavior may be 62 | reported to the community leaders responsible for enforcement at 63 | . 64 | All complaints will be reviewed and investigated promptly and fairly. 65 | 66 | All community leaders are obligated to respect the privacy and security of the 67 | reporter of any incident. 68 | 69 | ## Enforcement Guidelines 70 | 71 | Community leaders will follow these Community Impact Guidelines in determining 72 | the consequences for any action they deem in violation of this Code of Conduct: 73 | 74 | ### 1. Correction 75 | 76 | **Community Impact**: Use of inappropriate language or other behavior deemed 77 | unprofessional or unwelcome in the community. 78 | 79 | **Consequence**: A private, written warning from community leaders, providing 80 | clarity around the nature of the violation and an explanation of why the 81 | behavior was inappropriate. A public apology may be requested. 82 | 83 | ### 2. Warning 84 | 85 | **Community Impact**: A violation through a single incident or series 86 | of actions. 87 | 88 | **Consequence**: A warning with consequences for continued behavior. No 89 | interaction with the people involved, including unsolicited interaction with 90 | those enforcing the Code of Conduct, for a specified period of time. This 91 | includes avoiding interactions in community spaces as well as external channels 92 | like social media. Violating these terms may lead to a temporary or 93 | permanent ban. 94 | 95 | ### 3. Temporary Ban 96 | 97 | **Community Impact**: A serious violation of community standards, including 98 | sustained inappropriate behavior. 99 | 100 | **Consequence**: A temporary ban from any sort of interaction or public 101 | communication with the community for a specified period of time. No public or 102 | private interaction with the people involved, including unsolicited interaction 103 | with those enforcing the Code of Conduct, is allowed during this period. 104 | Violating these terms may lead to a permanent ban. 105 | 106 | ### 4. Permanent Ban 107 | 108 | **Community Impact**: Demonstrating a pattern of violation of community 109 | standards, including sustained inappropriate behavior, harassment of an 110 | individual, or aggression toward or disparagement of classes of individuals. 111 | 112 | **Consequence**: A permanent ban from any sort of public interaction within 113 | the community. 114 | 115 | ## Attribution 116 | 117 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], 118 | version 2.0, available at 119 | https://www.contributor-covenant.org/version/2/0/code_of_conduct.html. 120 | 121 | Community Impact Guidelines were inspired by [Mozilla's code of conduct 122 | enforcement ladder](https://github.com/mozilla/diversity). 123 | 124 | [homepage]: https://www.contributor-covenant.org 125 | 126 | For answers to common questions about this code of conduct, see the FAQ at 127 | https://www.contributor-covenant.org/faq. Translations are available at 128 | https://www.contributor-covenant.org/translations. 129 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Release Notes 2 | 3 | ## [v4.4.5](https://github.com/jsvibe/quanter/compare/v4.3.0...v4.4.0) - 15-08-2025 4 | 5 | * Update `README.md` file to Improve and Enhance more Readibility and Documentation [@indianmodassir](https://github.com/indianmodassir) 6 | 7 | ## [v4.4.0](https://github.com/jsvibe/quanter/compare/v4.3.0...v4.4.0) - 30-07-2025 8 | 9 | * Added new pseudo `:dir` matches elements based on the directionality of the text contained in them. [@indianmodassir](https://github.com/indianmodassir) 10 | * Update README.md file and enhance more documentation and supports. [@indianmodassir](https://github.com/indianmodassir) 11 | 12 | ## [v4.3.0](https://github.com/jsvibe/quanter/compare/v4.2.0...v4.3.0) - 21-07-2025 13 | 14 | * Add new pseudo `fixed` selects elements with `position: fixed`. [@indianmodassir](https://github.com/indianmodassir) 15 | * Fixed an issue in pseudo `:hidden` and `:visible` where this method not working `dialog`, `details` and `popover=""` attribute elem. we fixed it `v4.3.0`. [@indianmodassir](https://github.com/indianmodassir) 16 | * Fixed an minor issue and bugs `querySelectorAll` feature are disabled, we enabled `querySelectorAll` feature [@indianmodassir](https://github.com/indianmodassir) 17 | 18 | ## [v4.2.0](https://github.com/jsvibe/quanter/compare/v4.1.0...v4.2.0) - 13-07-2025 19 | 20 | * Add new pseudo `:xpath` to target elements XPath Expression through [@indianmodassir](https://github.com/indianmodassir) 21 | * Add new pseudo `:role` to target elements role attribute value [@indianmodassir](https://github.com/indianmodassir) 22 | * Fixed an issue in pseudo `:defined` where this method not proper working [@indianmodassir](https://github.com/indianmodassir) 23 | 24 | ## [v4.1.0](https://github.com/jsvibe/quanter/compare/v4.0.0...v4.1.0) - 07-07-2025 25 | 26 | * [4.x] Add new pseudo `:popover-open` to target elements that have their popover currently open. [@indianmodassir](https://github.com/indianmodassir) 27 | * [4.x] Add new pseudo `:defined` to target custom elements that have been defined (registered). [@indianmodassir](https://github.com/indianmodassir) 28 | 29 | ## [v4.0.0](https://github.com/jsvibe/quanter/compare/v3.0.0...v4.0.0) - 01-07-2025 30 | 31 | * Rename pseudo `:model` to `:modal` to target elements that are displayed as modals. [@indianmodassir](https://github.com/indianmodassir) 32 | * Add new pseudo `:rcontains` for selecting elements whose text content matches a given source. [@indianmodassir](https://github.com/indianmodassir) 33 | * Add new pseudo `:ircontains` for **case-insensitive** source matching of element text content. [@indianmodassir](https://github.com/indianmodassir) 34 | * Add new pseudo `:open` to target open element (e.g., details, dialog) [@indianmodassir](https://github.com/indianmodassir) 35 | * Add new pseudo `picture-in-picture` to target active picture-in-picture element [@indianmodassir](https://github.com/indianmodassir) 36 | * Add new pseudo `:fullscreen` to target active fullscreen element [@indianmodassir](https://github.com/indianmodassir) 37 | 38 | ## [v3.0.0](https://github.com/jsvibe/quanter/compare/v2.0.1...v3.0.0) - 30-06-2025 39 | 40 | * Remove temporary pseudo `:xpath` form Quanter [@indianmodassir](https://github.com/indianmodassir) 41 | * Add pseudo `:importmap` matches script type [@indianmodassir](https://github.com/indianmodassir) 42 | * Add pseudo `:module` matches script type [@indianmodassir](https://github.com/indianmodassir) 43 | * Add pseudo `:json` matches script type [@indianmodassir](https://github.com/indianmodassir) 44 | * Add pseudo `:ecmascript` matches script type [@indianmodassir](https://github.com/indianmodassir) 45 | * Add new method `Quanter.isBracketBalanced()` to match proper closed bracket of given string [@indianmodassir](https://github.com/indianmodassir) 46 | * Add new method `Quanter.XPathSelect()` to select full capabilities of XPath. [@indianmodassir](https://github.com/indianmodassir) 47 | * Fixed bugs of xpath in `Quanter()` with limited support [@indianmodassir](https://github.com/indianmodassir) 48 | 49 | ## [v2.0.1](https://github.com/jsvibe/quanter/compare/v2.0.0...v2.0.1) - 23-06-2025 50 | 51 | * Fixed an issue in `Quanter.selectors.pseudos["has"]` where this method not proper working showing error `contains` not a function [@indianmodassir](https://github.com/indianmodassir) 52 | 53 | ## [v2.0.0](https://github.com/jsvibe/quanter/compare/v1.6.2...v2.0.0) - 26-06-2025 54 | 55 | * Removed `Quanter.selectors.pseudos["named"` pseudo [@indianmodassir](https://github.com/indianmodassir) 56 | * Fixed an issue in `Quanter.uniqueSort` where this method not proper working [@indianmodassir](https://github.com/indianmodassir) 57 | 58 | ## [v1.6.3](https://github.com/jsvibe/quanter/compare/v1.6.2...v1.6.3) - 20-06-2025 59 | 60 | * Fixed an issue in `Quanter.contains` where this method not proper working showing error `contains` not a function [@indianmodassir](https://github.com/indianmodassir) 61 | 62 | ## [v1.6.2](https://github.com/jsvibe/quanter/compare/v1.6.1...v1.6.2) - 20-06-2025 63 | 64 | * Fixed an issue in `Quanter(selector, context, results, seed)` where the `context` parameter was not working correctly. [@indianmodassir](https://github.com/indianmodassir) 65 | 66 | ## [v1.6.1](https://github.com/jsvibe/quanter/compare/v1.6.0...v1.6.1) - 15-06-2025 67 | 68 | * Fixed missing method `:xpath` in minified file `quanter.min.js` [@indianmodassir](https://github.com/indianmodassir) 69 | 70 | ## [v1.6.0](https://github.com/jsvibe/quanter/compare/v1.5.0...v1.6.0) - 15-06-2025 71 | 72 | * Add `:xpath` pseudo method in Quanter [@indianmodassir](https://github.com/indianmodassir) 73 | 74 | ## [v1.5.0](https://github.com/jsvibe/quanter/compare/v1.0.4...v1.5.0) - 15-06-2025 75 | 76 | * Add `:editable` pseudo method in Quanter [@indianmodassir](https://github.com/indianmodassir) 77 | 78 | Quanter 1 includes a variety of changes to the application skeleton. Please consult the diff to see what's new. 79 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing to quanter 2 | 3 | 1. [Getting Involved](#getting-involved) 4 | 2. [Questions and Discussion](#questions-and-discussion) 5 | 3. [How To Report Bugs](#how-to-report-bugs) 6 | 4. [Tips for Bug Patching](#tips-for-bug-patching) 7 | 8 | Note: This is the code development repository for *quanter Core* only. Before opening an issue or making a pull request, be sure you're in the right place. 9 | * quanter plugin issues should be reported to the author of the plugin. 10 | * quanter Core API documentation issues can be filed [at the API repo](https://github.com/quanter/api.quanter.com/issues). 11 | * Bugs or suggestions for other quanter organization projects should be filed in [their respective repos](https://github.com/quanter/). 12 | 13 | ## Getting Involved 14 | 15 | [API design principles](https://github.com/jsvibe/quanter/wiki/API-design-guidelines) 16 | 17 | We're always looking for help [identifying bugs](#how-to-report-bugs), writing and reducing test cases, and improving documentation. And although new features are rare, anything passing our [guidelines](https://github.com/jsvibe/quanter/wiki/Adding-new-features) will be considered. 18 | 19 | More information on how to contribute to this and other quanter organization projects is at [contribute.quanter.org](https://contribute.quanter.org), including a short guide with tips, tricks, and ideas on [getting started with open source](https://contribute.quanter.org/open-source/). Please review our [commit & pull request guide](https://contribute.quanter.org/commits-and-pull-requests/) and [style guides](https://contribute.quanter.org/style-guide/) for instructions on how to maintain a fork and submit patches. 20 | 21 | When opening a pull request, you'll be asked to sign our Contributor License Agreement. Both the Corporate and Individual agreements can be [previewed on GitHub](https://github.com/openjs-foundation/easycla). 22 | 23 | If you're looking for some good issues to start with, [here are some issues labeled "help wanted" or "patch welcome"](https://github.com/jsvibe/quanter/issues?q=is%3Aissue+label%3A%22help+wanted%22%2C%22Patch+Welcome%22). 24 | 25 | ## Questions and Discussion 26 | 27 | ### Forum and IRC 28 | 29 | quanter is so popular that many developers have knowledge of its capabilities and limitations. Most questions about using quanter can be answered on popular forums such as [Stack Overflow](https://stackoverflow.com). Please start there when you have questions, even if you think you've found a bug. 30 | 31 | The quanter Core team watches the [quanter Development Forum](https://forum.quanter.com/developing-quanter-core). If you have longer posts or questions that can't be answered in places such as Stack Overflow, please feel free to post them there. If you think you've found a bug, please [file it in the bug tracker](#how-to-report-bugs). The Core team can be found in the [#quanter-dev](https://webchat.freenode.net/?channels=quanter-dev) IRC channel on irc.freenode.net. 32 | 33 | ### Weekly Status Meetings 34 | 35 | The quanter Core team has a weekly meeting to discuss the progress of current work. The meeting is held in the [#quanter-meeting](https://webchat.freenode.net/?channels=quanter-meeting) IRC channel on irc.freenode.net at [Noon EST](https://www.timeanddate.com/worldclock/fixedtime.html?month=1&day=17&year=2011&hour=12&min=0&sec=0&p1=43) on Mondays. 36 | 37 | [quanter Core Meeting Notes](https://meetings.quanter.org/category/core/) 38 | 39 | 40 | ## How to Report Bugs 41 | 42 | ### Make sure it is a quanter bug 43 | 44 | Most bugs reported to our bug tracker are actually bugs in user code, not in quanter code. Keep in mind that just because your code throws an error inside of quanter, this does *not* mean the bug is a quanter bug. 45 | 46 | Ask for help first in the [Using quanter Forum](https://forum.quanter.com/using-quanter) or another discussion forum like [Stack Overflow](https://stackoverflow.com/). You will get much quicker support, and you will help avoid tying up the quanter team with invalid bug reports. 47 | 48 | ### Disable browser extensions 49 | 50 | Make sure you have reproduced the bug with all browser extensions and add-ons disabled, as these can sometimes cause things to break in interesting and unpredictable ways. Try using incognito, stealth or anonymous browsing modes. 51 | 52 | ### Try the latest version of quanter 53 | 54 | Bugs in old versions of quanter may have already been fixed. In order to avoid reporting known issues, make sure you are always testing against the [latest build](https://releases.quanter.com/git/quanter-git.js). We cannot fix bugs in older released files, if a bug has been fixed in a subsequent version of quanter the site should upgrade. 55 | 56 | ### Simplify the test case 57 | 58 | When experiencing a problem, [reduce your code](https://webkit.org/quality/reduction.html) to the bare minimum required to reproduce the issue. This makes it *much* easier to isolate and fix the offending code. Bugs reported without reduced test cases take on average 9001% longer to fix than bugs that are submitted with them, so you really should try to do this if at all possible. 59 | 60 | ### Search for related or duplicate issues 61 | 62 | Go to the [quanter Core issue tracker](https://github.com/jsvibe/quanter/issues) and make sure the problem hasn't already been reported. If not, create a new issue there and include your test case. 63 | 64 | 65 | ## Tips For Bug Patching 66 | 67 | We *love* when people contribute back to the project by patching the bugs they find. Since quanter is used by so many people, we are cautious about the patches we accept and want to be sure they don't have a negative impact on the millions of people using quanter each day. For that reason it can take a while for any suggested patch to work its way through the review and release process. The reward for you is knowing that the problem you fixed will improve things for millions of sites and billions of visits per day. 68 | 69 | ### Build a Local Copy of quanter 70 | 71 | Create a fork of the quanter repo on github at https://github.com/jsvibe/quanter 72 | 73 | Change directory to your web root directory, whatever that might be: 74 | 75 | ```bash 76 | $ cd /path/to/your/www/root/ 77 | ``` 78 | 79 | Clone your quanter fork to work locally 80 | 81 | ```bash 82 | $ git clone git@github.com:username/quanter.git 83 | ``` 84 | 85 | Change directory to the newly created dir quanter/ 86 | 87 | ```bash 88 | $ cd quanter 89 | ``` 90 | 91 | Add the quanter main as a remote. I label mine "upstream" 92 | 93 | ```bash 94 | $ git remote add upstream git://github.com/jsvibe/quanter.git 95 | ``` 96 | 97 | Get in the habit of pulling in the "upstream" main to stay up to date as quanter receives new commits 98 | 99 | ```bash 100 | $ git pull upstream main 101 | ``` 102 | 103 | Run the build script 104 | 105 | ```bash 106 | $ npm run build 107 | ``` 108 | 109 | Now open the quanter test suite in a browser at http://localhost/test. If there is a port, be sure to include it. 110 | 111 | Success! You just built and tested quanter! 112 | 113 | 114 | ### Test Suite Tips... 115 | 116 | During the process of writing your patch, you will run the test suite MANY times. You can speed up the process by narrowing the running test suite down to the module you are testing by either double clicking the title of the test or appending it to the url. The following examples assume you're working on a local repo, hosted on your localhost server. 117 | 118 | Example: 119 | 120 | http://localhost/test/?module=css 121 | 122 | This will only run the "css" module tests. This will significantly speed up your development and debugging. 123 | 124 | **ALWAYS RUN THE FULL SUITE BEFORE COMMITTING AND PUSHING A PATCH!** 125 | 126 | 127 | #### Loading changes on the test page 128 | 129 | Rather than rebuilding quanter with `npm run build` every time you make a change, you can use the included watch task to rebuild distribution files whenever a file is saved. 130 | 131 | ```bash 132 | $ npm start 133 | ``` 134 | 135 | Alternatively, you can **load tests as ECMAScript modules** to avoid the need for rebuilding altogether. 136 | 137 | Click "Load as modules" after loading the test page. 138 | 139 | 140 | ### Repo organization 141 | 142 | The quanter source is organized with ECMAScript modules and then compiled into one file at build time. 143 | 144 | quanter also contains some special modules we call "var modules", which are placed in folders named "var". At build time, these small modules are compiled to simple var statements. This makes it easy for us to share variables across modules. Browse the "src" folder for examples. 145 | 146 | ### Browser support 147 | 148 | Remember that quanter supports multiple browsers and their versions; any contributed code must work in all of them. You can refer to the [browser support page](https://quanter.com/browser-support/) for the current list of supported browsers. 149 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Quanter 2 | 3 | > A Pure-JavaScript, CSS selector engine designed to be easily select DOM-Elements. 4 | 5 | [![npm version](https://img.shields.io/npm/v/quanter?logo=npm)](https://www.npmjs.com/package/quanter) 6 | [![license](https://img.shields.io/github/license/jsvibe/quanter?style=flat-square&color=blue&logo=mit)](https://github.com/jsvibe/fsmate/blob/main/LICENSE) 7 | [![author](https://img.shields.io/badge/Author-Modassir-blue)](https://github.com/indianmodassir) 8 | [![jsDelivr Hits](https://img.shields.io/jsdelivr/npm/hm/quanter?logo=jsdelivr)](https://www.jsdelivr.com/package/npm/quanter) 9 | [![downloads month](https://img.shields.io/npm/dm/quanter)](https://www.npmjs.com/package/quanter) 10 | [![Publish Package to npm](https://github.com/jsvibe/fsmate/actions/workflows/npm-publish.yml/badge.svg)](https://github.com/jsvibe/fsmate/actions/workflows/npm-publish.yml) 11 | 12 | - [Documentation](http://github.com/jsvibe/quanter/wiki) 13 | - [Browser support](https://github.com/jsvibe/quanter/wiki/#browsers) 14 | - [Pseudos support](#pseudos-supports) 15 | 16 | ## How to install Quanter 17 | To include Quanter in [Node](https://nodejs.org/), first install with npm. 18 | 19 | ```bash 20 | npm install quanter 21 | ``` 22 | 23 | ## How to build Quanter 24 | Clone a copy of the main Sizzle git repo by running: 25 | 26 | ```bash 27 | git clone git://github.com/jsvibe/quanter.git 28 | ``` 29 | 30 | In the `quanter/dist` folder you will find build version of sizzle along with the minified copy and associated map file. 31 | 32 | ## Including Quanter 33 | Below are some of the most common ways to include Quanter. 34 | 35 | ### Browser 36 | 37 | ```html 38 | 39 | ``` 40 | 41 | ### Webpack / Browserify / Babel 42 | There are several ways to use [Webpack](https://webpack.js.org/), [Browserify](http://browserify.org/) or [Babel](https://babeljs.io/). For more information on using these tools, please refer to the corresponding project's documentation. In the script, including Quanter will usually look like this: 43 | 44 | ```js 45 | import quanter from "quanter"; 46 | ``` 47 | 48 | ## Features 49 | ### Multi Selector 50 | 51 | The `Quanter` method allows for flexible element selection using a wide range of selector types: 52 | 53 | - ✅ **CSS Selectors** 54 | Supports tag names, class selectors (`.class`), ID selectors (`#id`), attribute selectors (`[attr=value]`), and pseudo-classes (like `:nth-child`, `:first-of-type`, etc.). 55 | 56 | - ⚠️ **Limited XPath Support** 57 | Basic XPath expressions are supported, but with limited syntax recognition. Use only for simple XPath needs. 58 | 59 | **Best Use:** When your use case involves a mix of CSS-style selectors and simple XPath, and you want to avoid switching methods. 60 | 61 | #### Signature and Parameters 62 | ```js 63 | Quanter(String expr, DOMNode context, Array results, Array seed); 64 | ``` 65 | 66 | - `selector` [required] A CSS Selector or XPath Expression (comma separated or non-comma separated) 67 | - `context` [optional] An element, document, or document fragment to use as the context for finding elements. 68 | - `results` [optional] An optional array to which the matched elements will be added. 69 | - `seed` [optional] A set of elements to match against 70 | 71 | ## Example 72 | 73 | `Sample HTML` 74 | 75 | ```html 76 |
77 |

Welcome

78 | 79 |
    80 |
  • Apple
  • 81 |
  • Banana
  • 82 |
  • Cherry
  • 83 |
84 | 85 |

Contact us at support@example.com

86 | 87 |
88 |
89 |

iPhone 15

90 | $999 91 |
92 |
93 |

Galaxy S25

94 | $899 95 |
96 |
97 |

MacBook Pro

98 | $1999 99 |
100 |
101 | 102 | Login 103 | Register 104 |
105 | ``` 106 | 107 | Quanter Selector Examples (With Multiple Comma-Separated Selectors) 108 | 109 | ### Basic (Comma-separated selectors) 110 | **ID + Class Selector** 111 | 112 | ```js 113 | Quanter("#main, .title"); 114 | ``` 115 | 116 | **Expected Output:** 117 | 118 | - `
...
` 119 | - `

Welcome

` 120 | 121 | **Class + Tag Selector** 122 | 123 | ```js 124 | Quanter(".fruit, h1"); 125 | ``` 126 | 127 | **Expected Output:** 128 | 129 | - `
  • Apple
  • ` 130 | - `
  • Banana
  • ` 131 | - `
  • Cherry
  • ` 132 | - `

    Welcome

    ` 133 | 134 | ### Attribute + Positional 135 | **Attribute Equals + First Child** 136 | 137 | ```js 138 | Quanter("li[data-id='2'], ul.items li:first-child"); 139 | ``` 140 | 141 | **Expected Output:** 142 | 143 | - `
  • Banana
  • ` 144 | - `
  • Apple
  • ` 145 | 146 | **Attribute Contains + Last Child** 147 | 148 | ```js 149 | Quanter("a[href*='reg'], ul.items li:last-child"); 150 | ``` 151 | 152 | **Expected Output:** 153 | 154 | - `Register` 155 | - `
  • Cherry
  • ` 156 | 157 | ### Combinators + Multiple Filters 158 | **Descendant + Direct Child** 159 | 160 | ```js 161 | Quanter(".products .price, .products > article"); 162 | ``` 163 | 164 | **Expected Output:** 165 | 166 | - All `` elements inside `.products` 167 | - All direct `
    ` elements inside `.products` 168 | 169 | **Multiple Attributes** 170 | 171 | ```js 172 | Quanter("article[data-stock='true'][data-type='phone'], article[data-type='laptop']"); 173 | ``` 174 | 175 | **Expected Output:** 176 | 177 | - `
    iPhone 15
    ` 178 | - `
    MacBook Pro
    ` 179 | 180 | ### Pseudo & Complex Chains 181 | **First-child + Not Selector** 182 | 183 | ```js 184 | Quanter("ul.items li:first-child, li:not(.special)"); 185 | ``` 186 | 187 | **Expected Output:** 188 | 189 | - `
  • Apple
  • ` 190 | - `
  • Apple
  • ` (duplicate match from both selectors) 191 | - `
  • Cherry
  • ` 192 | 193 | ### Advanced Combined Queries 194 | **Grouping Complex Paths** 195 | 196 | ```js 197 | Quanter("div#main .products > article[data-stock='true'] .price, li.fruit:last-child"); 198 | ``` 199 | 200 | **Expected Output:** 201 | 202 | `$999` (iPhone 15) 203 | `$1999` (MacBook Pro) 204 | `
  • Cherry
  • ` 205 | 206 | ### Combinators Supports 207 | 208 | | Combinator | Supported | Description | 209 | |:----------|:--------:|------------| 210 | | * | ✓ | Universal selector (matches any element) | 211 | | + | ✓ | Adjacent sibling combinator (next sibling only) | 212 | | > | ✓ | Child combinator (direct child only) | 213 | | < | ✓ | Parent combinator (selects parent of element) | 214 | | ~ | ✓ | General sibling combinator (all following siblings) | 215 | | ` ` | ✓ | Descendant combinator (any level child) | 216 | 217 | ### Pseudos Supports 218 | 219 | | Pseudos | Supported | Description | 220 | |:--------|:--------:|-------------| 221 | | :nth-last-of-type(n) | ✓ | Element at the nth position from the end of its type | 222 | | :nth-of-type(n) | ✓ | Element at the nth position of its type | 223 | | :first-of-type | ✓ | First element of its type | 224 | | :first-child | ✓ | First child of its parent | 225 | | :last-child | ✓ | Last child of its parent | 226 | | :last-of-type | ✓ | Last element of its type | 227 | | :nth-child(n) | ✓ | nth child of its parent | 228 | | :only-child | ✓ | The only child of its parent | 229 | | :only-of-type | ✓ | The only element of its type in the parent | 230 | | :nth-last-child(n) | ✓ | nth child from the end of its parent | 231 | | :viewport | ✓ | Targets the viewport | 232 | | :theme | ✓ | Applies theme-specific styles | 233 | | :contains | ✓ | Element containing specific text | 234 | | :icontains | ✓ | Element containing text (case-insensitive) | 235 | | :rcontains | ✓ | Element containing text via regex | 236 | | :ircontains | ✓ | Element containing text via regex (case-insensitive) | 237 | | :target | ✓ | Element targeted by URL fragment | 238 | | :has | ✓ | Element that contains a specific child/descendant | 239 | | :xpath | ✓ | Element matched by XPath | 240 | | :role | ✓ | Element with a specific ARIA role | 241 | | :lang | ✓ | Element with a specific language attribute | 242 | | :disabled | ✓ | Disabled form element | 243 | | :enabled | ✓ | Enabled form element | 244 | | :hidden | ✓ | Hidden element | 245 | | :visible | ✓ | Visible element | 246 | | :get | ✓ | Form using GET method | 247 | | :post | ✓ | Form using POST method | 248 | | :filter | ✓ | Filtered element | 249 | | :not | ✓ | Element that does not match a selector | 250 | | :indeterminate | ✓ | Checkbox/radio in an indeterminate state | 251 | | :read-only | ✓ | Read-only input or field | 252 | | :required | ✓ | Required form field | 253 | | :open | ✓ | Element in open state (e.g. `
    `) | 254 | | :link | ✓ | Unvisited link | 255 | | :out-of-range | ✓ | Value outside allowed range | 256 | | :in-range | ✓ | Value within allowed range | 257 | | :modal | ✓ | Open modal dialog | 258 | | :paused | ✓ | Media that is paused | 259 | | :muted | ✓ | Muted media element | 260 | | :invalid | ✓ | Invalid input | 261 | | :valid | ✓ | Valid input | 262 | | :autoplay | ✓ | Media with autoplay enabled | 263 | | :optional | ✓ | Optional (non-required) field | 264 | | :picture-in-picture | ✓ | Video in picture-in-picture mode | 265 | | :popover-open | ✓ | Popover currently open | 266 | | :fullscreen | ✓ | Element in fullscreen mode | 267 | | :playing | ✓ | Media currently playing | 268 | | :active | ✓ | Active (clicked or focused) element | 269 | | :defined | ✓ | Defined custom element | 270 | | :inline | ✓ | Inline-level element | 271 | | :root | ✓ | Root element (``) | 272 | | :editable | ✓ | Editable element | 273 | | :focus | ✓ | Element in focus | 274 | | :checked | ✓ | Checked input element | 275 | | :offset | ✓ | Element positioned with offset | 276 | | :fixed | ✓ | Fixed-position element | 277 | | :selected | ✓ | Selected `