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

Attribute on not passed to the DOM #2689

Closed
dpuscher opened this issue Jul 24, 2019 · 8 comments · Fixed by emotion-js/emotion#1584
Closed

Attribute on not passed to the DOM #2689

dpuscher opened this issue Jul 24, 2019 · 8 comments · Fixed by emotion-js/emotion#1584

Comments

@dpuscher
Copy link

dpuscher commented Jul 24, 2019

Environment

System:

  • OS: macOS 10.14.5
  • CPU: (4) x64 Intel(R) Core(TM) i7-7660U CPU @ 2.50GHz
  • Memory: 231.25 MB / 16.00 GB
  • Shell: 5.3 - /bin/zsh

Binaries:

  • Node: 10.15.0 - ~/.nvm/versions/node/v10.15.0/bin/node
  • Yarn: 1.16.0 - ~/.yarn/bin/yarn
  • npm: 6.4.1 - ~/.nvm/versions/node/v10.15.0/bin/npm

npmPackages:

  • babel-plugin-styled-components: ^1.10.6 => 1.10.6
  • styled-components: ^4.2.0 => 4.3.2

Reproduction

Define any styled component and add an on attribute to it:
https://codesandbox.io/s/styled-components-7qw97

Expected Behavior

The on attribute is passed to the dom element.

Actual Behavior

The on attribute is not showing up on the dom element.

@quantizor
Copy link
Contributor

quantizor commented Jul 24, 2019 via email

@dpuscher
Copy link
Author

Yes, it is not a valid HTML attribute, but I think there should be a way to add it to the DOM anyway.
Maybe by defining a list of custom "valid" attributes?

@quantizor
Copy link
Contributor

@dpuscher working on getting it into the whitelist since it'll probably come up often as part of amp

emmatown pushed a commit to emotion-js/emotion that referenced this issue Oct 29, 2019
* add "on" amp html property to whitelist

fixes styled-components/styled-components#2689

* add changeset
@quantizor
Copy link
Contributor

Fixed in the subdependency: https://github.com/emotion-js/emotion/releases/tag/%40emotion%2Fis-prop-valid%400.8.4

Just need to update with your package manager

@dpuscher
Copy link
Author

Thanks a lot @probablyup , this solves some annoying workarounds in our code base. 👍

@craigsketchley
Copy link

I had a warning pop up for a bunch of switch/button components in a React app after updating to 4.4.1:

Warning: Received `true` for a non-boolean attribute `on`.

If you want to write it to the DOM, pass a string instead: on="true" or on={value.toString()}.

I could be wrong but I feel like on is probably a common prop name used in components? Can't help but think there should be a way in styled-components to whitelist the props you want to pass through as non-standard attributes to the DOM.

@quantizor
Copy link
Contributor

quantizor commented Nov 5, 2019 via email

@craigsketchley
Copy link

Yeah, I was trying to highlight the impact of whitelisting arbitrary non-standard attributes to pass through to the DOM.

It'd be great if you could configure the props you want to pass through as attributes to the DOM. That way an AMP user could whitelist on and it wouldn't negatively affect others.

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 a pull request may close this issue.

3 participants