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.

Bug: parsing negative attributes in tag definition

See original GitHub issue

The code:

el("input[type=number][min=-1]");

Generates:

<input type="number"></input>

Instead of:

<input type="number" min="-1"></input>

Example: https://domvm.github.io/domvm/demos/playground/#mobx

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
jlgrallcommented, Feb 12, 2019

The advantage with the simpler regexp is that it doesn’t skip attributes that contain unsupported characters. It took me a few days to notice that the [min=-1] was not rendered, because I forgot that I wrote it. It is always better to not ignore errors.

I would also accept a = without a value. After all, HTML accepts empty attributes, so it is less surprising to accept it too.

i would add \s to the attr name exclusions

If you accept: el("div", {"at tr": "val"}), I think you can also accept el("div[at tr=val]"). At least this way it has a chance to trigger an error on the client instead of being completely ignored.

Which would give us:

/\[([^=\]]+)(?:=([^\]]+)?)?\]/g
0reactions
jlgrallcommented, Feb 19, 2019

Looks good.

Read more comments on GitHub >

github_iconTop Results From Across the Web

HTML 5.2: 8. The HTML syntax - W3C
This specification defines the parsing rules for HTML documents, whether they are syntactically correct or not. Certain points in the parsing ...
Read more >
4.1.1 Parsing - Duplicate attributes with no user impact cause ...
e) when the duplicated attributes specify have different values with exactly the same meaning - because the browser stores exactly one value ...
Read more >
HTML Standard
2.3.1 Common parser idioms; 2.3.2 Boolean attributes; 2.3.3 Keywords and enumerated attributes; 2.3.4 Numbers. 2.3.4.1 Signed integers; 2.3.4.2 Non-negative ...
Read more >
SyntaxError: JSON.parse: bad parsing - JavaScript | MDN
JSON.parse() parses a string as JSON. This string has to be valid JSON and will throw this error if incorrect syntax was encountered....
Read more >
XTF » Tag Reference - California Digital Library
Stylesheet parameters; Parser Input Tags; Error Generator Stylesheet · Utilities ... This section summarizes the attributes defined for the Pre-Filter ...
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