Skip to content

chore(typings): add typings #8

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 23, 2018
Merged

Conversation

bigopon
Copy link
Contributor

@bigopon bigopon commented Sep 14, 2018

No description provided.

@coveralls
Copy link

coveralls commented Sep 14, 2018

Coverage Status

Coverage remained the same at 97.917% when pulling 8b8c781 on bigopon:master into 412dc4b on WebReflection:master.

Copy link
Owner

@WebReflection WebReflection left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this PR! Please have a look at my comments.

types.d.ts Outdated
@@ -0,0 +1,37 @@
export interface IDomDiffNodeMarkerOptions {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add the following description and feel free to ask more if needed.

A specific live node to use as boundary for all nodes operations.
With live nodes [a,d] and {before: d}, the operation [] => [b, c] would place nodes right before d, resulting a live collection of [a, b, c, d].

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P.S. even before doesn't have to be necessarily a Node

types.d.ts Outdated

export interface IDomDiffOptionsGenericComparisonFn {
/**
* A callback to compare between two generic nodes. returns `true` to indicate they are the same
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is inaccurate. You can compare anything, even objects, not just DOM nodes. Basically, this module handle any sort of object, including, as example, hyper.Component instances that are not nodes per se.

types.d.ts Outdated

export interface IDomDiffOPtionsEachNodeCallbackFn {
/**
* The optional `{node: (generic, info) => node}` is invoked per each operation on the DOM.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As inaccurate as the previous one. The generic Node is not a DOM node, it can be pretty much any object.

types.d.ts Outdated
export default function domdiff(
parentNode: Node,
currentNodes: ArrayLike<Node>,
futureNodes: ArrayLike<Node>,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both currentNodes and futureNodes can be ArrayLike but if these are live collections things will go bananas. As example, body.getElementsByTagName('div') as collection wouldn't work, and so it wouldn't any collection that mutates live while DOM changes. I would probably stick with Array to avoid confusion and be clear about the kind of variable it is expecting.

On top of that, the <Node> type is also misleading, because this module handles every kind of object, even arrays, as shown in the example in the README.

Node in this whole types description, is not necessarily a Node. It could be a Node, but it could be literally any other kind of object (excluding null)

@bigopon
Copy link
Contributor Author

bigopon commented Sep 14, 2018

Fixed all as suggested 👍 . Note that most of the inaccurate description resulted from README and a little bit of inferring the code. You may want to update it as well.

@WebReflection WebReflection merged commit f4e5f31 into WebReflection:master Dec 23, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants