{"id":19065009,"url":"https://github.com/mathieucaroff/xadom","last_synced_at":"2026-06-24T05:32:06.289Z","repository":{"id":54072893,"uuid":"211712442","full_name":"mathieucaroff/xadom","owner":"mathieucaroff","description":"Small DOM Element wrapper library, for Typescript projects","archived":false,"fork":false,"pushed_at":"2021-03-09T19:08:30.000Z","size":830,"stargazers_count":0,"open_issues_count":5,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-22T03:12:40.595Z","etag":null,"topics":["dom","dom-library","dom-wrapper-library","lightweight","no-dependencies","typescript","typescript-wrapper","wrapper-library"],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mathieucaroff.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-09-29T19:08:15.000Z","updated_at":"2020-05-04T23:56:11.000Z","dependencies_parsed_at":"2022-08-13T06:31:05.513Z","dependency_job_id":null,"html_url":"https://github.com/mathieucaroff/xadom","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/mathieucaroff/xadom","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mathieucaroff%2Fxadom","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mathieucaroff%2Fxadom/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mathieucaroff%2Fxadom/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mathieucaroff%2Fxadom/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mathieucaroff","download_url":"https://codeload.github.com/mathieucaroff/xadom/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mathieucaroff%2Fxadom/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34719097,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-24T02:00:07.484Z","response_time":106,"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":["dom","dom-library","dom-wrapper-library","lightweight","no-dependencies","typescript","typescript-wrapper","wrapper-library"],"created_at":"2024-11-09T00:48:11.292Z","updated_at":"2026-06-24T05:32:06.248Z","avatar_url":"https://github.com/mathieucaroff.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Xadom\n\nA small DOM Element wrapper library, made to be used in Typescript project.\n\n```ts\nimport { createXa } from 'xadom'\n\nlet xa = createXa({ document })\n\nlet linkText = xa.body\n  .$$('a')\n  .map((a) =\u003e a.href)\n  .join('\\n')\n\nconsole.log(linkText)\n```\n\n## Bundling\n\n- `src/lib.ts` expects a browser environment and exports `xa` and `createXa` to the `window`\n- `src/xa.ts` is the module version of the library.\n\nBundling to a single file `dist/lib.js`:\n\n- Minified bundle: `yarn parcel build src/lib.ts`\n- Readable bundle: `yarn parcel src/lib.ts`\n\nCompiling each source file to `dist`, for use of `dist/xa.js` as a module:\n\n- `yarn tsc src/xa.ts`\n\n## Publishing\n\n- `yarn tsc src/xa.ts`\n\n## License\n\nThis code is available under CC0 License (public domain).\n\n## Documentation\n\n`xadom` exports a single function `createXa`, and most notable the types `Xa` and `XaElement\u003cT\u003e`.\n\n## createXa\n\nCreate an `Xa` instance.\n\n```ts\ncreateXa: (prop: { document: Document }): Xa\n```\n\n```ts\nlet xa = createXa({ document })\n```\n\n## Xa instance\n\n```ts\ninterface Xa extends Document {\n  create: \u003cK ...\u003e(\n    name: K,\n    attribute: Record\u003cstring, string\u003e = {},\n    children: Element[] = []\n  ): HTMLElement\n  intoTextNode: (child: Node | string) =\u003e Node\n  wrap: (el: Element) =\u003e XaElement\u003cELement\u003e\n\n  body: XaElement\u003cHTMLElement\u003e\n  head: XaElement\u003cHTMLHeadElement\u003e\n  html: XaElement\u003cHTMLElement\u003e\n}\n```\n\n`create` allows to quickly create an Html element with properties assigned:\n\n- `name` is the Html element name\n- `attribute` (defaults to `{}`) is a record of key-values to set onto the newly created element. If the keys are found in the element, they are set directly on the object. If they are not found though, they are set using `setAttribute`.\n- `children` (defaults to `[]`) is an array of children to be appended to the element. A child can be any Node (including Elements), or a string. In the latter case, the string will be use to make a text node which will be inserted.\n\n```ts\nlet el = xa.create('div', {}, [\n  xa.create('span', {}, [\n    'Mathematics allows for no hypocrisy and no vagueness.',\n  ]),\n  xa.create('p', {\n    textContent: 'Sometimes in life, random things can blind-side you.',\n  }),\n  xa.create('span', {\n    innerText: `\n    As far as the laws of mathematics refer to reality, they are not\n    certain, and as far as they are certain, they do not refer to reality.\n    `,\n  }),\n])\n```\n\n`wrap` returns an Xa-enabled, wrapped version of the given Element. See XaElement.\n\n```ts\nlet el = xa.wrap(xa.body.$('#main').firstNode as Element)\n```\n\n`xa.body`, `xa.head`, and `xa.html` are wrapped versions of `document.body`, `document.head` and `document.documentElement`.\n\n**`xa` inherits from `document`**. All properties available on `document` are\nalso available on `xa`.\n\n## XaElement\n\nAn `XaElement\u003cT\u003e` instances, obtained via `xa.wrap`, has all the properties of its original element `T`, plus the following properties:\n\n- `el.count` gives the number of children\n- `el.first` gives the first child element (wrapped), or `undefined`\n- `el.last` gives the last child element (wrapped), or `undefined`\n- `el.firstNode` gives the first node, just like `el.firstChild`, thought it defaults to `undefined` rather than `null`.\n- `el.lastNode` gives the first node, just like `el.firstChild`, thought it defaults to `undefined` rather than `null`.\n- `el.nodes`, with a performance cost, returns the array of the children elements\n- `el.firstT\u003cT extends Element\u003e()` and `el.lastT\u003cT extends Element\u003e()` are typescript helper functions which allow to specify the expected type of the element. This type is used in place of Element to parameter the return type `XaElement\u003cT\u003e`.\n\nFunction:\n\n- `el.$` is a synonyme of `document.querySelector`\n- `el.$$` is a synonyme of `document.querySelectorAll`\n- `el.append` accepts a node or a child and append it to the children of the element\n- `el.clone` is a synonyme of `el.cloneNode`\n- `el.on` is a synonyme of `el.addEventListener`, except it return an object\n  which contains a `remove` function which removes the event listener\n\nNote: all functions which return an element object return it wrapped\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmathieucaroff%2Fxadom","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmathieucaroff%2Fxadom","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmathieucaroff%2Fxadom/lists"}