{"id":19281273,"url":"https://github.com/zouloux/yadl","last_synced_at":"2025-10-14T01:16:03.397Z","repository":{"id":44987651,"uuid":"512864251","full_name":"zouloux/yadl","owner":"zouloux","description":"Yet Another DOM Library","archived":false,"fork":false,"pushed_at":"2023-03-09T14:12:37.000Z","size":60,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-09-07T18:50:52.204Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zouloux.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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,"publiccode":null,"codemeta":null}},"created_at":"2022-07-11T18:15:42.000Z","updated_at":"2022-07-12T15:34:32.000Z","dependencies_parsed_at":"2024-11-09T21:23:44.332Z","dependency_job_id":null,"html_url":"https://github.com/zouloux/yadl","commit_stats":{"total_commits":11,"total_committers":1,"mean_commits":11.0,"dds":0.0,"last_synced_commit":"b4a73fcbb9455c0cfcba1c181f0d661f9ee5363f"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/zouloux/yadl","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zouloux%2Fyadl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zouloux%2Fyadl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zouloux%2Fyadl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zouloux%2Fyadl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zouloux","download_url":"https://codeload.github.com/zouloux/yadl/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zouloux%2Fyadl/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279017452,"owners_count":26086081,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-13T02:00:06.723Z","response_time":61,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":[],"created_at":"2024-11-09T21:22:12.743Z","updated_at":"2025-10-14T01:16:03.368Z","avatar_url":"https://github.com/zouloux.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Yadl\n\nYet Another DOM Library\n\n### onReady / onLoad\n\n\n```typescript\n// Listen when DOM is ready\nonReady(() =\u003e {\n    console.log('DOM is ready')\n})\n\n// Listen when body is loaded\nonLoad(document.body, () =\u003e {\n    console.log('Body and its assets are loaded')\n})\n\n// Listen when an image is loaded\nonLoad(imageElement, () =\u003e {\n    console.log(imageElement, 'has loaded')\n})\n```\n\n\n### Find / FindAll\n\n- `find` will get one element from the document or a container.\n- `findAll` will target several elements from the document or a container.\n- `findAll` is an array, not a dom iterator.\n\n```typescript\nimport { find, findAll } from \"@zouloux/yadl\"\n\n// Select all divs which have \"Special\" class from document\nconst allSpecialDivs:HTMLElement[] = findAll('div.Special')\n\n// Find the only element which have the id \"Test\"\nconst testElement:HTMLElement = find('#Test')\n\n// Select all divs from element test\nconst allDivs:HTMLElement[] = findAll(testElement, 'div')\n\n// allDivs is a regular array\nallDivs.map( (div, i) =\u003e {\n    // Do something with selected div\n})\n```\n\n```typescript\nimport { $, $$ } from \"@zouloux/yadl\"\n// Alias for find\nconst oneDiv:HTMLElement = $('div#id') \n// Alias for findAll\nconst severalDivs:HTMLElement[] = $$('div.Special')\n```\n\n### Get parent with class\n\n`getParentWithClass` can help to select a parent of a DOM element with a specific class.\n\n```html\n\u003cdiv class=\"App\"\u003e\n    \u003c!-- POPUP --\u003e\n    \u003cdiv class=\"Popup_container\"\u003e\n        \u003cdiv class=\"Popup_inner\"\u003e\n            \u003cbutton onClick=\"popupCloseClicked()\"\u003eClose\u003c/button\u003e\n        \u003c/div\u003e\n    \u003c/div\u003e\n\u003c/div\u003e\n```\n```typescript\nimport { popupCloseClicked } from \"@zouloux/yadl\"\n// Close popup when close button is clicked\nfunction popupCloseClicked ( event:Event ) {\n    const popupContainer = getParentWithClass( event.currentTarget, 'Popup_container' )\n    popupContainer.remove();\n}\n```\n\n\n### Listen events with `on` / `once`\n\n```typescript\nimport { on, once } from \"@zouloux/yadl\"\n\n// Listen an event on a target\non(document, 'click', e =\u003e {\n    console.log(\"Document has been clicked\")\n})\n\n// Listen several events on a target from a selector\non(\"#Element\", ['mouseenter', 'mouseleave'], e =\u003e {\n    console.log(\"#Element mouse event\", e.type)\n})\n\n// Listen an event only once (removed after first dispatch)\nonce(target, \"click\", e =\u003e {\n    console.log(\"Called once\")\n})\n\n// Remove several attached listeners\nconst listeners = on(target, [\"eventA\", \"someevent\"], event =\u003e {\n    // Will remove event listeners if something is true\n    if ( something )\n        listeners();\n})\n\n// Listener options\non(target, 'scroll', scrollhandler, {\n    // addEventListener options can be added here\n    passive: true\n})\n```\n\n### Create elements with `element`\n\n\n```typescript\nimport { element, setAttributes } from \"@zouloux/yadl\"\n\n// Create a new div element\nconst div1:HTMLDivElement = element('div')\n\n// Create a new div element with attributes\nconst div2:HTMLDivElement = element('div', {\n    'class': 'Class1 Class2',\n    id: 'DivID',\n    disabled: true,\n})\n\n// Create a new div element with style\nconst div3:HTMLDivElement = element('div', {}, {\n    border: '1px solid red',\n    width: '50%',\n})\n\n// Bonus, set attributes to an element\nsetAttributes(div2, {\n\tid: 'MyID', \t// override attribute\n\t'class': null, \t// remove attribute\n\trole: 'status'\t// add attribute\n})\n```\n\n### Get and set style on elements with `getStyle` / `setStyle`\n\n#### TODO DOC\n\n### More with `getStyle`\n\n#### TODO DOC\n\n- `splitSizeAndUnit`\n- `remToPixels`\n\n#### TODO DOC\n\n### setAttributes\n\n#### TODO DOC\n\n### SVG `svgColor` / `svgPosition\n\n#### TODO DOC\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzouloux%2Fyadl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzouloux%2Fyadl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzouloux%2Fyadl/lists"}