{"id":19168178,"url":"https://github.com/masx200/dom-element-attribute-agent-proxy","last_synced_at":"2026-04-16T17:08:13.138Z","repository":{"id":37074515,"uuid":"207852180","full_name":"masx200/dom-element-attribute-agent-proxy","owner":"masx200","description":"基于proxy封装的对于dom元素的attribute的读写操作小工具库","archived":false,"fork":false,"pushed_at":"2023-01-23T20:01:56.000Z","size":436,"stargazers_count":1,"open_issues_count":5,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-04-25T18:20:19.375Z","etag":null,"topics":["dom","javascript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/masx200.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}},"created_at":"2019-09-11T15:59:50.000Z","updated_at":"2022-03-30T23:05:27.000Z","dependencies_parsed_at":"2023-02-13T02:46:03.995Z","dependency_job_id":null,"html_url":"https://github.com/masx200/dom-element-attribute-agent-proxy","commit_stats":null,"previous_names":[],"tags_count":23,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/masx200%2Fdom-element-attribute-agent-proxy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/masx200%2Fdom-element-attribute-agent-proxy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/masx200%2Fdom-element-attribute-agent-proxy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/masx200%2Fdom-element-attribute-agent-proxy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/masx200","download_url":"https://codeload.github.com/masx200/dom-element-attribute-agent-proxy/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240248502,"owners_count":19771486,"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":["dom","javascript"],"created_at":"2024-11-09T09:41:38.401Z","updated_at":"2026-04-16T17:08:13.086Z","avatar_url":"https://github.com/masx200.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# dom-element-attribute-agent-proxy\n\n基于 proxy 封装的对于 dom 元素的 attribute 的读写操作库\n\n# 安装方法\n\n```powershell\nyarn add https://github.com/masx200/dom-element-attribute-agent-proxy.git\n```\n\n或者\n\n```powershell\ncnpm install  --save https://github.com/masx200/dom-element-attribute-agent-proxy.git\n```\n\n# API\n\n```typescript\ndeclare function createeleattr(ele: HTMLElement): Record\u003cstring, any\u003e;\n```\n\n# 使用方法\n\n```javascript\nimport createeleattr from \"@masx200/dom-element-attribute-agent-proxy\";\nvar element1 = document.querySelector(\n    \"div.Popover.anim-scale-in.js-tagsearch-popover\"\n);\nvar attribute1 = createeleattr(element1);\nattribute1.testarray = [1, \"sssssssq\"];\nconsole.log(attribute1.testarray);\nconsole.log(Reflect.ownKeys(attribute1));\nconsole.log(attribute1.class);\nattribute1[\"data-tagsearch-ref\"] = \"master\";\nconsole.log(Object.entries(attribute1));\nattribute1.class = new Set([\"wwwwwwwww1\", \"sssssssq\"]);\nattribute1.style = { display: \"block\", width: \"500px\" };\nconsole.log(attribute1.style);\nattribute1.style = \"display:block;width:500px;height:100px\";\nconsole.log(attribute1.style);\n```\n\n# 设置`attributes`类型说明\n\n`style`属性支持类型为`string|Record\u003cstring,string\u003e`\n\n`class`属性支持类型为`string|Array\u003cstring\u003e|Set\u003cstring\u003e`\n\n其他属性支持`Set\u003cany\u003e|Array\u003cany\u003e|string|Record\u003cstring,string\u003e|Object`\n\n如果设置属性的值为类型`Object`,则将其用`JSON.stringify`转换成`string`类型\n\n# 更新 : 添加了对于 `input`元素中 `type=\"checkbox\"` 的 `checked` 的读写操作,\n\n# 更新 : 添加了对于 `input` 和 `textarea`和`select`元素 的 `value` 的读写操作,\n\n# 支持`style` 属性的对象类型和字符串类型\n\n# 更新：`style`属性支持驼峰命名法和横杠命名法，自动转换成字符串\n\n# 更新 :添加了 `class` 属性对于 `Array` 和 `Set` 的支持,也增加了其他属性对于 `Set` 转 `Array` 的支持\n\n# 关于 `Proxy`\n\nhttps://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Proxy\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmasx200%2Fdom-element-attribute-agent-proxy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmasx200%2Fdom-element-attribute-agent-proxy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmasx200%2Fdom-element-attribute-agent-proxy/lists"}