-
Notifications
You must be signed in to change notification settings - Fork 14
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
Conversation
There was a problem hiding this 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 { |
There was a problem hiding this comment.
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].
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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>, |
There was a problem hiding this comment.
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
)
Fixed all as suggested 👍 . Note that most of the inaccurate description resulted from |
No description provided.