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

Define props on script tag for "inline" render? #46

Open
niccross opened this issue Jan 16, 2020 · 1 comment
Open

Define props on script tag for "inline" render? #46

niccross opened this issue Jan 16, 2020 · 1 comment

Comments

@niccross
Copy link

Hey! Love this project in a major way! While tinkering around I noticed that the data-prop-propname attributes are ignored on the script tag. Can this be allowed?

<script async src="/bundle.js" data-prop-my-prop="yes please"></script>

Also, by accident I noticed that habitat will pull in ALL props defined in a script tag document-wide. Is this by design? Maybe we could pass a selector for the props instead of assuming all JSON in script tags belong to habitat?

... Now I have to say "All your JSONs are belong to us!" ... sorry if you don't get the reference. 😜

<script class="this-belongs-to-my-habitat" type="application/json">
{
  "forMyHabitat": true
}
</script>
<script type="application/json">
{
  "forMyHabitat": false
}
</script>
@mrudult
Copy link

mrudult commented Jan 23, 2020

@niccross Did you find any solution to this? I'm also looking for inline set to true and props on script tag. Otherwise, we can use it the below way by wrapping the script tag in a div and defining props on that.

<div class="widget-container" data-prop-name="MrRobot">
  <script async src="/build/bundle.js" type="text/javascript"></script>
</div>

Looking at the code also tells that with when inline option is true, data attribute props are checked on the parentNode and not the script tag itself.

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

No branches or pull requests

2 participants