Skip to content

Commit

Permalink
ux(exports): only named exports
Browse files Browse the repository at this point in the history
BREAKING CHANGE: No default exports exist. All exports are named.

Fixes #522.
Fixes #523.
  • Loading branch information
mightyiam committed Jun 18, 2020
1 parent f4e7885 commit fefd141
Show file tree
Hide file tree
Showing 24 changed files with 51 additions and 68 deletions.
46 changes: 23 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,17 +59,17 @@ performance, small size and all the features listed below.

```mjs
import { init } from 'snabbdom'
import clazz from 'snabbdom/modules/class'
import props from 'snabbdom/modules/props'
import style from 'snabbdom/modules/style'
import listeners from 'snabbdom/modules/eventlisteners'
import h from 'snabbdom/h' // helper function for creating vnodes
import { classModule } from 'snabbdom/modules/class'
import { propsModule } from 'snabbdom/modules/props'
import { styleModule } from 'snabbdom/modules/style'
import { eventListenersModule } from 'snabbdom/modules/eventlisteners'
import { h } from 'snabbdom/h' // helper function for creating vnodes

var patch = init([ // Init patch function with chosen modules
clazz, // makes it easy to toggle classes
props, // for setting properties on DOM elements
style, // handles styling on elements with support for animations
listeners, // attaches event listeners
classModule, // makes it easy to toggle classes
propsModule, // for setting properties on DOM elements
styleModule, // handles styling on elements with support for animations
eventListenersModule, // attaches event listeners
])

var container = document.getElementById('container')
Expand Down Expand Up @@ -153,10 +153,10 @@ takes a list of modules and returns a `patch` function that uses the
specified set of modules.

```mjs
import clazz from 'snabbdom/modules/class'
import style from 'snabbdom/modules/style'
import { classModule } from 'snabbdom/modules/class'
import { styleModule } from 'snabbdom/modules/style'

var patch = init([clazz, style])
var patch = init([classModule, styleModule])
```

### `patch`
Expand Down Expand Up @@ -197,7 +197,7 @@ tag/selector as a string, an optional data object and an optional string or
array of children.

```mjs
import h from 'snabbdom/h'
import { h } from 'snabbdom/h'

var vnode = h('div', { style: { color: '#000' } }, [
h('h1', 'Headline'),
Expand All @@ -212,18 +212,18 @@ server-side generated content.

```mjs
import { init } from 'snabbdom'
import clazz from 'snabbdom/modules/class'
import props from 'snabbdom/modules/props'
import style from 'snabbdom/modules/style'
import listeners from 'snabbdom/modules/eventlisteners'
import h from 'snabbdom/h' // helper function for creating vnodes
import toVNode from 'snabbdom/tovnode'
import { classModule } from 'snabbdom/modules/class'
import { propsModule } from 'snabbdom/modules/props'
import { styleModule } from 'snabbdom/modules/style'
import { eventListenersModule } from 'snabbdom/modules/eventlisteners'
import { h } from 'snabbdom/h' // helper function for creating vnodes
import { toVNode } from 'snabbdom/tovnode'

var patch = init([ // Init patch function with chosen modules
clazz, // makes it easy to toggle classes
props, // for setting properties on DOM elements
style, // handles styling on elements with support for animations
listeners, // attaches event listeners
classModule, // makes it easy to toggle classes
propsModule, // for setting properties on DOM elements
styleModule, // handles styling on elements with support for animations
eventListenersModule, // attaches event listeners
])

var newVNode = h('div', { style: { color: '#000' } }, [
Expand Down
1 change: 0 additions & 1 deletion src/package/h.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,3 @@ export function h (sel: any, b?: any, c?: any): VNode {
}
return vnode(sel, data, children, text, undefined)
};
export default h
1 change: 0 additions & 1 deletion src/package/helpers/attachto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,3 @@ export function attachTo (target: Element, vnode: VNode): VNode {
hook.destroy = destroy
return vnode
};
export default attachTo
2 changes: 0 additions & 2 deletions src/package/htmldomapi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,5 +93,3 @@ export const htmlDomApi: DOMAPI = {
isText,
isComment,
}

export default htmlDomApi
1 change: 0 additions & 1 deletion src/package/modules/attributes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,3 @@ function updateAttrs (oldVnode: VNode, vnode: VNode): void {
}

export const attributesModule: Module = { create: updateAttrs, update: updateAttrs }
export default attributesModule
1 change: 0 additions & 1 deletion src/package/modules/class.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,3 @@ function updateClass (oldVnode: VNode, vnode: VNode): void {
}

export const classModule: Module = { create: updateClass, update: updateClass }
export default classModule
1 change: 0 additions & 1 deletion src/package/modules/dataset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,3 @@ function updateDataset (oldVnode: VNode, vnode: VNode): void {
}

export const datasetModule: Module = { create: updateDataset, update: updateDataset }
export default datasetModule
1 change: 0 additions & 1 deletion src/package/modules/eventlisteners.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,4 +108,3 @@ export const eventListenersModule: Module = {
update: updateEventListeners,
destroy: updateEventListeners
}
export default eventListenersModule
1 change: 0 additions & 1 deletion src/package/modules/hero.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,4 +180,3 @@ function post () {
}

export const heroModule: Module = { pre, create, destroy, post }
export default heroModule
1 change: 0 additions & 1 deletion src/package/modules/props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,3 @@ function updateProps (oldVnode: VNode, vnode: VNode): void {
}

export const propsModule: Module = { create: updateProps, update: updateProps }
export default propsModule
1 change: 0 additions & 1 deletion src/package/modules/style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,4 +117,3 @@ export const styleModule: Module = {
destroy: applyDestroyStyle,
remove: applyRemoveStyle
}
export default styleModule
4 changes: 2 additions & 2 deletions src/package/snabbdom.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Module } from './modules/module'
import vnode, { VNode } from './vnode'
import { vnode, VNode } from './vnode'
import * as is from './is'
import htmlDomApi, { DOMAPI } from './htmldomapi'
import { htmlDomApi, DOMAPI } from './htmldomapi'

type NonUndefined<T> = T extends undefined ? never : T

Expand Down
2 changes: 0 additions & 2 deletions src/package/thunk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,3 @@ export const thunk = function thunk (sel: string, key?: any, fn?: any, args?: an
args: args
})
} as ThunkFn

export default thunk
6 changes: 2 additions & 4 deletions src/package/tovnode.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import vnode, { VNode } from './vnode'
import htmlDomApi, { DOMAPI } from './htmldomapi'
import { vnode, VNode } from './vnode'
import { htmlDomApi, DOMAPI } from './htmldomapi'

export function toVNode (node: Node, domApi?: DOMAPI): VNode {
const api: DOMAPI = domApi !== undefined ? domApi : htmlDomApi
Expand Down Expand Up @@ -35,5 +35,3 @@ export function toVNode (node: Node, domApi?: DOMAPI): VNode {
return vnode('', {}, [], undefined, node as any)
}
}

export default toVNode
2 changes: 0 additions & 2 deletions src/package/vnode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,3 @@ export function vnode (sel: string | undefined,
const key = data === undefined ? undefined : data.key
return { sel, data, children, text, elm, key }
}

export default vnode
2 changes: 1 addition & 1 deletion src/test/benchmark/core.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import 'core-js/stable/array/fill'
import faker from 'faker'
import { VNode } from '../../package/vnode'
import h from '../../package/h'
import { h } from '../../package/h'
import { init as curInit } from '../../package/snabbdom'
import { init as refInit } from 'latest-snabbdom-release'
import { assert } from 'chai'
Expand Down
4 changes: 2 additions & 2 deletions src/test/unit/attachto.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { assert } from 'chai'
import { init } from '../../package/snabbdom'
import { RemoveHook } from '../../package/hooks'
import attachTo from '../../package/helpers/attachto'
import h from '../../package/h'
import { attachTo } from '../../package/helpers/attachto'
import { h } from '../../package/h'

var patch = init([])

Expand Down
4 changes: 2 additions & 2 deletions src/test/unit/attributes.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { assert } from 'chai'
import { init } from '../../package/snabbdom'
import attributesModule from '../../package/modules/attributes'
import h from '../../package/h'
import { attributesModule } from '../../package/modules/attributes'
import { h } from '../../package/h'

var patch = init([
attributesModule
Expand Down
16 changes: 8 additions & 8 deletions src/test/unit/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ import { assert } from 'chai'
import shuffle from 'lodash.shuffle'

import { init } from '../../package/snabbdom'
import classModule from '../../package/modules/class'
import propsModule from '../../package/modules/props'
import styleModule from '../../package/modules/style'
import eventListenersModule from '../../package/modules/eventlisteners'
import h from '../../package/h'
import toVNode from '../../package/tovnode'
import vnode, { VNode } from '../../package/vnode'
import htmlDomApi from '../../package/htmldomapi'
import { classModule } from '../../package/modules/class'
import { propsModule } from '../../package/modules/props'
import { styleModule } from '../../package/modules/style'
import { eventListenersModule } from '../../package/modules/eventlisteners'
import { h } from '../../package/h'
import { toVNode } from '../../package/tovnode'
import { vnode, VNode } from '../../package/vnode'
import { htmlDomApi } from '../../package/htmldomapi'
import { CreateHook, InsertHook, PrePatchHook, RemoveHook, InitHook, DestroyHook, UpdateHook } from '../../package/hooks'

const hasSvgClassList = 'classList' in SVGElement.prototype
Expand Down
4 changes: 2 additions & 2 deletions src/test/unit/dataset.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { assert } from 'chai'

import datasetModule from '../../package/modules/dataset'
import { datasetModule } from '../../package/modules/dataset'
import { init } from '../../package/snabbdom'
import h from '../../package/h'
import { h } from '../../package/h'

var patch = init([
datasetModule
Expand Down
4 changes: 2 additions & 2 deletions src/test/unit/eventlisteners.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { assert } from 'chai'
import { VNode } from '../../package/vnode'

import { init } from '../../package/snabbdom'
import eventListenersModule from '../../package/modules/eventlisteners'
import h from '../../package/h'
import { eventListenersModule } from '../../package/modules/eventlisteners'
import { h } from '../../package/h'

var patch = init([
eventListenersModule
Expand Down
4 changes: 2 additions & 2 deletions src/test/unit/htmldomapi.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { assert } from 'chai'

import { init } from '../../package/snabbdom'
import h from '../../package/h'
import attributesModule from '../../package/modules/attributes'
import { h } from '../../package/h'
import { attributesModule } from '../../package/modules/attributes'

var patch = init([
attributesModule
Expand Down
6 changes: 3 additions & 3 deletions src/test/unit/style.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { assert } from 'chai'

import { init } from '../../package/snabbdom'
import styleModule from '../../package/modules/style'
import h from '../../package/h'
import toVNode from '../../package/tovnode'
import { styleModule } from '../../package/modules/style'
import { h } from '../../package/h'
import { toVNode } from '../../package/tovnode'

var patch = init([
styleModule
Expand Down
4 changes: 2 additions & 2 deletions src/test/unit/thunk.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { assert } from 'chai'

import { init } from '../../package/snabbdom'
import h from '../../package/h'
import thunk from '../../package/thunk'
import { h } from '../../package/h'
import { thunk } from '../../package/thunk'
import { VNode } from '../../package/vnode'

var patch = init([
Expand Down

0 comments on commit fefd141

Please sign in to comment.