Giter VIP home page Giter VIP logo

little-vdom's People

Contributors

lloydzhou avatar luwes avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

little-vdom's Issues

error update children component, which return Fragment

// Adapted and fixed bugs from little-vdom.js
// https://gist.github.com/developit/2038b141b31287faa663f410b6649a87

import { h, Fragment, render } from 'https://unpkg.com/@luwes/[email protected]/dist/little-vdom.js';

/** @jsx h */

// Components get passed (props, state, setState)
function Counter(props, { count = 0 }, update) {
  const increment = () => update({ count: ++count });
  return <button onclick={increment}>{count}</button>
}

function Since({ time }, state, update) {
  setTimeout(update, 1000); // update every second
  const ago = (Date.now() - time) / 1000 | 0;
  return <Fragment><h1>Since: </h1><time>{ago}s ago</time></Fragment>
}

function App(props, {visible=true}, update) {
  setTimeout(() => update({visible: false}), 3000)
  return <div id="app">
    <h1>Hello</h1>
      {visible ? <Since time={Date.now()} /> : false}
    <Counter />
  </div>
}

render(
  <App />,
  document.body
);

update visible delay 3s, can not remove the dom of children component Since
setTimeout(() => update({visible: false}), 3000)

image

Fix reordering components that return Fragments

This should ideally work, I couldn't find a solution right away.
This PR fixed the same bug in Preact: preactjs/preact#1515

little-vdom/test.jsx

Lines 376 to 407 in 3b1b149

it.skip('should handle reordering components that return Fragments #1325', () => {
const X = (props) => {
return props.children;
}
const App = (props) => {
if (props.i === 0) {
return (
<div>
<X key={1}>1</X>
<X key={2}>2</X>
</div>
);
}
return (
<div>
<X key={2}>2</X>
<X key={1}>1</X>
</div>
);
}
render(<App i={0} />, scratch);
expect(scratch.textContent).to.equal('12');
clearLog();
console.log('----------------------------------');
render(<App i={1} />, scratch);
console.log(getLog());
expect(scratch.textContent).to.equal('21');
});

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.