Skip to content

Allow to pass DOM object as parent selector. #340

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

Closed
wants to merge 1 commit into from

Conversation

aratak
Copy link
Contributor

@aratak aratak commented Aug 23, 2015

Extend possibility of findDOMNodes and as a consequence mountComponents. It allows to use it with an element which was inserted to the DOM tree without react.js. Example:

$(document).on('nested:fieldAdded', function(e) {
  window.ReactRailsUJS.mountComponents(e.target);
});

With backward compatibility, of course.

Extend possibility of `findDOMNodes` and as a consequence `mountComponents`. It allows to use it with an element which was inserted to the DOM tree without react.js. Example:

```
$(document).on('nested:fieldAdded', function(e) {
  window.ReactRailsUJS.mountComponents(e.target);
});
```

With backward compatibility, of course.
@facebook-github-bot
Copy link

Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign up at https://code.facebook.com/cla - and if you have received this in error or have any questions, please drop us a line at cla@fb.com. Thanks!

@facebook-github-bot
Copy link

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks!

@rmosolgo
Copy link
Member

👍 nice feature!

Can you investigate that failing test? It looks like it passes on master. Does it fail locally?

Also, could you add a test for this new behavior? I think you could base your new test off of the existing one for mounting & unmounting by selector strings.

You can see that the test clicks some buttons and makes sure that components are unmounted and re-mounted: https://github.com/reactjs/react-rails/blob/master/test/react/rails/view_helper_test.rb#L135-L136

The buttons are defined in this Rails view: https://github.com/reactjs/react-rails/blob/1c03b00b8105c78fbf674abe34be4941084bede4/test/dummy/app/views/pages/show.html.erb

So, I think you could make 2 new buttons which call those functions with DOM elements instead of strings. Then, in your test, click those buttons and make sure components are unmounted and re-mounted, just like the existing test.

@ximus
Copy link
Contributor

ximus commented Sep 26, 2015

I fixed and added tests for this branch here: master...ximus:support-dom-node-context

let me know what you want me to do with it

@rmosolgo
Copy link
Member

Awesome, please open a new Pull Request! If we merge that one, then we can close this one.

@aratak
Copy link
Contributor Author

aratak commented Sep 28, 2015

Thanks, @ximus!

@rmosolgo
Copy link
Member

closed by #358 , Thanks for getting this started!

@rmosolgo rmosolgo closed this Sep 28, 2015
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.

4 participants