question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Wrong attribute parsing

See original GitHub issue

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

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

error

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:open
  • Created 7 years ago
  • Comments:9 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
blahahcommented, Feb 28, 2017

@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.

0reactions
YerkoPalmacommented, Feb 28, 2017

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

bel(str)

or like

bel`${str}`

Because of the parsing made by yo-yoify. Also, it is only my thoughts as I havent checked the code yet.

Read more comments on GitHub >

github_iconTop Results From Across the Web

13.2 Parsing HTML documents - HTML Standard - whatwg
This error occurs if the parser encounters an attribute in a tag that already has an attribute with the same name. The parser...
Read more >
Finding the xml element attribute with the max value causes ...
Finding the xml element attribute with the max value causes parse error. Save this question. Show activity on this post.
Read more >
Schema validation error mentions `Error parsing attribute "@id ...
Given this schema generator js { provider = "prisma-client-js" previewFeatures = ["extendedIndexes"] } datasource db { provider = "mysql" ...
Read more >
Error while parsing file 'attribute "value" not allowed here
This error usually occurs in case of numbered lists. Unfortunately the current epub standards are unable to handle numbered lists if you...
Read more >
Parsing Issues | Reference - Total Validator
A character entity reference was found in an attribute that is not defined as part of the HTML specification being tested against. This...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found