Coder Social home page Coder Social logo

fadom's Introduction

Fadom: A Virtual DOM Library

fadom is a lightweight virtual DOM library that provides an efficient way to update and manipulate the DOM. It's designed to be easy to use and integrate into any web application.

Features

Virtual DOM implementation for efficient updates

Small size and minimal dependencies

Getting Started

To get started with fadom, you can simply include the library in your web application:

import fadom from '../dom;

You can also install fadom using a package manager like npm:

npm install fadom

Usage

Once you have included fadom in your web application, you can use it to create and manipulate virtual DOM elements:

// create a new virtual DOM element
const element = fadom.createElement('div', { id: 'my-element' }, [
  fadom.createElement('p', {}, 'Hello World!')
]);

// render the virtual DOM element to the real DOM
const vElement = fadom.render(element);

// Mount real Dom to container
fadom.mountElement(vElement, document.getElementById('app'));

// update the real DOM with the changes
fadom.update(element, newElement);

API fadom provides a simple API for creating and manipulating virtual DOM elements. Here are some of the key functions:

fadom.createElement(tagName, attributes, children)

Creates a new virtual DOM element with the given tag name, attributes, and children.

  • tagName - The tag name of the element (e.g. 'div', 'p', 'img').
  • attributes - An object containing any attributes to apply to the element (e.g. { id: 'my-element', class: 'my-class' }).
  • children - An array of child elements or text nodes.

fadom.render(element)

Renders the given virtual DOM element to the real DOM.

  • element - The virtual DOM element to render

fadom.mountElement(domElement, container)

  • domElement - Real Dom element
  • container - The DOM element to append the virtual DOM element into.

fadom.updateElement(element, newElement)

Updates the given virtual DOM element with the changes from the new virtual DOM element.

  • element - The virtual DOM element to update.
  • newElement - The new virtual DOM element with the changes

Contributing

If you'd like to contribute to fadom, you can fork the repository and submit a pull request with your changes. Please ensure that your changes are well-documented and include tests.

Inspired by Explained and created a simple virtual DOM from scratch

License

fadom is released under the MIT License. See LICENSE for more information.

fadom's People

Contributors

vyquocvu avatar

Stargazers

 avatar Roman avatar Vuvyteq avatar tranChien-teq avatar

Watchers

 avatar

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.