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

Add otherProps util and DangerouslySetHTML component #242

Merged
merged 2 commits into from
May 31, 2017

Conversation

bryceosterhaus
Copy link
Member

From discussion on #239

Fixes #127
Fixes #205

@bryceosterhaus
Copy link
Member Author

Not sure why this is failing on travis...

@jbalsas
Copy link
Contributor

jbalsas commented May 26, 2017

I've relaunched the tests, seemed like a network issue or something like that, all systems are green ☺️

I'll take a look at this on monday, but it looks good on first sight. In the meantime, maybe @mthadley or @ethib137 who might be more familiar with the use case could chime in!

@jbalsas jbalsas requested review from jbalsas and mthadley May 26, 2017 17:19
Copy link

@mthadley mthadley left a comment

Choose a reason for hiding this comment

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

@jbalsas I added a few nitpicks, but all in all, this seems good. Thanks @bryceosterhaus!

*/
class DangerouslySetHTML extends Component {
/**
* @return {Component}

Choose a reason for hiding this comment

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

Indentation looks a little funny here.


const retObj = object.mixin({}, component.props);

removeKeys.forEach(

Choose a reason for hiding this comment

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

I'm not sure if this really needs to change, but I can see most of the core library mostly prefers the C-style for loop over forEach. I'm guessing for performance? (The overhead of a function invocation for n items).

});

it('should ignore key and ref', function() {
class TestComponent extends JSXComponent {

Choose a reason for hiding this comment

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

I wonder if we can maybe start writing new tests completely in ES6? I mean, we are using class keywords already so...

@mthadley
Copy link

@bryceosterhaus Oh, I just realized something. Maybe this could be a class method on JSXComponent?

class MyComponent extends JSXComponent {
  render() {
    return <div ...this.otherProps() class="content" />;
  }
}

@bryceosterhaus
Copy link
Member Author

@mthadley, not a bad idea. Seems a little strange at first glance, but probably just because I am used to it being a separate function.

Also, for es6 in the unit tests, I decided to just follow the same patterns we had in our other tests

@mthadley
Copy link

@bryceosterhaus I figured you were, which is fine. But maybe going forward we can start pushing for more idiomatic ES6. I'll defer to you and @jbalsas on this.

@jbalsas
Copy link
Contributor

jbalsas commented May 29, 2017

Hey guys, thanks for working on this!

If otherProps is always meant to be used in the context of a JSXComponent, I also think it makes sense to make it part of the component directly, at least for now.

@bryceosterhaus, can you make that change and let me know? Regarding the tests, I'd love to start writing them in ES6 moving forward, but I wouldn't hold this PR for that, so no need to rewrite them right now.

Thanks!

@bryceosterhaus
Copy link
Member Author

@jbalsas @mthadley, just updated pr so that otherProps is on the component itself

@jbalsas
Copy link
Contributor

jbalsas commented May 30, 2017

LGTM! @mthadley, one final check and I'll merge 😉

@mthadley
Copy link

🎉 @jbalsas LGTM 🎉

@eduardolundgren
Copy link
Contributor

LGTM

@eduardolundgren
Copy link
Contributor

Could you add a test case for using DangerouslySetHTML from inside another component?

@bryceosterhaus
Copy link
Member Author

@eduardolundgren, added additional test case here

@ethib137
Copy link

LGTM

@eduardolundgren eduardolundgren merged commit d1f9b25 into metal:master May 31, 2017
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.

5 participants