vanilla-jsx / vanilla-jsx Goto Github PK
View Code? Open in Web Editor NEWVanilla jsx without runtime. HTML Tag return DOM in js, No virtual DOM.
Home Page: https://vanilla-jsx.github.io/vanilla-jsx/
License: MIT License
Vanilla jsx without runtime. HTML Tag return DOM in js, No virtual DOM.
Home Page: https://vanilla-jsx.github.io/vanilla-jsx/
License: MIT License
Hello,
I noticed a bug in your package today while testing it out: The Fragment()
function only parses arrays one level deep. This means that components that use a return statement like the following will render a bunch of text nodes that read "[object HTMLElement]" to the document.
return (
<>
<SingleComponent prop={value} />
{anArrayOfComponents}
</>
)
The following worked for me to correct this:
exports.Fragment = ({ children } = {}) => {
const fragment = document.createDocumentFragment();
if (!!children) {
const flat = flattenChildren(children)
flat.forEach(child => {
fragment.appendChild(child)
})
}
return fragment;
}
function flattenChildren (children) {
let flat = []
if (Array.isArray(children)) {
children.forEach((child) => {
flat = flat.concat(flattenChildren(child))
});
} else {
flat.push(children);
}
return flat
}
Bug is related to this:
https://stackoverflow.com/questions/56258167/why-does-svg-path-collapse-to-0x0-when-built-using-dom-interface-but-works-when
Basically when trying to create a function that returns svg structure, once rendered all the paths are 0x0.
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.