Wrong attribute parsing
See original GitHub issueI’m having problems with bel. I try to use bel to render some markdown content with the help of marked library. With this code
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
# hello world
I’m using stringify to require the .md
file content. When I console log the marked(post)
call, I get
<h1 id="hello-world">hello world</h1>
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
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 library inside hyperx, but again why would it work with hyperscript, but not with bel?
Any help would be appreciated.
Issue Analytics
- State:
- Created 7 years ago
- Comments:9 (6 by maintainers)
Top GitHub Comments
@roobie I have, only with certain elements. It always happens with
<img src="..." />
, but quite often I don’t get the error.I was suggesting that the usage pattern of passing HTML to
html()
is useful, and questioning why it would be a bad idea. I’d love to see this solved.I guess that the problem might be related with yo-yoify. As it is a browserify transform, it can make a difference if it is called like
or like
Because of the parsing made by yo-yoify. Also, it is only my thoughts as I havent checked the code yet.