{"id":16124275,"url":"https://github.com/jongacnik/sanitize-elements","last_synced_at":"2025-10-28T06:33:41.217Z","repository":{"id":29174031,"uuid":"32704687","full_name":"jongacnik/sanitize-elements","owner":"jongacnik","description":"sanitize-elements","archived":false,"fork":false,"pushed_at":"2015-03-23T01:27:21.000Z","size":100,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-06T18:19:31.226Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/jongacnik.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}},"created_at":"2015-03-23T01:26:40.000Z","updated_at":"2019-05-22T21:36:50.000Z","dependencies_parsed_at":"2022-08-17T20:05:10.596Z","dependency_job_id":null,"html_url":"https://github.com/jongacnik/sanitize-elements","commit_stats":null,"previous_names":["amongiants/sanitize-elements"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jongacnik%2Fsanitize-elements","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jongacnik%2Fsanitize-elements/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jongacnik%2Fsanitize-elements/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jongacnik%2Fsanitize-elements/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jongacnik","download_url":"https://codeload.github.com/jongacnik/sanitize-elements/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247479496,"owners_count":20945469,"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","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-10-09T21:20:23.107Z","updated_at":"2025-10-17T19:55:42.827Z","avatar_url":"https://github.com/jongacnik.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# sanitize-elements\n\nMakes sure you've got dom elements, if dom elements are what you want\n\nAccepts a dom node, a node list, a jQuery object, an array of dom nodes, etc. Will return dom elements as a plain array. Single dom elements can be wrapped in an array if optional wrap param is passed as true. If dom element(s) aren't passed in, returns false.\n\n## Install\n\n\tnpm install sanitize-elements\n\n## Usage\n\nsanitize-elements is meant to be consumed in a [CommonJS](http://www.commonjs.org/), [Browserify](http://browserify.org/) environment (though you can also use a pre-bundled version, more below):\n\t\n\tvar sanitizeElements = require('sanitize-elements');\n\n\tsanitizeElements(elements, wrap)\n\t// elements: elements to sanitize\n\t// wrap: wrap single dom elements in array, default false\n\nSome simple (abstracted) examples:\n\n\tsanitizeElements(document.querySelector('.element'))\n\t// returns $element\n\n\tsanitizeElements(document.querySelector('.element'), true)\n\t// returns [$element]\n\n\tsanitizeElements(document.querySelectorAll('.elements'))\n\t// returns [$element, $element, ...]\n\n\tsanitizeElements($('.elements'))\n\t// returns [$element, $element, ...]\n\n\tsanitizeElements(window)\n\t// returns false\n\n\tsanitizeElements('iWannaBeAnElement')\n\t// returns false\n\nIn the context of a function:\n\n\tvar something = function($elements) {\n\t\t\n\t\tif ($elements = sanitizeElements($elements)) {\n\t\t\t// do something\n\t\t} else {\n\t\t\tconsole.warn('Pass in some elements please!')\n\t\t\treturn\n\t\t}\n\n\t}\n\n## Bundled Version\n\nIf you don't want to mess with a build process you can also include the pre-bundled version found in `dist/sanitize-elements.bundled.js` in your project which exposes `sanitizeElements()` globally.\n\n## Todo\n\n- Tests","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjongacnik%2Fsanitize-elements","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjongacnik%2Fsanitize-elements","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjongacnik%2Fsanitize-elements/lists"}