Skip to content

Commit

Permalink
fix(events): fix incorrect imports ivi-events => events
Browse files Browse the repository at this point in the history
  • Loading branch information
localvoid committed May 29, 2018
1 parent ddc09d0 commit 368c387
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 27 deletions.
2 changes: 1 addition & 1 deletion documentation/general/synthetic-events.md
Expand Up @@ -11,7 +11,7 @@ and a handler function that will be executed when dispatcher fires an event.
`ivi` package provides event handler factories for all native events.

```ts
import { onClick, onKeyDown } from "ivi-events";
import { onClick, onKeyDown } from "ivi";

const click = onClick((ev) => {
console.log("clicked");
Expand Down
4 changes: 2 additions & 2 deletions packages/ivi-router/package.json
Expand Up @@ -23,10 +23,10 @@
},
"dependencies": {},
"peerDependencies": {
"ivi-events": "^0.13.0"
"ivi": "^0.13.0"
},
"devDependencies": {
"ivi-events": "^0.13.0"
"ivi": "^0.13.0"
},
"description": "ivi router",
"license": "MIT",
Expand Down
4 changes: 2 additions & 2 deletions packages/ivi-router/src/index.ts
@@ -1,4 +1,4 @@
import { EVENT_SOURCE_CLICK, SyntheticEventFlags, addAfterListener } from "ivi-events";
import { EVENT_DISPATCHER_CLICK, SyntheticEventFlags, afterNativeEvent } from "ivi";
import { RouteMap, ResolveResult, resolve } from "routekit-resolver";

export function initRouter<A, T>(
Expand All @@ -24,7 +24,7 @@ export function initRouter<A, T>(
goTo(location.pathname);
});

addAfterListener(EVENT_SOURCE_CLICK, (ev) => {
afterNativeEvent(EVENT_DISPATCHER_CLICK, (ev) => {
if ((ev.flags & (SyntheticEventFlags.PreventedDefault | SyntheticEventFlags.StoppedPropagation)) === 0) {
const anchor = findAnchorNode(ev.target as Element);
if (anchor !== null) {
Expand Down
7 changes: 3 additions & 4 deletions packages/ivi-test/src/query.ts
@@ -1,6 +1,5 @@
import { Predicate, CSSStyleProps } from "ivi-core";
import { EventSource } from "ivi-events";
import { StatefulComponent } from "ivi";
import { EventDispatcher, StatefulComponent } from "ivi";
import {
VNodeWrapper, visitWrapped,

Expand Down Expand Up @@ -108,8 +107,8 @@ export class VNodeElementMatcher extends Matcher<VNodeWrapper> {
return this;
}

hasEventHandler(eventSource: EventSource): this {
this.addPredicate((n: VNodeWrapper) => hasEventHandler(n, eventSource));
hasEventHandler(dispatcher: EventDispatcher): this {
this.addPredicate((n: VNodeWrapper) => hasEventHandler(n, dispatcher));
return this;
}

Expand Down
21 changes: 10 additions & 11 deletions packages/ivi-test/src/utils.ts
@@ -1,5 +1,4 @@
import { EventHandler, EventSource } from "ivi-events";
import { VNode, VNodeFlags } from "ivi";
import { EventHandler, EventDispatcher, VNode, VNodeFlags } from "ivi";

/**
* containsClassName checks if className list contains a className.
Expand Down Expand Up @@ -70,23 +69,23 @@ export function matchKeys(
/**
* containsEventHandler checks if event handler list contain an event source.
*
* @param eventHandlers Event handlers.
* @param eventSource Event source.
* @param handlers Event handlers.
* @param dispatcher Event source.
* @returns true when event handlers contain an event source.
*/
export function containsEventHandler(
eventHandlers: Array<EventHandler | null> | EventHandler | null,
eventSource: EventSource,
handlers: Array<EventHandler | null> | EventHandler | null,
dispatcher: EventDispatcher,
): boolean {
if (eventHandlers !== null) {
if (Array.isArray(eventHandlers)) {
for (const h of eventHandlers) {
if (h !== null && h.src === eventSource) {
if (handlers !== null) {
if (Array.isArray(handlers)) {
for (const h of handlers) {
if (h !== null && h.src === dispatcher) {
return true;
}
}
} else {
return (eventHandlers.src === eventSource);
return (handlers.src === dispatcher);
}
}
return false;
Expand Down
9 changes: 5 additions & 4 deletions packages/ivi-test/src/vdom.ts
@@ -1,6 +1,7 @@
import { CSSStyleProps, shallowEqual, Predicate } from "ivi-core";
import { EventSource } from "ivi-events";
import { VNode, VNodeFlags, Component, StatefulComponent, StatelessComponent, ConnectDescriptor } from "ivi";
import {
VNode, VNodeFlags, Component, StatefulComponent, StatelessComponent, ConnectDescriptor, EventDispatcher,
} from "ivi";
import { containsClassName, containsEventHandler, matchValues, matchKeys } from "./utils";
import { VNodeMatcher, query, queryAll, closest } from "./query";
import { SnapshotOptions, toSnapshot } from "./snapshot";
Expand Down Expand Up @@ -488,9 +489,9 @@ export function hasAssignedStyle(wrapper: VNodeWrapper, style: { [key: string]:
return (vnode._p !== null && matchKeys(vnode._s, style));
}

export function hasEventHandler(wrapper: VNodeWrapper, eventSource: EventSource): boolean {
export function hasEventHandler(wrapper: VNodeWrapper, dispatcher: EventDispatcher): boolean {
const vnode = wrapper.vnode;
return (vnode._p !== null && containsEventHandler(vnode._e, eventSource) === true);
return (vnode._p !== null && containsEventHandler(vnode._e, dispatcher) === true);
}

export function hasUnsafeHTML(wrapper: VNodeWrapper, html?: string): boolean {
Expand Down
3 changes: 1 addition & 2 deletions packages/ivi/src/vdom/__tests__/vnode_element.spec.ts
@@ -1,5 +1,4 @@
import { EventHandler } from "ivi-events";
import { VNodeFlags, VNode, getComponentInstanceFromVNode, autofocus } from "ivi";
import { EventHandler, VNodeFlags, VNode, getComponentInstanceFromVNode, autofocus } from "ivi";
import * as h from "ivi-html";

test(`element flags`, () => {
Expand Down
1 change: 0 additions & 1 deletion packages/ivi/webpack.config.unpkg.js
Expand Up @@ -17,7 +17,6 @@ module.exports = {
externals: {
"ivi-core": "iviCore",
"ivi-scheduler": "iviScheduler",
"ivi-events": "Events",
},
module: {
rules: [
Expand Down

0 comments on commit 368c387

Please sign in to comment.