{"id":17296082,"url":"https://github.com/timbeyer/html-to-vdom","last_synced_at":"2025-10-25T20:40:38.532Z","repository":{"id":18854498,"uuid":"22070939","full_name":"TimBeyer/html-to-vdom","owner":"TimBeyer","description":"Converts an HTML string into a virtual DOM","archived":false,"fork":false,"pushed_at":"2023-03-23T19:50:10.000Z","size":82,"stargazers_count":172,"open_issues_count":9,"forks_count":39,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-03-28T12:03:52.078Z","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/TimBeyer.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":"2014-07-21T16:07:10.000Z","updated_at":"2024-06-05T04:22:05.000Z","dependencies_parsed_at":"2024-06-18T13:38:10.100Z","dependency_job_id":"44761e2e-be4e-47bd-90c9-a97a889aff29","html_url":"https://github.com/TimBeyer/html-to-vdom","commit_stats":null,"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TimBeyer%2Fhtml-to-vdom","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TimBeyer%2Fhtml-to-vdom/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TimBeyer%2Fhtml-to-vdom/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TimBeyer%2Fhtml-to-vdom/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/TimBeyer","download_url":"https://codeload.github.com/TimBeyer/html-to-vdom/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247176666,"owners_count":20896509,"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-15T11:11:55.025Z","updated_at":"2025-10-25T20:40:38.459Z","avatar_url":"https://github.com/TimBeyer.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"html-to-vdom [![Build Status](https://travis-ci.org/TimBeyer/html-to-vdom.svg?branch=master)](https://travis-ci.org/TimBeyer/html-to-vdom) [![Coverage Status](https://coveralls.io/repos/TimBeyer/html-to-vdom/badge.svg?branch=master\u0026service=github)](https://coveralls.io/github/TimBeyer/html-to-vdom?branch=master) [![bitHound Score](https://www.bithound.io/github/TimBeyer/html-to-vdom/badges/score.svg)](https://www.bithound.io/github/TimBeyer/html-to-vdom)\n============\n\nAbout\n-----\n\nThis is yet another library to convert HTML into a [vtree](https://github.com/Matt-Esch/vtree).\nIt's used in conjunction with [virtual-dom](https://github.com/Matt-Esch/virtual-dom) to convert template based views into `virtual-dom` views.\n\nNote\n----\n\nAs of v0.7.0, HTML attribute parsing has been improved by using [React's list of attributes and properties](https://github.com/facebook/react/blob/c265504fe2fdeadf0e5358879a3c141628b37a23/src/renderers/dom/shared/HTMLDOMPropertyConfig.js) to decide what to set on the VNode. This means that you should experience better compatibility and full support for HTML5. Custom attributes are also no longer lower cased automatically. Inline SVG is not yet supported, but will be worked on for the next version.\n\nAs of v0.6.0, converting sibling nodes without an enclosing parent tag returns an array of type `VNode` instead of throwing an error\n\nAs of v0.5.1, `html-to-vdom` no longer supports browsers without a full ES5 implementation.\n\nAs of v0.3.0, the VNode and VText classes need to be passed in during library initialization from the `virtual-dom` module you are using.  \nThis is to reduce incompatibilties you might have due to depending on a different version of `virtual-dom` than the one this library would use. \n\nUsage\n-----\n\n```javascript\nvar VNode = require('virtual-dom/vnode/vnode');\nvar VText = require('virtual-dom/vnode/vtext');\n\nvar convertHTML = require('html-to-vdom')({\n    VNode: VNode,\n    VText: VText\n});\n\nvar html = '\u003cdiv\u003eFoobar\u003c/div\u003e';\n\nvar vtree = convertHTML(html);\nvar createElement = require('virtual-dom/create-element');\nvar el = createElement(vtree);\ndocument.body.appendChild(el);\n```\n\n#### Specifying a key\nIn order for `virtual-dom` to detect moves it needs a key. To specify your own custom method of finding a key pass in a method that takes the current tag and returns the key.\n\n```javascript\nvar convertHTML = require('html-to-vdom')({\n    VNode: VNode,\n    VText: VText\n});\n\nconvertHTML({\n    getVNodeKey: function (attributes) {\n        return attributes.id;\n    }\n}, '\u003cdiv id=\"foo\"\u003e\u003c/div\u003e');\n```\n\nIf you have a single key method you can also pass the options first, allowing you to create a single bound method for all key lookups:\n\n```javascript\nvar convertHTMLWithKey = convertHTML.bind(null, {\n    getVNodeKey: function (attributes) {\n        return attributes.id;\n    }\n});\n\nconvertHTMLWithKey('\u003cdiv id=\"foo\"\u003e\u003c/div\u003e');\n```\n\nCredits\n-------\n\nThanks to:  \n* [@nkzawa](https://github.com/nkzawa) for making me aware of attribute lowercasing problems and submitting a PR to fix it\n* [@mattferrin](https://github.com/mattferrin) for noticing that promises could be removed from the API and contributing a PR to do so\n* [@tiagorg](https://github.com/tiagorg) for contributing a PR for style attribute parsing\n* [@dariusriggins](https://github.com/dariusriggins) for adding VNode key support\n* [@jsyang](https://github.com/jsyang) for removing the `lodash` dependency for a leaner build and [improved performance](http://jsperf.com/html-to-vdom-lodash-vs-native)\n* [@bregenspan](https://github.com/bregenspan) for making the dataset conversion standards-compliant\n* [@jesseditson](https://github.com/jesseditson) for adding `\u003cscript\u003e` and `\u003cstyle\u003e` tag support and contributing to achieve better attribute/property handling\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftimbeyer%2Fhtml-to-vdom","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftimbeyer%2Fhtml-to-vdom","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftimbeyer%2Fhtml-to-vdom/lists"}