{"id":19380324,"url":"https://github.com/drivy/dom-query","last_synced_at":"2026-04-02T18:49:28.843Z","repository":{"id":38418565,"uuid":"187793553","full_name":"drivy/dom-query","owner":"drivy","description":"Enhanced HTML elements","archived":false,"fork":false,"pushed_at":"2024-04-17T12:26:27.000Z","size":1890,"stargazers_count":9,"open_issues_count":33,"forks_count":1,"subscribers_count":15,"default_branch":"main","last_synced_at":"2025-10-03T23:11:53.173Z","etag":null,"topics":["css-query-selector","dom","dom-manipulation","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/drivy.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2019-05-21T08:21:20.000Z","updated_at":"2025-07-16T12:59:41.000Z","dependencies_parsed_at":"2024-02-05T17:03:34.436Z","dependency_job_id":null,"html_url":"https://github.com/drivy/dom-query","commit_stats":{"total_commits":110,"total_committers":6,"mean_commits":"18.333333333333332","dds":"0.24545454545454548","last_synced_commit":"dd36787b8b29aca23d51c429388fa15af1e89702"},"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/drivy/dom-query","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drivy%2Fdom-query","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drivy%2Fdom-query/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drivy%2Fdom-query/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drivy%2Fdom-query/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/drivy","download_url":"https://codeload.github.com/drivy/dom-query/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drivy%2Fdom-query/sbom","scorecard":{"id":356369,"data":{"date":"2025-08-11","repo":{"name":"github.com/drivy/dom-query","commit":"0c8e9a4cae7167e98e55927997da25ebaa312859"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":1.9,"checks":[{"name":"Code-Review","score":1,"reason":"Found 2/12 approved changesets -- score normalized to 1","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'main'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 24 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Vulnerabilities","score":0,"reason":"12 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-968p-4wvh-cqc8","Warn: Project is vulnerable to: GHSA-v6h2-p8h4-qcjw","Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg","Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275","Warn: Project is vulnerable to: GHSA-ghr5-ch3p-vcr6","Warn: Project is vulnerable to: GHSA-fjxv-7rqg-78g4","Warn: Project is vulnerable to: GHSA-pfrx-2q88-qq97","Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv","Warn: Project is vulnerable to: GHSA-mwcw-c2x4-8c55","Warn: Project is vulnerable to: GHSA-gcx4-mw62-g8wm","Warn: Project is vulnerable to: GHSA-52f5-9888-hmc6","Warn: Project is vulnerable to: GHSA-3h5v-q93c-6h6q"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-18T09:42:49.886Z","repository_id":38418565,"created_at":"2025-08-18T09:42:49.887Z","updated_at":"2025-08-18T09:42:49.887Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31313416,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-02T12:59:32.332Z","status":"ssl_error","status_checked_at":"2026-04-02T12:54:48.875Z","response_time":89,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["css-query-selector","dom","dom-manipulation","typescript"],"created_at":"2024-11-10T09:13:40.009Z","updated_at":"2026-04-02T18:49:28.822Z","avatar_url":"https://github.com/drivy.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Enhanced HTML elements with query/event methods\n\nUtility functions to easily perform DOM element manipulation:\n\n- Element selection based on css query selectors. Chainable. NodeLists automatically converted as Arrays\n- Helpers to Attach/detach events. Event delegation supported\n\nThis library is provided as an ES module with Typescript declarations.\n\n## Install\n\nInstall with npm:\n\n```ts\n$ npm install @drivy/dom-query\n```\n\nInstall with pnpm:\n\n```ts\n$ pnpm install @drivy/dom-query\n```\n\nInstall with yarn:\n\n```ts\n$ yarn add @drivy/dom-query\n```\n\n## Usage\n\n```ts\nimport { query, queryAll } from \"@drivy/dom-query\";\n\nqueryAll(\".home-header\").map(header =\u003e console.log(header));\n// =\u003e \u003ch1 class=\"home-header\"\u003e Welcome \u003c/h1\u003e\n// =\u003e \u003ch1 class=\"home-header\"\u003e Get started \u003c/h1\u003e\n\nquery(\".confirm-button\").on(\"click\", e =\u003e {\n  confirm(e.target);\n});\n```\n\n## API\n\n### Get elements from the DOM\n\n`query`\n\n- selects an element from the DOM with a css query selector.\n- returns `null` if no element matches the selector.\n- chainable. Chained method will be based on the last selected element context\n\n`queryStrict`\n\n- like `query` method but will raise en exception if no element matches the selector.\n\n`queryAll`\n\n- selects a list of elements from the DOM with a css query selector. NodeList results will be converted to Arrays so you can directly access Array methods (forEach, map, reduce, filter...)\n\nExamples:\n\n```ts\nimport { query, queryStrict, queryAll } from \"@drivy/dom-query\"\n...\nconst myElement = query(\".js_my-element\")\nconst mySubElement = myElement.query(\".js_my-sub-element\")\nconst mySubElements = myElement.queryAll(\".js_my-sub-elements\")\n\nqueryAll(\".js_my-container .js_my-children-to-select\").map(enhancedElement =\u003e {\n  doSomething(enhancedElement)\n})\n\nconst myElement2 = queryStrict(\".js_my-existing-element\")\n//code below won't be reached if the previous element was not found\ndoSomething(myElement2)\n\n```\n\n### Transform existing javascript elements to EnhancedHTMLElements\n\nYou can transform an existing javascript Element/List of Elements to an EnhancedHTMLElement/EnhancedHTMLElementList with the following methods:\n\n- `toEnhancedHTMLElement`\n- `toEnhancedHTMLElementList`\n\nYou have to use those methods when input elements are out of your scope (function args, event.target ...)\n\n```ts\nimport { toEnhancedHTMLElement, toEnhancedHTMLElementList } from \"@drivy/dom-query\"\n...\n\nconst myElement = toEnhancedHTMLElement(myHTMLElement);\nconst myElements = toEnhancedHTMLElementList(myHTMLElements);\n```\n\n### Handle events\n\nYou can attach/detach events with the following methods:\n\nEnhancedHTMLElement`.on`\n\n- attaches event like native `target.addEventListener`.\n- returns a \"detach\" function. When called, will remove the event listener like `target.removeEventListener`.\n\nEnhancedHTMLElementList`.on`\n\n- same parameters and behavior than EnhancedHTMLElement`.on` but the event will be attached on each element contained in the list.\n- returns a \"detach\" function that when called will detach the events attached on each element of the list\n\nEnhancedHTMLElement`.onDelegate`\n\n- does event delegation. [pattern description here](https://davidwalsh.name/event-delegate).\n- like `.on` method but takes an extra parameter (first one) as a css query selector to specify the children to use as event targets\n- returns a \"detach\" function. When called, will remove the event listener attached to the container.\n\nEnhancedHTMLElementList`.onDelegate`\n\n- same parameters and behavior than EnhancedHTMLElement`.onDelegate` but the event delegation will be done for each element of the list.\n- returns a \"detach\" function that when called will detach the events attached on each element of the list\n\nExamples:\n\n```ts\n// EnhancedHTMLElement\n\nconst detach = myElement.on(\"click\", e =\u003e {\n  doSomething(e.target)\n})\n...\ndetach() //same behavior than native target.removeEventListener\n\nconst detachDelegation = myContainer.onDelegate(\".js_sub-elements\", \"click\", e =\u003e {\n  doSomething(e.target)\n});\n// clicking on a child having the \"js_sub-elements\" class will trigger the event\n\n...\ndetachDelegation() // remove event listener used to delegate\n\n// EnhancedHTMLElementList\n\nconst detach = queryAll(\".js_my-elements\").on(\"click\", e =\u003e {\n  doSomething(e.target)\n})\n...\ndetach()\n\nconst detachDelegations = queryAll(\".js_my-elements\").onDelegate(\n  \".js_my-sub-elements\",\n  \"click\",\n  e =\u003e {\n    doSomething(e.target)\n  }\n)\n...\ndetachDelegations()\n\n```\n\n### Advanced features\n\n#### Event configuration\n\nWhen attaching an event with `.on` or `.onDelegate` you can specify an optional event configuration object as last parameter.\nThis configuration object has a `once` boolean property that when `true` will automatically detach the event after having called once.\n\n```ts\nmyElement2.on(\n  \"click\",\n  e =\u003e {\n    doSomething(e.target);\n    // event listener will be detached\n  },\n  {\n    once: true\n  }\n);\n```\n\n#### Specializing the HTMLElement (ex: HTMLInputElement)\n\nBecause `EnhancedHTMLElement` enhances `HTMLElement` by default, to access properties/methods from an enhanced HTMLInputElement with Typescript (ex: `myEnhancedInput.value`), you must declare the target Type when calling the query/converting method\n\n```ts\nimport { query, queryAll, toEnhancedHTMLElement } from \"@drivy/dom-query\"\n...\n\nconst myEnhancedInput = query\u003cHTMLInputElement\u003e(\".js_my-target-input\");\ndoSomething(myEnhancedInput.value)\n\nconst myEnhancedInput2 = toEnhancedHTMLElement\u003cHTMLInputElement\u003e(myExistingInput);\ndoSomething(myEnhancedInput2.value)\n\nconst myEnhancedInputs = queryAll\u003cHTMLInputElement\u003e(\".js_my-target-inputs\");\nmyEnhancedInputs.forEach(myInput =\u003e {\n  doSomething(myInput.value);\n})\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdrivy%2Fdom-query","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdrivy%2Fdom-query","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdrivy%2Fdom-query/lists"}