{"id":16125542,"url":"https://github.com/semibran/patch","last_synced_at":"2025-04-06T13:12:43.636Z","repository":{"id":57139851,"uuid":"97748946","full_name":"semibran/patch","owner":"semibran","description":"efficient patch operation for HTML elements","archived":false,"fork":false,"pushed_at":"2021-01-04T20:46:54.000Z","size":12,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-30T09:26:11.256Z","etag":null,"topics":["diff","dom","html","patch","vdom","virtual-dom"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/semibran.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":"2017-07-19T18:30:48.000Z","updated_at":"2021-07-06T11:32:50.000Z","dependencies_parsed_at":"2022-09-03T02:43:10.635Z","dependency_job_id":null,"html_url":"https://github.com/semibran/patch","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/semibran%2Fpatch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/semibran%2Fpatch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/semibran%2Fpatch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/semibran%2Fpatch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/semibran","download_url":"https://codeload.github.com/semibran/patch/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247485291,"owners_count":20946398,"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":["diff","dom","html","patch","vdom","virtual-dom"],"created_at":"2024-10-09T21:29:57.195Z","updated_at":"2025-04-06T13:12:43.615Z","avatar_url":"https://github.com/semibran.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# patch\n\u003e efficient patch operation for matching HTML elements to vnodes\n\n```js\nlet element = document.createElement('h1')\nelement.innerText = 'hello world'\ndocument.body.appendChild(element)\n\npatch(element, {\n  tag: 'h1',\n  props: {},\n  content: ['goodbye world']\n})\n```\n\n## usage\n[![npm badge]][npm package]\n\n### `result = patch(elem, node)`\nAlters `elem` to match `node` and returns `result`.\n\n* `elem`: the `HTMLElement` to be patched\n* `node`: a virtual node of the structure `{ tag, props, content }` against which `elem` is compared\n\nNote that if `elem.tagName` and `node.tag` are different, `result` will be a brand new element. This behavior is caused by a property of the `HTMLElement` interface that prevents an element's tag from being changed once it is created. If there is a chance of the tag name being altered during runtime, make sure to update your element reference to match `result`; otherwise, any changes you make to the new element will not be reflected onscreen.\n\n[npm package]:                       https://npmjs.com/package/@semibran/patch\n[npm badge]:                         https://nodei.co/npm/@semibran/patch.png?mini\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsemibran%2Fpatch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsemibran%2Fpatch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsemibran%2Fpatch/lists"}