Skip to content

Commit

Permalink
feat: allow registration of action
Browse files Browse the repository at this point in the history
  • Loading branch information
aidenybai committed Jun 17, 2021
1 parent 43a3fda commit 461d95c
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 9 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
Current Virtual DOM implementations are inadequate—Ranging from overcomplicated to abandoned, most are unusable without sacrificing raw performance and size. Million aims to fix this, providing a library-agnostic Virtual DOM to serve as the core for Javascript libraries.

[![CI](https://img.shields.io/github/workflow/status/millionjs/million/CI?color=FD9336&labelColor=000&style=flat-square&label=build)](https://img.shields.io/github/workflow/status/millionjs/million)
![Code Size](https://badgen.net/badgesize/brotli/https/unpkg.com/million?style=flat-square&label=size&color=A04A9C&labelColor=000) [![NPM Version](https://img.shields.io/npm/v/million?style=flat-square&color=4E82EE&labelColor=000)](https://www.npmjs.com/package/million) ![Code Coverage](https://img.shields.io/coveralls/github/millionjs/million?color=3CF5EB&labelColor=000&style=flat-square)
![Code Size](https://badgen.net/badgesize/brotli/https/unpkg.com/million/dist/million.min.js?style=flat-square&label=size&color=A04A9C&labelColor=000) [![NPM Version](https://img.shields.io/npm/v/million?style=flat-square&color=4E82EE&labelColor=000)](https://www.npmjs.com/package/million) ![Code Coverage](https://img.shields.io/coveralls/github/millionjs/million?color=3CF5EB&labelColor=000&style=flat-square)

[**→ Check out the Million documentation**](https://million.js.org)

Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
"name": "million",
"version": "0.1.0",
"description": "3kb library for tiny web apps",
"main": "dist/million.js",
"main": "dist/million.umd.js",
"module": "dist/million.esm.js",
"browser": "dist/million.min.js",
"browser": "dist/million.umd.js",
"types": "dist/million.d.ts",
"scripts": {
"dev": "sh scripts/dev.sh",
Expand All @@ -20,7 +20,7 @@
"url": "git+https://github.com/millionjs/million.git"
},
"exports": {
"browser": "./dist/million.min.js",
"browser": "./dist/million.umd.js",
"require": "./dist/million.cjs.js",
"import": "./dist/million.esm.js"
},
Expand Down
8 changes: 6 additions & 2 deletions rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,16 @@ export default suite('./src/index.ts', [
format: 'cjs',
}),
unit({
file: './dist/million.js',
file: './dist/million.umd.js',
format: 'umd',
}),
unit({
file: './dist/million.js',
format: 'iife',
}),
unit({
file: './dist/million.min.js',
format: 'umd',
format: 'iife',
minify: true,
}),
]);
2 changes: 1 addition & 1 deletion src/createElement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const createElement = (vnode: VNode, attachField = true): HTMLElement | T
}

if (vnode.children) {
for (let i = 0; i < vnode.children.length; i++) {
for (let i = 0; i < vnode.children.length; ++i) {
el.appendChild(createElement(vnode.children[i]));
}
}
Expand Down
11 changes: 9 additions & 2 deletions src/m.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { VElement, VFlags, VNode, VProps } from './structs';
import { VActions, VElement, VFlags, VNode, VProps } from './structs';

/**
* Attaches ns props to svg element
Expand Down Expand Up @@ -51,7 +51,13 @@ export const className = (classObject: Record<string, boolean>): string => {
* @param {VFlags=} flag - Compiler flag for VNode
* @returns {VElement}
*/
export const m = (tag: string, props?: VProps, children?: VNode[], flag?: VFlags): VElement => {
export const m = (
tag: string,
props?: VProps,
children?: VNode[],
flag?: VFlags,
action?: [VActions, number],
): VElement => {
let key;
if (props?.key) {
key = <string | undefined>props.key;
Expand All @@ -63,5 +69,6 @@ export const m = (tag: string, props?: VProps, children?: VNode[], flag?: VFlags
children,
key,
flag,
action,
};
};

0 comments on commit 461d95c

Please sign in to comment.