From 5347c77ccfdebb30c011495f6cde224eb695457f Mon Sep 17 00:00:00 2001 From: Mordy Tikotzky Date: Thu, 18 Jan 2018 22:41:22 -0500 Subject: [PATCH] fix(withComponent): forward roolEl when calling withComponent (#377) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * failing test for withcomponent(β€˜a’) getting passed an href * reset rootEl when calling withComponent * add to all contributers * update to use getRootEl --- .all-contributorsrc | 10 ++++++++++ README.md | 4 ++-- src/__tests__/create-glamorous.with-component.js | 6 ++++++ src/create-glamorous.js | 1 + 4 files changed, 19 insertions(+), 2 deletions(-) diff --git a/.all-contributorsrc b/.all-contributorsrc index c3522897..a4aa9721 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -547,6 +547,16 @@ "code", "test" ] + }, + { + "login": "tikotzky", + "name": "Mordy Tikotzky", + "avatar_url": "https://avatars3.githubusercontent.com/u/200528?v=4", + "profile": "https://github.com/tikotzky", + "contributions": [ + "bug", + "code" + ] } ] } diff --git a/README.md b/README.md index edcd5d1e..8eadf723 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ [![downloads][downloads-badge]][npmcharts] [![MIT License][license-badge]][license] -[![All Contributors](https://img.shields.io/badge/all_contributors-57-orange.svg?style=flat-square)](#contributors) +[![All Contributors](https://img.shields.io/badge/all_contributors-58-orange.svg?style=flat-square)](#contributors) [![PRs Welcome][prs-badge]][prs] [![Chat][chat-badge]][chat] [![Code of Conduct][coc-badge]][coc] @@ -162,7 +162,7 @@ Thanks goes to these people ([emoji key][emojis]): | [
Lufty Wiranda](http://instagram.com/luftywiranda13)
[πŸ’»](https://github.com/paypal/glamorous/commits?author=luftywiranda13 "Code") | [
Ansuman Shah](https://github.com/ansumanshah)
[πŸ’»](https://github.com/paypal/glamorous/commits?author=ansumanshah "Code") [πŸ“–](https://github.com/paypal/glamorous/commits?author=ansumanshah "Documentation") | [
Travis LaDuke](http://-)
[πŸ’‘](#example-laduke "Examples") | [
AydΔ±n Γ‡ağrΔ± Dumlu](https://github.com/acgrdumlu)
[πŸ›](https://github.com/paypal/glamorous/issues?q=author%3Aacgrdumlu "Bug reports") [πŸ’»](https://github.com/paypal/glamorous/commits?author=acgrdumlu "Code") | [
Maja Wichrowska](https://github.com/majapw)
[πŸ›](https://github.com/paypal/glamorous/issues?q=author%3Amajapw "Bug reports") | [
Tom Liu](https://github.com/gt3240)
[πŸ“–](https://github.com/paypal/glamorous/commits?author=gt3240 "Documentation") | [
Siddharth Kshetrapal](https://github.com/siddharthkp)
[⚠️](https://github.com/paypal/glamorous/commits?author=siddharthkp "Tests") [πŸ”§](#tool-siddharthkp "Tools") | | [
WillowHQ](https://github.com/WillowHQ)
[πŸ“–](https://github.com/paypal/glamorous/commits?author=WillowHQ "Documentation") | [
Mohammad Rajabifard](https://tarino.ir)
[πŸ›](https://github.com/paypal/glamorous/issues?q=author%3Amorajabi "Bug reports") [πŸ“–](https://github.com/paypal/glamorous/commits?author=morajabi "Documentation") | [
Omar Albacha](https://github.com/Oalbacha)
[πŸ’»](https://github.com/paypal/glamorous/commits?author=Oalbacha "Code") [πŸ“–](https://github.com/paypal/glamorous/commits?author=Oalbacha "Documentation") | [
tdeschryver](https://github.com/tdeschryver)
[πŸ’»](https://github.com/paypal/glamorous/commits?author=tdeschryver "Code") [⚠️](https://github.com/paypal/glamorous/commits?author=tdeschryver "Tests") | [
Dylan Mozlowski](https://github.com/DylanMoz)
[πŸ’»](https://github.com/paypal/glamorous/commits?author=DylanMoz "Code") | [
andretshurotshka](https://github.com/goodmind)
[πŸ’»](https://github.com/paypal/glamorous/commits?author=goodmind "Code") [⚠️](https://github.com/paypal/glamorous/commits?author=goodmind "Tests") | [
Danila](https://github.com/O4epegb)
[⚠️](https://github.com/paypal/glamorous/commits?author=O4epegb "Tests") | | [
Junyoung Clare Jang](http://ailrun.github.io/)
[πŸ’»](https://github.com/paypal/glamorous/commits?author=Ailrun "Code") [⚠️](https://github.com/paypal/glamorous/commits?author=Ailrun "Tests") | [
BjΓΆrn Ricks](https://twitter.com/bjoernricks)
[πŸ›](https://github.com/paypal/glamorous/issues?q=author%3Abjoernricks "Bug reports") [πŸ’»](https://github.com/paypal/glamorous/commits?author=bjoernricks "Code") [πŸ“–](https://github.com/paypal/glamorous/commits?author=bjoernricks "Documentation") [⚠️](https://github.com/paypal/glamorous/commits?author=bjoernricks "Tests") | [
Tyler Deitz](http://tylerdeitz.com)
[πŸ’»](https://github.com/paypal/glamorous/commits?author=tvler "Code") | [
Shovan Chatterjee](https://twitter.com/shovan_ch)
[πŸ“–](https://github.com/paypal/glamorous/commits?author=shovanch "Documentation") | [
johnjessewood](https://github.com/johnjesse)
[πŸ’»](https://github.com/paypal/glamorous/commits?author=johnjesse "Code") | [
Daniel](https://www.danielberndt.net)
[πŸ’»](https://github.com/paypal/glamorous/commits?author=danielberndt "Code") [⚠️](https://github.com/paypal/glamorous/commits?author=danielberndt "Tests") | [
Ken Powers](https://knpw.rs)
[πŸ€”](#ideas-knpwrs "Ideas, Planning, & Feedback") | -| [
John Grishin](http://johngrish.in)
[πŸ›](https://github.com/paypal/glamorous/issues?q=author%3Aexah "Bug reports") [πŸ’»](https://github.com/paypal/glamorous/commits?author=exah "Code") [⚠️](https://github.com/paypal/glamorous/commits?author=exah "Tests") | +| [
John Grishin](http://johngrish.in)
[πŸ›](https://github.com/paypal/glamorous/issues?q=author%3Aexah "Bug reports") [πŸ’»](https://github.com/paypal/glamorous/commits?author=exah "Code") [⚠️](https://github.com/paypal/glamorous/commits?author=exah "Tests") | [
Mordy Tikotzky](https://github.com/tikotzky)
[πŸ›](https://github.com/paypal/glamorous/issues?q=author%3Atikotzky "Bug reports") [πŸ’»](https://github.com/paypal/glamorous/commits?author=tikotzky "Code") | diff --git a/src/__tests__/create-glamorous.with-component.js b/src/__tests__/create-glamorous.with-component.js index ab585165..b8b43971 100644 --- a/src/__tests__/create-glamorous.with-component.js +++ b/src/__tests__/create-glamorous.with-component.js @@ -63,3 +63,9 @@ test('resulting component can have its styles extended further', () => { render(), ).toMatchSnapshot('overriding styles via className') }) + +test('resulting component gets sent valid props', () => { + const A = glamorous.div({}).withComponent('a') + const rendered = render() + expect(rendered.prop('href')).toBe('https://glamorous.rocks') +}) diff --git a/src/create-glamorous.js b/src/create-glamorous.js index 929a22c6..4205bc68 100644 --- a/src/create-glamorous.js +++ b/src/create-glamorous.js @@ -114,6 +114,7 @@ function createGlamorous(splitProps) { { ...componentProperties, comp: newComp, + rootEl: getRootEl(newComp), }, { // allows the forwardProps and filterProps to be overridden