question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

v2.3.3 data-* attributes lost

See original GitHub issue

Version

styled-components: 2.3.3

Reproduction

As of version 2.3.3 Styled components are stripping out data-* attributes and not passing them on or respecting them in the rendering. Rolling back to 2.3.1 seems to still keep the desired behavior. These attributes should also continue to be passed on to any components that are extended by styled-components.

Steps to reproduce

const Node = styled.div` background-color: red;`
export default Component = () => <Node data-value="it works">Test</Node>

Expected Behavior

Html output

<div class="auto-generated"  data-value="it works">Test</div>

Actual Behavior

Html output

<div class="auto-generated">Test</div>

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:12 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
donovan-grahamcommented, Dec 20, 2017

I’ll double check, and post a more complete example. Thanks for the snappy response @mxstbr

0reactions
probablyupcommented, May 22, 2018

It should still be data-index. React doesn’t camelCase data and aria attributes. On Tue, May 22, 2018 at 5:25 AM George James notifications@github.com wrote:

I am using v3.1.6

const EventInfoComp = ({ dataindex, info, …rest}) => ( <div {…rest}> <div className='message'>{ info }</div> <FilledLikeIcon /> </div> )

export const EventInfo = styled(EventInfoComp)` font-size: 16px; height: 44px; color: #1D1B23; display: flex;

.message {
    flex: 1;
    margin-right: 30px;
}
.message::selection {
    background: none;
    color: #1D1B23;
}

`

{ this.state.events.map((event, index) => ( <Event like={false} key={event.id}> <EventTitle name={event.title} color={event.color} /> <EventInfo info={event.info} onDoubleClick={this.handleLikeEvent.bind(this)} dataindex={index}/> </Event> )) }

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/styled-components/styled-components/issues/1379#issuecomment-390923955, or mute the thread https://github.com/notifications/unsubscribe-auth/AAiy1jGjdHuE1Gzt5cpKbnFfgrNOMJ5Cks5t09mMgaJpZM4RInSi .

Read more comments on GitHub >

github_iconTop Results From Across the Web

3.2 Elements — HTML5 - W3C
The attribute has no invalid value default and no missing value default. The directionality of the element is 'ltr'. The directionality of the...
Read more >
Transfer Attribute doesn't work for nearest instance ...
This is a known bug (missing feature) in Blender versions lower than 3.4, which is now considered solved. The current solution for 3.4...
Read more >
3.3 COUNTER Report Common Attributes and Elements
3.3.2 Data Types¶. R5 reports on scholarly information in many ways. These major groupings, referred to as Data_Types, are listed in the table...
Read more >
3.3.2 Procedure 2: SETATTR - Set file attributes - Freesoft
Changing the size of a file with SETATTR indirectly changes the mtime. A client must account for this as size changes can result...
Read more >
3. Data model — Python 3.11.1 documentation
The pathname of the file from which the module was loaded, if it was loaded from a file. The __file__ attribute may be...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found