choojs / hyperx

🏷 - tagged template string virtual dom builder
BSD 2-Clause "Simplified" License
1.01k stars 48 forks source link

the example in the readme might be broken #59

Closed DanielRuf closed 6 years ago

DanielRuf commented 6 years ago

https://github.com/choojs/hyperx#hyperscript-node-example does not support the custom y attribute and does not render the same output.

yoshuawuyts commented 6 years ago

@DanielRuf could you create a repro? In bel I've definitely created all sorts of custom attributes — I wonder what scenario is preventing you from using the example. Thanks!

DanielRuf commented 6 years ago

Well, the y attribute isn't output at all in the pure Node version on Node 8 with npm 5.

DanielRuf commented 6 years ago

Will provide an example in about 2 hours because I'm sure this specific demo did just return a h1 element without the y attribute (on Windows 10).

DanielRuf commented 6 years ago
const h = require('hyperscript')
const hyperx = require('hyperx')
const hx = hyperx(h)

var title = 'world'
var wow = [1,2,3]
var tree = hx`<div>
  <h1 y="ab${1+2}cd">hello ${title}!</h1>

</div>`
console.log(tree.outerHTML)

outputs

<div>
  <h1>hello world!</h1>
</div>

It seems that custom tags and attributes are not fully supported.

My dependencies:

"hyperscript": "^2.0.2",
"hyperx": "^2.3.1",
"virtual-dom": "^2.1.1"
goto-bus-stop commented 6 years ago

yeah looks like hyperscript doesn't support custom attributes like that in the browser. it does on the server, which is why the test z_hyperscript that runs that snippet does work.

bel does support custom attributes, maybe we could switch the example to use that. or patch hyperscript so it works both on the server and the browser.

e; ref https://github.com/hyperhype/hyperscript/issues/21

DanielRuf commented 6 years ago

@goto-bus-stop

This was the node (server) example on my Windows command line, not in the browser.

goto-bus-stop commented 6 years ago

oh sorry. huh. could you check if npm test in this repo fail too then on windows? that uses the same snippet.

DanielRuf commented 6 years ago

All 53 tests pass.

Daniel MINGW64 ~/.../component-library3
$ cat index.js
const h = require('hyperscript')
const hyperx = require('hyperx')
const hx = hyperx(h)

var title = 'world'
var wow = [1,2,3]
var tree = hx`<div>
  <h1 y="ab${1+2}cd">hello ${title}!</h1>

</div>`
console.log(tree.outerHTML)
Daniel MINGW64 ~/.../component-library3
$ node index.js
<div>
  <h1>hello world!</h1>

</div>
DanielRuf commented 6 years ago
$ npm --version
5.3.0

$ node --version
v8.4.0