choojs / choojs/nanohtml

Wrong attribute parsing

Open
#62 9 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
688
Forks
48
PR merge metrics
No merged PRs in 30d

Description

I'm having problems with bel. I try to use bel to render some markdown content with the help of marked library. With this code

```js
const html = require('yo-yo')
const marked = require('marked')

const post = require('./posts/post.md')
console.log(marked(post))
document.body.appendChild(html(marked(post)))
```

And this markdown content

```md
# hello world
```
I'm using [stringify](https://github.com/JohnPostlethwait/stringify) to require the `.md` file content. When I console log the `marked(post)` call, I get

```text

hello world


```

That's pretty valid html to me, but bel complains with this error.

>Uncaught DOMException: Failed to execute 'setAttribute' on 'Element': 'hello-world"' is not a valid attribute name.
> at belCreateElement (http://playground-yerkopalma.c9users.io:8080/bundle.js:1447:14)
> at http://playground-yerkopalma.c9users.io:8080/bundle.js:1807:12
> at http://playground-yerkopalma.c9users.io:8080/bundle.js:1569:45
> at Object.1../posts/post.md (http://playground-yerkopalma.c9users.io:8080/bundle.js:7:27)
> at s (http://playground-yerkopalma.c9users.io:8080/bundle.js:1:254)
> at e (http://playground-yerkopalma.c9users.io:8080/bundle.js:1:425)
> at http://playground-yerkopalma.c9users.io:8080/bundle.js:1:443

And the problem is that when the belCreateElement function is called, it is called with wrong attributes

![error](https://cloud.githubusercontent.com/assets/5105812/21930603/ac2b754e-d975-11e6-91dd-0a156a1ce7d2.png)

Now why is that happening? I thought about an hyperx error, but tried it with hyperscript and it render correctly. Not sure what could it be, also looked at the [hyperscript-attribute-to-property](https://github.com/feross/hyperscript-attribute-to-property) library inside hyperx, but again why would it work with hyperscript, but not with bel?

Any help would be appreciated.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.