airbnb / hypernova

A service for server-side rendering your JavaScript views
MIT License
5.82k stars 212 forks source link

makeValidDataAttribute error for clients without support for hypernova-id #52

Open petterm opened 7 years ago

petterm commented 7 years ago

I have an issue with makeValidDataAttribute expecting to always get only defined values.

When I run an application where the hypernova server fails and the hypernova client (hypernova-python in my case) does not include the hypernova-id data attribute the call-chain from load("Component") ends up running from_script with an object like {hypernova-key: "Component", hypernova-id: null}. When that then wants to normalize the attributes it fails on hypernova-id.

By reading the commit that added the functionality of multiple copies of the same component I thought supporting hypernova-id was optional?

Context Code is transpiled with webpack 2 and babel-loader with presets es2015 and react.

Example html:

<div data-hypernova-key="Component"></div>
<script type="application/json" data-hypernova-key="Component">
        <!--{"someData": "here"}--></script>

Error-code:

Uncaught TypeError: Cannot read property 'replace' of null
  at makeValidDataAttribute