Skip to content
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

Clean up API (0.4.0 release) #13

Closed
padolsey opened this issue Sep 16, 2013 · 3 comments
Closed

Clean up API (0.4.0 release) #13

padolsey opened this issue Sep 16, 2013 · 3 comments
Assignees
Milestone

Comments

@padolsey
Copy link
Owner

After a recent API addition (the element filter, see #11) I was considering a slight refactor of the way findAndReplaceDOMText is called. It's getting quite busy/lengthy at the moment and it may benefit from something like:

findAndReplaceDOMText(elementToSearch, {
  match: /foo/,
  replace: theReplacement,
  capture: optionalCaptureGroupNumber,
  filter: optionalElementFilterFunction
});

(i.e. an intuitive configuration object as the second arg)

Of course, the old way would still work but would be deprecated.

This would make it more readable and much easier to add new features without adding complexity to the already-long argument list.

I am planning this change for 0.4.0. Thoughts are welcome.

@ghost ghost assigned padolsey Sep 16, 2013
padolsey added a commit that referenced this issue Sep 28, 2013
@padolsey
Copy link
Owner Author

I have made a provisional apiCleanup branch for people to play with. Let me know your thoughts. It'll most likely be completed and merged to master in the next few days.

Notable features are (see apiCleanup branch readme.md)

  • Ability to replace plain text or wrap text with DOM nodes
  • Cleaner API
  • More meaningful portion/match objects passed to custom replace functions.
  • Ability to choose between 'retain' and 'first' modes for portion-replacement-boundaries.
  • More tests

@padolsey
Copy link
Owner Author

Another "feature" of the cleanup is that it retains support for the deprecated argument signature (findAndReplaceDOMText(regex, node, replace, ...)).

@padolsey
Copy link
Owner Author

padolsey commented Oct 6, 2013

0.4.0 is out.

@padolsey padolsey closed this as completed Oct 6, 2013
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

No branches or pull requests

1 participant