[FIX] vdom: fix typing issues, small cleanup

This commit is contained in:
Géry Debongnie
2019-04-20 23:31:23 +02:00
parent 2fbf4f2c22
commit f5ce05c81e
3 changed files with 16 additions and 19 deletions
+1 -10
View File
@@ -2,14 +2,7 @@ import { EventBus } from "./event_bus";
import { Observer } from "./observer";
import { QWeb } from "./qweb";
import { idGenerator } from "./utils";
import {
attrsModule,
eventListenersModule,
h,
init,
propsModule,
VNode
} from "./vdom";
import { h, patch, VNode } from "./vdom";
let getId = idGenerator();
@@ -40,8 +33,6 @@ export interface Meta<T extends Env, Props> {
observer?: Observer;
}
const patch = init([eventListenersModule, attrsModule, propsModule]);
export interface Type<T> extends Function {
new (...args: any[]): T;
}
+14 -4
View File
@@ -1,3 +1,12 @@
// because those in TypeScript are too restrictive: https://github.com/Microsoft/TSJS-lib-generator/pull/237
declare global {
interface Element {
setAttribute(name: string, value: string | number | boolean): void;
setAttributeNS(namespaceURI: string, qualifiedName: string, value: string | number | boolean): void;
}
}
//------------------------------------------------------------------------------
// vnode.ts
//------------------------------------------------------------------------------
@@ -42,7 +51,6 @@ function vnode(
};
}
//------------------------------------------------------------------------------
// snabbdom.ts
//------------------------------------------------------------------------------
@@ -721,7 +729,10 @@ function updateProps(oldVnode: VNode, vnode: VNode): void {
}
}
export const propsModule = { create: updateProps, update: updateProps } as Module;
export const propsModule = {
create: updateProps,
update: updateProps
} as Module;
//------------------------------------------------------------------------------
// module/module.ts
@@ -847,7 +858,6 @@ export const eventListenersModule = {
destroy: updateEventListeners
} as Module;
//------------------------------------------------------------------------------
// attributes.ts
//------------------------------------------------------------------------------
@@ -908,4 +918,4 @@ export const attrsModule = {
update: updateAttrs
} as Module;
export const patch = init([eventListenersModule, attrsModule, propsModule]);
+1 -5
View File
@@ -1,6 +1,4 @@
import sdAttributes from "../libs/snabbdom/src/modules/attributes";
import sdListeners from "../libs/snabbdom/src/modules/eventlisteners";
import { init } from "../libs/snabbdom/src/snabbdom";
import { patch } from "../src/vdom";
import { EvalContext, QWeb } from "../src/qweb";
import { normalize } from "./helpers";
@@ -11,8 +9,6 @@ import { normalize } from "./helpers";
// We create before each test:
// - qweb: a new QWeb instance
const patch = init([sdAttributes, sdListeners]);
let qweb: QWeb;
beforeEach(() => {