timbeyer / html-to-vdom Goto Github PK
View Code? Open in Web Editor NEWConverts an HTML string into a virtual DOM
Converts an HTML string into a virtual DOM
I would like to avoid the require
function and use the basic window.something
syntax, because the legacy of my current project. Is that possible?
This is great but I could really use a sync version. Any plans to do so or should I create a separate project?
convertHTML(' <div>foo</div>');
// => TypeError: Cannot convert undefined or null to object
I forked this repo here to remove promises to allow me to create a streaming friendly Gulp plugin.
This Allows me to convert SVG XML icons to Mercury HyperScript and import them using Browserify.
SVG fill attribute discussion: Raynos/mercury#113
XML to HyperScript discussion: Raynos/mercury#115
I'm new to Gulp so I'm positive the plugin isn't perfect.
Hey @TimBeyer. Thanks for your work on this awesome library - excited to give it a shot while experimenting converting our Backbone/Marionette app to use vdom / FRP under the hood. My goal is to still use our current templates (jade->html) that we import into our views using a text module importer, and then parse them into vtrees using your library, before turning them into a vtree stream (see https://github.com/staltz/cycle)
My first roadblock has come here: return htmlparserToVdom.convertTag(tags[0]);
as our templates all contain more then one tag. I'm hoping to avoid adding boiler plate to all our views to wrap template code in an extra div
to ensure only one root tag is returned from the parser, and I'm curious if you given any thought to that problem?
Thanks again!
virtual-dom attribute names differ from basic HTML in two cases:
for -> htmlFor
class -> className
html-to-vdom does not behave consistent about the subj.
It automatically renames for
to htmlFor
but does not rename class
to className
.
import VNode from "virtual-dom/vnode/vnode";
import VText from "virtual-dom/vnode/vtext";
import HtmlToVdom from "html-to-vdom";
let convertHTML = HtmlToVdom({
VNode: VNode,
VText: VText
});
let html = `<p for="email" class="xxx">test</p>`;
convertHTML(html);
// actual result
VirtualNode {
properties: { attributes: { class: 'xxx' }, htmlFor: 'email' },
...
}
// expected result
VirtualNode {
properties: { attributes: { className: 'xxx' }, htmlFor: 'email' },
...
}
Hi @TimBeyer ,
Does this support attributes well? I was using dom-virtualize
and looking for comments on attribute support when I saw your comment: Matt-Esch/virtual-dom#88
when I was using dom-virtualize
in combination of virtual-dom
, all of my attributes were stripped out and it was a disaster.
I was wondering if this library can be/meant to be used in browser? I was looking for something like dist/mercury.js file that comes in mercury distribution that can be included in an HTML as script tag. But I couldn't find anything in the release distribution. I tried to create a bundle using browserify and index.js at the root of the project but it creates a huge 537KB file. How can I use it in an HTML?
Hey,
I was wondering how can I use this library and still define event handlers (functions) for stuff?
I'm reffering to the event handlers in mercury especially: https://github.com/Raynos/mercury/blob/master/docs/faq.md#how-do-i-do-custom-event-handling-in-mercury
Any tips?
Thanks a lot.
html: <input type="text" autocomplete="off">
;
vtree property after html-to-vdom:
{
"attributes": {},
"type": "text",
"autoComplete": "off"
}
node after <input type="text">
vtree property after virtual-dom.h:
{
"autocomplete": true,
"type": "text",
}
node after <input type="text" autocomplete="off">
Hi I´ve been playing around with turbo-react that is a plain old static HTML page that uses turbolinks and react.js to update its DOM through reacts virtual dom. It converts the html to jsx and then renders the new data to the current body tag.
Is it possible to do something similar with virtual-dom and html-to-vdom? As I find it the element has to be added to the DOM first after they has been created with createElement and later append / replaced. I can´t just initialize a current element in the DOM with a virtual-dom? Or am I wrong?
This library use abandoned package "ent" that use deprecated Node punycode module.
Temporary solution: https://github.com/andreinwald/ent-replace
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.